السلام عليكم ورحمة الله وبركاته
أريد مساعدة في تصحيح الأخطاء من فضلكم
clear all
close all
clc
format long e
global tauc taup q d J0 G0 N0
w = 3e-6;
d = 0.3e-6;
L = 500e-6;
area_I = w*L;
area_P = w*d;
tauc = 1e-9; %electron life time
sigmag = 2.5e-20; %gain cross-section
alpha_int = 0.5e2; %internal loss of the cavity
R1 = 0.9;
R2 = 0.9;
alpha_mir = -log(R1*R2)/(2*L);
alpha_cav = alpha_int + alpha_mir;
vg = 3e8/3.5; %velocity of light in medium
taup = 1/(vg*alpha_cav); %photon life time
q=1.60218e-19;
h=6.6256e-34;
G0 = sigmag*vg;
I0 = 150e-3; %Current
J0 = I0/(w*L); %Current density
N0 = 0.8e24;
Nth = N0 + 1/(G0*taup);
Ith = q*d*Nth*area_I/tauc;
f = 3e8/1.3e-6;
power_analyt = h*f*vg*taup*(I0-Ith)/(q*L);
tfinal = 20e-9;
fs = 1e15;
t = 0:1/fs:0.4e-9;
[T,Y] = ode45('rate_eqn',[0 tfinal], [1e-12 1e-12]);
power = Y(:,1)*h*f*vg*w*d;
% P = power(length(power))
plot(T*1e9,power*1e3)
grid on
Hp1=plot(T*1e9,power*1e3)
set(Hp1,'LineWidth',2)
Ha = gca;
set(Ha,'Fontsize',12)
Hx=xlabel('Time ns ');
set(Hx,'FontWeight','bold','Fontsize',12)
Hx=ylabel('Optical Power, mW');
set(Hx,'FontWeight','bold','Fontsize',12)
function z=rate_eqn(t,y)
global tauc taup q d J0 G0 N0
G = G0*(y(2)-N0);
% T1 = 10e-9;
% T0 = 5e-9;
% tt = (t-T0)/T1;
f = 0.2e9;
yp1 = G*y(1)-y(1)/taup; % + 1e8*randn(length(t),1);
% yp2 = -G*y(1)-y(2)/tauc + (J0)/(q*d);
% yp2 = -G*y(1)-y(2)/tauc + J0*exp(-tt .* tt)/(q*d);
% yp2 = -G*y(1)-y(2)/tauc + (J0 + 0.5*J0*cos(2*pi*f*t))/(q*d); %
fs = 1e15;
yp2 = -G*y(1)-y(2)/tauc + (J0 + 0.5*J0*square(2*pi*0.2e9*t))/(q*d);
z = [yp1 yp2]';