I am getting error while trying to generate data for qtot_eV through variation of "d".

1 回表示 (過去 30 日間)
Below is my code:
clear;
close all;
deld=(80E-9-10E-9)/100;
d=[10E-9:deld:80E-9]; %Distance between the emitter and TPV cell 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
V=0;
%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=100; %between lambda_min1 and lambda_max1
res2=100; %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(1,length(w)); %vector initialization
qevan_s=zeros(1,length(w));
qprop_p=zeros(1,length(w));
qprop_s=zeros(1,length(w));
for a=1:length(w)
betaevanmax=10./d; %upper limit of the parallel wavevector for evanescent wave integration
betaevanmin=w(a)/c; %lower limit
qevan_p(a)=(Theta(w(a), T1,0)-Theta(w(a), T2, V))*1/pi^2*integral(@(beta)sevan_p(w(a),beta, d),betaevanmin,betaevanmax,'Reltol',1E-6,'AbsTol',1E-10); %default abstol = 1E-10 reltol 1E-6
qevan_s(a)=(Theta(w(a), T1,0)-Theta(w(a), T2, V))*1/pi^2*integral(@(beta)sevan_s(w(a),beta, d),betaevanmin,betaevanmax,'Reltol',1E-6,'AbsTol',1E-10);
qprop_p(a)=(Theta(w(a), T1,0)-Theta(w(a), T2, V)).*1/pi^2.*integral(@(beta)(sprop_p(w(a),beta,d)),0,w(a)/c);
qprop_s(a)=(Theta(w(a), T1,0)-Theta(w(a), T2, V)).*1/pi^2.*integral(@(beta)(sprop_s(w(a),beta,d)),0,w(a)/c);
a/length(w) % progress indicator
end
qtot=qevan_p+qevan_s+qprop_p+qprop_s; %total intensity spectum
qtot_eV=qtot*1.5193E15/10000; %in w/cm2/eV
The error is:
Error using integral (line 85)
A and B must be floating-point scalars.
Error in optimization (line 59)
qevan_p(a)=(Theta(w(a), T1,0)-Theta(w(a), T2, V))*1/pi^2*integral(@(beta)sevan_p(w(a),beta, d),betaevanmin,betaevanmax,'Reltol',1E-6,'AbsTol',1E-10); %default abstol = 1E-10
reltol 1E-6

採用された回答

VBBV
VBBV 2022 年 11 月 30 日
As the error states, you need to provide scalar values for integral limits
betaevanmax=10./max(d); % use a scalar value for upper limit for integral function
  3 件のコメント
VBBV
VBBV 2022 年 11 月 30 日
In that case you need to use another for loop to consider each value in vector d.
clear;
close all;
deld=(80E-9-10E-9)/100;
d=[10E-9:deld:80E-9]; %Distance between the emitter and TPV cell 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
V=0;
%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=100; %between lambda_min1 and lambda_max1
res2=100; %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
qevan_p(a,k)=(Theta(w(a), T1,0)-Theta(w(a), T2, V))*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, V))*1/pi^2*integral(@(beta)sevan_s(w(a),beta, d(k)),betaevanmin,betaevanmax,'Reltol',1E-6,'AbsTol',1E-10);
qprop_p(a,k)=(Theta(w(a), T1,0)-Theta(w(a), T2, V)).*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, V)).*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
Also, matrix dimensions need to be changed as below
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));
Ambali Odebowale
Ambali Odebowale 2022 年 11 月 30 日
編集済み: Ambali Odebowale 2022 年 11 月 30 日
Thanks so much. This really helps me

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangePartial Differential Equation Toolbox についてさらに検索

製品


リリース

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by