Opened 6 years ago
Closed 6 years ago
#5095 closed defect (fixed)
Integer equation lost by 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.PowerPlants.ElectricGeneratorGroup.Tests.Test_Generator_SE. When flattening the model with the NF, the equation
steamTurbineStodola.steamState_iso.phase = 0;
does not show up in the flat model, as it does instead with the old FE.
Change History (4)
comment:1 by , 6 years ago
comment:2 by , 6 years ago
After 6654660 the NF now evaluates the mentioned function call, and instead generates the record equation (where the rhs still looks like a function call, but is actually a record expression):
steamTurbineStodola.steamState_iso = valveHP.Medium.ThermodynamicState(0, 100000.0, 997.3369503211875, 296.9948190753248, 100000.0);
This doesn't affect the outcome at all, the backend still complains about the model being under-determined. I also tried splitting the equation like the OF does, which made no difference either. So the problem must lie elsewhere, but comparing the flat model from the NF and the OF I can't spot any significant differences.
comment:3 by , 6 years ago
I had a look at the output of -d=optdaedump
when the NF is used. Until the pre-optimization module evalFunc (simulation) is invoked, the system is balanced. When this function is called, the set of equations is then reduced from 35 to 30 equations, but only 4 variables, namely
21: valveHP.w:VARIABLE(flow=false min = max(-100000.0, max(-1e+060, max(-1e+060, max(-100000.0, max(-1e+060, max(-1e+060, max(-1e+060, -100000.0))))))) max = min(100000.0, min(100000.0, min(100000.0, min(100000.0, min(100000.0, min(100000.0, min(100000.0, 100000.0))))))) start = steamTurbineStodola.wstart unit = "kg/s" ) "Mass flow rate" type: Real 25: steamTurbineStodola.Pm:VARIABLE(flow=false unit = "W" ) "Mechanical power input" type: Real 31: steamTurbineStodola.steamState_in.p:VARIABLE(flow=false min = 611.657 max = 100000000.0 start = 5000000.0 unit = "Pa" nominal = 1000000.0 ) "Pressure" type: Real 32: steamTurbineStodola.steamState_in.T:VARIABLE(flow=false min = 273.15 max = 2273.15 start = 500.0 unit = "K" nominal = 500.0 ) "Temperature" type: Real
are removed from the set of unknowns. If all the equations which are identical before and after the equations are omitted, what is left is:
Before (9 equations):
1/1 (1): valveHP.w = homotopy(steamTurbineStodola.Kt * sqrt(steamTurbineStodola.steamState_in.p * steamTurbineStodola.steamState_in.d) * ThermoPower.Functions.sqrtReg(1.0 - (1.0 / steamTurbineStodola.PR) ^ 2.0, 0.01), steamTurbineStodola.wnom / (steamTurbineStodola.partialArc_nom * steamTurbineStodola.pnom) * steamTurbineStodola.steamState_in.p) [dynamic |0|0|0|0|] 5/5 (1): steamTurbineStodola.Pm = steamTurbineStodola.eta_mech * valveHP.w * (sourceP.h - steamTurbineStodola.hout) [dynamic |0|0|0|0|] 6/6 (1): steamTurbineStodola.Pm = (-steamTurbineStodola.tau) * generator_SE.omega [dynamic |0|0|0|0|] 7/7 (5): steamTurbineStodola.steamState_in = ThermoPower.PowerPlants.ElectricGeneratorGroup.Tests.Test_Generator_SE.valveHP.Medium.setState_ph(steamTurbineStodola.pin, sourceP.h, 0) [dynamic |0|0|0|0|] 13/17 (1): valveHP.w = homotopy(ThermoPower.PowerPlants.ElectricGeneratorGroup.Tests.Test_Generator_SE.valveHP.FlowChar(valveHP.theta_act) * valveHP.Av * valveHP.Y * sqrt(valveHP.rho) * smooth(0, if valveHP.xs >= 0.0 then ThermoPower.Water.ValveVap.sqrtR(valveHP.p * valveHP.xs, valveHP.b * valveHP.dpnom) else 0.0), valveHP.theta_act / valveHP.thetanom * valveHP.wnom / valveHP.dpnom * valveHP.dp) [dynamic |0|0|0|0|]
After (5 equations):
4/4 (1): 0.0 = (-steamTurbineStodola.tau) * generator_SE.omega [dynamic |0|0|0|0|] 5/5 (2): (steamTurbineStodola.steamState_in.phase, steamTurbineStodola.steamState_in.h) = hermoPower.PowerPlants.ElectricGeneratorGroup.Tests.Test_Generator_SE.valveHP.Medium.setState_ph_eval3(steamTurbineStodola.pin, sourceP.h, 0) [dynamic |0|0|0|0|] 11/12 (1): 0.0 = homotopy(ThermoPower.PowerPlants.ElectricGeneratorGroup.Tests.Test_Generator_SE.valveHP.FlowChar(valveHP.theta_act) * valveHP.Av * valveHP.Y * sqrt(valveHP.rho) * smooth(0, if valveHP.xs >= 0.0 then ThermoPower.Water.ValveVap.sqrtR(valveHP.p * valveHP.xs, valveHP.b * valveHP.dpnom) else 0.0), valveHP.theta_act / valveHP.thetanom * valveHP.wnom / valveHP.dpnom * valveHP.dp) [dynamic |0|0|0|0|]
Now, I'm not sure where does the setState_ph_eval3()
come from, but it seems that there is some issue with functions involving record outputs, losing some pieces along the road.
Note that the the function call to setState_ph
, when fed by the old FE, is split by the first back-end function normalInlineFunction into:
20/20 (1): steamTurbineStodola.steamState_in.p = steamTurbineStodola.pin [dynamic |0|0|0|0|] 21/21 (1): steamTurbineStodola.steamState_in.T = Modelica.Media.Water.IF97_Utilities.T_props_ph(steamTurbineStodola.pin, valveHP.outlet.h_outflow, Modelica.Media.Water.IF97_Utilities.waterBaseProp_ph(steamTurbineStodola.pin, valveHP.outlet.h_outflow, 0, 0)) [dynamic |0|0|0|0|] 22/22 (1): steamTurbineStodola.steamState_in.d = Modelica.Media.Water.IF97_Utilities.rho_props_ph(steamTurbineStodola.pin, valveHP.outlet.h_outflow, Modelica.Media.Water.IF97_Utilities.waterBaseProp_ph(steamTurbineStodola.pin, valveHP.outlet.h_outflow, 0, 0)) [dynamic |0|0|0|0|] 23/23 (1): steamTurbineStodola.steamState_in.h = valveHP.outlet.h_outflow [dynamic |0|0|0|0|] 24/24 (1): steamTurbineStodola.steamState_in.phase = 0 [dynamic |0|0|0|0|]
while the same back-end module fed by the NF returns
31/35 (5): steamTurbineStodola.steamState_in = ThermoPower.PowerPlants.ElectricGeneratorGroup.Tests.Test_Generator_SE.valveHP.Medium.setState_ph(steamTurbineStodola.pin, valveHP.outlet.h_outflow, 0)}}}
I guess there's something wrong with the way the NF processes this function call - maybe the Inline
annotation is lost?
comment:4 by , 6 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
This model now simulates successfully
The NF generates the equation
instead, since
steamTurbineStodola.steamState_iso
isn't a parameter and thus doesn't require the function call to be evaluated. It's not clear whether this is the reason for the failure, but I would guess not since record equations are usually counted correctly.