Opened 10 years ago
Closed 10 years ago
#3087 closed defect (invalid)
Warn about iteration variables with default values
Reported by: | Francesco Casella | Owned by: | Lennart Ochel |
---|---|---|---|
Priority: | critical | Milestone: | 1.9.2 |
Component: | Backend | Version: | trunk |
Keywords: | Cc: | Adrian Pop |
Description
In many cases (e.g. thermo-fluid models), the default start attribute of zero is not at all a good choice for a first guess of nonlinear solvers - it might actually be out of the range of validity of fluid models.
Suggestion: when a variable is selected as iteration variable for an iterative solver, if the start attribute has not been set and is still the basic type default issue a warning such as:
Warning: Variable xxx is an iteration variable for the nonlinear solver and its start attribute has not been set, using the default value of yyy as initial guess might lead to numerical problems. In that case, please set the start attribute to a more appropriate value.
Change History (9)
comment:1 by , 10 years ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
comment:2 by , 10 years ago
If there are iteration variables without explicitly given start-values then will pop up the following warning:
Warning: There are iteration variables with default zero start attribute. Use +d=initialization for more information.
If +d=initialization is used, then the warning from my previous commit will show up.
It seems that there is an issue with nonlinear system of size 1 (see #3091). I do not know any further issue with this warnings.
comment:3 by , 10 years ago
The reason why I filed this ticket is that yesterday Willi pointed out to me that there were some test cases from the testsuite where we got error messages from the water medium model, which had been called with p = 100000 (which is fine) and h = 0 (which is definitely not a good value). This strongly smelled of a leftover default start value, though we didn't get warnings from the compiler.
I promised to investigate more, but now I can't remember which one this model was. Can someone help me find it out?
comment:4 by , 10 years ago
Just found one: ModelicaTest.Fluid.TestComponents.Sensors.TestTemperature1
outputs
Warning: Variable sink2.medium.MM out of [min, max] interval: sink2.medium.MM >= 0.001 and sink2.medium.MM <= 0.25 has value: 0 Warning: Variable source2.medium.MM out of [min, max] interval: source2.medium.MM >= 0.001 and source2.medium.MM <= 0.25 has value: 0 Warning: Variable volume2.medium.MM out of [min, max] interval: volume2.medium.MM >= 0.001 and volume2.medium.MM <= 0.25 has value: 0 Warning: Variable sink1.medium.MM out of [min, max] interval: sink1.medium.MM >= 0.001 and sink1.medium.MM <= 0.25 has value: 0 Warning: Variable source1.medium.MM out of [min, max] interval: source1.medium.MM >= 0.001 and source1.medium.MM <= 0.25 has value: 0 Warning: Variable volume1.medium.MM out of [min, max] interval: volume1.medium.MM >= 0.001 and volume1.medium.MM <= 0.25 has value: 0 Error: Error in region computation of IF97 steam tables(p = 101325, h = 0) stdout | warning | Non-Linear Solver try to handle a problem with a called assert. stdout | warning | While solving non-linear system an assertion failed during initialization. | | | | | The non-linear solver tries to solve the problem that could take some time. | | | | | It could help to provide better start-values for the iteration variables. | | | | | For more information simulate with -lv LOG_NLS assert | debug | OnePortTemperature and TwoPortTemperature shall give the same result stdout | warning | Integrator attempt to handle a problem with a called assert. assert | debug | OnePortTemperature and TwoPortTemperature shall give the same result stdout | info | model terminate | Simulation terminated by an assert at time: 7.0035
No trace of warning here, but the IF97 steam tables (i.e., the water medium model) was called with p = 101325 (that is, atmospheric pressure), and h = 0 (that is, the wrong default).
Lennart, can you please check where does this zero value come from?
comment:5 by , 10 years ago
I get the following omc output:
[build/lib/omlibrary/Modelica 3.2.1/Fluid/Interfaces.mo:740:9-745:39:writable] Notification: From here: [build/lib/omlibrary/Modelica 3.2.1/Fluid/Interfaces.mo:332:3-334:69:writable] Warning: Inherited elements are not identical: bug: https://trac.modelica.org/Modelica/ticket/627 first: Medium.MassFlowRate m_flow(min = if allowFlowReversal then -Modelica.Constants.inf else 0, start = m_flow_start, stateSelect = if momentumDynamics == Modelica.Fluid.Types.Dynamics.SteadyState then StateSelect.default else StateSelect.prefer) "mass flow rates between states" second: Medium.MassFlowRate m_flow(min = if allowFlowReversal then -Modelica.Constants.inf else 0, start = m_flow_start) "Mass flow rate in design flow direction" Continue .... [build/lib/omlibrary/Modelica 3.2.1/Fluid/Interfaces.mo:740:9-745:39:writable] Notification: From here: [build/lib/omlibrary/Modelica 3.2.1/Fluid/Interfaces.mo:332:3-334:69:writable] Warning: Inherited elements are not identical: bug: https://trac.modelica.org/Modelica/ticket/627 first: Medium.MassFlowRate m_flow(min = if allowFlowReversal then -Modelica.Constants.inf else 0, start = m_flow_start, stateSelect = if momentumDynamics == Modelica.Fluid.Types.Dynamics.SteadyState then StateSelect.default else StateSelect.prefer) "mass flow rates between states" second: Medium.MassFlowRate m_flow(min = if allowFlowReversal then -Modelica.Constants.inf else 0, start = m_flow_start) "Mass flow rate in design flow direction" Continue .... Warning: There are iteration variables with default zero start attribute. Use +d=initialization for more information.
If +d=initialization is used, then the following variable get reported:
Warning: Iteration variables with default zero start attribute in torn nonlinear equation system: orifice1.port_b.h_outflow:VARIABLE(min = -10000000000.0 max = 10000000000.0 unit = "J/kg" nominal = 1000000.0 ) "Specific thermodynamic enthalpy close to the connection point if m_flow < 0".ModelicaTest.Fluid.TestComponents.Sensors.TestTemperature1, .Modelica.Fluid.Fittings.SimpleGenericOrifice$orifice1, .Modelica.Fluid.Interfaces.FluidPort_b$orifice1$port_b, .Modelica.Fluid.Interfaces.FluidPort_b$orifice1$port_b.Medium.SpecificEnthalpy type: Real
Do you think that there should be more variables/systems reported?
comment:6 by , 10 years ago
Cc: | added |
---|
Ooops, I was looking for the warning in the simulation log, while of course it was given in the compilation log. Sorry about that.
I guess there is a compiler problem here then. The variable orifice1.port_b.h_outflow
has type Medium.SpecificEnthalpy
, with Medium = Modelica.Media.Water.StandardWater
, which eventually extends Modelica.Media.Water.WaterIF97_base
, which finally redefines SpecificEnthalpy(start = 1.0e5, nominal = 5.0e5)
. It seems that this start attribute is somehow lost by OMC in the instantiation process, so that zero is used instead.
Can you understand why?
comment:7 by , 10 years ago
Flattening ModelicaTest.Fluid.TestComponents.Sensors.TestTemperature1 gives:
Real orifice1.port_b.h_outflow(quantity = \"SpecificEnergy\", unit = \"J/kg\", min = -10000000000.0, max = 10000000000.0, nominal = 1000000.0) \"Specific thermodynamic enthalpy close to the connection point if m_flow < 0\";
which does not have a start attribute. Seems we're loosing that somewhere.
I'll open another ticket about this and have a look into where this happens.
comment:9 by , 10 years ago
Resolution: | → invalid |
---|---|
Status: | assigned → closed |
The original claim of this ticket (i.e., that some iteration variables with a default start attribute go unnoticed) proved to be false. Now that we have #3095 which properly addresses the specific issue reported here, we can close the ticket.
I generate such warnings already for a long time during initialization:
Maybe there are some cases missing, so that the warnings do not always occur. I will check that tomorrow.