Opened 3 years ago

Closed 3 years ago

#6257 closed defect (fixed)

Issue with ThermoSysPro

Reported by: casella Owned by: AnHeuermann
Priority: high Milestone: 1.17.0
Component: Backend Version: 1.16.0
Keywords: Cc: daniel.bouskela@…

Description (last modified by casella)

The attached model doesn't work in ThermoSysPro 3.2. daniel.bouskela@… reports the following error:

post-optimization module wrapFunctionCalls (simulation) failed

Attachments (2)

Reconciled_NewDataReconciliationSimpleTests_TSP_FourFlows5.mo (13.8 KB) - added by casella 3 years ago.
results_new.mat (655.0 KB) - added by AnHeuermann 3 years ago.
Results with fixed OMC

Download all attachments as: .zip

Change History (20)

comment:1 Changed 3 years ago by casella

  • Description modified (diff)

comment:2 Changed 3 years ago by casella

I tried with the latest nightly build, but I actually get a different issue

[1] 13:15:49 Translation Error
[C:/dev/OM64bit/OMCompiler/Compiler/BackEnd/BackendDAETransform.mo: 342:7-342:48]: 
Internal error BackendDAETransform.analyseStrongComponentBlock failed
variables:
  singularPressureLoss4_C1_P
  singularPressureLoss4_C2_P
equations:
  singularPressureLoss4_Pm = 0.5 * (singularPressureLoss4_C1_P + singularPressureLoss4_C2_P)
  singularPressureLoss4_C1_P - singularPressureLoss4_C2_P = singularPressureLoss4_deltaP

[2] 13:15:49 Translation Error
[C:/dev/OM64bit/OMCompiler/Compiler/BackEnd/BackendDAETransform.mo: 346:7-346:90]: Internal error function analyseStrongComponentBlock failed

[3] 13:15:49 Translation Error
[C:/dev/OM64bit/OMCompiler/Compiler/BackEnd/BackendDAETransform.mo: 196:5-196:89]: Internal error function analyseStrongComponentScalar failed

[4] 13:15:49 Translation Error
[C:/dev/OM64bit/OMCompiler/Compiler/BackEnd/BackendDAETransform.mo: 107:7-107:113]: Internal error function strongComponentsScalar failed (sorting strong components)

[5] 13:15:49 Translation Error
[C:/dev/OM64bit/OMCompiler/Compiler/BackEnd/BackendDAEUtil.mo: 7903:5-7903:89]: Internal error Transformation module sort components failed

comment:3 Changed 3 years ago by casella

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!

Last edited 3 years ago by casella (previous) (diff)

comment:4 Changed 3 years ago by AnHeuermann

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.

Last edited 3 years ago by AnHeuermann (previous) (diff)

comment:5 Changed 3 years ago by AnHeuermann

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 Changed 3 years ago by adrpo

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 Changed 3 years ago by mahge930

@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.

Last edited 3 years ago by mahge930 (previous) (diff)

comment:8 follow-up: Changed 3 years ago by AnHeuermann

@mahge Currently I'm on Linux, that's a Windows issue, right? Also my Windows won't build at the moment.

comment:9 Changed 3 years ago by AnHeuermann

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 in reply to: ↑ 8 Changed 3 years ago by mahge930

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 Changed 3 years ago by AnHeuermann

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.

comment:12 follow-up: Changed 3 years ago by AnHeuermann

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 Changed 3 years ago by AnHeuermann

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:14 Changed 3 years ago by casella

I confirm I can reproduce the issue with the .mos script.

Changed 3 years ago by AnHeuermann

Results with fixed OMC

comment:15 Changed 3 years ago by AnHeuermann

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

Last edited 3 years ago by AnHeuermann (previous) (diff)

comment:16 in reply to: ↑ 12 Changed 3 years ago by AnHeuermann

I used the model from comment 12 to validate my results. They seem to be correct.

comment:17 Changed 3 years ago by casella

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 Changed 3 years ago by AnHeuermann

  • Resolution set to fixed
  • Status changed from new to 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.

Note: See TracTickets for help on using tickets.