Archived OpenModelica forums. Posting is disabled.

Alternative forums include GitHub discussions or StackOverflow (make sure to read the Stack Overflow rules; you need to have well-formed questions)


Forgot password? | Forgot username? | Register

how to get constants from other models?

how to get constants from other models?

Hi,
I'm trying to access some constants from a package that i created. While doing so I get the following error "Real Alias variable c.Tc not found".
.I have constants in 'Database' package, I want to edit 'data' model so that i can take only required things from 'Database' and use them in 'testdata' model. Below is the code

Code:


class paramtertest

package Database
model General_Properties
constant Real Tc;
end General_Properties;

model Hydrogen
extends General_Properties(Tc = 30);
end Hydrogen;

model Helium
extends General_Properties(Tc = 40);
end Helium;
end Database;

model data
constant Database.Hydrogen a ;
end data;

model testdata
Real b;
constant Database.General_Properties c = data.a;
equation
b= c.Tc;
end testdata;
end paramtertest;

how to assign Tc of Hydrogen to variable b?

Re: how to get constants from other models?

You can write "b = data.a.Tc". Also if you instantiate the Hydrogen model in testdata model and equate it to c then also it will work.

Although I am not sure why this error is coming.

There are 0 guests and 0 other users also viewing this topic
You are here: