Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Modelica propagation/default variable name

Tags:

modelica

I want to set a default variable name T (=xx) inside a model - drag that model into a new model and define there the variable xx. I get the error message: Use of undeclared variable xx.

This is the sub-model

model test
  parameter Real T = xx;
  Real f;
equation 
  f = T + time;
end test;

this is the full model

model fullmodel
  parameter Real xx = 12;
  Test Test1; 
end fullmodel;

My question: How would you do that in Modelica? I need for my model 100 of the same models and i want to set a few parameters (diamter, lenghts, etc.) per default to a variable name and then define just this variables. I know i could propagate the variable - but it would be nice, if i just have to drag the model and then defining the parameters. Thank you for your help!

like image 531
Kenni Avatar asked Mar 01 '26 17:03

Kenni


1 Answers

Alternatively you can do this using inner/outer:

model Test
  outer parameter Real xx;
  parameter Real T = xx;
  Real f;
equation 
  f = T + time;
end Test;

model fullmodel
  inner parameter Real xx = 12;
  Test test1;
end fullmodel;
like image 182
Adrian Pop Avatar answered Mar 04 '26 05:03

Adrian Pop



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!