I have a very simple fluid model : a source, a meshed pipe, a sink.
Dymola (2024x) choose, among the initialization variables, the value of the enthalpy h
in some of the nodes. However the initial value is not good enough to find a solution and the solver fails to initialize the simulation.
I know a better guess value and I achieve in initializing the simulation by adding h(each start=my_better_value)
in te text of my model but I did not found any way to provide just the value in the specific node Dymola is asking.
For example, in the variable browser, among the initial values
, Dymola only shows the my_module.h[2]
. However, if I try to modify this sole value I get the following messages in the command panel and my change does not take effect:
A heterogenous array in array of records my_module.h is not supported.
Warning: Undeclared variable or command: my_module.h
Why is this happening? I am pretty sure of having independently modified the values of an array in the past...
What else can I do to set the initial value (instead of the each start
command)?
EDIT - Actual example
This is an "elementary" test case to reproduce the issue. It is based on the ThermoSysPro library.
model BOP
ThermoSysPro.Fluid.BoundaryConditions.SourceQ sourceQ(
Q0=10,
T0=500);
ThermoSysPro.Fluid.BoundaryConditions.SinkP sinkP;
ThermoSysPro.Fluid.HeatExchangers.DynamicOnePhaseFlowPipe
dynamicOnePhaseFlowPipe(
Ns=1,
h(each start=2.e6));
equation
connect(dynamicOnePhaseFlowPipe.C1, sourceQ.C);
connect(dynamicOnePhaseFlowPipe.C2, sinkP.C);
end BOP;
The error message is only expected to occur if my_module is also an array (of components) where each element has an array h of a different length.
Like the following:
model MyModule
parameter Integer n;
Real h[n];
equation
sin(h)+1e-3*h=zeros(n); // Non-linear system
end MyModule;
MyModule my_module[2](n={2,1});
It might be that it can also occur for just a plain array in some very rare cases, but we would need the model to see why.
The work-around is similar in both cases - introduce a new alias to the specific element and give it a start-value:
Real x(start=...)=my_module[1].h[1];
And you should then be able to set the start-value of x
after translation in the usual way.