OpenModelica / OpenModelica

OpenModelica is an open-source Modelica-based modeling and simulation environment intended for industrial and academic usage.
https://openmodelica.org
Other
820 stars 305 forks source link

Translation fails with model using Externalmedia #11374

Open albertoleva opened 11 months ago

albertoleva commented 11 months ago

SETUP

OpenModelica 1.21.0 OMSimulator 2.1.1~188-gaf996ad-linux MSL 3.2.3 ExternalMedia 3.3.2

MODEL

model EM_prova_004
 package Medium
         extends ExternalMedia.Media.CoolPropMedium(
          mediumName = "R134A",
          substanceNames = {"R134A"},
          ThermoStates =
          Modelica.Media.Interfaces.Choices.IndependentVariables.ph,
          SpecificEnthalpy(start=2e5)
         );
 end Medium;

 Medium.ThermodynamicState state1;
 Modelica.SIunits.Pressure p;
 Modelica.SIunits.SpecificEnthalpy h;

equation
  state1 = Medium.setState_phX(p,h);

  state1.p = 2e5;
  state1.T = 273.15-10;

annotation(
    experiment(StartTime = 0, StopTime = 1, Tolerance = 1e-6, Interval = 0.002),
    __OpenModelica_commandLineOptions = "--matchingAlgorithm=PFPlusExt --indexReductionMethod=dynamicStateSelection -d=initialization,NLSanalyticJacobian",
    __OpenModelica_simulationFlags(lv = "LOG_STDOUT,LOG_ASSERT,LOG_STATS", s = "dassl", variableFilter = ".*"));
end EM_prova_004;

EXPECTED BEHAVIOUR

Simulate and provide fluid state.

ACTUAL BEHAVIOUR

Translation fails with

[4] 09:35:06 Translation Error
[/var/lib/jenkins2/ws/LINUX_BUILDS/tmp.build/openmodelica-1.21.0/OMCompiler/Compiler/SimCode/SimCodeUtil.mo: 6449:7-6449:46]: Internal error No support of solving not real variables with a non-linear solver. Equation:
Prove_tesi_AriannaS.Prove_ExternalMedia.EM_prova_004.Medium.ThermodynamicState(263.15, state1.a, state1.beta, state1.cp, state1.cv, state1.d, state1.ddhp, state1.ddph, state1.eta, state1.h, state1.kappa, state1.lambda, 200000.0, state1.phase, state1.s) = Prove_tesi_AriannaS.Prove_ExternalMedia.EM_prova_004.Medium.setState_ph(p, h, 0) solve for {state1.eta,state1.lambda,state1.d,state1.phase,state1.kappa,state1.h,state1.beta,p,state1.cv,h,state1.s,state1.a,state1.ddhp,state1.cp,state1.ddph}

[5] 09:35:06 Translation Error
[/var/lib/jenkins2/ws/LINUX_BUILDS/tmp.build/openmodelica-1.21.0/OMCompiler/Compiler/SimCode/SimCodeUtil.mo: 1543:5-1543:72]: Internal error SimCodeUtil.createEquationsForSystems failed

[6] 09:35:06 Translation Error
[/var/lib/jenkins2/ws/LINUX_BUILDS/tmp.build/openmodelica-1.21.0/OMCompiler/Compiler/SimCode/SimCodeUtil.mo: 798:5-798:146]: Internal error function createSimCode failed [Transformation from optimised DAE to simulation code structure failed]
casella commented 11 months ago

I'm not sure why this happens, I'll investigate. The question is, why don't you use setState_pT instead?