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

If-branch selection at initial time

If-branch selection at initial time

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

Edited by: antoinem - Jul-22-13 17:31:09
There are 0 guests and 0 other users also viewing this topic
You are here: