I am currently working on a multi-fluid library in which I have coded physical components, connectors, boundary conditions, sensors, physical properties and so on... The fluid selection is currently based on an Integer fluid selection.
So far, I have been able to conditionally assign the color of the components' style based on fluid value.
Now, I want to go a step further and also conditionally assign the color of the connection. I know about Stack Overflow - Assign specific connection style to connector in Modelica as I have already put it to good use.
So I defined the parameter parameter Integer fluid=fluid in the connector, so that it inherits the fluid value from the component. Then I assigned a conditional style on a rectangle as stated in the link above.
However, I end up with the following error: mean circular equalities for conduite.C1.fluid
(where "conduite" is the component and "C1" one of its connector)
I am currently a bit clueless.
EDIT:
Initial approach:
In connector model:
parameter Integer fluid=fluid "1: 1st fluid / 2: 2nd fluid";In component model:
parameter Integer fluid=1 "1: 1st fluid / 2: 2nd fluid";
for both instances of the connector: in the fluid parameter cell, I leave the default fluid value.
The obtained flat Modelica shed light on the circular equalities:
parameter Integer conduite.C1.fluid = conduite.C1.fluid; parameter Integer conduite.C2.fluid = conduite.C2.fluid;
Other approach, that works but is not satisfying:
In connector model:
parameter Integer fluid=1 "1: 1st fluid / 2: 2nd fluid";In component model:
parameter Integer fluid=1 "1: 1st fluid / 2: 2nd fluid";for both instances of the connector: in the
fluidcell: I typefluidinstead of the default1value.The obtained flat Modelica is what I actually wanted:
parameter Integer conduite.C1.fluid = conduite.fluid; parameter Integer conduite.C2.fluid = conduite.fluid;
Why does not the default value fluid refer to the upper level parameter, whereas the locally overwritten value does?
I didn't fully understand the question so I'm doing some guessing here: My assumption is, that propagation went wrong somehow.
Would the following code result in what you need? Note that neither component nor Example will work:
gives the flat Modelica code for the Example:
If my assumption is correct, the essential part is the propagation of the
Integer fluidfrom theparameterinComponent:This line passes the actual value from
Componentto the instancesC1ofCon.