- Index
- » Programming
- » Modelica Language
- » Access initial variables of subclass
Page Start Prev 1 Next End
Access initial variables of subclass
Access initial variables of subclass
Jan-13-17 13:42:23
Hello,
I am trying to access the initial condition of the variable in a sub class. The code is as given below.
Code:
class MainClass001
class SubClass001
Modelica.Blocks.Interfaces.RealInput u annotation(
Placement(visible = true, transformation(origin = {-106, 0}, extent = {{-20, -20}, {20, 20}}, rotation = 0), iconTransformation(origin = {-106, 0}, extent = {{-20, -20}, {20, 20}}, rotation = 0)));
Modelica.Blocks.Interfaces.RealOutput y annotation(
Placement(visible = true, transformation(origin = {106, 0}, extent = {{-10, -10}, {10, 10}}, rotation = 0), iconTransformation(origin = {106, 0}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
Modelica.SIunits.Angle phi(start=0) "phi";
equation
der(phi) = u;
y = phi;
end SubClass001;
class SubClass002
Modelica.Blocks.Interfaces.RealInput u annotation(
Placement(visible = true, transformation(origin = {-108, 0}, extent = {{-20, -20}, {20, 20}}, rotation = 0), iconTransformation(origin = {-108, 0}, extent = {{-20, -20}, {20, 20}}, rotation = 0)));
Modelica.Blocks.Interfaces.RealOutput y annotation(
Placement(visible = true, transformation(origin = {100, 0}, extent = {{-10, -10}, {10, 10}}, rotation = 0), iconTransformation(origin = {100, 0}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
MainClass001.SubClass001 subClass0011 annotation(
Placement(visible = true, transformation(origin = {0, 0}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
parameter Real initial_condition "Initial condition for phi";
equation
subClass0011.phi.start = initial_condition;
connect(subClass0011.u,u);
connect(subClass0011.y,y);
end SubClass002;
annotation(
uses(Modelica(version = "3.2.2")));
end MainClass001;
I am getting the following error.
Code:
[1] 19:07:32 Translation Error
[MainClass001: 26:5-26:47]: Variable subClass0011.phi.start not found in scope MainClass001.SubClass002.
[2] 19:07:32 Translation Error
Error occurred while flattening model MainClass001.SubClass002
Please let me know how to resolve this issue. It would be a great help if I could get through this.
Thanks in advance!!
Re: Access initial variables of subclass
Jan-13-17 13:57:49
You cannot access variable attributes by dot-notation
- sjoelund.se
- 1700 Posts
Re: Access initial variables of subclass
Jan-13-17 17:32:08
Only via modification on variable declaration:
Code:
MainClass001.SubClass001 subClass0011(phi(start = initial_condition));
- adrpo
- 885 Posts
Page Start Prev 1 Next End
- Index
- » Programming
- » Modelica Language
- » Access initial variables of subclass
There are 0 guests and 0 other users also viewing this topic