3
votes

When I check Modelica.Thermal.HeatTransfer.Components.HeatCapacitor using OpenModelica, it tells me that HeatCapacitor has 4 equations and 4 variables. But I can only find 3 equations in the model listed below for 4 variables(i.e, T, port.T, der_T, port.Q_flow):

T = port.T;
der_T = der(T);
C*der(T) = port.Q_flow;

I created a new model named MyHeatCapacitor by deleting der_T and the second equation listed above. The tool indicates that MyHeatCapacitor has 3 equations for 3 variables.

The two heat-capacitor models can give me the correct answers. I was just wondering where I can find the equation which does not appear in the equation section.

Thanks!!!

1
The output of Dymola is: Check of Modelica.Thermal.HeatTransfer.Components.HeatCapacitor: The model has the same number of unknowns and equations: 3 This makes sense, as the model will need two equations for the two unkowns (T and der_T). Another one is necessary for every pair of across and flow variables in a physical connector (which in this case is one). This assumes that one equation is used to relate the interface variables internally and the other one is set from the outside (which happens when you connect the component).Markus A.
Thanks for the kind reply. I understand it.Min Li

1 Answers

4
votes

The missing equation will be generated when you create an instance of the HeatCapacitor and connect the thermal port with the port of another instance of a thermal class. From the connect statement the tool will generate topology equations, which add to the number of equations when you check a model.

Topology equations are generated as follows:

  • all flow variables of connected connectors are summed up to zero

    for the HeatPort this is Q_flow, giving e.g. the following equation for 2 instances:

    instance1.Q_flow + instance2.Q_flow = 0
    
  • non-flow variables in connectors are treated as potential variables. the potentials of connected instances are set equal.

    for the HeatPort this is T, giving e.g. the following equations for 2 connected instances:

    instance1.T = instance2.T
    

As the heat capacitor uses an a-causal connector (the thermal port), on check the tool knows that it will be later connected to another instance, resulting in the equations stated above. So two HeatCapacitor instances have 2*4=8 variables and 2*3=6 equations. With the 2 topology equations we get 8 equations in total.

If nothing is connected, a default connection is assumed, where the flow is set on zero.