Rootfinder in CasADi

1,130 views
Skip to first unread message

Andreea Oltean

unread,
Aug 1, 2016, 11:12:35 AM8/1/16
to CasADi
I am having a state-space model and I want to simulate it in order to get the "steady-state" values for my model. I am using rootfinder of CasADi, as my system is nonlinear. I have the following code:

ue  = 1;
Xdt = 0.000105;
de  = 1;
dt  = 1;
Mde = -0.027419;

Uvel = SX.sym('Uvel');
Wvel = SX.sym('Wvel');
q = SX.sym('q');
theta = SX.sym('theta');

de = SX.sym('de');
dt = SX.sym('dt');

x = [Uvel; Wvel; q; theta];
u = [de; dt];

xdot = [((Xu)* (Uvel^3) + (Xw)*(Wvel^3) -(g)*theta + (Xdt)*dt);
        ((Zu)* (Uvel^3) + (Zw)*(Wvel^3) + ue*q);
        ((Mu)* (Uvel^3)+ (Mw)*(Wvel^3) + (Mq)*q *(Uvel^2)  + (Mde)*de);
        q];
    
f=Function ('f', {x, u}, {xdot});
s=rootfinder('s', 'newton', f);
s([10, 1, 0, 0], [10, 1])

The other parameters you see there are some constants.
So what I understood is that on the last line, I am giving some initial guess, and I am waiting as outputs the values which are the solution for the equation xdot=0.
But as a result, I get some 4 valued vector (which I suppose is the x vector solution) and I am expecting to get some values also for my second input vector, u.
Am I getting this the wrong way?
Thank you in advance. Any help is appreciated! 

Regards,
Andreea Oltean

Joel Andersson

unread,
Aug 1, 2016, 11:22:18 AM8/1/16
to CasADi
Hi Andreea,

You have a system of 4 equations and 4 unknowns, namely x. That's what the "rootfinding" object returns. The u that you are providing on the last line is not a guess, it's the actual (fixed) value. It allows you to e.g. calculate derivatives of x with respect to u.

Best regards,
Joel
Reply all
Reply to author
Forward
0 new messages