## Parameters defined by (static) equations

If you have some good ideas to improve 20-sim, you can post them here.

Moderators: Frank, paul, Hiwot, Chris, peter

HUisman
Posts: 31
Joined: Wed Sep 21, 2005 8:48 am

### Parameters defined by (static) equations

Is it possible to implement the possibility to assign a static equation (even with predifined constants like pi ) when defining a parameter?

So

parameters

real force = 10 {N};
real ratio = 10/37;
real diameter = 2*pi*10 {m};

paul
Posts: 152
Joined: Mon Sep 19, 2005 2:00 pm
Location: Controllab Products B.V.

### Re: Parameters defined by (static) equations

HUisman wrote:Is it possible to implement the possibility to assign a static equation (even with predifined constants like pi ) when defining a parameter?

So

parameters

real force = 10 {N};
real ratio = 10/37;
real diameter = 2*pi*10 {m};
We're are testing this at the moment.
member 20-sim development team

Ludo Visser
Posts: 51
Joined: Wed Sep 28, 2005 10:13 pm

### Re: Parameters defined by (static) equations

This is still not working (nearly 6 years later). Are there any plans to include this in near-future versions? Would be very nice.

paul
Posts: 152
Joined: Mon Sep 19, 2005 2:00 pm
Location: Controllab Products B.V.

### Re: Parameters defined by (static) equations

Ludo Visser wrote:This is still not working (nearly 6 years later). Are there any plans to include this in near-future versions? Would be very nice.
Perhaps there is a nice work-around (that is present since 20-sim 4.0) that was written for parameter relations:
You can assign parameters in the initialequations and finalequations as well, so

Code: Select all

``mass = volume * density;``
is a valid assignment in these sections when all three are parameters.
member 20-sim development team

Ludo Visser
Posts: 51
Joined: Wed Sep 28, 2005 10:13 pm

### Re: Parameters defined by (static) equations

Does this imply that the value for "mass" is overwritten, regardless of what value you give it? Doesn't this imply that "mass" is a variable rather than a parameter?
Maybe I'm missing something, but I cannot see why this is a workaround.

Ludo Visser
Posts: 51
Joined: Wed Sep 28, 2005 10:13 pm

### Re: Parameters defined by (static) equations

Ludo Visser wrote:I cannot see why this is a workaround.
Maybe I can clarify this with an example. Let's assume that I need the area of a circle with known radius as a parameter to my model. The "workaround" requires that I make two parameters: one for the radius, say R, and one for the area, say A:

Code: Select all

``````parameters
real R = 2.0 {m};
real A = 0.0 {m^2};    // According to Paul, it does not matter what value I put here
initialequations
A = pi*R^2;
``````
How I do it now (which I believe is the correct way, since A is not really a parameter):

Code: Select all

``````parameters
real R = 2.0 {m};
variables
real A;
initialequations
A = pi*R^2;
``````
The "workaround" doesn't really help anything, but only adds confusion because the assigned value for A is overwritten.

What Huisman and I would like to do is:

Code: Select all

``````parameters
real A = pi*2.0^2 {m^2};
``````
Instead of having to pre-calculate A:

Code: Select all

``````parameters
real A = 12.566370614 {m^2}
``````

paul
Posts: 152
Joined: Mon Sep 19, 2005 2:00 pm
Location: Controllab Products B.V.

### Re: Parameters defined by (static) equations

Maybe I can clarify this with an example. Let's assume that I need the area of a circle with known radius as a parameter to my model. The "workaround" requires that I make two parameters: one for the radius, say R, and one for the area, say A:

Code: Select all

``````parameters
real R = 2.0 {m};
real A = 0.0 {m^2};    // According to Paul, it does not matter what value I put here
initialequations
A = pi*R^2;
``````
The parameter A does not need to have a value in this case, since there is a parameter relation that assigns it.
It still is a parameter, since it does not change over time during the simulation. This is the work around:

Code: Select all

``````parameters
real R = 2.0 {m};
real A {m^2};
initialequations
A = pi*R^2;
``````
member 20-sim development team

sabahat
Posts: 1
Joined: Thu Nov 06, 2014 10:24 am

### Re: Parameters defined by (static) equations

I found them, thanks! This is great work, and will save me a lot of effort.
Are you worried about LX0-102 questions exam prep and IFPUG