0

I am currently simulating a cooling circuit in OpenModelica. I want to give the simulation a starting value of the temperature. To do this, I insert the model of the medium into the circuit and specify an initial value with 'initial equation'. The temperature specification should only be used for the start. Since the circuit is closed, the temperatures for the next loop should calculate themselves through the heat flows in the circuit. Unfortunately, the code does not work as expected. Does anyone know how I can give the medium a start value without needing any further input afterwards?

model Glysantin_FC_G20 "properties of Glysantin FC G20"
  // Parameter
  parameter SpecificHeatCapacity cp = 3560;
  parameter Density rho = 1042;
  parameter Temperature T = 338.15;
  
Interfaces.FluidPort_a inflow annotation(...);
Interfaces.FluidPort_b outflow annotation(...);

initial equation
  outflow.T = T;
  outflow.m_flow = -inflow.m_flow;
  outflow.V_flow = -inflow.V_flow;
  inflow.p = outflow.p;
  
equation
  outflow.T = inflow.T;
  outflow.m_flow = -inflow.m_flow;
  outflow.V_flow = -inflow.V_flow;
  inflow.p = outflow.p;


annotation(...);
end Glysantin_FC_G20;
Luca
  • 1

1 Answers1

1

It's a bit difficult to fully answer without the full model and error message. However, the initial equations are combined with the normal equations so they should not be duplicated giving just:

initial equation
  outflow.T = T;

Alternatively you can remove all initial equation and write it as:

Interfaces.FluidPort_b outflow(T(start=T),fixed=true) annotation(...);

or possibly even without the fixed=true.

Hans Olsson
  • 11,123
  • 15
  • 38
  • Thank you for your reply. Unfortunately, both options do not work. It always gives me the following error: The following assertion has been violated at time 0.240000 Simulation process failed. Exited with code 0x00000001. Currently, I always specify a temperature at the radiator outlet. Then it runs. Unfortunately, it is not possible to upload the complete simulation because it is too large. The components in the circuit all have the same structure. Each has an inflow and an outflow port. Values for pressure, mass flow, volume flow and temperature are passed on through the ports. – Luca May 24 '22 at 15:21
  • If an assertion is violated at time 0.24 it is not a problem of initialization, but a different problem that requires a more complete model. (Unless you start the simulation at that exact time.) Try to plot temperatures etc before that time to see where it goes wrong - likely the temperature (etc) is going up or down too much at one end. – Hans Olsson May 24 '22 at 15:26
  • I can even plot the temperature up to 13 seconds. But it is completely wrong over the entire time. If I tell the model to always go back to 65 °C at the radiator outflow, it works fine. But I only want to specify a start value once and then the temperature should calculate itself in the circuit. – Luca May 24 '22 at 15:43
  • Is this component a medium model or a component of the cycle? Which other components are inside the cycle? I think that storage of energy is missing in your components. Changes at one side are directly fed through, which might lead to your erronous results. Piping components usually need some kind of energy balance e.g. der(T)*m*c_p=H-In-H-Out where m is the mass of fluid stored in the component. – Imke Krueger Jun 23 '22 at 11:08