Closed Mathadon closed 7 years ago
might be related: #675 and #689
@Mathadon Would
parameter Integer iWat(min=1, start=1) = ...
help?
That works too! But it's not really a proper solution, is it?
But then dymola complains:
Index 1 of Xi[iWat] is 1, which is outside of range 1 to 0.
and, more surprisingly:
The parameter wetBul.iWat has the attribute fixed = false
indicating its value to be calculated from initial conditions.
Error: However, it is used to specify a structural property and
it must be possible to evaluate it at translation.
somehow dymola (and apparently also JModelica) does accept this without the start
and min
attributes.
If this causes issues we can't work around, I would be fine with changing the protected parameter to a public constant of the from
constant Integer iWat=1 "Index of water in medium composition vector"
annotation (HideResult=true);
and then add an assert to make sure that water is at the right index.
However, you still have the same problem with IBPSA.Fluid.Sensors.TraceSubstances
where such a fix won't work.
That's an idea too.
What is wrong with the solution that I proposed, though?
What exactly is your solution? You wrote above "dymola complains"... and "somehow dymola (and apparently also JModelica) does accept this " of which I don't know what "this" is.
If you have a working solution that satisfies the tools, then that's fine and please post a pull request or commit to review.
In the initial post I suggested
parameter Integer iWat = sum( { (if Modelica.Utilities.Strings.isEqual(string1=Medium.substanceNames[i],string2="Water", caseSensitive=false) then i else 0) for i in 1:Medium.nX})
I'll make a pull request.
In
IBPSA.Utilities.Psychrometrics.TWetBul_TDryBulXi
the Medium water index is computed usingthis is causing problems when doing optimisations since the water medium index is unknown at translation time.
This can be resolved using
but that in turn leads to an error when checking the model:
Index 1 of Xi[iWat] is 0, which is outside of range 1 to 0.
This can be resolved by setting as default medium
IBPSA.Media.Air
instead ofModelica.Media.Interfaces.PartialCondensingGases
.I propose to make these changes.