how to solve a DAE system inside multiple class method with ode solver?
이전 댓글 표시
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
darova
2020년 3월 24일
Why do you want to simulate them together? Are they connected somehow?
Fh1=@(t,y) TypeA.DAEs(t,y);
Fh2=@(t,y) TypeB.DAEs(t,y);
F={Fh1;Fh2};
Can you show the objects?
Marco Antonio David Hernández
2020년 3월 24일
darova
2020년 3월 24일
I don't understand how they are connected
Marco Antonio David Hernández
2020년 3월 24일
darova
2020년 3월 24일
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])
Marco Antonio David Hernández
2020년 3월 26일
답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Ordinary Differential Equations에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!