Opened 6 years ago
Closed 6 years ago
#5019 closed defect (fixed)
Issue with Media function flattening in the NF
Reported by: | Francesco Casella | Owned by: | Per Östlund |
---|---|---|---|
Priority: | high | Milestone: | 2.0.0 |
Component: | New Instantiation | Version: | |
Keywords: | Cc: |
Description
Please check ThermoPower.Test.WaterComponents.TestValveChoked. The C code compilation fails with
ThermoPower_ThermoPower.Test.WaterComponents.TestValveChoked_functions.o ThermoPower_ThermoPower.Test.WaterComponents.TestValveChoked_functions.c ThermoPower_ThermoPower.Test.WaterComponents.TestValveChoked_functions.c:5237:3: error: use of undeclared identifier 'ThermoPower_Test_WaterComponents_TestValveChoked_ValveVap_Medium_ThermodynamicState'; did you mean 'omc_ThermoPower_Test_WaterComponents_TestValveChoked_ValveVap_Medium_setState__ph'? ThermoPower_Test_WaterComponents_TestValveChoked_ValveVap_Medium_ThermodynamicState tmp1; ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ omc_ThermoPower_Test_WaterComponents_TestValveChoked_ValveVap_Medium_setState__ph
If I flatten this function with the old FE, I get
function ThermoPower.Water.ValveVap$ValveVap.Medium.setState_ph "Return thermodynamic state from p and h" input Real p(quantity = "Pressure", unit = "Pa", displayUnit = "bar", min = 611.657, max = 100000000.0, start = 5000000.0, nominal = 1000000.0) "Pressure"; input Real h(quantity = "SpecificEnergy", unit = "J/kg", min = -10000000000.0, max = 10000000000.0, start = 100000.0, nominal = 500000.0) "Specific enthalpy"; input Integer phase(min = 0, max = 2) = 0 "2 for two-phase, 1 for one-phase, 0 if not known"; output ThermoPower.Water.ValveVap$ValveVap.Medium.ThermodynamicState state "Thermodynamic state record"; algorithm state := ThermoPower.Water.ValveVap$ValveVap.Medium.setState_phX(p, h, {}, phase, 0); end ThermoPower.Water.ValveVap$ValveVap.Medium.setState_ph;
while the NF returns
function ThermoPower.Test.WaterComponents.TestValveChoked.ValveVap.Medium.setState_ph "Return thermodynamic state from p and h" input Real p(quantity = "Pressure", unit = "Pa", displayUnit = "bar", min = 611.657, max = 100000000.0, start = 5000000.0, nominal = 1000000.0) "Pressure"; input Real h(quantity = "SpecificEnergy", unit = "J/kg", min = -10000000000.0, max = 10000000000.0, start = 100000.0, nominal = 500000.0) "Specific enthalpy"; input Integer phase(min = 0, max = 2) = 0 "2 for two-phase, 1 for one-phase, 0 if not known"; output Medium.ThermodynamicState state "Thermodynamic state record"; algorithm state := ThermoPower.Test.WaterComponents.TestValveChoked.Medium.setState_phX(p, h, {}, phase, 0); end ThermoPower.Test.WaterComponents.TestValveChoked.ValveVap.Medium.setState_ph;
The paths of the two functions are different, and it seems to me that the one of the NF is in principle more correct, because it refers to the Medium
package defined by the specific instance of the ValveVap
mode, rather than to the one generically defined in the library, even though the two should actually be the same, because the default Medium package of the library model has not been redeclared in the instance.
I guess the problem is in the type of the state
output, which the NF does not replace with the correct path, but rather leaves to a generic Medium.ThermodynamicState
, which the backend cannot process later on.
This problem was solved by one of the last commits, the model now compiles and simulates regularly.