Failure when using ode15i : not meeting integration tolerances
Show older comments
Hello !
Thanks to your answers, I have been able to solve a DAE using ode15i. The code runs but only until a specific time, and after it it stops:
My code solves the following DAE :
d²x/dt² = 1/m * (- f2(x-x1, dx/dt - dx1/dt))
0 = f2(x-x1, dx/dt - dx1/dt) - f1(x1,dx1/dt)
and f1 and f2 are functions calculating the force corresponding to x1,x and dx/dt, dx1/dt.
f1 and f2 look like this :
function force = f1(x - x1, dx - dx1)
if dx - dx1 <= 0 %COMPRESSION
force = ... (a polynom P(x - x1))
else %DETENTE
force = ... (another polynom P(x - x1))
end
I then use it in my DAE :
function res = f(t,Y,dY)
% Y = (x; x1; dx) and dY = (dx; dx1; d²x)
course1 = l0(1) - Y(2);
coursetot = l0(1) + l0(2) - Y(1);
course2 = coursetot - course1;
forcemi79 = f1(course1, dY(2))
forcemi20 = f_MI20ode15i(course2,Y(3)-dY(2));
res = [dY(1) - Y(3);
- forcemi20 + forcemi79;
dY(3) - 1/m_materiel*(forcemi20)];
And then I use ode15i :
sol = ode15i(@f,tspan,y0,yp0)
But when dx - dx1 goes from negative to positive, the code stops, with this error :
Warning: Failure at t=5.111363e-01. Unable to meet integration tolerances without reducing the step size below the smallest value allowed (1.815921e-15) at time t.
> In ode15i at 406
In wagon79face20 at 31
I don't understand how I can change f1 and f2 in order for it to run anyway ?
Thank you for your help !
6 Comments
A function like your f1 will immediately throw an error:
a = 25;
b = 31;
force = f1(a,b)
function force = f1(x - x1, dx - dx1)
if dx - dx1 <= 0 %COMPRESSION
force = x-x1;
else %DETENTE
force = (x-x1).^2;
end
end
The input arguments to a function cannot be arithmetic expressions of some variables.
It must read:
function force = f1(x ,x1, dx, dx1)
if dx-dx1 <= 0 %COMPRESSION
force = x-x1;
else %DETENTE
force = (x-x1).^2;
end
end
Zoé Cord'homme
on 22 Jul 2022
Walter Roberson
on 22 Jul 2022
What is your current code?
Zoé Cord'homme
on 22 Jul 2022
Edited: Zoé Cord'homme
on 22 Jul 2022
Walter Roberson
on 22 Jul 2022
forcemi79 = ...a polynom P(course)
elseif course<=...
The three dots at in the forcemi79 assignment act as continuation markers. The rest of that line is ignored, and the next line is treated as if it was part of the same line, so you effectively have a line
forcemi79 = elseif course<= forcemi79 else forcemi79=0
which is not valid syntax.
Reminder: if you are hoping that someone can debug your code, they need your actual code to test with.
Zoé Cord'homme
on 22 Jul 2022
Accepted Answer
More Answers (0)
Categories
Find more on Numerical Integration and Differential Equations in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!