How can I make my ODE system run faster

조회 수: 5(최근 30일)
Gideon Idumah
Gideon Idumah 2021년 11월 12일
답변: Sulaymon Eshkabilov 2021년 11월 12일
options = odeset('mass',BigM,'MassSingular','no','BDF','on','MaxOrder',2,'Jacobian',...
@(t,u) MyJacobian(t,u,MM_params, RHS_params, mask));
[time,u_sol] = ode15s(@(t,u) TGetRHS(t,u, MM_params, RHS_params, mask), 0:0.4:tspan, U_init, options);
I have a project in which the main bulk of the work is solving a huge ODE coupled system of size of the form:
where
The RHS is partitioned into the sum of a "fast scale" and "slow" scale component. This makes the system very stiff, hence I am using ode15s in MATLAB and I tried to make things as sparse as possible.
However, my code takes several hours to run, and I have been thinking about how to use parallel or gpu computing to speed things up. I have checked MATLAB documentation to see if Ode15s can be solved on GPU, but I havent found any good answer.
I will appreciate any suggestion on how to make my code run faster in MATLAB or using other external software.

답변(1개)

Sulaymon Eshkabilov
Sulaymon Eshkabilov 2021년 11월 12일
Use a variable step solver instead of the fixed step, e.g.:
options = odeset('mass',BigM,'MassSingular','no','BDF','on','MaxOrder',2,'Jacobian',...
@(t,u) MyJacobian(t,u,MM_params, RHS_params, mask));
[time,u_sol] = ode15s(@(t,u) TGetRHS(t,u, MM_params, RHS_params, mask), [0, tspan], U_init, options);
% 0:0.4:tspan --> To avoid the fixed step of 0.4

제품


릴리스

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by