ibpsa / modelica-ibpsa

Modelica library for building and district energy systems developed within IBPSA Project 1
https://ibpsa.github.io/project1
140 stars 83 forks source link

Fluid/Interfaces/Examples/Humidifier_u.mo fails in OpenModelica #187

Closed mwetter closed 6 years ago

mwetter commented 9 years ago

The model Annex60.Fluid.Interfaces.Examples.Humidifier_u fails in OpenModelica with the message:

Error: Variable T in package Annex60.Fluid.Interfaces.Examples.Humidifier_u.Humidifier$hea1 is not constant.
[/var/lib/hudson/jobs/OpenModelica_TEST_ALL_LIBRARIES/workspace/OpenModelica/build/lib/omlibrary/Annex60 0.1/Fluid/Interfaces/Examples/Humidifier_u.mo:113:45-113:58:writable] Error: Variable hea1.staB.T not found in scope Annex60.Fluid.Interfaces.Examples.Humidifier_u.
Error: Error occurred while flattening model Annex60.Fluid.Interfaces.Examples.Humidifier_u

The issue is that for the asserts, the variables staA.T and staA.X[1] (and the same for B) are accessed, but these are not always state variables, and OpenModelica therefore thinks they do not exist.

As a fix, Annex60.Fluid.Interfaces.Examples.Humidifier_u.Humidifier should be deleted, and sensors should be used as is done for Annex60.Fluid.Interfaces.Examples.HeaterCooler_u.

thorade commented 6 years ago

The error message is now a different one: https://libraries.openmodelica.org/branches/master/IBPSA_latest/files/IBPSA_latest_IBPSA.Fluid.Interfaces.Examples.Humidifier_u.err

Humidifier should propagate the Medium, I think:

protected
  model Humidifier
    "Model for humidifier that adds a variable for the thermodynamic states at its ports"
    extends IBPSA.Fluid.Humidifiers.Humidifier_u(
      redeclare replaceable package Medium = Medium);

but with that version, OpenModelica has a StackOverflow.

Would that change be correct? And should I push it?

thorade commented 6 years ago

After thinking about it some more, the redeclaration should not be necessary and is not done in other similar models.

Maybe that error is instead a duplicate of https://trac.openmodelica.org/OpenModelica/ticket/4235 ?

mwetter commented 6 years ago

Redeclaration is indeed not necessairy.

thorade commented 6 years ago

Closing for now, should be checked again once the new OMC frontend is available: https://trac.openmodelica.org/OpenModelica/ticket/4138 https://trac.openmodelica.org/OpenModelica/milestone/2.0.0