Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MATLAB solve ODE on invariant manifold

Tags:

matlab

ode

I have a system that looks like

dn/dt=f(n,v)
dh/dt=g(h,v)

I want to solve this equation on the manifold F(v,n,h)=0, a nonlinear function in v. I tried to use something like v=fzero(@(x) F(x,n,h),0) to solve for the value of v on the manifold at each time step. But this is incredibly slow and ode15s (my system is a relaxation oscillator) fails to meet integration tolerance. How do I find solution to the ODE on the manifold defined by F(v,n,h)=0?

like image 367
Badoe Avatar asked Oct 29 '22 19:10

Badoe


1 Answers

I find @LutzL's comment very helpful. It is possible to set up a DAE solver using ode15s. Example: The "Solve Robertson Problem as Semi-Explicit Differential Algebraic Equations (DAEs)" section in https://www.mathworks.com/help/matlab/ref/ode15s.html

In my case, I would setup a matrix:

M=[zeros(1,3);0,1,0;0,0,1];
options = odeset('Mass',M,'RelTol',1e-5,'AbsTol',1e-6,'MaxStep',0.01);
y0=[v0,n0,h0];
[T,Y]=ode15s(@slow,[0 50],y0,options);

And slow is a function defined as:

function dy = slow(t,y)
    v=y(1); n=y(2); h=y(3);
    dy=zeros(3,1);
    dy(1)=F(v,n,h);
    dy(2)=f(n,v);
    dy(3)=g(h,v);
end
like image 64
Badoe Avatar answered Nov 15 '22 08:11

Badoe