I am running CasADi, IDAS DAE from matlab .
My objective is to integrate an ODE with algebraic constraints.
The ODE represents a mechanical 4 bar chain with torque applied at one link.
The algebraic constraints represent the 4 bar loop closure.
The main loop in code is shown below.
I am happy to share the full code.
Actually, I found it difficult to get a good example, so maybe this is a good
example for the community.
dae.x = x; % ode states, size(x) = 2
dae.z = z; % algebraic constraints, size(z) = 2
dae.p = u; % a control torque on one link, size(u) = 1
dae.ode = f_x(x,z,u); % f_x() returning d/dt(x)
dae.alg = f_z(x,z); % f_z(x,z) == 0 the constraint equations
dae.quad = f_q(x,u); % objective function
Ts = 0.1;
Tf = 3; % simulation end time
opts.t0 = 0;
opts.tf = Ts; % integration step interval (sec)
U0 = 6; % constant torque applied to link A = 6 N*m
I = integrator('I', 'idas', dae, opts);
for i=1:Tf/Ts
res = I('x0', X0, ...
'z0', Z0, ...
'p', U0); % integrate for Ts seconds
X0 = full(res.xf);
Z0 = full(res.zf);
LL(:,i+1) = full(f_z(X0, Z0));
XX(:,i+1) = X0;
ZZ(:,i+1) = Z0;
end
Here is the problem I don't understand or know how to address.
If U0 = 6 N*m, the integration works fine.
If I reduce U0 to 2 N*m, the integration fails with the warning
On the 6th iteration of the loop, I see:
At t = 0.0582508, , mxstep steps taken before reaching tout.
IDASolve returned "IDA_TOO_MUCH_WORK". Consult IDAS documentation.
If someone can help me to understand:
- the reason for failure
- integrator options or another work around
- insight into how to debug or get deeper understanding
I would be much obliged.
Many thanks,
Paul