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 Martin Sjölund, 12 years ago

Cc: Willi Braun Jens Frenkel added

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...

  assert(n >= 2, "linspace requires n>=2 but got " + String(n));
  v := {x1 + (x2-x1)*(i-1)/(n-1) for i in 1:n};

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.

comment:2 by Martin Sjölund, 11 years ago

Milestone: 1.9.01.9.1

Postponed until 1.9.1

comment:3 by Martin Sjölund, 10 years ago

Owner: changed from Jens Frenkel to Willi Braun
Status: newassigned

comment:4 by Martin Sjölund, 10 years ago

Milestone: 1.9.11.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 Martin Sjölund, 10 years ago

Milestone: 1.9.21.9.3

Milestone changed to 1.9.3 since 1.9.2 was released.

comment:6 by Martin Sjölund, 9 years ago

Milestone: 1.9.31.9.4

Moved to new milestone 1.9.4

comment:7 by Martin Sjölund, 9 years ago

Milestone: 1.9.41.9.5

Milestone pushed to 1.9.5

comment:8 by Martin Sjölund, 9 years ago

Milestone: 1.9.51.10.0

Milestone renamed

comment:9 by Martin Sjölund, 8 years ago

Milestone: 1.10.01.11.0

Ticket retargeted after milestone closed

comment:10 by Martin Sjölund, 8 years ago

Milestone: 1.11.01.12.0

Milestone moved to 1.12.0 due to 1.11.0 already being released.

comment:11 by Francesco Casella, 7 years ago

Milestone: 1.12.0Future

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.

Note: See TracTickets for help on using tickets.