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

More Newbie: reinit() with arrays

More Newbie: reinit() with arrays

I would like to modify the BouncingBall demo to be three dimensional instead of one. The cleanest way to do this would seem to be to use 3-vectors for the position and velocity. However, a straightforward rewrite of the demo code fails; the problem is apparently the reinit() command. The code is as follows:



model Ball
    Real[3] x(start={0.0, 0.0, 0.0});
    Real[3] xdot;
    Real[3] xdot_new;
   
    parameter Real g=9.81 "gravitational acceleration";
    parameter Real e=0.7 "coefficient of restitution";

    Boolean impactWithFloor;
    Boolean flying(start=true) "true, if ball is flying";
 
equation
    impactWithFloor = x[3]<=0.0;
   
    der(x) = xdot;
    der(xdot) = if flying then {0.0, 0.0, -g} else {0.0, 0.0, 0.0};
   
    when {x[3] <= 0.0 and xdot[3] <= 0.0, impactWithFloor} then
        xdot_new = if edge(impactWithFloor) then {0.0, 0.0, -e*pre(xdot[3])} else {0.0, 0.0, 0.0};
        flying = xdot_new[3] > 0;
        reinit(xdot, xdot_new);
    end when;

end Ball;


The simulation fails with the error:

base_array.c: array dimensions sizes are NULL!
Assertion failed: (base_array_ok(source)), function copy_real_array_data_mem, file util/real_array.c, line 142.

Rewriting the Ball object to use three scalar variables x1, x2, x3 works fine. What's going on here?

Re: More Newbie: reinit() with arrays

This is already reported here https://trac.openmodelica.org/OpenModelica/ticket/1853
I am not sure when this will be fixed current/smile

Adeel.

Re: More Newbie: reinit() with arrays

Oh, so it's a bug? That's good to know, won't keep banging my head against it then. Thanks!

There are 0 guests and 0 other users also viewing this topic
You are here: