how to solve a DAE system inside multiple class method with ode solver?
3 views (last 30 days)
Show older comments
Marco Antonio David Hernández
on 24 Mar 2020
Commented: Marco Antonio David Hernández
on 26 Mar 2020
Good day,
For a school work, I am using object oriented programming in MatLab to simulate a system which consist of more than one object. Each object has it's own set of differential equations and algebraic equations. But in conjuction they are a system that I would like to solve with the ode solver for DAEs of MatLab.
I already simulate a single component, and has been analyzed using ode15s. for example, TypeA.DAEs is one of the components and depends on t and y (for this, the mass matrix is already defined for the opt input, and also the timestep). DAEs is a method inside the class which has the set of differential angebraic equations:
F=@(t,y) TypeA.DAEs(t,y);
[tsol,ysol]=ode15s(F,[0 timestep],y0,opt);
Like this, it works. However when I want to include a second component, TypeB.DAEs, I don't know how to include it. Also, this TypeB.DAEs also dependes on t and y and has defined the set of DAEs. I have ytrie dsomething like:
Fh1=@(t,y) TypeA.DAEs(t,y);
Fh2=@(t,y) TypeB.DAEs(t,y);
F={Fh1;Fh2};
[tsol,ysol]=ode15s(F,[0 timestep],y0,opt);
But I have errors that the ode solver does not accept this kind of input.
I would like to know if there is a way to do it and how to implement it.
If anyone knows or have already done this kind of thing and have a solution, I would very much appreciate it.
Thank you,
6 Comments
darova
on 24 Mar 2020
try this
f1 = @(t,y) [y(2);y(1)*y(2)];
f2 = @(t,y) [y(3);y(2);y(1)*y(3)];
F = @(t,y) [f1(t,y);f2(t,y)];
F(1,[1 2 3])
Answers (0)
See Also
Categories
Find more on Configure Simulation Conditions 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!