Opened 6 years ago

Last modified 5 years ago

#5170 closed defect

GenerationOfFMUs examples in the MSL are broken because of unrecognized redundant initial equations — at Version 1

Reported by: Francesco Casella Owned by: Karim Adbdelhak
Priority: blocker Milestone: 1.14.0
Component: Backend Version:
Keywords: Cc: Lennart Ochel, Per Östlund

Description (last modified by Francesco Casella)

The four GenerationOfFMU models in the MSL 3.2.3:
Modelica.Electrical.Analog.Examples.GenerationOfFMUs
Modelica.Mechanics.Rotational.Examples.GenerationOfFMUs
Modelica.Mechanics.Translational.Examples.GenerationOfFMUs
Modelica.Thermal.HeatTransfer.Examples.GenerationOfFMUs
all share the same issue. They involve the initialization of high-index systems with redundant and consistent initial equations. All of them fail during analyzeInitialSystem with this kind of error

Error: The given system is mixed-determined.   [index > 3]
Please checkout the option "--maxMixedDeterminedIndex".
Error: No system for the symbolic initialization was generated

I prepared a reduced model that replicates the issue, please find it attached. It contains the following two variable declarations with fixed = true

Real directCapacity.heatCapacitor.T(quantity = "ThermodynamicTemperature", unit = "K", displayUnit = "degC", min = 0.0, start = 293.15, fixed = true, nominal = 300.0) "Temperature of element";
Real inverseCapacity.mass.T(quantity = "ThermodynamicTemperature", unit = "K", displayUnit = "degC", min = 0.0, start = 293.15, fixed = true, nominal = 300.0) "Temperature of element";

and the following chain of equalities

directCapacity.heatCapacitor.T = directCapacity.heatCapacitor.port.T;
directCapacity.heatCapacitor.port.T = directCapacity.heatFlowToTemperature.heatPort.T;
directCapacity.heatFlowToTemperature.y = directCapacity.heatFlowToTemperature.heatPort.T
directCapacity.heatFlowToTemperature.y = directCapacity.heatFlowToTemperature.p;
directCapacity.heatFlowToTemperature.p = directCapacity.T;
directCapacity.T = inverseCapacity.T;
inverseCapacity.temperatureToHeatFlow.p = inverseCapacity.T;
inverseCapacity.temperatureToHeatFlow.u = Modelica.Blocks.Interfaces.Adaptors.Functions.state1({inverseCapacity.temperatureToHeatFlow.p, inverseCapacity.temperatureToHeatFlow.u1}, time);
inverseCapacity.temperatureToHeatFlow.u = inverseCapacity.temperatureToHeatFlow.heatPort.T
inverseCapacity.temperatureToHeatFlow.heatPort.T = inverseCapacity.mass.port.T;
inverseCapacity.mass.T = inverseCapacity.mass.port.T;

which is ultimately equivalent to

directCapacity.heatCapacitor.T = inverseCapacity.mass.T

that involves two differentiated variables, thus leading to an index-2 problem with overdetermined and consistent initial equations.

We do have algorithms in OMC to deal with this case (see paper). The chain of equality equations is trivial and handled by alias elimination, except for the equation

inverseCapacity.temperatureToHeatFlow.u = Modelica.Blocks.Interfaces.Adaptors.Functions.state1({inverseCapacity.temperatureToHeatFlow.p, inverseCapacity.temperatureToHeatFlow.u1}, time);

The function state1() has lateInline = true, so it should be eventually eliminated once the index has been analyzed. By turning on -d=optdaedump this seems to be the case: the pre-optimization phase ends with the state1() function call still in place

7/7 (1): inverseCapacity.mass.T = Modelica.Blocks.Interfaces.Adaptors.Functions.state1({directCapacity.heatFlowToTemperature.y, directCapacity.derT}, time)   [dynamic |0|0|0|0|] 

but then, the next time the dynamic equations are printed out, it shows up (correctly) as

7/7 (1): inverseCapacity.mass.T = directCapacity.heatFlowToTemperature.y   [dynamic |0|0|0|0|] 

However, for some reason the redundant initial equation is ultimately not eliminated, leading to a mixed-determined initialization problem.

I tentatively assign this issue to @Karim.Abdelhak, since he's working on index reduction. You may co-ordinate with @lochel, who wrote the algorithm to remove the redundant initial equations.

Change History (2)

by Francesco Casella, 6 years ago

Attachment: GenerationOfFMUs.mo added

comment:1 by Francesco Casella, 6 years ago

Description: modified (diff)
Note: See TracTickets for help on using tickets.