- Index
- » Users
- » paolo090172
- » Profile
Posts
Posts
Thank you very much!!!
Good morning,
I have to solve a certain problem with Modelica.
I have reduced the code to the minimum, leaving only the part that gives me problems.
------------------------------------------------------------------
model test
public parameter Integer Nmax = 100;
protected parameter Real x[Nmax](each fixed=false) "abscissa";
protected parameter Real y[Nmax](each fixed=false) "y=f(x)";
// any variable for my calculation
initial algorithm
x := linspace(0.0,14.5,Nmax);
// In this example f (x) = -1 and there would be no need for an array,
// obviously I fill y with a more complicated algorithm, not a simple formula...
y := fill(-1.0,Nmax);
equation
// any equation for my calculation
end test;
------------------------------------------------------------------
In a model that I would like to realize, I need to have as a parameter a function given for points x-y. The points are many ... the problem is that up to Nmax = 1000 the program runs, but already with 10000 points OMEdit occupies 22 Gb of RAM and then it stops. Is this normal? Two 10000 arrays or real cannot occupy all this RAM. Is it as if thousands and thousands of instances were created temporary ... Is there no way to allocate them, such as is done for other languages as "static" (common to all instances), or is it a compiler bug? I use OMEdit v1.12.0 (64-bit) on Windows 7 SP1.
If it were normal behavior, is there a way to do this without wasting all this RAM?
Thanks to everyone for the help.
Paolo Ferraresi, Italy.
Good morning.
I'm trying to model a spool that runs into a valve body.
The stroke of the spool is mechanically limited to the positions x1 = 0 and x2 = 3.3 mm (millimeters).
There is a spring, which pushes the spool to x1.
By an external force Fm applied to the spool, this one should therefore move between x1 <= x <= x2.
I have so a problem of rigid constraints.
I have modeled the rigid constraints with a viscoelastic model (Kelvin-Voigt) and it works quite well. For example with Fm = 1000 N, x is about 0.5 mm (correct).
If Fm = 0 x is around zero (-0.0015, this depends on the elasticity) if Fm = 10000 N (for example) the stroke is stopped at about 3.3 mm.
Here's the model I wrote:
model VS30CC
parameter Real m(unit="m") = 1;
parameter Real k(unit="N/mm") = 192.6, L0(unit="mm") = 38;
parameter Real c(unit="N.s/m") = 50;
parameter Real d(unit="mm") = 6;
parameter Real Ptar(unit="bar")=320;
parameter Modelica.SIunits.Force Fm = 1000;
Real x(unit="mm",start=0),v(unit="m/s",start=0);
Modelica.SIunits.Force F,Fk;
protected
parameter Real x1(unit="mm")=0,x2(unit="mm")=3.3;
parameter Real E(unit="N/mm2")=210000;
parameter Real A(unit="mm2")=0.25*Modelica.Constants.pi*d^2;
parameter Real L(unit="mm")=10;
parameter Real Kv(unit="N/mm") = E*A/L;
parameter Real Ck(unit="N.s/m") = -1000;
parameter Modelica.SIunits.Force F0 = 0.1*Ptar*A;
equation
if x<x1 then
Fk = -Kv*(x-x1)+Ck*v;
elseif x>x2 then
Fk = -Kv*(x-x2)+Ck*v;
else
Fk = 0;
end if;
v = der(0.001*x);
m * der(v) = F+Fk;
F = Fm-c*v-k*x-F0;
end VS30CC;
The problem is that I have already tried this method for problems like this, but more complex, where there are forces of surfaces variable in time (the result of pressure variables) and my experience is that the calculation becomes very very slow due the stiffness around the constraints. I submit the basic example and not the more complex because the other codes are very long and not focused to the problem of the constraints. In those codes I also tried to round Fk with the hyperbolic tangent (tanh) but the execution is still very slow.
So I wanted to try something like the classic example "BouncingBall" but with both constraints, so I adjusted the example I found on the Tiller book "Introduction to physical modeling with Modelica". Here's how I've adapted my model:
model VS30CC
parameter Real m(unit="m") = 1;
parameter Real k(unit="N/mm") = 192.6, L0(unit="mm") = 38;
parameter Real c(unit="N.s/m") = 50;
parameter Real d(unit="mm") = 6;
parameter Real Ptar(unit="bar")=320;
parameter Modelica.SIunits.Force Fm = 0;
Real x(unit="mm",start=0),v(unit="m/s",start=0);
Modelica.SIunits.Force F;
protected
parameter Real x1(unit="mm")=0,x2(unit="mm")=3.3;
parameter Real A(unit="mm2")=0.25*Modelica.Constants.pi*d^2;
parameter Modelica.SIunits.Force F0 = 0.1*Ptar*A;
parameter Real e = 0.1;
Boolean impactL,canBounceL(start=true),impactR,canBounceR(start=true);
equation
v = der(0.001*x);
if canBounceL and canBounceR then
m*der(v)=F;
else
m*der(v)=0;
end if;
F = Fm-c*v-k*x-F0;
algorithm
impactL := x<=x1;
impactR := x>=x2;
when {impactL, impactL and v<=0} then
if edge(impactL) then
canBounceL := pre(v)<=0;
reinit(v,-e*pre(v));
reinit(x,x1);
else
reinit(v,0.0);
canBounceL := false;
end if;
end when;
when {impactR, impactR and v>=0} then
if edge(impactR) then
canBounceR := pre(v)>=0;
reinit(v,-e*pre(v));
else
reinit(v,0.0);
canBounceR := false;
end if;
end when;
end VS30CC;
The problem is, of course, with Fm = 1000 N works as before (x = 0.5 mm), even with Fm = 10000 works well (x = x2), but if imposed Fm = 0 the resulting chart is chilling: that the stroke instantly get to x = -8.5 mm before stopping at x = -1.4 mm.
Maybe I done something wrong. Do you know where is the mistake? Moreover, what is the best way to model efficiently rigid constraints? Is there any example of a body with two constraints that kind of my problem?
Thank you very much.
Best Regards,
Paolo Ferraresi, Italy.
fp.box@alice.it
- Index
- » Users
- » paolo090172
- » Profile