Opened 4 years ago
Closed 4 years ago
#6257 closed defect (fixed)
Issue with ThermoSysPro
Reported by: | Francesco Casella | Owned by: | Andreas Heuermann |
---|---|---|---|
Priority: | high | Milestone: | 1.17.0 |
Component: | Backend | Version: | 1.16.0 |
Keywords: | Cc: | daniel.bouskela@… |
Description (last modified by )
The attached model doesn't work in ThermoSysPro 3.2. daniel.bouskela@… reports the following error:
post-optimization module wrapFunctionCalls (simulation) failed
Attachments (2)
Change History (20)
by , 4 years ago
Attachment: | Reconciled_NewDataReconciliationSimpleTests_TSP_FourFlows5.mo added |
---|
comment:1 by , 4 years ago
Description: | modified (diff) |
---|
comment:2 by , 4 years ago
comment:3 by , 4 years ago
This looks quite similar to the issue reported in PR #6991, I wonder if some change was recently introduced that broke some stuff, so I don't see the same error that @daniel sees, I guess he's using 1.16.1. Or maybe I have some weird setting in OMEdit I'm not aware of.
@AnHeuermann, mind having a look?
Thanks!
comment:4 by , 4 years ago
So I tried with ThermoSysPro from https://github.com/ThermoSysPro/v3.2
loadFile("/some/path/To/ThermoSysPro/package.mo"); getErrorString(); loadFile("Reconciled_NewDataReconciliationSimpleTests_TSP_FourFlows5.mo"); getErrorString(); setCommandLineOptions("-d=newInst"); getErrorString(); buildModel(Reconciled_NewDataReconciliationSimpleTests_TSP_FourFlows5); getErrorString();
and got the same error message as daniel.bouskela:
"Notification: ThermoSysPro requested package Modelica of version 3.2.2. Modelica 3.2.3 is used instead which states that it is fully compatible without conversion script needed. Error: post-optimization module wrapFunctionCalls (simulation) failed. "
I'll dig into this.
EDIT:
I'm using latest OMCompiler v1.17.0-dev.232+g990310b9f5 on Ubuntu 20.04.
comment:5 by , 4 years ago
Of course the error is a missing else case in a match expression. I'll create a PR which will issue an error at the correct location.
And now I have to find the cause for the error.
My PR: https://github.com/OpenModelica/OpenModelica/pull/6999
comment:6 by , 4 years ago
Windows had 133 test failures 10 days ago:
https://test.openmodelica.org/jenkins/job/Windows/job/OM_Win/987/
and then the next build went up to 183:
https://test.openmodelica.org/jenkins/job/Windows/job/OM_Win/988/
Some of the messages in the new failures are similar to what I see in this ticket.
So it might be this?
https://github.com/OpenModelica/OpenModelica/commit/34a1da0a24cb60c363e323d2d71206305ebcd5fc
comment:7 by , 4 years ago
@AnHeuermann Can you try adding
#define HAVE_LAPACK
to Compiler/runtime/omc_config.h and compile omc and try again.
Let's see if that is the issue.
follow-up: 10 comment:8 by , 4 years ago
@mahge Currently I'm on Linux, that's a Windows issue, right? Also my Windows won't build at the moment.
comment:9 by , 4 years ago
We have a cse-equation:
(ThermoSysPro.Properties.WaterSteam.Common.PropThermoSat(staticDrum1_lsat_P, staticDrum1_lsat_T, staticDrum1_lsat_rho, staticDrum1_lsat_h, staticDrum1_lsat.cp, staticDrum1_lsat.pt, staticDrum1_lsat.cv), ThermoSysPro.Properties.WaterSteam.Common.PropThermoSat(staticDrum1_vsat_P, staticDrum1_vsat_T, staticDrum1_vsat_rho, staticDrum1_vsat_h, staticDrum1_vsat.cp, staticDrum1_vsat.pt, staticDrum1_vsat.cv)) = ThermoSysPro.Properties.WaterSteam.IF97.Water_sat_P(staticDrum1_P)
coming from
(staticDrum1_lsat, staticDrum1_vsat) = ThermoSysPro.Properties.WaterSteam.IF97.Water_sat_P(staticDrum1_P);
wrapFunctionCalls is struggling with it.
I dumped the expression and the record and it looks kinda strange:
--> cse-equation: (ThermoSysPro.Properties.WaterSteam.Common.PropThermoSat(staticDrum1_lsat_P, staticDrum1_lsat_T, staticDrum1_lsat_rho, staticDrum1_lsat_h, staticDrum1_lsat.cp, staticDrum1_lsat.pt, staticDrum1_lsat.cv), ThermoSysPro.Properties.WaterSteam.Common.PropThermoSat(staticDrum1_vsat_P, staticDrum1_vsat_T, staticDrum1_vsat_rho, staticDrum1_vsat_h, staticDrum1_vsat.cp, staticDrum1_vsat.pt, staticDrum1_vsat.cv)) = ThermoSysPro.Properties.WaterSteam.IF97.Water_sat_P(staticDrum1_P)
Left expression: TUPLE |CALL ThermoSysPro.Properties.WaterSteam.Common.PropThermoSat | |CREF staticDrum1_lsat_P [Real] CREFTYPE:Real | |CREF staticDrum1_lsat_T [Real] CREFTYPE:Real | |CREF staticDrum1_lsat_rho [Real] CREFTYPE:Real | |CREF staticDrum1_lsat_h [Real] CREFTYPE:Real | |CREF staticDrum1_lsat [record ThermoSysPro.Properties.WaterSteam.Common.PropThermoSat Real P; Real T; Real rho; Real h; Real cp; Real pt; Real cv; end ThermoSysPro.Properties.WaterSteam.Common.PropThermoSat;] .cp [Real] CREFTYPE:Real | |CREF staticDrum1_lsat [record ThermoSysPro.Properties.WaterSteam.Common.PropThermoSat Real P; Real T; Real rho; Real h; Real cp; Real pt; Real cv; end ThermoSysPro.Properties.WaterSteam.Common.PropThermoSat;] .pt [Real] CREFTYPE:Real | |CREF staticDrum1_lsat [record ThermoSysPro.Properties.WaterSteam.Common.PropThermoSat Real P; Real T; Real rho; Real h; Real cp; Real pt; Real cv; end ThermoSysPro.Properties.WaterSteam.Common.PropThermoSat;] .cv [Real] CREFTYPE:Real |CALL ThermoSysPro.Properties.WaterSteam.Common.PropThermoSat | |CREF staticDrum1_vsat_P [Real] CREFTYPE:Real | |CREF staticDrum1_vsat_T [Real] CREFTYPE:Real | |CREF staticDrum1_vsat_rho [Real] CREFTYPE:Real | |CREF staticDrum1_vsat_h [Real] CREFTYPE:Real | |CREF staticDrum1_vsat [record ThermoSysPro.Properties.WaterSteam.Common.PropThermoSat Real P; Real T; Real rho; Real h; Real cp; Real pt; Real cv; end ThermoSysPro.Properties.WaterSteam.Common.PropThermoSat;] .cp [Real] CREFTYPE:Real | |CREF staticDrum1_vsat [record ThermoSysPro.Properties.WaterSteam.Common.PropThermoSat Real P; Real T; Real rho; Real h; Real cp; Real pt; Real cv; end ThermoSysPro.Properties.WaterSteam.Common.PropThermoSat;] .pt [Real] CREFTYPE:Real | |CREF staticDrum1_vsat [record ThermoSysPro.Properties.WaterSteam.Common.PropThermoSat Real P; Real T; Real rho; Real h; Real cp; Real pt; Real cv; end ThermoSysPro.Properties.WaterSteam.Common.PropThermoSat;] .cv [Real] CREFTYPE:Real
Right expression: CALL ThermoSysPro.Properties.WaterSteam.IF97.Water_sat_P |CREF staticDrum1_P [Real] CREFTYPE:Real
I think the record ThermoSysPro.Properties.WaterSteam.Common.PropThermoSat
is containing a record of type ThermoSysPro.Properties.WaterSteam.Common.PropThermoSat
as 5th element but that should be Modelica.SIunits.SpecificHeatCapacity cp
??
Not sure if the dump is correct, though.
comment:10 by , 4 years ago
Replying to AnHeuermann:
@mahge Currently I'm on Linux, that's a Windows issue, right? Also my Windows won't build at the moment.
Yes. I thought the errors were for Windows. If the problem is not on Windows you can ignore it.
comment:11 by , 4 years ago
I think the record ThermoSysPro.Properties.WaterSteam.Common.PropThermoSat is containing a record of type ThermoSysPro.Properties.WaterSteam.Common.PropThermoSat as 5th element but that should be Modelica.SIunits.SpecificHeatCapacity cp??
Not sure if the dump is correct, though.
Never mind, the dump was just different than I thought.
The basic problem:
In CommonSubExpressions.mo in function isEquationRedundant_flatten
we need an additional case
case BackendDAE.COMPLEX_EQUATION(_, exp1 as DAE.TUPLE(lhs), exp2 as DAE.CALL(), _, _)
But I'm not 100% sure how to handle that case.
This is basically an equation of the form TUPLE(a,b,c,d) = CALL(e)
. I need a variable cse1
for CALL(e)
and possibly additional cse variables for a,b,c and d because they could be CALL
's as well.
follow-up: 16 comment:12 by , 4 years ago
I managed to simplify the test and create a smaller example to reproduce the error:
model simplified parameter Real P = 1450000; ThermoSysPro.Properties.WaterSteam.Common.PropThermoSat staticDrum1_lsat, staticDrum1_vsat; Real staticDrum1_vsat_P = staticDrum1_vsat.P; // Remove me to simulate correctly equation (staticDrum1_lsat, staticDrum1_vsat) = ThermoSysPro.Properties.WaterSteam.IF97.Water_sat_P(P); end simplified;
If all alias variables from record elements are removed the model will simulate just fine.
comment:13 by , 4 years ago
And another one:
loadString(" model simplified parameter Real inputParam = 1; record ARecord Real var1; Real var2; end ARecord; ARecord recordLeft, recordRight; Real recordLeft_var1 = recordLeft.var1; // Remove me to simulate correctly function myFunc input Real inp; output ARecord leftOutput; output ARecord rightOutput; algorithm leftOutput := ARecord(1,2); rightOutput := ARecord(3,4); end myFunc; equation (recordLeft, recordRight) = myFunc(inputParam); end simplified; "); getErrorString(); setCommandLineOptions("-d=newInst,dumpCSE_verbose"); getErrorString(); buildModel(simplified); getErrorString();
This should simplify debugging immensely.
comment:15 by , 4 years ago
Okay, I got something and for my newest model simplified
I'm getting the correct solution 1,2,3,4
. So there is noooo way this could ever fail *strong sarcasm*.
I pushed the changes to my PR.
I uploaded the new results https://trac.openmodelica.org/OpenModelica/attachment/ticket/6257/results_new.mat
comment:16 by , 4 years ago
I used the model from comment 12 to validate my results. They seem to be correct.
comment:17 by , 4 years ago
Very good!
@AnHeuermann, please notify here when PR 6999 is merged in.
@daniel, if you are on Windows, on the following day you can download the nightly build and check if all works fine. If you are on Linux, we have some trouble with the nightly builds, I hope it gets resolved soon.
comment:18 by , 4 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
https://github.com/OpenModelica/OpenModelica/pull/6999 is now merged.
Set ticket to solved.
@daniel If the problem is not solved for you please reopen this ticket or open a new one.
I tried with the latest nightly build, but I actually get a different issue