IDASolve returned "IDA_TOO_MUCH_WORK"

449 views
Skip to first unread message

Paul Montgomery

unread,
Sep 9, 2021, 6:28:35 PM9/9/21
to CasADi
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:
  1. the reason for failure
  2. integrator options or another work around
  3. insight into how to debug or get deeper understanding
I would be much obliged.
Many thanks,
Paul






Joel Andersson

unread,
Sep 21, 2021, 9:23:01 PM9/21/21
to CasADi
Often this type of failures happen whenever the Jacobian system becomes singular or almost singular. You can try adding some options like:

opts.dump_in = true;
opts.dump_out = true;

If you find out for what values the integrator breaks down, you can look at the Jacobian at that point.

Best regards,
Joel

Reply all
Reply to author
Forward
0 new messages