Info
La pregunta está cerrada. Vuélvala a abrir para editarla o responderla.
Using 'if' to evaluate independent variable on DAE
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Hello Be 't' the independent variable
I can use if to evaluate 't' on ODE:
function f=ODE(t,y)
if t<10 a=10; else a=0; end
f=a;
end
[t,y]=ode15s('ODE',[0,100],1)
I can use if to evaluate 't' on DAE: When the algebraic equation don't depend on the result from if
function f=DAE(t,y)
if t>10 a=0; else a=10; end
b=y(2)+1;
f=[a;b];
end
[t,y]=ode15s(@(t,y) DAE(t,y),[0,100],[1,1],odeset('Mass',[1 0; 0 0]))
But, cant use it when the algebraic equation depend on the result from if
function f=DAE(t,y)
if t>10 a=0; else a=10; end
b=y(2)+a;
f=[a;b];
end
[t,y]=ode15s(@(t,y) DAE(t,y),[0,100],[1,1],odeset('Mass',[1 0; 0 0]))
The solver works until the condition t>10 is reached, then I get this error: Warning: Failure at t=1.000000e+100. Unable to meet integration tolerances without reducing the step size below the smallest value allowed (2.842171e-014) at time t.
The solver reduce the step size when t is near 10, and all sucesive iterations are on t=10, so I can't get the values for t>10.
I guess this happen because the "function if" is a discontinous function, so the solver get this as a singularity and his algorithm can't solve it.
So, my question is: How to use if to evaluate the independent variable, and make the algebraics equations depend on his result avoiding the solver stop working?
0 comentarios
Respuestas (1)
Jan
el 31 de Mzo. de 2012
You can and should use an event, which stops the integration and restart it afterwards. Unfortunately this has to be done manually, because the event functions in Matlab's integrators cannot restart the integration with new parameters.
1 comentario
La pregunta está cerrada.
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!