- Index
- » Usage and Applications
- » OpenModelica Usage and Applications
- » How to define an array of instances...
How to define an array of instances of a class with the parameter
How to define an array of instances of a class with the parameter
I'm trying to define an array (with a fixed dimension) of instances of a class. for each instances I need to assign three parameters. These parameters have the same values for every instances.
Heater.Wood[N] woodInHeater(v=woodInput.v, rho=woodInput.rho, s0=s_0, h0=h_0);
So my way is that
it is correct, isn't it?
'cause every-time when I try to translate this code the compiler returns to me a warning
Warning: Automatically introducing 'each' in definition equation for:
woodinHeater[1].v
Examine the release notes on array of components
what is the correct way to write that, without generating warning?
thank
have good day
Re: How to define an array of instances of a class with the parameter
I'm not 100% sure, but I believe this is the correct syntax:
Code:
Heater.Wood[N] woodInHeater(each v=woodInput.v, each rho=woodInput.rho, each s0=s_0, each h0=h_0);
I don't recognize the warning though. OpenModelica output is:
[b.mo:2:1-2:20:readonly] Warning: Variable x: Non-array modification '10' for array component, possibly due to missing 'each'.
- sjoelund.se
- 1700 Posts
- Index
- » Usage and Applications
- » OpenModelica Usage and Applications
- » How to define an array of instances...