Runge Kutta 4th order Solution Problem

1 view (last 30 days)
NRIPESH DIXIT
NRIPESH DIXIT on 29 Nov 2020
Edited: Alan Stevens on 30 Nov 2020
Hello There
I am designing a program for my project where I am having difficulties while solving the equations for RK4 method, your help will be much appreciated.
%Function File
function Output1= C60function(t,N_MH,I_m)
global sigma_0 tau_S0 tau_T0 tau_ST c cc I_m0 h nu delt t_m
N_S0 = N_MH(1);
N_S1 = N_MH(2);
N_T1 = N_MH(3);
N_S0dot = ((-(sigma_0.*I_m.*N_S0)./(h.*nu)))+((N_S1)./(tau_S0))+((N_T1)./(tau_T0));
N_S1dot = (((sigma_0.*I_m.*N_S0)./(h.*nu))-((N_S1./tau_S0))-((N_S1)./(tau_ST)));
N_T1dot = (((N_S1)./(tau_ST))-((N_T1)./(tau_T0)));
Output1 = [N_S0dot N_S1dot N_T1dot];
end
Main File
clear all ; clc
global sigma_0 tau_S0 tau_T0 tau_ST c I_m0 h nu delt t_m cc lambda
sigma_0 = 2.87e-4; %Nanometer^2
tau_S0 = 30; %Nanosecond
tau_T0 = 280e+3; %Microsecond
tau_ST = 1.2; %Nanosecond
c = 4*log(2); %Pulse Profile Parameter
h = 6.64e-25; %Joule.Second
I_m0 = 50e-8; %MegaWatt/nanometer^2
nu = 3.384e+23; %Nanohertz
cc = 2.998e-1; %nanometer
lambda = 885; %nanometer
t_m = 2; %nanometer
delt = 1.5; %nanometer
dt = 0.001;
Light = [0:dt:10];
I_m = (I_m0.*(exp(-c.*((Light-t_m)./(delt)).^2)));
Itrs = length(Light);
N_MH(1,:) = [1 0 0];
t(1) = 0;
for ii = 1:1:Itrs-1
k_1 = Output1(t,N_MH(ii,:),I_m(ii));
k_2 = Output1((t+0.5*dt),(N_MH(ii,:)+0.5*k_1*dt),(I_m(ii)));
k_3 = Output1((t+0.5*dt),(N_MH(ii,:)+0.5*k_2*dt),(I_m(ii)));
k_4 = Output1((t+dt),(N_MH(ii,:)+k_3*dt),(I_m(ii)));
N_MH(ii+1,:) = N_MH(ii)+dt/6*(k_1+2*k_2+2*k_3+k_4);
end
plot(t,N_MH(:,1));
grid on
  5 Comments
NRIPESH DIXIT
NRIPESH DIXIT on 30 Nov 2020
Hey There!
I am delighted with your answer but I am working on managing the simulation of Output at 885 nm with respect to time (nanoseconds), so i have to simulate RK4 for the above mentioned graph. Isn't it so possible the simulation for those curves?
Your guidance in simulating graphical curves would be loved.
Alan Stevens
Alan Stevens on 30 Nov 2020
Edited: Alan Stevens on 30 Nov 2020
I can't make out what is plotted in the published graph - a ratio of something, but I can't read what!
I'm not convinced your units are consistent. For example, you have nu ~ 10^23 per nanosecond. If nu is meant to be the frequency of your 885nm light this seems orders of magnitude too large.

Sign in to comment.

Answers (0)

Community Treasure Hunt

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

Start Hunting!