ode23s solver: f(x)<0 even though f'(x)>0 as soon as time becomes internal variable
4 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Hello,
I got a problem during my simulation using the ode23s solver, probably because of a very small inconstancy.
Firstly I got:
xInit = [0,0,0,0,0,0,0];
dxdt = odefun(t,x); % with dxdt = [..,.. ,duds, ...,..];
[t,x] = ode23s(odefun, [0 250e-9], xInit); % so i simulate from t = 0ns until t = 250ns
in the odefun there is a statement calculating duds:
ids = ia + ib + ir + ip;
duds = 1/C*ids;
ir is a function of uds and duds is the derivative of this uds:
if uds<0
ir = f*exp(g*(-uds))-1;
else
ir = 0;
end
Furthermore:
For 0<t<t0 the following statement applies without exception: iq = 0
As long as this applies the simulation runs smoothly, but at the time instance t0 there is an event triggering the start of the calculation of iq with:
iq = a*tanh(b*(t-t0))^c; % a,b,c are just coefficients and t is the simulation-time
The very moment this calculation starts, there is an error accumulating rapidly. Even though it applies that duds > 0 before and after the time instance t0 the variable uds starts to become more and more negative after t0, although it was becoming more positive before t0 when duds > 0 applies. Because ir is an exp-function of (-uds) it starts to diverge when uds becomes more negative.
I already understood that odexx is not solely taking duds to calculate uds, but it's doing further semi-random steps in order to compute higher-order derivatives. And I guess that suddenly introducing a time dependent variable does not come easily, but how do I solve this.
Discontinuities are fatal, but because tanh(t-t0) = 0 when t=t0 and because tanh is a continuous differentiable as like as its derivatives it should work, right?
Is there a way to make ode work with that, or just tell it to work with duds alone to calculate my uds of the next time instance?
Best regards,
Fabian
7 comentarios
Harald
el 20 de Abr. de 2024
This "jumping back and forth" is expected behavior of an ode solver with step size control: if the estimated error violates the tolerances, a smaller step has to be taken. This implies evaluating the function at previous times.
Respuestas (0)
Ver también
Categorías
Más información sobre General Applications en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!