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
  • Index
  • » Users
  • » antoinem
  • » Profile

Posts

Posts

Mar-14-14 16:17:05
Category: Programming

Ok I understand why the program with cpt is looping.

But why the omc compiler is accepting the first program? Should I report this bug?

Mar-13-14 19:32:59
Category: Programming

Hello,

I don't understand why it is possible to call pre() during integration time. With omc 1.9.1+dev (r18345) I can simulate equation

Code:


  Real x (start=0);
  x = pre(x) + 1;

where I observe that the growth of x depends on the numberOfIntervals parameter, which seems odd to me, I would expect the compiler to reject this program.

My other question is on the use of pre() in a discrete context. Does anyone know why equation

Code:


  Integer cpt (start=0);
  cpt = if time <= 10 then pre(cpt) + 1 else pre(cpt);

returns

Code:

ERROR: Too many event iterations.

?

Thank you,
Antoine

Hello,

I am experimenting with index reduction and conditionals in OM. I understand that during continuous integration, the same if-branch is evaluated and that a new if-branch may only be selected at zero-crossings. However I wonder how an if-branch is selected at inital time. In particular I simulated the following model:

Code:

model mode

  Real x(start=0),y(start=3);
equation
  der(x) = y - 3;
  0 = if x < 0 then y else x;
end mode;

Since x = 0 at initial time, the DAE at initial time should be

Code:

  der(x) = y - 3;

  0 = x;

and I would expect OM to do index reduction.

However I found that OM is using the if-equation to solve for y:

Code:


Variables (2)
========================================
1:  y:VARIABLE(start = 3.0 ) .mode, .Real type: Real
2:  x:STATE(1)(start = 0.0 ) .mode, .Real type: Real

Equations (2, 2)
========================================
1/1 (1): der(x) = -3.0 + y
2/2 (1): 0.0 = if x < 0.0 then y else x

Matching
========================================
2 variables and equations
var 1 is solved in eqn 2
var 2 is solved in eqn 1

and I get the following simulation plot:
http://www.di.ens.fr/~madet/om/modecc.jpg

So how come OM initially selected the first if-branch without checking the conditional?

I use OpenModelica Compiler 1.9.0 beta4+dev (r15987).

Thanks in advance for your insights,
Antoine

Jul-16-13 16:57:27
meaning of numberOfIntervals parameter

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

Jul-16-13 14:27:56
meaning of numberOfIntervals parameter

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.

Jul-16-13 13:56:45
meaning of numberOfIntervals parameter

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).

Jul-11-13 18:55:52
meaning of numberOfIntervals parameter

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

  • Index
  • » Users
  • » antoinem
  • » Profile
You are here: