Archived OpenModelica forums. Posting is disabled.

Alternative forums include GitHub discussions or StackOverflow (make sure to read the Stack Overflow rules; you need to have well-formed questions)


Forgot password? | Forgot username? | Register

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:
http://www.di.ens.fr/~madet/om/plot_t50_int500.jpg

But if I ask for simulation with stopTime=80 and numberOfIntervals=500 I get this strange result:
http://www.di.ens.fr/~madet/om/plot_t80_int500.jpg

By increasing to numberOfIntervals=5000 with stopTime=80 the simulation seems to be again as expected:
http://www.di.ens.fr/~madet/om/plot_t80_int5000.jpg

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

Edited by: antoinem - Jul-11-13 19:00:39

Re: Strange pendulum behaviour

Hi antoinem,

I tried to reproduce your problem and it was possible for me. I used rev16563 from jul-09-13.

Can you please give some information about your version of omc.

Thanks.

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

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):
http://www.di.ens.fr/~madet/om/plot_t80_int500_uode.jpg

I forgot to mention that I use tolerance=1e.-6.

Re: Strange pendulum behaviour

How OpenModelica decide to dynamically change of state variables? Does the solver tells him that the system has become singular?

There are 0 guests and 0 other users also viewing this topic