- Index
- » Usage and Applications
- » OpenModelica Usage and Applications
- » Strange pendulum behaviour
Strange pendulum behaviour
Strange pendulum behaviour
Hello,
I'm currently experimenting with the standard planar pendulum model in OpenModelica and would like to understand why I get the following strange results.
Here is the model:
Code:
model pendulum
parameter Real g = 9.81;
parameter Real L = 0.5; // length
parameter Real m = 1.0; // mass
Real x(start = L);
Real y(start = 0.0);
Real vx;
Real vy;
Real T; // tension
equation
der(x) = vx;
der(y) = vy;
m * der(vx) = - T * x / L;
m * der(vy) = - T * y / L - m * g;
x^2 + y^2 = L^2;
end pendulum;
If I ask for simulation with stopTime=50 and numberOfIntervals=500 I get the following expected result:
But if I ask for simulation with stopTime=80 and numberOfIntervals=500 I get this strange result:
By increasing to numberOfIntervals=5000 with stopTime=80 the simulation seems to be again as expected:
Can someone explain to me the meaning of the numberOfIntervals parameter and why I get strange results in the second plot? Note that in both cases, the number of steps taken by the DASSL solver is approximately the same (~10300).
Thank you,
Antoine
Re: Strange pendulum behaviour
Hi,
it seems to be a bug, I've added an ticket for that
https://trac.openmodelica.org/OpenModelica/ticket/2282
The numberOfIntervals parameter determines the number of steps
that are emitted to the result file. Also the dynamic state selection,
which seems to fail here, is deciding at that level which states we
should use.
so long.
Willi
- wbraun
- 75 Posts
Re: Strange pendulum behaviour
Hi,
if you need some information about dynamic state selection you could have a look at [https://www.modelica.org/events/workshop2000/proceedings/old/Mattsson.pdf][/url]
Maybe the solver uses for the calculation of the next step also cached values from the time before the last state switch. This could be the reason for the problem.
Re: Strange pendulum behaviour
Yes thank you I've read this paper some times ago, I should read it
again.
The compiler tells me that there are two state sets {x,y} and
{vx,vy}. And from the log of dynamic state selection we can see that
the solver either pick {x,vx} or {y,vy} as state variables. Here's an
excertp:
LOG_DSS | info | select new states at time 0.320000| | | | | select vx
LOG_DSS | info | select new states at time 0.320000| | | | | select x
LOG_DSS | info | select new states at time 0.640000| | | | | select vy
LOG_DSS | info | select new states at time 0.640000| | | | | select y
LOG_DSS | info | select new states at time 1.280000| | | | | select vx
LOG_DSS | info | select new states at time 1.280000| | | | | select x
LOG_DSS | info | select new states at time 1.440000| | | | | select vy
LOG_DSS | info | select new states at time 1.440000| | | | | select y
LOG_DSS | info | select new states at time 2.080000| | | | | select vx
LOG_DSS | info | select new states at time 2.080000| | | | | select x
I use version 1.9.0 beta4+dev (r15987).
Re: Strange pendulum behaviour
The problem indeed may come from the dynamic state selection because if I run the simulation on the underlying ODE with setIndexReductionMethod("uode") we observe no strange results except that x and y are drifting from the analytical solution (but this is normal since we only use the second order derivative of the constraint x^2 + y^2 = L^2):
I forgot to mention that I use tolerance=1e.-6.
- Index
- » Usage and Applications
- » OpenModelica Usage and Applications
- » Strange pendulum behaviour