Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
greenwoodms06 opened this issue May 7, 2021 · 2 comments
Open

Comments

@greenwoodms06
Copy link

greenwoodms06 commented May 7, 2021

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
    ]
)
@HildingElmqvist
Copy link
Contributor

Your observations are correct. Both these features are not supported yet.

@greenwoodms06
Copy link
Author

Well alrighty then. I'll stop trying to force it to work! haha.

Thank you for your response.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants