Open
Description
I am testing porting simple Modelica models over to Modia to test its capabilities, syntax, etc. I have an issue with inferred initial conditions. The code below is a lumped heat capacitor (i.e., volume).
When using the UnitVolume component below in a simple example, it provides the following error
LoadError: Missing start/init value unitVolume.U
However, U
's starting value comes from the value specified with the provided parameters and the start value set to T
.
My simple test works if I modify the code and remove T = Var(init=(180+273.15)u"K")
and instead set U=Var(start=6000.0u"J")
. However this is not an appropriate solution of course. Variations of start
and init
didn't seem to fix the issue either.
Questions:
- Is this ability to derive initial conditions from other variables a limitation of Modia at this time? If not, any suggestions would be appreciated.
- Removing
U
andm
and replacingder(U)
withder(d*V*cp*(T-T_reference))
also fails. Does Modia not support equations within theder()
operator at this time?
Model
UnitVolume = Model(
nParallel=1,
V=1.0u"m^3",
d=1000.0u"kg/m^3",
cp=1.0u"J/(kg*K)",
Q_gen=0.0u"W",
T_reference = 273.15u"K",
T = Var(init=(180+273.15)u"K"),
port = HeatPort,
equations = :[
m = d*V
U = m*cp*(T-T_reference)
Qb_flow = port.Q_flow / nParallel + Q_gen
der(U) = Qb_flow
port.T = T
]
)
Metadata
Metadata
Assignees
Labels
No labels