Vectorizing DAE with strong State Dependance Mass matrix

조회 수: 1 (최근 30일)
Andrii
Andrii 2025년 7월 9일
댓글: Torsten 2025년 7월 11일
Hello,
Please help me to vectorize my DAE, I want Vectorized='on'
Thank you
Andrii
a=0.4; b=0.1; c=0.9;
A = @(y) c/y(1);
Ms=@(t,y) [A(y) 0 -a/y(2); 0 b 0; 0 0 0];
Ds=@(t,y) [y(1)*y(3)-y(2)+1; y(1)-1; a*y(1)+y(2)+y(3)];
Y0=[1, 1, -2];
opts = odeset('MStateDependence','strong','MassSingular','yes','Mass',Ms,Vectorized='off');
%opts = odeset('MStateDependence','strong','MassSingular','yes','Mass',Ms,Vectorized='on');
[t,Y] = ode15s(Ds,[0 10],Y0,opts);
plot(t,Y,"-x")

채택된 답변

Chuguang Pan
Chuguang Pan 2025년 7월 9일
The Vectorized option in odeset means that your DAEs can be writen as , apparently your DAEs can not be expressed as separable form.
[a,b,c] = deal(.4,.1,.9);
Ms = @(t,y) [c./y(1),0,-a./y(2);0,b,0;zeros(1,3)];
Ds = @(t,y) [y(1).*y(3)-y(2)+1;y(1)-1;a.*y(1)+y(2)+y(3)];
Y0=[1;1;-2];
opts = odeset('MStateDependence','strong','MassSingular','yes','Mass',Ms,Vectorized='off');
[t,Y] = ode15s(Ds,[0 10],Y0,opts);
plot(t,Y)
  댓글 수: 7
Andrii
Andrii 2025년 7월 11일
Thanks, appreciate your help. Lets see if vectorization will save me some calculation time.
Regards
Andrii
Torsten
Torsten 2025년 7월 11일
Lets see if vectorization will save me some calculation time.
But the code from above is not vectorized - you are still left with the need to vectorize the loop.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Numerical Integration and Differential Equations에 대해 자세히 알아보기

제품


릴리스

R2024b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by