SlideShare a Scribd company logo
3 (a) calculate thy potential at point P located a distance z above the center of a charged disk of
radius a and surface charge density p, Coulombs per square meter. Please show all work An
integral that you may need is The elemental area in cylindrical coordinates is dA = (b) Calculate
the electric field at P. Use back of page if necessary
Solution
function [Ef] = Loop_Ef() %(Main M-File function)
clc, clear all, close all
u.N1 = 1e21; %This is the number of states
u.NA = 1e15; %This is the number of acceptors
u.ND = 0; %This is the number of donors
u.Z1 = 281.73e19; %This term in front of the square root of the energy (this contains mass of
electron)
u.Z2 = 757.989e19; %This is the mass of hole
u.Eg = 1.12/2; %This is the energy gap
u.a = 0.0259;
%u.rat_a = 2 %scaling factor that modifies the steepness of the oxide exponential density of
states
u.es = 11.9 * 8.854187817e-14; %permittivity measured C / cm * V
u.qe = 1.602e-19; %This is the value of charge
u.psi_0_range = linspace(-0.4, 1, 160)'; %This defines the range of Psi_0
u.display = true; %psi is in Volts Not ev?
%%
%ratN_range = 1e-2; ratS_range = [ 0.5: 0.2: 2];
ratN_range = 1; ratS_range = 1; %This doesn’t matter for Parabolic DOS
for iN = 1 : length(ratN_range)
for iS = 1 : length(ratS_range)
u.ratN = ratN_range(iN);
u.ratS = ratS_range(iS);
u.N2 = u.ratN * u.N1;
try
% Ef_(iN,iS) = Calculate_Ef(u); %Here its calculating the f_function
Ef_(iN,iS) = -0.356324 %REMOVE-TESTING
u.Ef_ = Ef_(iN,iS); %Here Ef equals
u.Q = Calculate_El(u);%Here is calculating the charge
DiffQ(u);
catch
Ef_(iN,iS) = NaN; %If there is nothing then NaN
end
end
end
clf,
plot(u.psi_0_range, u.Q) %Its plotting the graph
u.Ef_all = Ef_;
save 'u.mat' %It saves all the data in u.file
save 'Ef_.dat' Ef_ -ascii %Exports the data of Ef as ascii
keyboard %This command gives the control to the user
end
%================================================
function [Ef_] = Calculate_Ef(u)
clc
time = cputime;
%rescale volumes for numerical stability
u.Nscale = u.N1 ^ 2;
Nscale = u.Nscale;
u.N1 = u.N1 / Nscale;
u.N2 = u.N2 / Nscale;
u.Z1 = u.Z1 / Nscale;
u.Z2 = u.Z2 / Nscale;
%get rid of the u.''
N1 = u.N1; N2 = u.N2;
Z1 = u.Z1; Z2 = u.Z2;
Eg = u.Eg;
a = u.a;
NA = u.NA/Nscale; ND = u.ND/Nscale;
P_1 = @(E) Z1.*sqrt(-Eg-E); %This is the parabolic function(Valance band)
P_2 = @(E) Z2.*sqrt(E-Eg); %This is the parabolic function (Conduction band)
Fn = @(E,Ef) 1 ./ ( exp((E-Ef)/a) ); %This is the Fermi-dirac for electrons
Fp = @(E,Ef) 1 ./ ( exp((Ef-E)/a) ); %This is the Fermi-dirac for holes
dp = @(E,Ef) P_1(E) .* Fp(E,Ef); %the integrands
dn = @(E,Ef) P_2(E) .* Fn(E,Ef);
p = @(Ef) Nscale * (IntegrateInf_p( @(E) dp(E,Ef), u ) + ND); %define our functions p & n
(Ef)
n = @(Ef) Nscale * (IntegrateInf_n( @(E) dn(E,Ef), u ) + NA);
%%we need to make sure that multiplication/division with Nscale is consistent all the way
through to DiffQ
Ef_ = Solve_Ef(-0.5, p, n); %Ef* is obtained here
fprintf('The value Ef*= %f, gives equal values for: p(Ef*)= %f & n(Ef*)= %f ', Ef_, p(Ef_),
n(Ef_) )
fprintf('Time: %2.2fsecs  ', cputime-time ) %displays the time
if u.display
clf
b = 1; %range of the graphs AND of Ef search
PlotParabolics (Eg, b, P_1, P_2); %This is plotting the parabolics
PlotFermis (b, Fn, Fp, Ef_); %This is plotting the fermis
PlotIntegrands(Eg, b, dp, dn, Ef_);%This is plotting the integrands
PlotIntegrals(Ef_, p, n, 0.05); %This is plotting the integrals
pause
end
end
%================================================
The algorithm presented below is used to generate the Current
function [Q_values] = Calculate_Q(u)
clc
time = cputime;
%rescale volumes for numerical stability
u.Nscale = u.N1^2;
Nscale = u.Nscale;
u.N1 = u.N1 / Nscale;
u.N2 = u.N2 / Nscale;
u.NA = u.NA / Nscale;
u.ND = u.ND / Nscale;
u.Z1 = u.Z1 / Nscale;
u.Z2 = u.Z2 / Nscale;
%get rid of the u.x
N1 = u.N1;
N2 = u.N2;
Z1 = u.Z1; Z2 = u.Z2;%so, now all terms in rho are scaled
NA = u.NA;
ND = u.ND;
Eg = u.Eg;
a = u.a;
Ef_ = u.Ef_;
es = u.es;
qe = u.qe;
%%
%anonynous functions for Q
P_1_ = @(E,psi) Z1.*sqrt(-(Eg+psi)-E); %This defines parabolic but includes psi
P_2_ = @(E,psi) Z2.*sqrt(E-(Eg-psi)); % + 1e14*exp(E/rat_a * a);
Fn_ = @(E) 1 ./ exp((E - Ef_)/a) ; %This is the Fermi-Dirac
Fp_ = @(E) 1 ./ exp((Ef_- E)/a) ;
dp_ = @(E,psi) P_1_(E,psi) .* Fp_(E); %The integrands
dn_ = @(E,psi) P_2_(E,psi) .* Fn_(E);
p_ = @(psi) IntegrateInf_p_( @(E) dp_(E,psi), u, psi); %These are the new integrals with psi
n_ = @(psi) IntegrateInf_n_( @(E) dn_(E,psi), u, psi);
rho = @(psi) qe * ( p_(psi) + ND - NA - n_(psi) ); %charge density, NA & ND here =
NA&ND / Nscale
%we multiply with charge of electron to convert carrier density to charge density
ElI = @(psi_0) Nscale * quadv( rho, 0, psi_0, 1e-15 ); %use quadv here as inputs cannot be
vectored in our case
%we multiply by Nscale here to bring data to their un-
scaled values
Q = @(psi_0) sqrt( abs( 2 * es * ElI(psi_0) ) ); % C/cm^2
Q_values = [];
% warning('off', 'MATLAB:quadl:MaxFcnCount') %shoot the pigs!
for i = 1 : length(u.psi_0_range) %This determines Q for every psi
psi_0 = u.psi_0_range(i);
try
Q_values(i) = Q(psi_0);
catch
Q_values(i) = NaN;
end
fprintf( ' Q(%3.5f)= %3.10f', psi_0, Q_values(end) )
end
fprintf(' Time: %2.2fsecs  ', cputime-time )
end
%================================================
The following algorithm will be used to integrate the information
function [val] = IntegrateInf_p(func, u) %For Holes
Eg = u.Eg; %This defines Eg
Nsc = u.Nscale;
b = 66; %bound for approximation of integral: intuitive!!!
type = 'smart';
switch lower(type)
case 'fixed'
b1 = -b;
b2 = +b;
case 'smart' %find integral significance interval
E_range = linspace(-b, -Eg, 10000)';%This defines the range of E
y = func(E_range); This calculates the max value
[mx, idx] = max(y);
tol = mx / Nsc; %Nsc>>1
left = find( abs(y(1:idx-1)) < tol );
left = max(left);
if false
figure
plot(E_range, y, '-'), hold on
plot( E_range(left ), y(left ), 'rs', 'markersize', 2)
pause(1), close
end
b1 = E_range(left); %This is the limites of the integral
b2 = -Eg;
end
val = quadl(func, b1, b2, 1e-33);%This calculates the integral
end
%================================================
function [val] = IntegrateInf_p_(func, u, pote)%For holes
Eg= u.Eg;
Nsc = u.Nscale;
b = 66; %bound for approximation of integral: intuitive!!!
type = 'smart';
switch lower(type)
case 'fixed'
b1 = -b;
b2 = +b;
case 'smart' %find integral significance interval
E_range = linspace(-b, -(Eg+pote), 10000)';
y = func(E_range);
[mx, idx] = max(y);
tol = mx / Nsc; %Nsc>>1
left = find( abs(y(1:idx-1)) < tol );
left = max(left);
if false
figure
plot(E_range, y, '-'), hold on
plot( E_range(left ), y(left ), 'rs', 'markersize', 2)
pause(1), close
end
b1 = E_range(left); %This limits the integral including psi
b2 = -(Eg+pote);
end
val = quadl(func, b1, b2, 1e-33);%This calculates the integral using quadl
end
%================================================
function [val] = IntegrateInf_n(func, u) %For electrons
Eg = u.Eg;
Nsc = u.Nscale;
b = 66; %bound for approximation of integral: intuitive!!!
type = 'smart';
switch lower(type)
case 'fixed'
b1 = -b;
b2 = +b;
case 'smart' %find integral significance interval
E_range = linspace(Eg, +b, 10000)';
y = func(E_range);
[mx, idx] = max(y);
tol = mx / Nsc; %Nsc>>1
right = find( abs(y(idx+1:end)) < tol );
right = idx+min(right);
if false
figure
plot(E_range, y, '-'), hold on
plot( E_range(right), y(right), 'rs', 'markersize', 2)
pause(1), close
end
b1 = Eg;
b2 = E_range(right);
end
val = quadl(func, b1, b2, 1e-33);
end
%================================================
function [val] = IntegrateInf_n_(func, u, pote)%For electrons
Eg= u.Eg;
Nsc = u.Nscale;
b = 66; %bound for approximation of integral: intuitive!!!
type = 'smart';
switch lower(type)
case 'fixed'
b1 = -b;
b2 = +b;
case 'smart' %find integral significance interval
E_range = linspace((Eg-pote), +b, 10000)';
y = func(E_range);
[mx, idx] = max(y);
tol = mx / Nsc; %Nsc>>1
right = find( abs(y(idx+1:end)) < tol );
right = idx+min(right);
if false
figure
plot(E_range, y, '-'), hold on
plot( E_range(right), y(right), 'rs', 'markersize', 2)
pause(1), close
end
b1 = Eg-pote;
b2 = E_range(right);
end
val = quadl(func, b1, b2, 1e-33);
end
%================================================
function [] = PlotIntegrals(Ef_, p, n, b) %These are the plotting commands
Ef_range = linspace( Ef_-b, Ef_+b, 30);
p_vals = [];
n_vals = [];
for Ef = Ef_range
p_vals = [ p_vals; p(Ef) ];
n_vals = [ n_vals; n(Ef) ];
end
subplot(2,2,4)
plot_prop = { 'linewidth', 1 };
plot( Ef_range, p_vals, 'k', plot_prop{:} );
hold on
plot( Ef_range, n_vals, 'r', plot_prop{:} );
plot( Ef_, p(Ef_), 'og', 'markersize', 10, plot_prop{:} )
xlabel('E_f'); ylabel('p(E_f), n(E_f)')
title( ['plot2: Ef*=', num2str(Ef_) ] )
axis tight
end
%================================================
Following algorithms are used for the plotting purpose of the results
function [] = PlotIntegrands(Eg, b, dp, dn, Ef) %These are the plotting commands
subplot(2,2,2)
E_range_pos = linspace(Eg, +b, 500)';
E_range_neg = linspace(-b, -Eg, 500)';
plot_prop = { 'linewidth', 1 };
plot( E_range_neg, dp(E_range_neg, Ef), 'k', plot_prop{:} );
hold on
plot( E_range_pos, dn(E_range_pos, Ef), 'r', plot_prop{:} );
xlabel('E'); ylabel('dn(E) & dp(E)')
title('bf dp(black), dn(red)')
axis tight
end
%================================================
function [] = PlotParabolics(Eg, b, N_1, N_2) %These are the plotting commands
subplot(2,2,1)
E_range_neg = linspace(-b, -Eg, 500)';
E_range_pos = linspace(Eg, b, 500)';
plot_prop = { 'linewidth', 1 };
plot( E_range_neg, N_1(E_range_neg), 'k', plot_prop{:} );
hold on
plot( E_range_pos, N_2(E_range_pos), 'r', plot_prop{:} );
xlabel('E'); ylabel('N(E)')
title('bf N1(black): Valence, N2(red): Conduction')
axis tight
end
%================================================
function [] = PlotFermis(b, Fn, Fp, Ef) %These are the plotting commands
hold off
subplot(2,2,3)
E_range = linspace(-b, +b, 500)';
plot_prop = { 'linewidth', 1 };
plot( E_range, Fn(E_range, Ef), 'r', plot_prop{:} );
hold on
plot( E_range, Fp(E_range, Ef), 'k', plot_prop{:} );
xlabel('E'); ylabel('Fn(E), Fp(E)')
title('bfFp(black), Fn(red)')
axis tight
end
%================================================
function [Eq] = Solve_Ef(x0, p, n)%This calculates Ef for every value
type = 'optim';
switch lower(type)
case 'manual'
b = 6;
Ef_range = -b+2.3 : 0.001 : +b-2.3;
p_vals = [];
n_vals = [];
for Ef = Ef_range
p_vals = [ p_vals; p(Ef) ];
n_vals = [ n_vals; n(Ef) ];
end
[val, idx] = min( abs(p_vals-n_vals) ); %find intersection
Eq = Ef_range(idx);
case 'optim'
options = optimset('TolFun', 1e-12,...
'TolX', 1e-7,...
'MaxIter', 500, ...
'FunValCheck', 'on',...
'Display', 'iter');
[Eq, fval, exitflag, output] = fminsearch(@error, x0, options); %Nelder-Mead
end
%---nested error function---
function y = error(x);
y = abs( p(x) - n(x) );
end
%---nested error function---
end
%================================================
function [] =xxx() %This symbolic.Ef defines our parameters to be real
clear all
clc
syms E N1 N2 Eg real
pi_ = sym(pi);
N_1 = @(E) Z1.*sqrt(-Eg-E);
N_2 = @(E) Z2.*sqrt(E-Eg);
%G1 = subs(G1,N1,1);
%int(G1, E, -inf, +inf)
syms Ef real
syms a positive
Fn = 1 / ( 1 + exp((E-Ef)/a) );
Fp = 1 / ( 1 + exp((Ef-E)/a) );
%int(Fp, E, -inf,+inf)
%p = int( G1*Fp, E, -inf, +inf );
%n = int( G2*Fn, E, -inf, +inf );
pd = subs( G1 * Fp, {N1, s1, a}, {12, 0.12, 1} );
end
%================================================
%side = +ve or - ve side
function [] = DiffQ(u, side) %Calculation of the capacitance
clc
time = cputime;
x = u.psi_0_range; %This defines the x
y = u.Q'; %This defines the y
%y(x>0) = -y(x>0); %THIS HAS TO BE HANDLED WITHIN El
%y(x<0) = -y(x<0);
if exist( 'side', 'var')
region = sign(side)*x >= 0.0;
x = x(region);
y = y(region);
end
if false
gnum = min( floor(length(x)/3), 8 );
model = [ 'gauss' num2str(gnum) ];
obj = fittype(model);
opts = fitoptions( 'method', 'nonlinear', 'display', 'iter' );
fres = fit(x, y, obj, opts );
else %splines
fres = fit(x, y, 'cubicspline');
% fres = fit(x, y, 'smoothingspline', 'SmoothingParam', 1-1e-6);
end
x2 = linspace( min(x), max(x), 200); %Fitting for 200 points
diff = differentiate(fres, x2); %This is the differentiation of Q
diff = abs(diff);%This gives the absolute values of diff
clf
subplot(3,1,1), plot(fres, 'k-', x, y, 'bo');%The plotting commands
ylabel('Q')
axis tight
%legend('data', 'fitted curve')
legend off
subplot(3,1,2), plot(x2, diff,'r-', 'linewidth', 1)
ylabel('dQ/dpsi')
axis tight
cox = 17.2659e-9 %Farads, dox=200nm, eox=3.9
%cox = 23.020868e-9 %Farads, dox=150nm, eox=3.9
cap = diff*cox ./ (diff+cox); %This calculates the capacitance
subplot(3,1,3), plot(x2, cap,'r-', 'linewidth', 1)
ylabel('cap')
axis tight
fprintf(' Time: %2.2fsecs  ', cputime-time )
end
%================================================
-Matlab code Gaussian (polymer) DOS distribution
The below mentioned algorithm is used to iterate the values and generate the data for results.
function [Ef] = Loop_Ef() %(This is the Main M-file function)
clc, clear all, close all
%For Gaussian (polymer)
u.N1 = 1e21; %This is the number of states
u.NA = 1e15; %This is the number of acceptors
u.ND = 0; %This is the number of donors
u.Z1 = 89.6167e19; %This term in front of the square root of the energy (this contains mass of
electron)
u.Z2 = 241.2757e19; %This is the mass of hole
u.Eg = 1.12./2; %This is the energy gap
u.a = 0.0259; %This is the term that represents KT
%u.rat_a = 2 %scaling factor that modifies the steepness of the oxide exponential density of
states
u.es = 3 * 8.854187817e-14;%The permittivity measured C / cm * V
u.qe = 1.602e-19; %This is the value of charge
u.psi_0_range = linspace(-0.4, 1, 160)'; %This defines the range of Psi_0
u.display = true; %psi is in eV
%%
%ratN_range = 1e-2; ratS_range = [ 0.5: 0.2: 2];
ratN_range = 1; ratS_range = 1; %This doesn’t matter for Parabolic DOS
for iN = 1 : length(ratN_range)
for iS = 1 : length(ratS_range)
u.ratN = ratN_range(iN);
u.ratS = ratS_range(iS);
u.N2 = u.ratN * u.N1;
try
%Ef_(iN,iS) = Calculate_Ef(u); %Here its calculating the f_function
Ef_(iN,iS) = -0.386001 %REMOVE-TESTING
u.Ef_ = Ef_(iN,iS); %The ef equals
u.Q = Calculate_El(u); %Here is calculating the charge
DiffQ(u);
catch
Ef_(iN,iS) = NaN; %If there is nothing then NaN
end
end
end
clf,
plot(u.psi_0_range, u.Q) %Here its plotting
u.Ef_all = Ef_;
save 'u.mat' %It saves all data in a u.file
save 'Ef_.dat' Ef_ -ascii %This exports the data of Ef AS ascii
keyboard %Here the command gives control to the user
end
%================================================
function [Ef_] = Calculate_Ef(u) %This is the same as parabolic
clc
time = cputime;
%rescale volumes for numerical stability
Nscale = u.N1 ^ 2;
u.N1 = u.N1 / Nscale;
u.N2 = u.N2 / Nscale;
%get rid of the u.''
N1 = u.N1; N2 = u.N2;
s1 = u.s1; s2 = u.s2;
Eg = u.Eg;
a = u.a;
NA = u.NA/Nscale; ND = u.ND/Nscale;
G1 = @(E) N1/(s1*sqrt(2*pi)) .* exp( -(E+Eg).^2 / (2*s1^2) ); %This is the Gausssian
(Valance band)
G2 = @(E) N2/(s2*sqrt(2*pi)) .* exp( -(E-Eg).^2 / (2*s2^2) ); %This is the Gaussian
(Conduction band)
Fn = @(E,Ef) 1 ./ ( 1 + exp((E-Ef)/a) );
Fp = @(E,Ef) 1 ./ ( 1 + exp((Ef-E)/a) );
dp = @(E,Ef) G1(E) .* Fp(E,Ef); %the integrands
dn = @(E,Ef) G2(E) .* Fn(E,Ef);
p = @(Ef) Nscale * (IntegrateInf( @(E) dp(E,Ef), Nscale ) + ND); %define our functions p & n
(Ef)
n = @(Ef) Nscale * (IntegrateInf( @(E) dn(E,Ef), Nscale ) + NA);
%%we need to make sure that multiplication/devision with Nscale is consistent all the eay
through to DiffQ
Ef_ = Solve_Ef(0, p, n); %Ef* is obtained here
fprintf('The value Ef*= %f, gives equal values for: p(Ef*)= %f & n(Ef*)= %f ', Ef_, p(Ef_),
n(Ef_) )
fprintf('Time: %2.2fsecs  ', cputime-time )
if u.display
clf
b = 3; %range of the graphs AND of Ef search
PlotGaussians (b, G1, G2);
PlotFermis (b, Fn, Fp, Ef_);
PlotIntegrands(b, dp, dn, Ef_);
PlotIntegrals(Ef_, p, n, 0.05);
pause
end
end
%================================================
The algorithm presented below is used to generate the Current
function [Q_values] = Calculate_Q(u) %This calculates the total charge
clc
time = cputime;
%rescale volumes for numerical stability
u.Nscale = u.N1^2;
Nscale = u.Nscale;
u.N1 = u.N1 / Nscale;
u.N2 = u.N2 / Nscale;
u.NA = u.NA / Nscale;
u.ND = u.ND / Nscale;
u.Z1 = u.Z1 / Nscale;
u.Z2 = u.Z2 / Nscale;
%get rid of the u.x
N1 = u.N1;
N2 = u.N2;
Z1 = u.Z1; Z2 = u.Z2;%so, now all terms in rho are scaled
NA = u.NA;
ND = u.ND;
Eg = u.Eg;
a = u.a;
Ef_ = u.Ef_;
es = u.es;
qe = u.qe;
%%
%anonynous functions for Q
N_1_ = @(E,psi) Z1.*sqrt(-(Eg+psi)-E);
N_2_ = @(E,psi) Z2.*sqrt(E-(Eg-psi)); % + 1e14*exp(E/rat_a * a);
Fn_ = @(E) 1 ./ ( 1 + exp((E - Ef_)/a) );
Fp_ = @(E) 1 ./ ( 1 + exp((Ef_- E)/a) );
dp_ = @(E,psi) N_1_(E,psi) .* Fp_(E);
dn_ = @(E,psi) N_2_(E,psi) .* Fn_(E);
p_ = @(psi) IntegrateInf_p_( @(E) dp_(E,psi), u, psi);
n_ = @(psi) IntegrateInf_n_( @(E) dn_(E,psi), u, psi);
rho = @(psi) qe * ( p_(psi) + ND - NA - n_(psi) ); %NA & ND here = NA&ND / Nscale
%we multiply with charge of electron to convert carrier density to charge density
ElI = @(psi_0) Nscale * quadv( rho, 0, psi_0, 1e-15 ); %use quadv here as inputs cannot be
vectored in our case
%we multiply by Nscale here to bring data to their un-
scaled values
Q = @(psi_0) sqrt( abs( 2 * es * ElI(psi_0) ) ); % C/cm^2
Q_values = [];
% warning('off', 'MATLAB:quadl:MaxFcnCount') %shoot the pigs!
for i = 1 : length(u.psi_0_range)
psi_0 = u.psi_0_range(i);
try
Q_values(i) = Q(psi_0);
catch
Q_values(i) = NaN;
end
fprintf( ' Q(%3.5f)= %3.10f', psi_0, Q_values(end) )
end
fprintf(' Time: %2.2fsecs  ', cputime-time )
end
%================================================
The following algorithm will be used to integrate the information
function [val] = IntegrateInf_n(func, u) %Again same as parabolic but it’s not necessary to
change the limits of our integration
Eg = u.Eg;
Nsc = u.Nscale;
b = 66; %bound for approximation of integral: intuitive!!!
type = 'smart';
switch lower(type)
case 'fixed'
b1 = -b;
b2 = +b;
case 'smart' %find integral significance interval
E_range = linspace(Eg, +b, 10000)';
y = func(E_range);
[mx, idx] = max(y);
tol = mx / Nsc; %Nsc>>1
right = find( abs(y(idx+1:end)) < tol );
right = idx+min(right);
if false
figure
plot(E_range, y, '-'), hold on
plot( E_range(right), y(right), 'rs', 'markersize', 2)
pause(1), close
end
b1 = Eg;
b2 = E_range(right);
end
val = quadl(func, b1, b2, 1e-33);
end
%================================================
function [] =xxx() %This is symbolic Ef (Its exactly the same as Parabolic but here is for
Gaussian)
clear all
clc
syms E N1 N2 Eg real
syms s1 s2 positive
pi_ = sym(pi);
G1 = N1/(s1*sqrt(2*pi_)) * exp( -E^2 / (2*s1^2) );
G2 = N2/(s2*sqrt(2*pi_)) * exp( -(E-Eg)^2 / (2*s2^2) );
%G1 = subs(G1,N1,1);
%int(G1, E, -inf, +inf)
syms Ef real
syms a positive
Fn = 1 / ( 1 + exp((E-Ef)/a) );
Fp = 1 / ( 1 + exp((Ef-E)/a) );
%int(Fp, E, -inf,+inf)
%p = int( G1*Fp, E, -inf, +inf );
%n = int( G2*Fn, E, -inf, +inf );
pd = subs( G1 * Fp, {N1, s1, a}, {12, 0.12, 1} );
end
%================================================
function [Eq] = Solve_Ef(x0, p, n) %The same as parabolic but here is for Gaussian
type = 'optim';
switch lower(type)
case 'manual'
b = 6;
Ef_range = -b+2.3 : 0.001 : +b-2.3;
p_vals = [];
n_vals = [];
for Ef = Ef_range
p_vals = [ p_vals; p(Ef) ];
n_vals = [ n_vals; n(Ef) ];
end
[val, idx] = min( abs(p_vals-n_vals) ); %find intersection
Eq = Ef_range(idx);
case 'optim'
options = optimset('TolFun', 1e-12,...
'TolX', 1e-7,...
'MaxIter', 500, ...
'FunValCheck', 'on',...
'Display', 'iter');
[Eq, fval, exitflag, output] = fminsearch(@error, x0, options); %Nelder-Mead
end
%---nested error function---
function y = error(x);
y = abs( p(x) - n(x) );
end
%---nested error function---
end
%================================================
function [] = PlotGaussians(b, G1, G2) %Here is plotting the Gaussian
subplot(2,2,1)
E_range = linspace(-b, +b, 500)';
plot_prop = { 'linewidth', 1 };
plot( E_range, G1(E_range), 'k', plot_prop{:} );
hold on
plot( E_range, G2(E_range), 'r', plot_prop{:} );
xlabel('E'); ylabel('G1(E), G2(E)')
title('bfG1(black): HOMO, G2(red): LUMO')
axis tight
end
%================================================
Following algorithms are used for the plotting purpose of the results
function [] = PlotIntegrals(Ef_, p, n, b)%Here is plotting the Integrals
Ef_range = linspace( Ef_-b, Ef_+b, 30);
p_vals = [];
n_vals = [];
for Ef = Ef_range
p_vals = [ p_vals; p(Ef) ];
n_vals = [ n_vals; n(Ef) ];
end
subplot(2,2,4)
plot_prop = { 'linewidth', 1 };
plot( Ef_range, p_vals, 'k', plot_prop{:} );
hold on
plot( Ef_range, n_vals, 'r', plot_prop{:} );
plot( Ef_, p(Ef_), 'og', 'markersize', 10, plot_prop{:} )
xlabel('E_f'); ylabel('p(E_f), n(E_f)')
title( ['plot2: Ef*=', num2str(Ef_) ] )
axis tight
end
%================================================
function [] = PlotIntegrands(b, dp, dn, Ef) )%Here is plotting the Integrands
subplot(2,2,2)
E_range = linspace(-b, +b, 500)';
plot_prop = { 'linewidth', 1 };
[ax,h1,h2] = plotyy( E_range, dp(E_range, Ef), E_range, dn(E_range, Ef) );
set( get(ax(1),'Ylabel'), 'String', 'dp')
set(get(ax(2),'Ylabel'),'String','dn')
set( h1, 'Color','k' )
set( h2, 'Color','r')
%plot( E_range, dp(E_range, Ef), 'k', plot_prop{:} ); hold on
%plot( E_range, dn(E_range, Ef), 'r', plot_prop{:} );
%ylabel('dp(E) & dn(E)')
xlabel('E');
title('bfdp=G_1*F_p(black) and dn=G_2*F_n(red)')
axis tight
end
%================================================
function [] = PlotFermis(b, Fn, Fp, Ef) %Here is plotting the Fermis
hold off
subplot(2,2,3)
E_range = linspace(-b, +b, 500)';
plot_prop = { 'linewidth', 1 };
plot( E_range, Fn(E_range, Ef), 'r', plot_prop{:} );
hold on
plot( E_range, Fp(E_range, Ef), 'k', plot_prop{:} );
xlabel('E'); ylabel('Fn(E), Fp(E)')
title('bfFp(black), Fn(red)')
axis tight
end
%================================================
%side = +ve or - ve side
function [] = DiffQ(u, side)
clc
time = cputime;
x = u.psi_0_range; %This defines x
y = u.Q'; %This defines y
%y(x>0) = -y(x>0); %THIS HAS TO BE HANDLED WITHIN El
%y(x<0) = -y(x<0);
if exist( 'side', 'var')
region = sign(side)*x >= 0.0;
x = x(region);
y = y(region);
end
if false
gnum = min( floor(length(x)/3), 8 );
model = [ 'gauss' num2str(gnum) ];
obj = fittype(model);
opts = fitoptions( 'method', 'nonlinear', 'display', 'iter' );
fres = fit(x, y, obj, opts );
else %splines
%fres = fit(x, y, 'cubicspline');
fres = fit(x, y, 'smoothingspline', 'SmoothingParam', 1-1e-6);
end
x2 = linspace( min(x), max(x), 200); %Here is fitting with 200 points
diff = differentiate(fres, x2); %This is the differentiation of Q
diff = abs(diff); %This gives the absolute value of diff
clf
subplot(3,1,1), plot(fres, 'k-', x, y, 'bo'); %Here is the plotting commands
ylabel('Q')
axis tight
%legend('data', 'fitted curve')
legend off
subplot(3,1,2), plot(x2, diff,'r-', 'linewidth', 1)
ylabel('dQ/dpsi')
axis tight
%cox = 17.2659e-9 %Farads, dox=200nm, eox=3.9
cox = 23.020868e-9 %Farads, dox=150nm, eox=3.9
cap = diff*cox ./ (diff+cox); %Here is calculating the capacitance
subplot(3,1,3), plot(x2, cap,'r-', 'linewidth', 1)
ylabel('cap')
axis tight
fprintf(' Time: %2.2fsecs  ', cputime-time )
end
%================================================

