Opened 9 years ago
Closed 7 years ago
#3742 closed defect (wontfix)
Modelica.Fluid.Examples.HeatingSystem fails to translate since Feb 26
Reported by: | Rüdiger Franke | Owned by: | Lennart Ochel |
---|---|---|---|
Priority: | blocker | Milestone: | 1.12.0 |
Component: | Backend | Version: | v1.9.4-dev-nightly |
Keywords: | Cc: | Niklas Worschech |
Description
There must have been introduced something bad on Feb 25 that causes a new compilation error in the Cpp runtime.
See:
https://test.openmodelica.org/libraries/history/MSL_3.2.1_cpp-trend.svg
Also visible in detailed view until March 3:
https://test.openmodelica.org/libraries/history/MSL_3.2.1_cpp-trend-detailed.svg
The error message:
Change History (34)
comment:1 by , 9 years ago
Status: | new → accepted |
---|
comment:4 by , 9 years ago
It appears to work again when reverting the commit referred in comment:2 above. Should we do this until a better solution will have been found?
comment:5 by , 9 years ago
Reverting this commit would break other tickets. I need to change matching/index reduction a bit. I will try to fix it until the next OSMC meeting on Monday. Then, we can also discuss how to proceed with this ticket if it's still open.
comment:6 by , 9 years ago
The question is why does it work for the C runtime but not for the Cpp runtime?
The errors here:
https://test.openmodelica.org/libraries/MSL_3.2.1_cpp/files/Modelica.Fluid.Examples.HeatingSystem.err
are undefined variables mostly.
follow-up: 8 comment:7 by , 9 years ago
@lochel: Can you elaborate a bit more which other tickets would be broken?
This information might also help to understand which equation system is not generated by the Cpp runtime. The commit message does not mention any ticket.
comment:8 by , 9 years ago
comment:9 by , 9 years ago
My first impression was wrong, since I tested on a machine with broken environment and thus I got misleading error messages.
Here is what I can tell so far:
Before I've introduced the differentiation rule for homotopy expressions, the model compiled but didn't simulate. Now, the example fails to compile due to a different set of equations. The same issue was already there before, if the model was compiled with --replaceHomotopy=actual
.
I think this is not a back end issue, but a Cpp codegen issue.
comment:10 by , 9 years ago
Unfortunately the example does neither simulate with C nor with Cpp runtime in the nightly tests. It was simulating with the Cpp runtime before the change when manually tweaking nonlinear solver options.
After the change the generation of a simulator fails because the Cpp code accesses an equation system for which it generates no code. The question is where this additional equation system comes from and why it is not considered during Cpp code generation.
comment:11 by , 9 years ago
Cc: | added |
---|
I've not much experience with the Cpp code generation. Maybe someone else can give some input.
follow-up: 13 comment:12 by , 9 years ago
I havn't seen this error message in any other of many hundred examples so far.
The code seems to contain nested nonlinear equation systems. +d=dumpSimCode lists the missing system (equation 969, index 9) as subsystem of 980, index 8. Where does this nesting come from?
comment:13 by , 9 years ago
Replying to rfranke:
I havn't seen this error message in any other of many hundred examples so far.
The code seems to contain nested nonlinear equation systems. +d=dumpSimCode lists the missing system (equation 969, index 9) as subsystem of 980, index 8. Where does this nesting come from?
I guess because ExpressionSolve.solve fail(+d=failtrace)
[c:/dev/OM/OMCompiler/Compiler/BackEnd/ExpressionSolve.mo:256:9-256:210:writable] Error: Interner Fehler Failed to so lve "$DER.pump.dp_pump = $DER.pump.medium.p + $DER.pump.dp_pump" w.r.t. "$DER.pump.dp_pump"
comment:14 by , 9 years ago
for me cpp -Code is fine :)
and we have a bug in C-Code generation...
solve
0 = $DER.pump.medium.p" w.r.t. "$DER.pump.dp_pump"
should be a bug.
comment:15 by , 9 years ago
Rüdiger can you check PR 516 for cpp/Modelica.Fluid.Examples.HeatingSystem :) ?
comment:16 by , 9 years ago
It's basially the same as before. When I select -d=evalparam
, then the backend fails with:
[Modelica 3.2.1/Fluid/Machines.mo:389:5-389:66:writable] Error: Model is structurally singular, error found sorting equations 22: 0.0 = -pump_medium_pSeedStateSetJac13; for variables pump.dp_pump.$pDERStateSetJac13.dummyVarStateSetJac13(1), tank.s_2_.$pDERStateSetJac13.dummyVarStateSetJac13(22) Error: Internal error Transformation Module PFPlusExt index Reduction Method Pantelides failed! [OpenModelica/OMCompiler/Compiler/BackEnd/SymbolicJacobian.mo:1835:10-1835:88:writable] Error: Internal error function optimizeJacobianMatrix failed [OpenModelica/OMCompiler/Compiler/BackEnd/SymbolicJacobian.mo:1770:9-1770:79:writable] Error: Internal error function createJacobian failed
follow-up: 19 comment:17 by , 9 years ago
The model initializes in steady-state, meaning that both "$DER.pump.medium.p" and "$DER.pump.dp_pump" should be zero. Can it be that you have to merge the nested equation system into one, in order to get rid of the sigularity? Have a look at the output of +d=dumpSimCode.
980: (NONLINEAR) index:8 jacobian: false crefs: $DER.pump.medium.p , $DER.pump.medium.h 965: $DER.pump.rho=...[Real ] 966: $DER.heater.statesFM[1].d=...[Real ] 967: $DER.heater.statesFM[1].T=...[Real ] 969: (NONLINEAR) index:9 jacobian: false crefs: $DER.pump.dp_pump 968: $DER.pump.medium.p (RESIDUAL) 970: $DER.heater.flowModel.mus[1]=...[Real ] 971: $DER.heater.flowModel.Fs_p[1]=...[Real ] 972: $DER.heater.flowModel.dps_fg[1]=...[Real ] 973: $DER.m_flow=...[Real ] 977: $DER.pump.W_single=...(RESIDUAL) 978: if tank.regularFlow[2] then ... (RESIDUAL)
comment:18 by , 9 years ago
some notes to comment 13:
omc Modelica.Fluid.Examples.HeatingSystem.mos +d=dumpeqninorder
return
internal vars 1: $DER.pump.rho:DUMMY_DER(fixed = false ) .Modelica.Fluid.Examples.HeatingSystem, .Modelica.Fluid.Machines.ControlledPump$pump, .Modelica.Fluid.Machines.ControlledPump$pump.Medium.Density$pump$rho type: Real 2: $DER.heater.statesFM[1].d:DUMMY_DER(fixed = false ) "Density".Modelica.Fluid.Examples.HeatingSystem, .Modelica.Fluid.Pipes.DynamicPipe$heater, .Modelica.Fluid.Pipes.DynamicPipe$heater.Medium.ThermodynamicSta te, .Modelica.Fluid.Pipes.DynamicPipe$heater.Medium.Density$heater$statesFM$d type: Real [3] 3: $DER.heater.statesFM[1].T:DUMMY_DER(fixed = false ) "Temperature".Modelica.Fluid.Examples.HeatingSystem, .Modelica.Fluid.Pipes.DynamicPipe$heater, .Modelica.Fluid.Pipes.DynamicPipe$heater.Medium.Thermodynami cState, .Modelica.Fluid.Pipes.DynamicPipe$heater.Medium.Temperature$heater$statesFM$T type: Real [3] 4: $DER.pump.dp_pump:DUMMY_DER(fixed = false ) "Pressure increase".Modelica.Fluid.Examples.HeatingSystem, .Modelica.Fluid.Machines.ControlledPump$pump, .Modelica.SIunits.Pressure type: Real 5: $DER.heater.flowModel.mus[1]:DUMMY_DER(fixed = false ) .Modelica.Fluid.Examples.HeatingSystem, .Modelica.Fluid.Pipes.DynamicPipe$heater, .Modelica.Fluid.Pipes.DynamicPipe$heater.FlowModel$heater$flowModel, .M odelica.Fluid.Pipes.DynamicPipe$heater.FlowModel$heater$flowModel.Medium.DynamicViscosity type: Real [3] 6: $DER.heater.flowModel.Fs_p[1]:DUMMY_DER(fixed = false ) "Pressure forces".Modelica.Fluid.Examples.HeatingSystem, .Modelica.Fluid.Pipes.DynamicPipe$heater, .Modelica.Fluid.Pipes.DynamicPipe$heater.FlowModel$h eater$flowModel, .Modelica.SIunits.Force type: Real [2] 7: $DER.heater.flowModel.dps_fg[1]:DUMMY_DER(fixed = false ) "pressure drop between states".Modelica.Fluid.Examples.HeatingSystem, .Modelica.Fluid.Pipes.DynamicPipe$heater, .Modelica.Fluid.Pipes.DynamicPipe$hea ter.FlowModel$heater$flowModel, .Modelica.SIunits.Pressure$heater$flowModel$dps_fg type: Real [2] 8: output $DER.m_flow:DUMMY_DER(fixed = false ) .Modelica.Fluid.Examples.HeatingSystem, .Modelica.Blocks.Interfaces.RealOutput type: Real 9: $DER.pump.V_flow:DUMMY_DER(fixed = false ) "Volume flow rate (total)".Modelica.Fluid.Examples.HeatingSystem, .Modelica.Fluid.Machines.ControlledPump$pump, .Modelica.SIunits.VolumeFlowRate type: Real 10: $DER.pump.Hb_flow:DUMMY_DER(fixed = false ) "Enthalpy flow across boundaries or energy source/sink".Modelica.Fluid.Examples.HeatingSystem, .Modelica.Fluid.Machines.ControlledPump$pump, .Modelica.SIunits.Ent halpyFlowRate type: Real 11: $DER.pump.V_flow_single:DUMMY_DER(fixed = false ) "Volume flow rate (single pump)".Modelica.Fluid.Examples.HeatingSystem, .Modelica.Fluid.Machines.ControlledPump$pump, .Modelica.SIunits.VolumeFlowRate$pump$ V_flow_single type: Real 12: $DER.pump.W_single:DUMMY_DER(fixed = false ) "Power Consumption (single pump)".Modelica.Fluid.Examples.HeatingSystem, .Modelica.Fluid.Machines.ControlledPump$pump, .Modelica.SIunits.Power type: Real residual vars 1: $DER.pump.medium.p:DUMMY_DER(fixed = false ) "Absolute pressure of medium".Modelica.Fluid.Examples.HeatingSystem, .Modelica.Fluid.Machines.ControlledPump$pump, .Modelica.Fluid.Machines.ControlledPump$pump.Me dium.BaseProperties$pump$medium, .Modelica.Fluid.Machines.ControlledPump$pump.Medium.BaseProperties$pump$medium.InputAbsolutePressure$pump$medium$p type: Real 2: $DER.pump.medium.h:DUMMY_DER(fixed = false ) "Specific enthalpy of medium".Modelica.Fluid.Examples.HeatingSystem, .Modelica.Fluid.Machines.ControlledPump$pump, .Modelica.Fluid.Machines.ControlledPump$pump.Me dium.BaseProperties$pump$medium, .Modelica.Fluid.Machines.ControlledPump$pump.Medium.BaseProperties$pump$medium.InputSpecificEnthalpy$pump$medium$h type: Real internal equation 1/1 (1): $DER.pump.rho = Modelica.Media.Water.IF97_Utilities.rho_ph_der(pump.medium.p, pump.medium.h, Modelica.Media.Water.IF97_Utilities.waterBaseProp_ph(pump.medium.p, pump.medium.h, pump.heatTransfer.states[1 ].phase, 0), $DER.pump.medium.p, $DER.pump.medium.h) [dynamic] 2/2 (1): $DER.heater.statesFM[1].d = Modelica.Media.Water.IF97_Utilities.rho_ph_der(pump.medium.p, pump.medium.h, Modelica.Media.Water.IF97_Utilities.waterBaseProp_ph(pump.medium.p, pump.medium.h, 0, 0), $DER.pu mp.medium.p, $DER.pump.medium.h) [dynamic] 3/3 (1): $DER.heater.statesFM[1].T = Modelica.Media.Water.IF97_Utilities.T_ph_der(pump.medium.p, pump.medium.h, Modelica.Media.Water.IF97_Utilities.waterBaseProp_ph(pump.medium.p, pump.medium.h, 0, 0), $DER.pump .medium.p, $DER.pump.medium.h) [dynamic] 4/4 (1): $DER.pump.dp_pump = $DER.pump.medium.p + $DER.pump.dp_pump [binding] 5/5 (1): $DER.heater.flowModel.mus[1] = $DER$$PModelica$PMedia$PWater$PIF97_Utilities$PdynamicViscosity(heater.statesFM[1].d, heater.statesFM[1].T, pump.medium.p, 0, $DER.heater.statesFM[1].d, $DER.heater.states FM[1].T, $DER.pump.medium.p) [dynamic] 6/6 (1): $DER.heater.flowModel.Fs_p[1] = heater.crossAreas[1] * ($DER.heater.mediums[1].p - $DER.pump.medium.p) * heater.flowModel.nParallel [dynamic] 7/7 (1): $DER.heater.flowModel.dps_fg[1] = -2.0 * $DER.heater.flowModel.Fs_p[1] * heater.flowModel.nParallel * 2.0 * heater.crossAreas[1] / (heater.flowModel.nParallel ^ 2.0 * 4.0 * heater.crossAreas[1] ^ 2.0) [dynamic] 8/8 (1): $DER.m_flow = ($DER.heater.flowModel.dps_fg[1] * $DER$$PModelica$PFluid$PPipes$PDynamicPipe$heater$PFlowModel$heater$flowModel$PWallFriction$PmassFlowRate_dp_staticHead(heater.flowModel.dps_fg[1], heate r.statesFM[1].d, heater.statesFM[2].d, heater.flowModel.mus[1], heater.flowModel.mus[2], heater.pathLengths[1], heater.dimensions[1], 0.0, heater.crossAreas[1], heater.roughnesses[1], 0.5 * heater.flowModel.dp_s mall, heater.flowModel.Re_turbulent, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0) + $DER.heater.statesFM[1].d * $DER$$PModelica$PFluid$PPipes$PDynamicPipe$heater$PFlowModel$heater$flowModel$PWallF riction$PmassFlowRate_dp_staticHead(heater.flowModel.dps_fg[1], heater.statesFM[1].d, heater.statesFM[2].d, heater.flowModel.mus[1], heater.flowModel.mus[2], heater.pathLengths[1], heater.dimensions[1], 0.0, hea ter.crossAreas[1], heater.roughnesses[1], 0.5 * heater.flowModel.dp_small, heater.flowModel.Re_turbulent, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0) + $DER.heater.statesFM[2].d * $DER$$PModelica $PFluid$PPipes$PDynamicPipe$heater$PFlowModel$heater$flowModel$PWallFriction$PmassFlowRate_dp_staticHead(heater.flowModel.dps_fg[1], heater.statesFM[1].d, heater.statesFM[2].d, heater.flowModel.mus[1], heater.fl owModel.mus[2], heater.pathLengths[1], heater.dimensions[1], 0.0, heater.crossAreas[1], heater.roughnesses[1], 0.5 * heater.flowModel.dp_small, heater.flowModel.Re_turbulent, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0 .0, 0.0, 0.0, 0.0, 0.0) + $DER.heater.flowModel.mus[1] * $DER$$PModelica$PFluid$PPipes$PDynamicPipe$heater$PFlowModel$heater$flowModel$PWallFriction$PmassFlowRate_dp_staticHead(heater.flowModel.dps_fg[1], heater .statesFM[1].d, heater.statesFM[2].d, heater.flowModel.mus[1], heater.flowModel.mus[2], heater.pathLengths[1], heater.dimensions[1], 0.0, heater.crossAreas[1], heater.roughnesses[1], 0.5 * heater.flowModel.dp_sm all, heater.flowModel.Re_turbulent, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0) + $DER.heater.flowModel.mus[2] * $DER$$PModelica$PFluid$PPipes$PDynamicPipe$heater$PFlowModel$heater$flowModel$PWal lFriction$PmassFlowRate_dp_staticHead(heater.flowModel.dps_fg[1], heater.statesFM[1].d, heater.statesFM[2].d, heater.flowModel.mus[1], heater.flowModel.mus[2], heater.pathLengths[1], heater.dimensions[1], 0.0, h eater.crossAreas[1], heater.roughnesses[1], 0.5 * heater.flowModel.dp_small, heater.flowModel.Re_turbulent, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0)) * heater.flowModel.nParallel [dynamic] 9/9 (1): $DER.pump.V_flow = ($DER.m_flow * pump.rho - m_flow * $DER.pump.rho) / pump.rho ^ 2.0 [dynamic] 10/10 (1): $DER.pump.Hb_flow = m_flow * ($DER.tank.medium.h - $DER.pump.medium.h) + $DER.m_flow * (smooth(0, tank.medium.h) - smooth(0, pump.medium.h)) [dynamic] 11/11 (1): $DER.pump.V_flow_single = $DER.pump.V_flow / /*Real*/(pump.nParallel) [dynamic] 12/12 (1): $DER.pump.W_single = pump.dp_pump * $DER.pump.V_flow_single / pump.eta + $DER.pump.dp_pump * pump.V_flow_single / pump.eta [dynamic]
the issue is internal tearing equation
4/4 (1): $DER.pump.dp_pump = $DER.pump.medium.p + $DER.pump.dp_pump [binding]
where we want solve $DER.pump.dp_pump
. If ExpressionSolve fail we create a nonlinear system ... the internal loop/nested equation.
comment:19 by , 9 years ago
Replying to rfranke:
The model initializes in steady-state, meaning that both "$DER.pump.medium.p" and "$DER.pump.dp_pump" should be zero. Can it be that you have to merge the nested equation system into one, in order to get rid of the sigularity?
next try in PR516 :)
comment:20 by , 9 years ago
This looks better!
And it triggered a bug in the Cpp code generation, which is hopefully fixed with db37146/OMCompiler.
@adrpo: after this change, can you please trigger the tests once more or wait until tomorrow with the release?
Note that the model does still not simulate. With 'evalparam' the translation fails due to a structurally singular system.
comment:21 by , 9 years ago
The translation error with evalparam
Error: Model is structurally singular, error found sorting equations 22: 0.0 = -pump_medium_pSeedStateSetJac13
disappears when reverting the originating bd44300/OMCompiler.
Note that the example simulated with the C runtime until about a year ago, see:
https://test.openmodelica.org/libraries/history/MSL_3.2.1-2015-03-08.html
This must also be the time when the warning/comment was introduced into Differentiate.mo
: "lochel: see #3305 - this is commented out since it breaks Modelica.Fluid.Examples.HeatingSystem."
Then something was changed in the numerics to make the example fail. Now with bd44300/OMCompiler it appears that the example became unsolvable (structurally singular)!!!
comment:23 by , 9 years ago
Priority: | blocker → critical |
---|
The renewed library coverage tests show that a simulator is built again. It is still unclear if the translated model is solvable (see error about structural singularity in comment:21). This is why the ticket is kept open with reduced priority.
comment:24 by , 9 years ago
There seems to be a dip in MSL_trunk_cpp_Simulation:
https://test.openmodelica.org/hudson/job/MSL_trunk_cpp_Simulation/
comment:25 by , 9 years ago
It's the two examples Modelica.Fluid.Examples.AST_BatchPlant.Test.TanksWithEmptyingPipe1
and 2
that verified until yesterday and don't simulate after vitalij's fix in the backend anymore. They still succeed in the C runtime, meaning the generated simcode should be ok.
comment:28 by , 9 years ago
Priority: | critical → blocker |
---|
blocked further development in the Backendend.
With small changes (like change order of post-,preModules e.g. solveSimpleEquation before removeSimpleEquation) in the backend it is possible running in the issues described in comment21.
By the way #3716 has issues with nonlinear solver, which can the same issues like described in comment21.
follow-up: 30 comment:29 by , 9 years ago
Btw. the PowerSystems library also has some examples where the Cpp code accesses not existing algebraic loops. I didn't further investigate yet. The error pattern is the same. Do we have again "nested" equation systems?
See: https://test.openmodelica.org/libraries/PowerSystems_cpp/BuildModelRecursive.html
PowerSystems.Examples.Spot.GenerationAC3ph.TurbineGeneratorLine
PowerSystems.Examples.Spot.GenerationAC3ph.TurboGeneratorLine
PowerSystems.Examples.Spot.GenerationAC3ph.Vsource
PowerSystems.Examples.Spot.Introduction.SimulationTransient
The C runtime generates a simulator that fails to run with:
assert | debug | residual function pointer is invalid
comment:30 by , 9 years ago
comment:31 by , 9 years ago
The four examples mentioned in comment:29 work now!
Lets see if it also has impact on #3799 once #3798 (RemoveSimpleEquations) will be fixed.
comment:33 by , 8 years ago
Milestone: | 1.11.0 → 1.12.0 |
---|
Milestone moved to 1.12.0 due to 1.11.0 already being released.
comment:34 by , 7 years ago
Resolution: | → wontfix |
---|---|
Status: | accepted → closed |
This ticket had a quite drastic evolution since it was first opened. The issue with HeatingSystem is reported as a blocker in #4316. Other than that, at this point it is not really clear to me what should be done in order to clear this ticket.
Please feel free to reopen this ticket by changing the subject and pointing out clearly what is still going wrong.
The related commit is obviously this one bd44300/OMCompiler, see the comment in the changeset.