Opened 12 years ago
Last modified 7 years ago
#2000 assigned enhancement
Modelica.Fluid.Examples.IncompressibleFluidNetwork
Reported by: | Christian Schubert | Owned by: | Willi Braun |
---|---|---|---|
Priority: | normal | Milestone: | Future |
Component: | Backend | Version: | trunk |
Keywords: | merging start values | Cc: | Adrian Pop, fcasella, Willi Braun, Jens Frenkel |
Description
Hi,
this model gives rise to some interesting questions, when merging alias variables.
First, we have the warning
Warning: Aliasset with several free start values Candidate pipe6.mediums[1].p(start = linspace(500000.0, 500000.0, 2)[1]) Candidate pipe8.mediums[2].p(start = linspace(500000.0, 500000.0, 2)[2]) Candidate pipe5.mediums[1].p(start = linspace(500000.0, 500000.0, 2)[1]) Candidate pipe4.mediums[2].p(start = linspace(500000.0, 500000.0, 2)[2]) Candidate pipe10.mediums[1].p(start = linspace(500000.0, 500000.0, 2)[1]) Select value from pipe6.mediums[1].p(start = linspace(500000.0, 500000.0, 2)[1])
which might be avoided since
linspace(x,x,n) = x*ones(n)
and thus
linspace(500000.0, 500000.0, 2)[1] == linspace(500000.0, 500000.0, 2)[2]
Next, we have
Warning: Aliasset with several free start values Candidate pipe2.m_flows[3](start = 0.0) Candidate pipe7.m_flows[1](start = 0.0) Candidate valve1.m_flow(start = valve1.m_flow_start)
which is interesting for several reasons. First, let's look at their definition
Modelica.Media.Interfaces.PartialMedium.MassFlowRate pipe7.m_flows[pipe7.n+1] (start = fill(pipe7.m_flow_start, size(pipe7.m_flows, 1)), min = -1E+060); Modelica.Media.Interfaces.PartialMedium.MassFlowRate valve1.m_flow (start = valve1.m_flow_start, min = -1E+060);
with
parameter Modelica.Media.Interfaces.PartialMedium.MassFlowRate pipe7.m_flow_start = system.m_flow_start; parameter Modelica.SIunits.MassFlowRate system.m_flow_start = 0; parameter Modelica.Media.Interfaces.PartialMedium.MassFlowRate valve1.m_flow_start = valve1.m_flow_nominal; parameter Modelica.Media.Interfaces.PartialMedium.MassFlowRate valve1.m_flow_nominal = 1;
Why does the first start attribute get evalauted while the second does not?
For me the warning is correct in this case, I am puzzled though how a tool should decide which to take, since both start values have been given explicitly. Is it safe to say: "Always take the non-zero start value"?
Also, we get
"Warning: Modification or redeclaration of protected elements is not allowed." which is correct as stated in Modelica Spec 3.3, Chapter 4.1, p. 33. However, it occurs quite frequently in MSL?
What is your opinion?
Change History (11)
comment:1 by , 12 years ago
Cc: | added |
---|
comment:3 by , 10 years ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
comment:4 by , 10 years ago
Milestone: | 1.9.1 → 1.9.2 |
---|
This ticket was not closed for 1.9.1, which has now been released. It was batch modified for milestone 1.9.2 (but maybe an empty milestone was more appropriate; feel free to change it).
comment:5 by , 10 years ago
Milestone: | 1.9.2 → 1.9.3 |
---|
Milestone changed to 1.9.3 since 1.9.2 was released.
comment:10 by , 8 years ago
Milestone: | 1.11.0 → 1.12.0 |
---|
Milestone moved to 1.12.0 due to 1.11.0 already being released.
comment:11 by , 7 years ago
Milestone: | 1.12.0 → Future |
---|
The milestone of this ticket has been reassigned to "Future".
If you think the issue is still valid and relevant for you, please select milestone 1.13.0 for back-end, code generation and run-time issues, or 2.0.0 for front-end issues.
If you are aware that the problem is no longer present, please select the milestone corresponding to the version of OMC you used to check that, and set the status to "worksforme".
In both cases, a short informative comment would be welcome.
It is quite easy to fix this... Simply add EarlyInline=true to linspace. But that requires removing the assertion since the inline module cannot handle this...
The problem is we then cannot give any sensible error-message to the user. On the other hand, it seems we segfault on the old code anyway. The reason seems to be that we do not abort execution of the function when the assertion is hit... Hint: If you spot a failed assertion, don't try to finish the function - the program might abort :(
I suggest adding the possibility to inline expressions and return a list of assertions that need to be added (or at least the possibility to check the assertion before we try to inline, and only if true we inline). I will modify the linspace code to simplify better.