How to efficiently integrate odes with time-dependent input and analytical jacobian?

2 ビュー (過去 30 日間)
kika198513
kika198513 2015 年 10 月 7 日
Dear all, I integrated an ODEs system with ode15s in Matlab. In order to make the integration more quick and precise, I provided the analytical jacobian to the ode solver. The first ODE is characterised by a time-dependent input. This implies that I used interp1 inside both the functions of the ODEs and of the Jacobian. However, I had a look to the profiler and I saw that interp1 inside both the functions has an exaggerate time consumption. Do you know if there is a way to compute interp1 just once?
Hereafter, I paste the codes:
A=[1.6776 0.6647 -1.9931 -39.0379 17.6702 0.4813 1.0504 49.8175 -15.4547 5.7915 5.8660];
IN1=ones(1,301); %actually I have here some data from experiments
IN2=ones(1,301); %actually I have here some data from experiments
tspan=-2:0.005:-0.5;
ww0=[0.6869 1];
options = odeset('Jacobian',@(t,y)J_LC(t,y,A,IN1,IN2));
[t_,sim_v]=ode15s(@(t,ww)f_fhn_ga_LC(t,ww,A,IN1,IN2),tspan,ww0,options);
%---------------
function dfdy = J_LC(t,y,A,IN1,IN2)
in_lc_1=interp1(-2:0.005:-0.5,IN1,t);
in_lc_2=interp1(-2:0.005:-0.5,IN2,t);
dfdy = [ 3*A(3)*y(1)^2+2*A(2)*y(1)+A(1)+A(10)*in_lc_1+A(11)*in_lc_2 A(4);
1/A(6) -1/A(6)];
%---------------
function wdot= f_fhn_ga_LC(t,ww,param,IN1,IN2)
www=[ww(1) ww(1)^2 ww(1)^3];
fn=sum(param(1:3).*www,2);
in_lc_1=interp1(-2:0.005:-0.5,IN1,t);
in_lc_2=interp1(-2:0.005:-0.5,IN2,t);
wdot(1)=fn+param(4)*ww(2)+param(5)+in_lc_1.*param(8)+in_lc_2.*param(9)+param(10).*in_lc_1.*ww(1)+param(11).*in_lc_2.*ww(1);
wdot(2)=(ww(1)-ww(2))/param(6);
wdot=wdot';
Many thanks in advance!

回答 (0 件)

カテゴリ

Help Center および File ExchangeOrdinary Differential Equations についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by