More Related Content

Similar to 3 (a) calculate thy potential at point P located a distance z above .pdf

Fourier series example
Fourier series exampleFourier series example
Fourier series example
Abi finni
 
MATLAB Final Project
MATLAB Final ProjectMATLAB Final Project
MATLAB Final Project
Alexis Ploss
 
Incorporate the SOR method in the multigridTest-m and apply the multig.pdf
Incorporate the SOR method in the multigridTest-m and apply the multig.pdfIncorporate the SOR method in the multigridTest-m and apply the multig.pdf
Incorporate the SOR method in the multigridTest-m and apply the multig.pdf
aartechindia
 
Natural and Clamped Cubic Splines
Natural and Clamped Cubic SplinesNatural and Clamped Cubic Splines
Natural and Clamped Cubic Splines
Mark Brandao
 
error 2.pdf101316, 6(46 PM01_errorPage 1 of 5http.docx
error 2.pdf101316, 6(46 PM01_errorPage 1 of 5http.docxerror 2.pdf101316, 6(46 PM01_errorPage 1 of 5http.docx
error 2.pdf101316, 6(46 PM01_errorPage 1 of 5http.docx
SALU18
 

Similar to 3 (a) calculate thy potential at point P located a distance z above .pdf (20)

Fourier series example
Fourier series exampleFourier series example
Fourier series example
 
MATLAB Final Project
MATLAB Final ProjectMATLAB Final Project
MATLAB Final Project
 
There's more than one way to empty it
There's more than one way to empty itThere's more than one way to empty it
There's more than one way to empty it
 
3.pdf
3.pdf3.pdf
3.pdf
 
Incorporate the SOR method in the multigridTest-m and apply the multig.pdf
Incorporate the SOR method in the multigridTest-m and apply the multig.pdfIncorporate the SOR method in the multigridTest-m and apply the multig.pdf
Incorporate the SOR method in the multigridTest-m and apply the multig.pdf
 
Control System Assignment Help
Control System Assignment HelpControl System Assignment Help
Control System Assignment Help
 
Programming Assignment Help
Programming Assignment HelpProgramming Assignment Help
Programming Assignment Help
 
Numerical Analysis Assignment Help
Numerical Analysis Assignment HelpNumerical Analysis Assignment Help
Numerical Analysis Assignment Help
 
5th Sem SS lab progs
5th Sem SS lab progs5th Sem SS lab progs
5th Sem SS lab progs
 
DSP LAB COMPLETE CODES.docx
DSP LAB COMPLETE CODES.docxDSP LAB COMPLETE CODES.docx
DSP LAB COMPLETE CODES.docx
 
Informe laboratorio n°1
Informe laboratorio n°1Informe laboratorio n°1
Informe laboratorio n°1
 
Electrical Engineering Assignment Help
Electrical Engineering Assignment HelpElectrical Engineering Assignment Help
Electrical Engineering Assignment Help
 
Scientific Computing II Numerical Tools & Algorithms - CEI40 - AGA
Scientific Computing II Numerical Tools & Algorithms - CEI40 - AGAScientific Computing II Numerical Tools & Algorithms - CEI40 - AGA
Scientific Computing II Numerical Tools & Algorithms - CEI40 - AGA
 
DSP Lab Manual (10ECL57) - VTU Syllabus (KSSEM)
DSP Lab Manual (10ECL57) - VTU Syllabus (KSSEM)DSP Lab Manual (10ECL57) - VTU Syllabus (KSSEM)
DSP Lab Manual (10ECL57) - VTU Syllabus (KSSEM)
 
Digital Signal Processing
Digital Signal ProcessingDigital Signal Processing
Digital Signal Processing
 
Numerical Analysis Assignment Help
Numerical Analysis Assignment HelpNumerical Analysis Assignment Help
Numerical Analysis Assignment Help
 
C language program
C language programC language program
C language program
 
Natural and Clamped Cubic Splines
Natural and Clamped Cubic SplinesNatural and Clamped Cubic Splines
Natural and Clamped Cubic Splines
 
Numerical methods generating polynomial
Numerical methods generating polynomialNumerical methods generating polynomial
Numerical methods generating polynomial
 
error 2.pdf101316, 6(46 PM01_errorPage 1 of 5http.docx
error 2.pdf101316, 6(46 PM01_errorPage 1 of 5http.docxerror 2.pdf101316, 6(46 PM01_errorPage 1 of 5http.docx
error 2.pdf101316, 6(46 PM01_errorPage 1 of 5http.docx
 

More from Info489948

4) A wastewater treatment operator has been fined because the.pdf
 4) A wastewater treatment operator has been fined because the.pdf 4) A wastewater treatment operator has been fined because the.pdf
4) A wastewater treatment operator has been fined because the.pdf
Info489948
 
3. Transportation technology (15 points) a. Explain both generally an.pdf
 3. Transportation technology (15 points) a. Explain both generally an.pdf 3. Transportation technology (15 points) a. Explain both generally an.pdf
3. Transportation technology (15 points) a. Explain both generally an.pdf
Info489948
 

More from Info489948 (19)

4) Converting data into indices is... a) used only by governments.pdf
 4) Converting data into indices is... a) used only by governments.pdf 4) Converting data into indices is... a) used only by governments.pdf
