How can I modify my code to generate data sets (qtot_eV) for each variation of layer thickness and vacuum gap
1 次查看(过去 30 天)
显示 更早的评论
The code below is used to generate a data set (qtot_eV) by varying only the gap between the two stacks. However, I would like to modify the code so as to generate data set by varying the thicknsess of each layers. I already modified the functions that contain the layer thickness variations for each stacks as pasted below the main code. I need help on how to accurately generate dataset by varying the layer thicknesses and gap between them. I need the data for further optimization in deep learning. Thanks
%Main code
deld=(80E-9-10E-9)/5;
d=[10E-9:deld:80E-9]; % Variation of the distance between the hot and cold stacks
q=1.602E-19;
hbar=1.054571596E-34;
hbar_eV=hbar/q; %eV s
kb=1.3806503E-23;
kb_eV=kb/q;
h=2*pi*hbar;
h_eV=h/q; % eVs
T1=1500; %Emitter temperature, in K
T2=300; %TPV cell temperature, in K
c=2.9979E8; %speed of light
%Wavelength over which the near field heat transfer spectrum is calculated.
lambda_min1=10000E-6;
lambda_max1=2.5E-6;
lambda_max2=1E-6;
%number frequency points in the two calculation ranges
res1=200; %between lambda_min1 and lambda_max1
res2=200; %between lambda_max1 and lambda_max2
%wavelength to frequency conversion, do not touch
w_min1=2*pi*3E8/lambda_min1;
w_max1=2*pi*3E8/lambda_max1;
del1=(w_max1-w_min1)/res1;
w_min2=w_max1+del1;
w_max2=2*pi*3E8/lambda_max2;
del2=(w_max2-w_min2)/res2;
w=[(w_min1:del1:w_max1) (w_min2:del2:w_max2)];
lambda=2*pi*c./w;
w_ev=w/1.5193E15;
qevan_p=zeros(length(w),length(d)); %vector initialization
qevan_s=zeros(length(w),length(d));
qprop_p=zeros(length(w),length(d));
qprop_s=zeros(length(w),length(d));
for k = 1:length(d)
for a=1:length(w)
betaevanmax=10/d(k); %upper limit of the parallel wavevector for evanescent wave integration
betaevanmin=w(a)/c; %lower limit
gap=d(k);
qevan_p(a,k)=(Theta(w(a), T1,0)-Theta(w(a), T2))*1/pi^2*integral(@(beta)sevan_p(w(a),beta, d(k)),betaevanmin,betaevanmax,'Reltol',1E-6,'AbsTol',1E-10); %default abstol = 1E-10 reltol 1E-6
qevan_s(a,k)=(Theta(w(a), T1,0)-Theta(w(a), T2))*1/pi^2*integral(@(beta)sevan_s(w(a),beta, d(k,t)),betaevanmin,betaevanmax,'Reltol',1E-6,'AbsTol',1E-10);
qprop_p(a,k)=(Theta(w(a), T1,0)-Theta(w(a), T2)).*1/pi^2.*integral(@(beta)(sprop_p(w(a),beta,d(k))),0,w(a)/c);
qprop_s(a,k)=(Theta(w(a), T1,0)-Theta(w(a), T2)).*1/pi^2.*integral(@(beta)(sprop_s(w(a),beta,d(k))),0,w(a)/c);
a/length(w) % progress indicator
end
end
qtot=qevan_p+qevan_s+qprop_p+qprop_s; %total intensity spectum
qtot_eV=qtot*1.5193E15/10000; %in w/cm2/eV
qprop=(qprop_p+qprop_s)*1.5193E15/10000; %prop waves only, in w/cm2/eV
qevan=(qevan_p+qevan_s)*1.5193E15/10000; %evan waves only, in w/cm2/eV
bb=blackb(w,T1)*1.5193E15/10000; %in w/cm2/eV
%Function for first stack
function [t,n]=stack1(lambda)
t=[linspace(10E-9,150E-9, 5) linspace(10E-9,100E-9, 5)]; %layer thicknesses
n=ones((length(t)+2),length(lambda));
n(1,:)=1*n(1,:);
n(2,:)=sqrt(epsilon_ITO( lambda ));
n(3,:)=sqrt(epsilon_SiC( lambda ));
n(4,:)=sqrt(epsilon_w(lambda));
%Function for stack2
function [t,n]=stack2(lambda)
t=[linspace(10E-9,150E-9, 5) linspace(500E-9,1E-6, 5)];
n=ones((length(t)+2),length(lambda)); %intializes a 2D matrix of wavelenght-dependant refractive indices
n(1,:)=1*n(1,:);
n(2,:)=sqrt(epsilon_tisi2(lambda));
n(3,:)=3.5*n(1,:);
n(4,:)=sqrt(epsilon_Al( lambda )); %cell back electrode
0 个评论
回答(1 个)
Sandeep
2023-3-2
Hi Ambali Odebowale,
Here is the modified MATLAB code to generate dataset by varying the layer thicknesses and vacuum gap between stacks. Hope you find it helpful.
% Define parameters
d1 = linspace(5, 50, 10); % thicknesses of first stack layers
d2 = linspace(5, 50, 10); % thicknesses of second stack layers
gap = 5; % gap between the two stacks
lambda = 632.8; % wavelength of light
% Initialize data set
qtot_eV = zeros(length(d1)*length(d2), 3);
% Loop over all combinations of layer thicknesses
for ii = 1:length(d1)
for jj = 1:length(d2)
r1 = (n1 - n2)/(n1 + n2);
t1 = 2*n1/(n1 + n2);
r2 = (n2 - n3)/(n2 + n3);
t2 = 2*n2/(n2 + n3);
% Calculate phase shift in second stack
delta = 2*pi*n2*d2(jj)/lambda;
% Calculate total reflectance and transmittance
r_tot = r1 + t1*t2*r2*exp(1i*delta)/(1 - r1*r2*exp(2*1i*delta));
t_tot = t1*t2*exp(1i*delta)/(1 - r1*r2*exp(2*1i*delta));
% Calculate total energy
qtot = abs(t_tot)^2/(n3/n1);
qtot_eV(ii*jj, 1) = d1(ii);
qtot_eV(ii*jj, 2) = d2(jj);
qtot_eV(ii*jj, 3) = qtot;
end
end
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Deep Learning Toolbox 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!