Parameters defined by (static) equations
Moderators: Frank, paul, Hiwot, Chris, peter
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};
So
parameters
real force = 10 {N};
real ratio = 10/37;
real diameter = 2*pi*10 {m};
Re: Parameters defined by (static) equations
We're are testing this at the moment.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};
member 20sim development team

 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 nearfuture versions? Would be very nice.
Re: Parameters defined by (static) equations
Perhaps there is a nice workaround (that is present since 20sim 4.0) that was written for parameter relations:Ludo Visser wrote:This is still not working (nearly 6 years later). Are there any plans to include this in nearfuture versions? Would be very nice.
You can assign parameters in the initialequations and finalequations as well, so
Code: Select all
mass = volume * density;
member 20sim development team

 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.
Maybe I'm missing something, but I cannot see why this is a workaround.

 Posts: 51
 Joined: Wed Sep 28, 2005 10:13 pm
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:Ludo Visser wrote:I cannot see why this is a workaround.
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;
Code: Select all
parameters
real R = 2.0 {m};
variables
real A;
initialequations
A = pi*R^2;
What Huisman and I would like to do is:
Code: Select all
parameters
real A = pi*2.0^2 {m^2};
Code: Select all
parameters
real A = 12.566370614 {m^2}
Re: Parameters defined by (static) equations
The parameter A does not need to have a value in this case, since there is a parameter relation that assigns it.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;
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 20sim development team
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 LX0102 questions exam prep and IFPUG