Skip to content

Issue with inferring initial conditions for variables used in der() #116

Open
@greenwoodms06

Description

@greenwoodms06

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:

  1. Is this ability to derive initial conditions from other variables a limitation of Modia at this time? If not, any suggestions would be appreciated.
  2. Removing U and m and replacing der(U) with der(d*V*cp*(T-T_reference)) also fails. Does Modia not support equations within the der() 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

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions