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};
Parameters defined by (static) equations
Moderators: Frank, paul, Hiwot, Chris, peter
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 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
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.
Perhaps there is a nice workaround (that is present since 20sim 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 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
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 precalculate A:
Code: Select all
parameters
real A = 12.566370614 {m^2}
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 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
Who is online
Users browsing this forum: No registered users and 3 guests