Unreasonable ODE45 results

2 次查看(过去 30 天)
Arjun Iyer
Arjun Iyer 2015-12-29
I have been seeing some weird behavior when using the ODE45 solver to solve a system of coupled differential equations. There is strange behavior around t=0, after which it converges to the required steady state values, since I am interested in the transient behavior, I would like to know what is going wrong. This behavior seems to pretty much independent of the initial values I choose. The system of equations are laser rate equations. I am attaching the solution recovered and the code.
if true
-------calling the solver-----------
paramfile='laser_param_1';
eval(paramfile);
global R A_fr del_om;
A_fr= sqrt(( J-(gamma_n*N_th))/gamma_p);
R=db2mag(-12.055);
del_om=1.7e9*2*pi;
options = odeset('RelTol',1e-7,'AbsTol',[1e-5,1e-5]);
[t,Y] = ode45(@leqn_solver_fun2,[0 5e-9],[A_fr N_th],options);
--------------defining the system of equations--------------
function [dY] = leqn_solver_fun2(t,Y)
paramfile='laser_param_1';
eval(paramfile);
% A simple function to simulate laser rate equations.
global R A_fr del_om;
dY=zeros(2,1);
dY(1)=0.5*g*(Y(2)-N_th)*(1+1i*3.5)*Y(1)+k*(R)*A_fr-1i*del_om*Y(1);
dY(2)= J-gamma_n*Y(2)-(gamma_p+g*(Y(2)-N_th))*abs(Y(1))^2;
end

回答(1 个)

Josh Meyer
Josh Meyer 2016-1-6
This looks to me as if ODE45 is initially taking big steps which only coarsely capture the behavior, but it quickly recovers and takes appropriately sized steps.
Some things to try to fix this:
  1. The initial step taken by the solver appears too large. Set the 'InitialStep' option of ODESET to restrict this initial step size.
  2. Alternatively you can set the 'MaxStep' option so that the solver does not step over this behavior. Your solution appears periodic so a good value would be the length of a period (or perhaps half a period).

类别

Help CenterFile Exchange 中查找有关 Ordinary Differential Equations 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by