4) Converting data into indices is... a) used only by governments.pdf
 
4) A wastewater treatment operator has been fined because the.pdf
 4) A wastewater treatment operator has been fined because the.pdf 4) A wastewater treatment operator has been fined because the.pdf
4) A wastewater treatment operator has been fined because the.pdf
 
4.634.154.764.704.654.524.705.064.424.514.2.pdf
 4.634.154.764.704.654.524.705.064.424.514.2.pdf 4.634.154.764.704.654.524.705.064.424.514.2.pdf
4.634.154.764.704.654.524.705.064.424.514.2.pdf
 
4. Let TL, t 2 be a colloclion of arbitrary vcclors in R. Is span(T.pdf
 4. Let TL, t 2 be a colloclion of arbitrary vcclors in R. Is span(T.pdf 4. Let TL, t 2 be a colloclion of arbitrary vcclors in R. Is span(T.pdf
4. Let TL, t 2 be a colloclion of arbitrary vcclors in R. Is span(T.pdf
 
4. Image and Kernel of homomorphism. Let f R S be a ring homomo.pdf
 4. Image and Kernel of homomorphism.  Let f R   S be a ring homomo.pdf 4. Image and Kernel of homomorphism.  Let f R   S be a ring homomo.pdf
4. Image and Kernel of homomorphism. Let f R S be a ring homomo.pdf
 
4. Find all values of z that satisfy the equation sin z = -5. Express.pdf
 4. Find all values of z that satisfy the equation sin z = -5. Express.pdf 4. Find all values of z that satisfy the equation sin z = -5. Express.pdf
4. Find all values of z that satisfy the equation sin z = -5. Express.pdf
 
4. A steel channel made of 1040 HR is welded to a thick steel wall wi.pdf
 4. A steel channel made of 1040 HR is welded to a thick steel wall wi.pdf 4. A steel channel made of 1040 HR is welded to a thick steel wall wi.pdf
4. A steel channel made of 1040 HR is welded to a thick steel wall wi.pdf
 
4. A f-unction f D right arrow R is a Lipschitz function if there is.pdf
 4. A f-unction f D right arrow R is a Lipschitz function if there is.pdf 4. A f-unction f D right arrow R is a Lipschitz function if there is.pdf
4. A f-unction f D right arrow R is a Lipschitz function if there is.pdf
 
3. Use the compound interest formulas A F 1+ and A Pe to find the acc.pdf
 3. Use the compound interest formulas A F 1+ and A Pe to find the acc.pdf 3. Use the compound interest formulas A F 1+ and A Pe to find the acc.pdf
3. Use the compound interest formulas A F 1+ and A Pe to find the acc.pdf
 
3. Transportation technology (15 points) a. Explain both generally an.pdf
 3. Transportation technology (15 points) a. Explain both generally an.pdf 3. Transportation technology (15 points) a. Explain both generally an.pdf
3. Transportation technology (15 points) a. Explain both generally an.pdf
 
3. Use the compound interest formulas A=P(1+rn)^m and A= Pe^rt to fi.pdf
 3. Use the compound interest formulas A=P(1+rn)^m and A= Pe^rt to fi.pdf 3. Use the compound interest formulas A=P(1+rn)^m and A= Pe^rt to fi.pdf
3. Use the compound interest formulas A=P(1+rn)^m and A= Pe^rt to fi.pdf
 
3. The number N of bacteria present in a culture at time t, in ho.pdf
 3. The number N of bacteria present in a culture at time t, in ho.pdf 3. The number N of bacteria present in a culture at time t, in ho.pdf
3. The number N of bacteria present in a culture at time t, in ho.pdf
 
3. Suppose for f(z) holomorphic C there are constants a, b, e 0 Pr.pdf
 3. Suppose for f(z) holomorphic C there are constants a, b, e  0 Pr.pdf 3. Suppose for f(z) holomorphic C there are constants a, b, e  0 Pr.pdf
3. Suppose for f(z) holomorphic C there are constants a, b, e 0 Pr.pdf
 
3. Joe is considering pursuing an MBA degree. He has applied to t.pdf
 3. Joe is considering pursuing an MBA degree. He has applied to t.pdf 3. Joe is considering pursuing an MBA degree. He has applied to t.pdf
3. Joe is considering pursuing an MBA degree. He has applied to t.pdf
 
3. Let On be the set of odd permutations in Sn. Is On a subgroup .pdf
 3. Let On be the set of odd permutations in Sn. Is On a subgroup .pdf 3. Let On be the set of odd permutations in Sn. Is On a subgroup .pdf
3. Let On be the set of odd permutations in Sn. Is On a subgroup .pdf
 
3. (4 points) Consider the function (in the domain {z i Solut.pdf
 3. (4 points) Consider the function (in the domain {z  i Solut.pdf 3. (4 points) Consider the function (in the domain {z  i Solut.pdf
3. (4 points) Consider the function (in the domain {z i Solut.pdf
 
3. Find currents (values and directions) in all resistors of the circ.pdf
 3. Find currents (values and directions) in all resistors of the circ.pdf 3. Find currents (values and directions) in all resistors of the circ.pdf
3. Find currents (values and directions) in all resistors of the circ.pdf
 
3. Assume that the DS register contains 0100 and register SI contains.pdf
 3. Assume that the DS register contains 0100 and register SI contains.pdf 3. Assume that the DS register contains 0100 and register SI contains.pdf
3. Assume that the DS register contains 0100 and register SI contains.pdf
 
2a Briefly describe the 1st law of thermodynamics. You can use either.pdf
 2a Briefly describe the 1st law of thermodynamics. You can use either.pdf 2a Briefly describe the 1st law of thermodynamics. You can use either.pdf
2a Briefly describe the 1st law of thermodynamics. You can use either.pdf
 

Recently uploaded

Accounting and finance exit exam 2016 E.C.pdf
Accounting and finance exit exam 2016 E.C.pdfAccounting and finance exit exam 2016 E.C.pdf
Accounting and finance exit exam 2016 E.C.pdf
YibeltalNibretu
 

Recently uploaded (20)

Jose-Rizal-and-Philippine-Nationalism-National-Symbol-2.pptx
Jose-Rizal-and-Philippine-Nationalism-National-Symbol-2.pptxJose-Rizal-and-Philippine-Nationalism-National-Symbol-2.pptx
Jose-Rizal-and-Philippine-Nationalism-National-Symbol-2.pptx
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
 
Solid waste management & Types of Basic civil Engineering notes by DJ Sir.pptx
Solid waste management & Types of Basic civil Engineering notes by DJ Sir.pptxSolid waste management & Types of Basic civil Engineering notes by DJ Sir.pptx
Solid waste management & Types of Basic civil Engineering notes by DJ Sir.pptx
 
The Benefits and Challenges of Open Educational Resources
The Benefits and Challenges of Open Educational ResourcesThe Benefits and Challenges of Open Educational Resources
The Benefits and Challenges of Open Educational Resources
 
How to Break the cycle of negative Thoughts
How to Break the cycle of negative ThoughtsHow to Break the cycle of negative Thoughts
How to Break the cycle of negative Thoughts
 
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
 
UNIT – IV_PCI Complaints: Complaints and evaluation of complaints, Handling o...
UNIT – IV_PCI Complaints: Complaints and evaluation of complaints, Handling o...UNIT – IV_PCI Complaints: Complaints and evaluation of complaints, Handling o...
UNIT – IV_PCI Complaints: Complaints and evaluation of complaints, Handling o...
 
Forest and Wildlife Resources Class 10 Free Study Material PDF
Forest and Wildlife Resources Class 10 Free Study Material PDFForest and Wildlife Resources Class 10 Free Study Material PDF
Forest and Wildlife Resources Class 10 Free Study Material PDF
 
Instructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptxInstructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptx
 
Application of Matrices in real life. Presentation on application of matrices
Application of Matrices in real life. Presentation on application of matricesApplication of Matrices in real life. Presentation on application of matrices
Application of Matrices in real life. Presentation on application of matrices
 
Matatag-Curriculum and the 21st Century Skills Presentation.pptx
Matatag-Curriculum and the 21st Century Skills Presentation.pptxMatatag-Curriculum and the 21st Century Skills Presentation.pptx
Matatag-Curriculum and the 21st Century Skills Presentation.pptx
 
Basic Civil Engg Notes_Chapter-6_Environment Pollution & Engineering
Basic Civil Engg Notes_Chapter-6_Environment Pollution & EngineeringBasic Civil Engg Notes_Chapter-6_Environment Pollution & Engineering
Basic Civil Engg Notes_Chapter-6_Environment Pollution & Engineering
 
NCERT Solutions Power Sharing Class 10 Notes pdf
NCERT Solutions Power Sharing Class 10 Notes pdfNCERT Solutions Power Sharing Class 10 Notes pdf
NCERT Solutions Power Sharing Class 10 Notes pdf
 
NLC-2024-Orientation-for-RO-SDO (1).pptx
NLC-2024-Orientation-for-RO-SDO (1).pptxNLC-2024-Orientation-for-RO-SDO (1).pptx
NLC-2024-Orientation-for-RO-SDO (1).pptx
 
slides CapTechTalks Webinar May 2024 Alexander Perry.pptx
slides CapTechTalks Webinar May 2024 Alexander Perry.pptxslides CapTechTalks Webinar May 2024 Alexander Perry.pptx
slides CapTechTalks Webinar May 2024 Alexander Perry.pptx
 
B.ed spl. HI pdusu exam paper-2023-24.pdf
B.ed spl. HI pdusu exam paper-2023-24.pdfB.ed spl. HI pdusu exam paper-2023-24.pdf
B.ed spl. HI pdusu exam paper-2023-24.pdf
 
Advances in production technology of Grapes.pdf
Advances in production technology of Grapes.pdfAdvances in production technology of Grapes.pdf
Advances in production technology of Grapes.pdf
 
Basic Civil Engineering Notes of Chapter-6, Topic- Ecosystem, Biodiversity G...
Basic Civil Engineering Notes of Chapter-6,  Topic- Ecosystem, Biodiversity G...Basic Civil Engineering Notes of Chapter-6,  Topic- Ecosystem, Biodiversity G...
Basic Civil Engineering Notes of Chapter-6, Topic- Ecosystem, Biodiversity G...
 
Accounting and finance exit exam 2016 E.C.pdf
Accounting and finance exit exam 2016 E.C.pdfAccounting and finance exit exam 2016 E.C.pdf
Accounting and finance exit exam 2016 E.C.pdf
 
PART A. Introduction to Costumer Service
PART A. Introduction to Costumer ServicePART A. Introduction to Costumer Service
PART A. Introduction to Costumer Service
 

3 (a) calculate thy potential at point P located a distance z above .pdf

  • 1. 3 (a) calculate thy potential at point P located a distance z above the center of a charged disk of radius a and surface charge density p, Coulombs per square meter. Please show all work An integral that you may need is The elemental area in cylindrical coordinates is dA = (b) Calculate the electric field at P. Use back of page if necessary Solution function [Ef] = Loop_Ef() %(Main M-File function) clc, clear all, close all u.N1 = 1e21; %This is the number of states u.NA = 1e15; %This is the number of acceptors u.ND = 0; %This is the number of donors u.Z1 = 281.73e19; %This term in front of the square root of the energy (this contains mass of electron) u.Z2 = 757.989e19; %This is the mass of hole u.Eg = 1.12/2; %This is the energy gap u.a = 0.0259; %u.rat_a = 2 %scaling factor that modifies the steepness of the oxide exponential density of states u.es = 11.9 * 8.854187817e-14; %permittivity measured C / cm * V u.qe = 1.602e-19; %This is the value of charge u.psi_0_range = linspace(-0.4, 1, 160)'; %This defines the range of Psi_0 u.display = true; %psi is in Volts Not ev? %% %ratN_range = 1e-2; ratS_range = [ 0.5: 0.2: 2]; ratN_range = 1; ratS_range = 1; %This doesn’t matter for Parabolic DOS for iN = 1 : length(ratN_range) for iS = 1 : length(ratS_range) u.ratN = ratN_range(iN); u.ratS = ratS_range(iS); u.N2 = u.ratN * u.N1; try % Ef_(iN,iS) = Calculate_Ef(u); %Here its calculating the f_function
  • 2. Ef_(iN,iS) = -0.356324 %REMOVE-TESTING u.Ef_ = Ef_(iN,iS); %Here Ef equals u.Q = Calculate_El(u);%Here is calculating the charge DiffQ(u); catch Ef_(iN,iS) = NaN; %If there is nothing then NaN end end end clf, plot(u.psi_0_range, u.Q) %Its plotting the graph u.Ef_all = Ef_; save 'u.mat' %It saves all the data in u.file save 'Ef_.dat' Ef_ -ascii %Exports the data of Ef as ascii keyboard %This command gives the control to the user end %================================================ function [Ef_] = Calculate_Ef(u) clc time = cputime; %rescale volumes for numerical stability u.Nscale = u.N1 ^ 2; Nscale = u.Nscale; u.N1 = u.N1 / Nscale; u.N2 = u.N2 / Nscale; u.Z1 = u.Z1 / Nscale; u.Z2 = u.Z2 / Nscale; %get rid of the u.'' N1 = u.N1; N2 = u.N2; Z1 = u.Z1; Z2 = u.Z2; Eg = u.Eg; a = u.a;
  • 3. NA = u.NA/Nscale; ND = u.ND/Nscale; P_1 = @(E) Z1.*sqrt(-Eg-E); %This is the parabolic function(Valance band) P_2 = @(E) Z2.*sqrt(E-Eg); %This is the parabolic function (Conduction band) Fn = @(E,Ef) 1 ./ ( exp((E-Ef)/a) ); %This is the Fermi-dirac for electrons Fp = @(E,Ef) 1 ./ ( exp((Ef-E)/a) ); %This is the Fermi-dirac for holes dp = @(E,Ef) P_1(E) .* Fp(E,Ef); %the integrands dn = @(E,Ef) P_2(E) .* Fn(E,Ef); p = @(Ef) Nscale * (IntegrateInf_p( @(E) dp(E,Ef), u ) + ND); %define our functions p & n (Ef) n = @(Ef) Nscale * (IntegrateInf_n( @(E) dn(E,Ef), u ) + NA); %%we need to make sure that multiplication/division with Nscale is consistent all the way through to DiffQ Ef_ = Solve_Ef(-0.5, p, n); %Ef* is obtained here fprintf('The value Ef*= %f, gives equal values for: p(Ef*)= %f & n(Ef*)= %f ', Ef_, p(Ef_), n(Ef_) ) fprintf('Time: %2.2fsecs ', cputime-time ) %displays the time if u.display clf b = 1; %range of the graphs AND of Ef search PlotParabolics (Eg, b, P_1, P_2); %This is plotting the parabolics PlotFermis (b, Fn, Fp, Ef_); %This is plotting the fermis PlotIntegrands(Eg, b, dp, dn, Ef_);%This is plotting the integrands PlotIntegrals(Ef_, p, n, 0.05); %This is plotting the integrals pause end end %================================================ The algorithm presented below is used to generate the Current function [Q_values] = Calculate_Q(u) clc time = cputime;
  • 4. %rescale volumes for numerical stability u.Nscale = u.N1^2; Nscale = u.Nscale; u.N1 = u.N1 / Nscale; u.N2 = u.N2 / Nscale; u.NA = u.NA / Nscale; u.ND = u.ND / Nscale; u.Z1 = u.Z1 / Nscale; u.Z2 = u.Z2 / Nscale; %get rid of the u.x N1 = u.N1; N2 = u.N2; Z1 = u.Z1; Z2 = u.Z2;%so, now all terms in rho are scaled NA = u.NA; ND = u.ND; Eg = u.Eg; a = u.a; Ef_ = u.Ef_; es = u.es; qe = u.qe; %% %anonynous functions for Q P_1_ = @(E,psi) Z1.*sqrt(-(Eg+psi)-E); %This defines parabolic but includes psi P_2_ = @(E,psi) Z2.*sqrt(E-(Eg-psi)); % + 1e14*exp(E/rat_a * a); Fn_ = @(E) 1 ./ exp((E - Ef_)/a) ; %This is the Fermi-Dirac Fp_ = @(E) 1 ./ exp((Ef_- E)/a) ; dp_ = @(E,psi) P_1_(E,psi) .* Fp_(E); %The integrands dn_ = @(E,psi) P_2_(E,psi) .* Fn_(E); p_ = @(psi) IntegrateInf_p_( @(E) dp_(E,psi), u, psi); %These are the new integrals with psi n_ = @(psi) IntegrateInf_n_( @(E) dn_(E,psi), u, psi);
  • 5. rho = @(psi) qe * ( p_(psi) + ND - NA - n_(psi) ); %charge density, NA & ND here = NA&ND / Nscale %we multiply with charge of electron to convert carrier density to charge density ElI = @(psi_0) Nscale * quadv( rho, 0, psi_0, 1e-15 ); %use quadv here as inputs cannot be vectored in our case %we multiply by Nscale here to bring data to their un- scaled values Q = @(psi_0) sqrt( abs( 2 * es * ElI(psi_0) ) ); % C/cm^2 Q_values = []; % warning('off', 'MATLAB:quadl:MaxFcnCount') %shoot the pigs! for i = 1 : length(u.psi_0_range) %This determines Q for every psi psi_0 = u.psi_0_range(i); try Q_values(i) = Q(psi_0); catch Q_values(i) = NaN; end fprintf( ' Q(%3.5f)= %3.10f', psi_0, Q_values(end) ) end fprintf(' Time: %2.2fsecs ', cputime-time ) end %================================================ The following algorithm will be used to integrate the information function [val] = IntegrateInf_p(func, u) %For Holes Eg = u.Eg; %This defines Eg Nsc = u.Nscale; b = 66; %bound for approximation of integral: intuitive!!! type = 'smart'; switch lower(type) case 'fixed' b1 = -b;
  • 6. b2 = +b; case 'smart' %find integral significance interval E_range = linspace(-b, -Eg, 10000)';%This defines the range of E y = func(E_range); This calculates the max value [mx, idx] = max(y); tol = mx / Nsc; %Nsc>>1 left = find( abs(y(1:idx-1)) < tol ); left = max(left); if false figure plot(E_range, y, '-'), hold on plot( E_range(left ), y(left ), 'rs', 'markersize', 2) pause(1), close end b1 = E_range(left); %This is the limites of the integral b2 = -Eg; end val = quadl(func, b1, b2, 1e-33);%This calculates the integral end %================================================ function [val] = IntegrateInf_p_(func, u, pote)%For holes Eg= u.Eg; Nsc = u.Nscale; b = 66; %bound for approximation of integral: intuitive!!! type = 'smart'; switch lower(type) case 'fixed' b1 = -b; b2 = +b; case 'smart' %find integral significance interval E_range = linspace(-b, -(Eg+pote), 10000)'; y = func(E_range); [mx, idx] = max(y); tol = mx / Nsc; %Nsc>>1
  • 7. left = find( abs(y(1:idx-1)) < tol ); left = max(left); if false figure plot(E_range, y, '-'), hold on plot( E_range(left ), y(left ), 'rs', 'markersize', 2) pause(1), close end b1 = E_range(left); %This limits the integral including psi b2 = -(Eg+pote); end val = quadl(func, b1, b2, 1e-33);%This calculates the integral using quadl end %================================================ function [val] = IntegrateInf_n(func, u) %For electrons Eg = u.Eg; Nsc = u.Nscale; b = 66; %bound for approximation of integral: intuitive!!! type = 'smart'; switch lower(type) case 'fixed' b1 = -b; b2 = +b; case 'smart' %find integral significance interval E_range = linspace(Eg, +b, 10000)'; y = func(E_range); [mx, idx] = max(y); tol = mx / Nsc; %Nsc>>1 right = find( abs(y(idx+1:end)) < tol ); right = idx+min(right); if false figure plot(E_range, y, '-'), hold on plot( E_range(right), y(right), 'rs', 'markersize', 2)
  • 8. pause(1), close end b1 = Eg; b2 = E_range(right); end val = quadl(func, b1, b2, 1e-33); end %================================================ function [val] = IntegrateInf_n_(func, u, pote)%For electrons Eg= u.Eg; Nsc = u.Nscale; b = 66; %bound for approximation of integral: intuitive!!! type = 'smart'; switch lower(type) case 'fixed' b1 = -b; b2 = +b; case 'smart' %find integral significance interval E_range = linspace((Eg-pote), +b, 10000)'; y = func(E_range); [mx, idx] = max(y); tol = mx / Nsc; %Nsc>>1 right = find( abs(y(idx+1:end)) < tol ); right = idx+min(right); if false figure plot(E_range, y, '-'), hold on plot( E_range(right), y(right), 'rs', 'markersize', 2) pause(1), close end b1 = Eg-pote; b2 = E_range(right); end
  • 9. val = quadl(func, b1, b2, 1e-33); end %================================================ function [] = PlotIntegrals(Ef_, p, n, b) %These are the plotting commands Ef_range = linspace( Ef_-b, Ef_+b, 30); p_vals = []; n_vals = []; for Ef = Ef_range p_vals = [ p_vals; p(Ef) ]; n_vals = [ n_vals; n(Ef) ]; end subplot(2,2,4) plot_prop = { 'linewidth', 1 }; plot( Ef_range, p_vals, 'k', plot_prop{:} ); hold on plot( Ef_range, n_vals, 'r', plot_prop{:} ); plot( Ef_, p(Ef_), 'og', 'markersize', 10, plot_prop{:} ) xlabel('E_f'); ylabel('p(E_f), n(E_f)') title( ['plot2: Ef*=', num2str(Ef_) ] ) axis tight end %================================================ Following algorithms are used for the plotting purpose of the results function [] = PlotIntegrands(Eg, b, dp, dn, Ef) %These are the plotting commands subplot(2,2,2) E_range_pos = linspace(Eg, +b, 500)'; E_range_neg = linspace(-b, -Eg, 500)'; plot_prop = { 'linewidth', 1 }; plot( E_range_neg, dp(E_range_neg, Ef), 'k', plot_prop{:} ); hold on plot( E_range_pos, dn(E_range_pos, Ef), 'r', plot_prop{:} ); xlabel('E'); ylabel('dn(E) & dp(E)') title('bf dp(black), dn(red)')
  • 10. axis tight end %================================================ function [] = PlotParabolics(Eg, b, N_1, N_2) %These are the plotting commands subplot(2,2,1) E_range_neg = linspace(-b, -Eg, 500)'; E_range_pos = linspace(Eg, b, 500)'; plot_prop = { 'linewidth', 1 }; plot( E_range_neg, N_1(E_range_neg), 'k', plot_prop{:} ); hold on plot( E_range_pos, N_2(E_range_pos), 'r', plot_prop{:} ); xlabel('E'); ylabel('N(E)') title('bf N1(black): Valence, N2(red): Conduction') axis tight end %================================================ function [] = PlotFermis(b, Fn, Fp, Ef) %These are the plotting commands hold off subplot(2,2,3) E_range = linspace(-b, +b, 500)'; plot_prop = { 'linewidth', 1 }; plot( E_range, Fn(E_range, Ef), 'r', plot_prop{:} ); hold on plot( E_range, Fp(E_range, Ef), 'k', plot_prop{:} ); xlabel('E'); ylabel('Fn(E), Fp(E)') title('bfFp(black), Fn(red)') axis tight end %================================================ function [Eq] = Solve_Ef(x0, p, n)%This calculates Ef for every value type = 'optim'; switch lower(type) case 'manual'
  • 11. b = 6; Ef_range = -b+2.3 : 0.001 : +b-2.3; p_vals = []; n_vals = []; for Ef = Ef_range p_vals = [ p_vals; p(Ef) ]; n_vals = [ n_vals; n(Ef) ]; end [val, idx] = min( abs(p_vals-n_vals) ); %find intersection Eq = Ef_range(idx); case 'optim' options = optimset('TolFun', 1e-12,... 'TolX', 1e-7,... 'MaxIter', 500, ... 'FunValCheck', 'on',... 'Display', 'iter'); [Eq, fval, exitflag, output] = fminsearch(@error, x0, options); %Nelder-Mead end %---nested error function--- function y = error(x); y = abs( p(x) - n(x) ); end %---nested error function--- end %================================================ function [] =xxx() %This symbolic.Ef defines our parameters to be real clear all clc syms E N1 N2 Eg real pi_ = sym(pi); N_1 = @(E) Z1.*sqrt(-Eg-E); N_2 = @(E) Z2.*sqrt(E-Eg);
  • 12. %G1 = subs(G1,N1,1); %int(G1, E, -inf, +inf) syms Ef real syms a positive Fn = 1 / ( 1 + exp((E-Ef)/a) ); Fp = 1 / ( 1 + exp((Ef-E)/a) ); %int(Fp, E, -inf,+inf) %p = int( G1*Fp, E, -inf, +inf ); %n = int( G2*Fn, E, -inf, +inf ); pd = subs( G1 * Fp, {N1, s1, a}, {12, 0.12, 1} ); end %================================================ %side = +ve or - ve side function [] = DiffQ(u, side) %Calculation of the capacitance clc time = cputime; x = u.psi_0_range; %This defines the x y = u.Q'; %This defines the y %y(x>0) = -y(x>0); %THIS HAS TO BE HANDLED WITHIN El %y(x<0) = -y(x<0); if exist( 'side', 'var') region = sign(side)*x >= 0.0; x = x(region); y = y(region); end if false gnum = min( floor(length(x)/3), 8 ); model = [ 'gauss' num2str(gnum) ];
  • 13. obj = fittype(model); opts = fitoptions( 'method', 'nonlinear', 'display', 'iter' ); fres = fit(x, y, obj, opts ); else %splines fres = fit(x, y, 'cubicspline'); % fres = fit(x, y, 'smoothingspline', 'SmoothingParam', 1-1e-6); end x2 = linspace( min(x), max(x), 200); %Fitting for 200 points diff = differentiate(fres, x2); %This is the differentiation of Q diff = abs(diff);%This gives the absolute values of diff clf subplot(3,1,1), plot(fres, 'k-', x, y, 'bo');%The plotting commands ylabel('Q') axis tight %legend('data', 'fitted curve') legend off subplot(3,1,2), plot(x2, diff,'r-', 'linewidth', 1) ylabel('dQ/dpsi') axis tight cox = 17.2659e-9 %Farads, dox=200nm, eox=3.9 %cox = 23.020868e-9 %Farads, dox=150nm, eox=3.9 cap = diff*cox ./ (diff+cox); %This calculates the capacitance subplot(3,1,3), plot(x2, cap,'r-', 'linewidth', 1) ylabel('cap') axis tight fprintf(' Time: %2.2fsecs ', cputime-time ) end %================================================
  • 14. -Matlab code Gaussian (polymer) DOS distribution The below mentioned algorithm is used to iterate the values and generate the data for results. function [Ef] = Loop_Ef() %(This is the Main M-file function) clc, clear all, close all %For Gaussian (polymer) u.N1 = 1e21; %This is the number of states u.NA = 1e15; %This is the number of acceptors u.ND = 0; %This is the number of donors u.Z1 = 89.6167e19; %This term in front of the square root of the energy (this contains mass of electron) u.Z2 = 241.2757e19; %This is the mass of hole u.Eg = 1.12./2; %This is the energy gap u.a = 0.0259; %This is the term that represents KT %u.rat_a = 2 %scaling factor that modifies the steepness of the oxide exponential density of states u.es = 3 * 8.854187817e-14;%The permittivity measured C / cm * V u.qe = 1.602e-19; %This is the value of charge u.psi_0_range = linspace(-0.4, 1, 160)'; %This defines the range of Psi_0 u.display = true; %psi is in eV %% %ratN_range = 1e-2; ratS_range = [ 0.5: 0.2: 2]; ratN_range = 1; ratS_range = 1; %This doesn’t matter for Parabolic DOS for iN = 1 : length(ratN_range) for iS = 1 : length(ratS_range) u.ratN = ratN_range(iN); u.ratS = ratS_range(iS); u.N2 = u.ratN * u.N1; try
  • 15. %Ef_(iN,iS) = Calculate_Ef(u); %Here its calculating the f_function Ef_(iN,iS) = -0.386001 %REMOVE-TESTING u.Ef_ = Ef_(iN,iS); %The ef equals u.Q = Calculate_El(u); %Here is calculating the charge DiffQ(u); catch Ef_(iN,iS) = NaN; %If there is nothing then NaN end end end clf, plot(u.psi_0_range, u.Q) %Here its plotting u.Ef_all = Ef_; save 'u.mat' %It saves all data in a u.file save 'Ef_.dat' Ef_ -ascii %This exports the data of Ef AS ascii keyboard %Here the command gives control to the user end %================================================ function [Ef_] = Calculate_Ef(u) %This is the same as parabolic clc time = cputime; %rescale volumes for numerical stability Nscale = u.N1 ^ 2; u.N1 = u.N1 / Nscale; u.N2 = u.N2 / Nscale; %get rid of the u.'' N1 = u.N1; N2 = u.N2; s1 = u.s1; s2 = u.s2; Eg = u.Eg; a = u.a; NA = u.NA/Nscale; ND = u.ND/Nscale; G1 = @(E) N1/(s1*sqrt(2*pi)) .* exp( -(E+Eg).^2 / (2*s1^2) ); %This is the Gausssian
  • 16. (Valance band) G2 = @(E) N2/(s2*sqrt(2*pi)) .* exp( -(E-Eg).^2 / (2*s2^2) ); %This is the Gaussian (Conduction band) Fn = @(E,Ef) 1 ./ ( 1 + exp((E-Ef)/a) ); Fp = @(E,Ef) 1 ./ ( 1 + exp((Ef-E)/a) ); dp = @(E,Ef) G1(E) .* Fp(E,Ef); %the integrands dn = @(E,Ef) G2(E) .* Fn(E,Ef); p = @(Ef) Nscale * (IntegrateInf( @(E) dp(E,Ef), Nscale ) + ND); %define our functions p & n (Ef) n = @(Ef) Nscale * (IntegrateInf( @(E) dn(E,Ef), Nscale ) + NA); %%we need to make sure that multiplication/devision with Nscale is consistent all the eay through to DiffQ Ef_ = Solve_Ef(0, p, n); %Ef* is obtained here fprintf('The value Ef*= %f, gives equal values for: p(Ef*)= %f & n(Ef*)= %f ', Ef_, p(Ef_), n(Ef_) ) fprintf('Time: %2.2fsecs ', cputime-time ) if u.display clf b = 3; %range of the graphs AND of Ef search PlotGaussians (b, G1, G2); PlotFermis (b, Fn, Fp, Ef_); PlotIntegrands(b, dp, dn, Ef_); PlotIntegrals(Ef_, p, n, 0.05); pause end end %================================================ The algorithm presented below is used to generate the Current function [Q_values] = Calculate_Q(u) %This calculates the total charge clc time = cputime;
  • 17. %rescale volumes for numerical stability u.Nscale = u.N1^2; Nscale = u.Nscale; u.N1 = u.N1 / Nscale; u.N2 = u.N2 / Nscale; u.NA = u.NA / Nscale; u.ND = u.ND / Nscale; u.Z1 = u.Z1 / Nscale; u.Z2 = u.Z2 / Nscale; %get rid of the u.x N1 = u.N1; N2 = u.N2; Z1 = u.Z1; Z2 = u.Z2;%so, now all terms in rho are scaled NA = u.NA; ND = u.ND; Eg = u.Eg; a = u.a; Ef_ = u.Ef_; es = u.es; qe = u.qe; %% %anonynous functions for Q N_1_ = @(E,psi) Z1.*sqrt(-(Eg+psi)-E); N_2_ = @(E,psi) Z2.*sqrt(E-(Eg-psi)); % + 1e14*exp(E/rat_a * a); Fn_ = @(E) 1 ./ ( 1 + exp((E - Ef_)/a) ); Fp_ = @(E) 1 ./ ( 1 + exp((Ef_- E)/a) ); dp_ = @(E,psi) N_1_(E,psi) .* Fp_(E); dn_ = @(E,psi) N_2_(E,psi) .* Fn_(E); p_ = @(psi) IntegrateInf_p_( @(E) dp_(E,psi), u, psi); n_ = @(psi) IntegrateInf_n_( @(E) dn_(E,psi), u, psi);
  • 18. rho = @(psi) qe * ( p_(psi) + ND - NA - n_(psi) ); %NA & ND here = NA&ND / Nscale %we multiply with charge of electron to convert carrier density to charge density ElI = @(psi_0) Nscale * quadv( rho, 0, psi_0, 1e-15 ); %use quadv here as inputs cannot be vectored in our case %we multiply by Nscale here to bring data to their un- scaled values Q = @(psi_0) sqrt( abs( 2 * es * ElI(psi_0) ) ); % C/cm^2 Q_values = []; % warning('off', 'MATLAB:quadl:MaxFcnCount') %shoot the pigs! for i = 1 : length(u.psi_0_range) psi_0 = u.psi_0_range(i); try Q_values(i) = Q(psi_0); catch Q_values(i) = NaN; end fprintf( ' Q(%3.5f)= %3.10f', psi_0, Q_values(end) ) end fprintf(' Time: %2.2fsecs ', cputime-time ) end %================================================ The following algorithm will be used to integrate the information function [val] = IntegrateInf_n(func, u) %Again same as parabolic but it’s not necessary to change the limits of our integration Eg = u.Eg; Nsc = u.Nscale; b = 66; %bound for approximation of integral: intuitive!!! type = 'smart'; switch lower(type) case 'fixed' b1 = -b;
  • 19. b2 = +b; case 'smart' %find integral significance interval E_range = linspace(Eg, +b, 10000)'; y = func(E_range); [mx, idx] = max(y); tol = mx / Nsc; %Nsc>>1 right = find( abs(y(idx+1:end)) < tol ); right = idx+min(right); if false figure plot(E_range, y, '-'), hold on plot( E_range(right), y(right), 'rs', 'markersize', 2) pause(1), close end b1 = Eg; b2 = E_range(right); end val = quadl(func, b1, b2, 1e-33); end %================================================ function [] =xxx() %This is symbolic Ef (Its exactly the same as Parabolic but here is for Gaussian) clear all clc syms E N1 N2 Eg real syms s1 s2 positive pi_ = sym(pi); G1 = N1/(s1*sqrt(2*pi_)) * exp( -E^2 / (2*s1^2) ); G2 = N2/(s2*sqrt(2*pi_)) * exp( -(E-Eg)^2 / (2*s2^2) ); %G1 = subs(G1,N1,1); %int(G1, E, -inf, +inf) syms Ef real
  • 20. syms a positive Fn = 1 / ( 1 + exp((E-Ef)/a) ); Fp = 1 / ( 1 + exp((Ef-E)/a) ); %int(Fp, E, -inf,+inf) %p = int( G1*Fp, E, -inf, +inf ); %n = int( G2*Fn, E, -inf, +inf ); pd = subs( G1 * Fp, {N1, s1, a}, {12, 0.12, 1} ); end %================================================ function [Eq] = Solve_Ef(x0, p, n) %The same as parabolic but here is for Gaussian type = 'optim'; switch lower(type) case 'manual' b = 6; Ef_range = -b+2.3 : 0.001 : +b-2.3; p_vals = []; n_vals = []; for Ef = Ef_range p_vals = [ p_vals; p(Ef) ]; n_vals = [ n_vals; n(Ef) ]; end [val, idx] = min( abs(p_vals-n_vals) ); %find intersection Eq = Ef_range(idx); case 'optim' options = optimset('TolFun', 1e-12,... 'TolX', 1e-7,... 'MaxIter', 500, ... 'FunValCheck', 'on',... 'Display', 'iter'); [Eq, fval, exitflag, output] = fminsearch(@error, x0, options); %Nelder-Mead end
  • 21. %---nested error function--- function y = error(x); y = abs( p(x) - n(x) ); end %---nested error function--- end %================================================ function [] = PlotGaussians(b, G1, G2) %Here is plotting the Gaussian subplot(2,2,1) E_range = linspace(-b, +b, 500)'; plot_prop = { 'linewidth', 1 }; plot( E_range, G1(E_range), 'k', plot_prop{:} ); hold on plot( E_range, G2(E_range), 'r', plot_prop{:} ); xlabel('E'); ylabel('G1(E), G2(E)') title('bfG1(black): HOMO, G2(red): LUMO') axis tight end %================================================ Following algorithms are used for the plotting purpose of the results function [] = PlotIntegrals(Ef_, p, n, b)%Here is plotting the Integrals Ef_range = linspace( Ef_-b, Ef_+b, 30); p_vals = []; n_vals = []; for Ef = Ef_range p_vals = [ p_vals; p(Ef) ]; n_vals = [ n_vals; n(Ef) ]; end subplot(2,2,4) plot_prop = { 'linewidth', 1 }; plot( Ef_range, p_vals, 'k', plot_prop{:} ); hold on plot( Ef_range, n_vals, 'r', plot_prop{:} );
  • 22. plot( Ef_, p(Ef_), 'og', 'markersize', 10, plot_prop{:} ) xlabel('E_f'); ylabel('p(E_f), n(E_f)') title( ['plot2: Ef*=', num2str(Ef_) ] ) axis tight end %================================================ function [] = PlotIntegrands(b, dp, dn, Ef) )%Here is plotting the Integrands subplot(2,2,2) E_range = linspace(-b, +b, 500)'; plot_prop = { 'linewidth', 1 }; [ax,h1,h2] = plotyy( E_range, dp(E_range, Ef), E_range, dn(E_range, Ef) ); set( get(ax(1),'Ylabel'), 'String', 'dp') set(get(ax(2),'Ylabel'),'String','dn') set( h1, 'Color','k' ) set( h2, 'Color','r') %plot( E_range, dp(E_range, Ef), 'k', plot_prop{:} ); hold on %plot( E_range, dn(E_range, Ef), 'r', plot_prop{:} ); %ylabel('dp(E) & dn(E)') xlabel('E'); title('bfdp=G_1*F_p(black) and dn=G_2*F_n(red)') axis tight end %================================================ function [] = PlotFermis(b, Fn, Fp, Ef) %Here is plotting the Fermis hold off subplot(2,2,3) E_range = linspace(-b, +b, 500)'; plot_prop = { 'linewidth', 1 }; plot( E_range, Fn(E_range, Ef), 'r', plot_prop{:} ); hold on plot( E_range, Fp(E_range, Ef), 'k', plot_prop{:} ); xlabel('E'); ylabel('Fn(E), Fp(E)') title('bfFp(black), Fn(red)') axis tight
  • 23. end %================================================ %side = +ve or - ve side function [] = DiffQ(u, side) clc time = cputime; x = u.psi_0_range; %This defines x y = u.Q'; %This defines y %y(x>0) = -y(x>0); %THIS HAS TO BE HANDLED WITHIN El %y(x<0) = -y(x<0); if exist( 'side', 'var') region = sign(side)*x >= 0.0; x = x(region); y = y(region); end if false gnum = min( floor(length(x)/3), 8 ); model = [ 'gauss' num2str(gnum) ]; obj = fittype(model); opts = fitoptions( 'method', 'nonlinear', 'display', 'iter' ); fres = fit(x, y, obj, opts ); else %splines %fres = fit(x, y, 'cubicspline'); fres = fit(x, y, 'smoothingspline', 'SmoothingParam', 1-1e-6); end x2 = linspace( min(x), max(x), 200); %Here is fitting with 200 points diff = differentiate(fres, x2); %This is the differentiation of Q diff = abs(diff); %This gives the absolute value of diff clf subplot(3,1,1), plot(fres, 'k-', x, y, 'bo'); %Here is the plotting commands
  • 24. ylabel('Q') axis tight %legend('data', 'fitted curve') legend off subplot(3,1,2), plot(x2, diff,'r-', 'linewidth', 1) ylabel('dQ/dpsi') axis tight %cox = 17.2659e-9 %Farads, dox=200nm, eox=3.9 cox = 23.020868e-9 %Farads, dox=150nm, eox=3.9 cap = diff*cox ./ (diff+cox); %Here is calculating the capacitance subplot(3,1,3), plot(x2, cap,'r-', 'linewidth', 1) ylabel('cap') axis tight fprintf(' Time: %2.2fsecs ', cputime-time ) end %================================================