Tags and keywords
The Modelica By Example target code is:
within ModelicaByExample.Components.HeatTransfer.Examples;
model Cooling "A model using generic convection to ambient conditions"
ThermalCapacitance cap(C=0.12, T0(displayUnit="K") = 363.15)
"Thermal capacitance component"
annotation ...
Convection convection(h=0.7, A=1.0)
annotation ...
AmbientCondition amb(T_amb(displayUnit="K") = 298.15)
annotation ...
equation
connect(convection.port_a, cap.node) annotation ...
connect(amb.node, convection.port_b) annotation ...
end Cooling;
This just connects up the components that were defined in the previous few slides, along with some 'start' values. In SysPhS we use SysML context-specific values carried by the indicated instances.
The block Cooling
exports via SysPhS to Modelica as:
model Cooling
Cooling _Cooling;
model Cooling
Convection conv(h.start=0.7,h.fixed=true,a.start=1.0,a.fixed=true);
AmbientCondition amb(tAmb.start=298.15,tAmb.fixed=true);
ThermalCapacitance cap(c.start=0.12,c.fixed=true,node.t.start=363.15,node.t.fixed=true);
equation
connect(cap.node,conv.hPA);
connect(conv.hPB,amb.node);
end Cooling;
model Convection
parameter CoefficientOfHeatTransfer h;
parameter Area a;
HeatPortA hPA;
HeatPortB hPB;
equation
hPA.hFR+hPB.hFR=0;
hPA.hFR=h*a*(hPA.t-hPB.t);
end Convection;
model AmbientCondition
HeatPortA node;
parameter Temperature tAmb;
equation
node.t=tAmb;
end AmbientCondition;
model ThermalCapacitance
parameter HeatCapacitance c;
parameter Temperature t0;
HeatPortA node;
equation
c*der(node.t)=node.hFR;
end ThermalCapacitance;
connector HeatPortA
extends HeatFlowElement;
end HeatPortA;
connector HeatPortB
extends HeatFlowElement;
end HeatPortB;
connector HeatFlowElement
flow HeatFlowRate hFR;
Temperature t;
end HeatFlowElement;
type CoefficientOfHeatTransfer=Real(unit="W/(m2.K)");
type Area=Real(unit="m2");
type Temperature=Real(unit="K");
type HeatCapacitance=Real(unit="J/K");
type HeatFlowRate=Real(unit="J/s");
end Cooling;