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 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.
So my way is that

Heater.Wood[N] woodInHeater(v=woodInput.v, rho=woodInput.rho, s0=s_0, h0=h_0);



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'.

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