Chapter 5 - Part 1 - Illustration

ECE 4339
Han Q. Le (copyrighted) U. of Houston

Start package

Please excute the below to get start

Manipulate[
If[ONOFF==1,
NDOS0[SemiParm_]:= Module[{ Eg, me, gc, mh,ϵ},
{ Eg, me, gc, mh,ϵ}=SemiParm ;
4.829415887919019`*^15  {gc  (me^(3/2)) , (mh^(3/2))} 
];
FermiLevel[Dopant_,T_,SemiParm_]:=Module[{Eg, me, gc, mh,ϵ
, NC0,NV0,type, DopeDensity, kB=  8.61739*10^(-5)},
{ Eg, me, gc, mh,ϵ}=SemiParm  ;
{NC0,NV0}= NDOS0[SemiParm] ;
{type, DopeDensity}=Dopant ;
If[type>0  , 
kB T Log[DopeDensity/(NC0 (T^(3/2)))] 
,-kB T Log[DopeDensity/(NV0 (T^(3/2))) ] ]
] ;
DepletionW[T_,Vbias_,JuncDopant_, SemiParm_]:=Module[{Eg, me, gc, mh,ϵ
,Dopant1, Dopant2,
ContactV, V0, W,
,aB=5.29177*10^(-9)
,Ryd=13.6057},
{ Eg, me, gc, mh,ϵ}=SemiParm  ;
{Dopant1, Dopant2}=JuncDopant ;
ContactV=Eg+Sign[Dopant1[[1]] ]*FermiLevel[Dopant1,T,SemiParm]+Sign[Dopant2[[1]] ]*FermiLevel[Dopant2,T,SemiParm] ;
V0=ContactV-Vbias ;
W=Sqrt[(ϵ V0/(aB  Ryd))* (1/Dopant1[[2]] +1/Dopant2[[2]]) ]  ;
10^4* W {1, Dopant2[[2]]/(Dopant1[[2]] +Dopant2[[2]])
,Dopant1[[2]]/(Dopant1[[2]] +Dopant2[[2]])  }] ;
ϕJ[x_, T_,Vbias_,JuncDopant_, SemiParm_]:= Module[{Eg, me, gc, mh,ϵ
, ContactV, V0, W, x1,x2},
{ Eg, me, gc, mh,ϵ}=SemiParm  ; 
{W, x1,x2} =DepletionW[T,Vbias,JuncDopant, SemiParm] ;
ContactV=Eg+Sign[JuncDopant[[1,1]] ]*FermiLevel[JuncDopant[[1]],T,SemiParm]+Sign[JuncDopant[[2,1]] ]*FermiLevel[JuncDopant[[2]] ,T,SemiParm] ;
V0=ContactV-Vbias ;
Sign[JuncDopant[[1,1]] ]*If[x≤-x1,0.,If[x≤ 0., V0  (x+x1)^2 /(x1*W),
If[x≤ x2, V0*(1-(x-x2)^2/(x2*W)) ,V0]
]
]
] ;
BandDiagram[x_, T_,Vbias_,JuncDopant_, SemiParm_]:= Module[{Eg, me, gc, mh,ϵ
, ContactV, V0, W,w, x1,x2},
{ Eg, me, gc, mh,ϵ}=SemiParm  ; 
{W, x1,x2} =DepletionW[T,Vbias,JuncDopant, SemiParm] ;
ContactV=Eg+Sign[JuncDopant[[1,1]] ]*FermiLevel[JuncDopant[[1]],T,SemiParm]+Sign[JuncDopant[[2,1]] ]*FermiLevel[JuncDopant[[2]] ,T,SemiParm] ;
V0=ContactV-Vbias ;
w=Sign[JuncDopant[[1,1]] ]*If[x≤-x1,0.,If[x≤ 0., V0  (x+x1)^2 /(x1*W),
If[x≤ x2, V0*(1-(x-x2)^2/(x2*W)) ,V0]
]
] ;
w-FermiLevel[JuncDopant[[1]],T,SemiParm]
+{Sign[JuncDopant[[2,1]] ]*Eg,0.} 
] ;

FermiLine[x_, T_,Vbias_,JuncDopant_, SemiParm_]:=Module[{Eg, me, gc, mh,ϵ
, ContactV, V0, W, x1,x2},
{ Eg, me, gc, mh,ϵ}=SemiParm  ; 
{W, x1,x2} =DepletionW[T,Vbias,JuncDopant, SemiParm] ;
ContactV=Eg+Sign[JuncDopant[[1,1]] ]*FermiLevel[JuncDopant[[1]],T,SemiParm]+Sign[JuncDopant[[2,1]] ]*FermiLevel[JuncDopant[[2]] ,T,SemiParm] ;
V0=ContactV-Vbias ;
If[x≥- x1,-Sign[JuncDopant[[1,1]] ]*Vbias,  ]
];
CarrierEqui[x_, T_,JuncDopant_, SemiParm_]:= Module[{Eg, me, gc, mh,ϵ 
,NC0,NV0, F
, kB=  8.61739*10^(-5)},
{ Eg, me, gc, mh,ϵ}=SemiParm  ; 
{NC0,NV0}= NDOS0[SemiParm] ;
F=BandDiagram[x, T,0.,JuncDopant, SemiParm] ;
If[JuncDopant[[1,1]]>0, 
{NC0 (T^(3/2)) (E^(-F[[2]]/(kB T))), NV0 (T^(3/2)) (E^(F[[1]]/(kB T))), NC0 (T^(3/2)) (E^(-F[[2]]/(kB T)))  +  NV0 (T^(3/2)) (E^(F[[1]]/(kB T)))} 
, {NC0 (T^(3/2)) (E^(-F[[1]]/(kB T))), NV0 (T^(3/2)) (E^(F[[2]]/(kB T))), NC0 (T^(3/2)) (E^(-F[[1]]/(kB T)))  +  NV0 (T^(3/2)) (E^(F[[2]]/(kB T)))}
]
];
CarrierJ[x_, T_,Vbias_,JuncDopant_, SemiParm_,DiffParm_]:= Module[{Eg, me, gc, mh,ϵ
, μn,μp,τ,Ln, Lp 
,NC0,NV0
, W, x1,x2
,q1,q2,F1,F2,G
, kB=  8.61739*10^(-5)},
{ Eg, me, gc, mh,ϵ}=SemiParm  ; 
{ μn,μp,τ,Ln,Lp}=DiffParm  ;
If[Ln==0. || TrueQ[Ln== Null], Ln=10^4*Sqrt[μn kB T τ], ];
If[Lp==0. || TrueQ[Lp ==  Null],Lp=10^4*Sqrt[μp kB T τ], ];
{NC0,NV0}= NDOS0[SemiParm] ;
{W, x1,x2} =DepletionW[T,Vbias,JuncDopant, SemiParm] ;
F1=BandDiagram[-x1, T,0.,JuncDopant, SemiParm] ;
F2=BandDiagram[x2, T,0.,JuncDopant, SemiParm] ;
q1=If[JuncDopant[[1,1]]≥ 0., NV0 (T^(3/2.)) (E^(F1[[1]]/(kB T))), NC0 (T^(3/2.)) (E^(-F1[[1]]/(kB T)))] ;
q2=If[JuncDopant[[1,1]]≥ 0., NC0 (T^(3/2.)) (E^(-F2[[2]]/(kB T))), NV0 (T^(3/2.)) (E^(F2[[2]]/(kB T)))] ;
G=Exp[Vbias/(kB T)]-1;
If[JuncDopant[[1,1]]≥ 0.,
If[x≤ -x1, q1 G  (E^((x+x1)/Lp)),
If [x≥ x2, q2 G  (E^(-(x-x2)/Ln)), ]
]
, If[x≤ -x1, q1 G  (E^((x+x1)/Ln)),
If [x≥ x2, q2 G  (E^(-(x-x2)/Lp)), ]
]
]
]  ;
DiffJ[x_, T_,Vbias_,JuncDopant_, SemiParm_,DiffParm_]:= Module[{Eg, me, gc, mh,ϵ
, μn,μp,τ,Ln, Lp 
,NC0,NV0
, W, x1,x2
,q1,q2,F1,F2,G
, kB=  8.61739*10^(-5)},
{ Eg, me, gc, mh,ϵ}=SemiParm  ; 
{ μn,μp,τ,Ln,Lp}=DiffParm  ;
If[Ln==0. || TrueQ[Ln== Null], Ln=10^4*Sqrt[μn kB T τ], ];
If[Lp==0. || TrueQ[Lp ==  Null],Lp=10^4*Sqrt[μp kB T τ], ];
{NC0,NV0}= NDOS0[SemiParm] ;
{W, x1,x2} =DepletionW[T,Vbias,JuncDopant, SemiParm] ;
F1=BandDiagram[-x1, T,0.,JuncDopant, SemiParm] ;
F2=BandDiagram[x2, T,0.,JuncDopant, SemiParm] ;
q1=If[JuncDopant[[1,1]]>0, NV0 (T^(3/2)) (E^(F1[[1]]/(kB T))), NC0 (T^(3/2)) (E^(-F1[[1]]/(kB T)))] ;
q2=If[JuncDopant[[1,1]]>0, NC0 (T^(3/2)) (E^(-F2[[2]]/(kB T))), NV0 (T^(3/2)) (E^(F2[[2]]/(kB T)))] ;
G=Exp[Vbias/(kB T)]-1;
1.602176487`*^-23*If[JuncDopant[[1,1]]>0,
If[x≤ -x1,Lp q1 G  (E^((x+x1)/Lp))/τ,
If [x≥ x2,Ln q2 G  (E^(-(x-x2)/Ln))/τ, ]
]
, If[x≤ -x1,Ln q1 G  (E^((x+x1)/Ln))/τ,
If [x≥ x2,Lp q2 G  (E^(-(x-x2)/Lp))/τ, ]
]
]
]  ;
DiodeC[ T_,Vbias_,JuncDopant_, SemiParm_,DiffParm_]:= Module[{Eg, me, gc, mh,ϵ
, μn,μp,τ,Ln, Lp 
,NC0,NV0
, W, x1,x2
,q1,q2,F1,F2,G
, kB=  8.61739*10^(-5)},
{ Eg, me, gc, mh,ϵ}=SemiParm  ; 
{ μn,μp,τ,Ln,Lp}=DiffParm  ;
If[Ln==0. || TrueQ[Ln== Null], Ln=10^4*Sqrt[μn kB T τ], ];
If[Lp==0. || TrueQ[Lp ==  Null],Lp=10^4*Sqrt[μp kB T τ], ];
{NC0,NV0}= NDOS0[SemiParm] ;
{W, x1,x2} =DepletionW[T,Vbias,JuncDopant, SemiParm] ;
F1=BandDiagram[-x1, T,0.,JuncDopant, SemiParm] ;
F2=BandDiagram[x2, T,0.,JuncDopant, SemiParm] ;
q1=If[JuncDopant[[1,1]]>0, NV0 (T^(3/2)) (E^(F1[[1]]/(kB T))), NC0 (T^(3/2)) (E^(-F1[[1]]/(kB T)))] ;
q2=If[JuncDopant[[1,1]]>0, NC0 (T^(3/2)) (E^(-F2[[2]]/(kB T))), NV0 (T^(3/2)) (E^(F2[[2]]/(kB T)))] ;
G=Exp[Vbias/(kB T)]-1;
1.602176487`*^-23*If[JuncDopant[[1,1]]>0,
( Lp q1 +Ln q2 ) G  /τ ,( Ln q1 +Lp q2 ) G /τ]
]  ;
DiodeC1[ T_,Vbias_,JuncDopant_, SemiParm_,DiffParm_]:= Module[{Eg, me, gc, mh,ϵ
, μn,μp,τ,Ln, Lp 
,NC0,NV0
, W, x1,x2,ContactV,Ef1,Ef2
,q1,q2,F1,F2,G,r1,r2,H
, kB=  8.61739*10^(-5)},
{ Eg, me, gc, mh,ϵ}=SemiParm  ; 
{ μn,μp,τ,Ln,Lp}=DiffParm  ;
If[Ln==0. || TrueQ[Ln== Null], Ln=10^4*Sqrt[μn kB T τ], ];
If[Lp==0. || TrueQ[Lp ==  Null],Lp=10^4*Sqrt[μp kB T τ], ];
{NC0,NV0}= NDOS0[SemiParm] ;
Ef1=  FermiLevel[JuncDopant[[1]],T,SemiParm];
Ef2=  FermiLevel[JuncDopant[[2]],T,SemiParm];
ContactV=Eg+Sign[JuncDopant[[1,1]] ]*FermiLevel[JuncDopant[[1]],T,SemiParm]+Sign[JuncDopant[[2,1]] ]*FermiLevel[JuncDopant[[2]] ,T,SemiParm] ;
{W, x1,x2} =DepletionW[T,Vbias,JuncDopant, SemiParm] ;
F1=BandDiagram[-x1, T,0.,JuncDopant, SemiParm] ;
F2=BandDiagram[x2, T,0.,JuncDopant, SemiParm] ;
q1=If[JuncDopant[[1,1]]>0, NV0 (T^(3/2)) (E^(F1[[1]]/(kB T))), NC0 (T^(3/2)) (E^(-F1[[1]]/(kB T)))] ;
q2=If[JuncDopant[[1,1]]>0, NC0 (T^(3/2)) (E^(-F2[[2]]/(kB T))), NV0 (T^(3/2)) (E^(F2[[2]]/(kB T)))] ;
r1=  If[JuncDopant[[1,1]]>0,(mh/me)^3/2  *Exp[(F1[[1]]+F1[[2]])/(kB T)] , (me/mh)^3/2  *Exp[-(F1[[1]]+F1[[2]])/(kB T)] ] ;
r2=   If[JuncDopant[[1,1]]>0,(me/mh)^3/2  *Exp[-(F2[[1]]+F2[[2]])/(kB T)] , (mh/me)^3/2  *Exp[(F2[[1]]+F2[[2]])/(kB T)] ] ;
G=Exp[Vbias/(kB T)]-1; H=1-Exp[-2(ContactV-Vbias)/(kB T)] ;
1.602176487`*^-23*If[JuncDopant[[1,1]]>0,
( Lp q1 (1+r1 (G+1)) +Ln q2  (1+ r2 (G+1))) G  /(τ H)
,( Ln q1 (1+r1 (G+1)) +Lp q2 (1+ r2 (G+1)) ) G /(τ H)]
];

 ONOFF=0, ];
,
{{ONOFF,1,"Click to start"},{0,1}} ]

0. Physical constants or frequently used formulas

Execute the package below will give you the full list of physical constants in Mathematica.

<<PhysicalConstants`

Execute the package below helps do unit conversion.

<<Units`

0.1 Fundamental constants

ℏ=(PlanckConstant/(2 π ))
e=ElectronCharge
m=ElectronMass
c=SpeedOfLight
(Subscript[k, B]) = BoltzmannConstant

The above constants are given in MKS unit. Another very useful unit system is the CGS unit:

ℏ=(PlanckConstant/(2 π))  /. Joule->10^(7) Erg
e=ElectronCharge /. Coulomb->2.99792458*10^(9) Esu
m=ElectronMass /. Kilogram->10^3 Gram
c=SpeedOfLight  /. Meter->100 Cm
(Subscript[k, B]) = BoltzmannConstant /. Joule->10^(7) Erg

0.2 Other useful physical constants

0.2.1 Bohr radius

Bohr radius is the "effective" radius of the electron orbit in the lowest energy state of the ideal hydrogen atom. It is NOT the actual orbit, of course, but only a secondary physical constant useful in many calculations.
It is defined as (in CGS units)

(Subscript[a, B])=((ℏ^2)/(m (e^2)))

(Subscript[a, B])=(Subscript[a, B]) /. Esu-> (Sqrt[Erg Cm]) /.  Erg->Gram ((Cm^2)/(Second^(2 )))

0.2.2 Rydberg

Rydberg is the binding energy of the electron in the hydrogen atom (ideal atom).

(Subscript[R, ∞])=((e^2)/(2 (Subscript[a, B])))

(Subscript[R, ∞]) = (Subscript[R, ∞]) /. Esu-> (Sqrt[Erg Cm])

But nobody really use (Subscript[R, ∞]) in erg unit. The more convenient unit is eV: electron volt. In this unit:

(Subscript[R, ∞])=(e/(2 (Subscript[a, B])))c(Second/Esu) 10^(-8)  eV

Thus: (Subscript[R, ∞])=13.605691932782346` eV

What is the value of eV in other energy unit?

eV=ElectronCharge Volt

eV = eV /. Volt-> Joule/Coulomb

eV = eV /. Joule->10^7 Erg

0.3 Use of physical constants as "natural" units

As the natural unit of length, we can use Bohr radius. For energy, we can use Rydberg, or eV (semi natural). Boltzmann constant is often used with eV

(Subscript[k, B]) = (BoltzmannConstant/(ElectronCharge ))

(Subscript[k, B])  =  (Subscript[k, B]) /. Joule-> Coulomb  eV

Thus, sometimes, we use this value:
                                 (Subscript[k, B]) =8.61734×(10^(-5))  eV/K

Overview

Calculation package

Modules for illustration

SemiParm={ Eg, me, gc, mh, ϵ} ;
NDOS0[SemiParm_]:= Module[{ Eg, me, gc, mh,ϵ},
{ Eg, me, gc, mh,ϵ}=SemiParm ;
4.829415887919019`*^15  {gc  (me^(3/2)) , (mh^(3/2))} 
];
FermiLevel[Dopant_,T_,SemiParm_]:=Module[{Eg, me, gc, mh,ϵ
, NC0,NV0,type, DopeDensity, kB=  8.61739*10^(-5)},
{ Eg, me, gc, mh,ϵ}=SemiParm  ;
{NC0,NV0}= NDOS0[SemiParm] ;
{type, DopeDensity}=Dopant ;
If[type>0  , 
kB T Log[DopeDensity/(NC0 (T^(3/2)))] 
,-kB T Log[DopeDensity/(NV0 (T^(3/2))) ] ]
] ;

DepletionW[T_,Vbias_,JuncDopant_, SemiParm_]:=Module[{Eg, me, gc, mh,ϵ
,Dopant1, Dopant2,
ContactV, V0, W,
,aB=5.29177*10^(-9)
,Ryd=13.6057},
{ Eg, me, gc, mh,ϵ}=SemiParm  ;
{Dopant1, Dopant2}=JuncDopant ;
ContactV=Eg+Sign[Dopant1[[1]] ]*FermiLevel[Dopant1,T,SemiParm]+Sign[Dopant2[[1]] ]*FermiLevel[Dopant2,T,SemiParm] ;
V0=ContactV-Vbias ;
W=Sqrt[(ϵ V0/(aB  Ryd))* (1/Dopant1[[2]] +1/Dopant2[[2]]) ]  ;
10^4* W {1, Dopant2[[2]]/(Dopant1[[2]] +Dopant2[[2]])
,Dopant1[[2]]/(Dopant1[[2]] +Dopant2[[2]])  }] ;

ϕJ[x_, T_,Vbias_,JuncDopant_, SemiParm_]:= Module[{Eg, me, gc, mh,ϵ
, ContactV, V0, W, x1,x2},
{ Eg, me, gc, mh,ϵ}=SemiParm  ; 
{W, x1,x2} =DepletionW[T,Vbias,JuncDopant, SemiParm] ;
ContactV=Eg+Sign[JuncDopant[[1,1]] ]*FermiLevel[JuncDopant[[1]],T,SemiParm]+Sign[JuncDopant[[2,1]] ]*FermiLevel[JuncDopant[[2]] ,T,SemiParm] ;
V0=ContactV-Vbias ;
Sign[JuncDopant[[1,1]] ]*If[x≤-x1,0.,If[x≤ 0., V0  (x+x1)^2 /(x1*W),
If[x≤ x2, V0*(1-(x-x2)^2/(x2*W)) ,V0]
]
]
] ;
BandDiagram[x_, T_,Vbias_,JuncDopant_, SemiParm_]:= Module[{Eg, me, gc, mh,ϵ
, ContactV, V0, W, x1,x2},
{ Eg, me, gc, mh,ϵ}=SemiParm  ; 
{W, x1,x2} =DepletionW[T,Vbias,JuncDopant, SemiParm] ;
ContactV=Eg+Sign[JuncDopant[[1,1]] ]*FermiLevel[JuncDopant[[1]],T,SemiParm]+Sign[JuncDopant[[2,1]] ]*FermiLevel[JuncDopant[[2]] ,T,SemiParm] ;
V0=ContactV-Vbias ;
w=Sign[JuncDopant[[1,1]] ]*If[x≤-x1,0.,If[x≤ 0., V0  (x+x1)^2 /(x1*W),
If[x≤ x2, V0*(1-(x-x2)^2/(x2*W)) ,V0]
]
] ;
w-FermiLevel[JuncDopant[[1]],T,SemiParm]
+{Sign[JuncDopant[[2,1]] ]*Eg,0.} 
] ;

FermiLine[x_, T_,Vbias_,JuncDopant_, SemiParm_]:=Module[{Eg, me, gc, mh,ϵ
, ContactV, V0, W, x1,x2},
{ Eg, me, gc, mh,ϵ}=SemiParm  ; 
{W, x1,x2} =DepletionW[T,Vbias,JuncDopant, SemiParm] ;
ContactV=Eg+Sign[JuncDopant[[1,1]] ]*FermiLevel[JuncDopant[[1]],T,SemiParm]+Sign[JuncDopant[[2,1]] ]*FermiLevel[JuncDopant[[2]] ,T,SemiParm] ;
V0=ContactV-Vbias ;
If[x≥- x1,-Sign[JuncDopant[[1,1]] ]*Vbias,  ]
];

CarrierEqui[x_, T_,JuncDopant_, SemiParm_]:= Module[{Eg, me, gc, mh,ϵ 
,NC0,NV0, F
, kB=  8.61739*10^(-5)},
{ Eg, me, gc, mh,ϵ}=SemiParm  ; 
{NC0,NV0}= NDOS0[SemiParm] ;
F=BandDiagram[x, T,0.,JuncDopant, SemiParm] ;
If[JuncDopant[[1,1]]>0, 
{NC0 (T^(3/2)) (E^(-F[[2]]/(kB T))), NV0 (T^(3/2)) (E^(F[[1]]/(kB T))), NC0 (T^(3/2)) (E^(-F[[2]]/(kB T)))  +  NV0 (T^(3/2)) (E^(F[[1]]/(kB T)))} 
, {NC0 (T^(3/2)) (E^(-F[[1]]/(kB T))), NV0 (T^(3/2)) (E^(F[[2]]/(kB T))), NC0 (T^(3/2)) (E^(-F[[1]]/(kB T)))  +  NV0 (T^(3/2)) (E^(F[[2]]/(kB T)))}
]
]

CarrierJ[x_, T_,Vbias_,JuncDopant_, SemiParm_,DiffParm_]:= Module[{Eg, me, gc, mh,ϵ
, μn,μp,τ,Ln, Lp 
,NC0,NV0
, W, x1,x2
,q1,q2,F1,F2,G
, kB=  8.61739*10^(-5)},
{ Eg, me, gc, mh,ϵ}=SemiParm  ; 
{ μn,μp,τ,Ln,Lp}=DiffParm  ;
If[Ln==0. || TrueQ[Ln== Null], Ln=10^4*Sqrt[μn kB T τ], ];
If[Lp==0. || TrueQ[Lp ==  Null],Lp=10^4*Sqrt[μp kB T τ], ];
{NC0,NV0}= NDOS0[SemiParm] ;
{W, x1,x2} =DepletionW[T,Vbias,JuncDopant, SemiParm] ;
F1=BandDiagram[-x1, T,0.,JuncDopant, SemiParm] ;
F2=BandDiagram[x2, T,0.,JuncDopant, SemiParm] ;
q1=If[JuncDopant[[1,1]]>0, NV0 (T^(3/2)) (E^(F1[[1]]/(kB T))), NC0 (T^(3/2)) (E^(-F1[[1]]/(kB T)))] ;
q2=If[JuncDopant[[1,1]]>0, NC0 (T^(3/2)) (E^(-F2[[2]]/(kB T))), NV0 (T^(3/2)) (E^(F2[[2]]/(kB T)))] ;
G=Exp[Vbias/(kB T)]-1;
If[JuncDopant[[1,1]]>0,
If[x≤ -x1, q1 G  (E^((x+x1)/Lp)),
If [x≥ x2, q2 G  (E^(-(x-x2)/Ln)), ]
]
, If[x≤ -x1, q1 G  (E^((x+x1)/Ln)),
If [x≥ x2, q2 G  (E^(-(x-x2)/Lp)), ]
]
]
]  ;

DiffJ[x_, T_,Vbias_,JuncDopant_, SemiParm_,DiffParm_]:= Module[{Eg, me, gc, mh,ϵ
, μn,μp,τ,Ln, Lp 
,NC0,NV0
, W, x1,x2
,q1,q2,F1,F2,G
, kB=  8.61739*10^(-5)},
{ Eg, me, gc, mh,ϵ}=SemiParm  ; 
{ μn,μp,τ,Ln,Lp}=DiffParm  ;
If[Ln==0. || TrueQ[Ln== Null], Ln=10^4*Sqrt[μn kB T τ], ];
If[Lp==0. || TrueQ[Lp ==  Null],Lp=10^4*Sqrt[μp kB T τ], ];
{NC0,NV0}= NDOS0[SemiParm] ;
{W, x1,x2} =DepletionW[T,Vbias,JuncDopant, SemiParm] ;
F1=BandDiagram[-x1, T,0.,JuncDopant, SemiParm] ;
F2=BandDiagram[x2, T,0.,JuncDopant, SemiParm] ;
q1=If[JuncDopant[[1,1]]>0, NV0 (T^(3/2)) (E^(F1[[1]]/(kB T))), NC0 (T^(3/2)) (E^(-F1[[1]]/(kB T)))] ;
q2=If[JuncDopant[[1,1]]>0, NC0 (T^(3/2)) (E^(-F2[[2]]/(kB T))), NV0 (T^(3/2)) (E^(F2[[2]]/(kB T)))] ;
G=Exp[Vbias/(kB T)]-1;
1.602176487`*^-23*If[JuncDopant[[1,1]]>0,
If[x≤ -x1,Lp q1 G  (E^((x+x1)/Lp))/τ,
If [x≥ x2,Ln q2 G  (E^(-(x-x2)/Ln))/τ, ]
]
, If[x≤ -x1,Ln q1 G  (E^((x+x1)/Ln))/τ,
If [x≥ x2,Lp q2 G  (E^(-(x-x2)/Lp))/τ, ]
]
]
]  ;

DiodeC[ T_,Vbias_,JuncDopant_, SemiParm_,DiffParm_]:= Module[{Eg, me, gc, mh,ϵ
, μn,μp,τ,Ln, Lp 
,NC0,NV0
, W, x1,x2
,q1,q2,F1,F2,G
, kB=  8.61739*10^(-5)},
{ Eg, me, gc, mh,ϵ}=SemiParm  ; 
{ μn,μp,τ,Ln,Lp}=DiffParm  ;
If[Ln==0. || TrueQ[Ln== Null], Ln=10^4*Sqrt[μn kB T τ], ];
If[Lp==0. || TrueQ[Lp ==  Null],Lp=10^4*Sqrt[μp kB T τ], ];
{NC0,NV0}= NDOS0[SemiParm] ;
{W, x1,x2} =DepletionW[T,Vbias,JuncDopant, SemiParm] ;
F1=BandDiagram[-x1, T,0.,JuncDopant, SemiParm] ;
F2=BandDiagram[x2, T,0.,JuncDopant, SemiParm] ;
q1=If[JuncDopant[[1,1]]>0, NV0 (T^(3/2)) (E^(F1[[1]]/(kB T))), NC0 (T^(3/2)) (E^(-F1[[1]]/(kB T)))] ;
q2=If[JuncDopant[[1,1]]>0, NC0 (T^(3/2)) (E^(-F2[[2]]/(kB T))), NV0 (T^(3/2)) (E^(F2[[2]]/(kB T)))] ;
G=Exp[Vbias/(kB T)]-1;
1.602176487`*^-23*If[JuncDopant[[1,1]]>0,
( Lp q1 +Ln q2 ) G  /τ ,( Ln q1 +Lp q2 ) G /τ]
]  ;

DiodeC1[ T_,Vbias_,JuncDopant_, SemiParm_,DiffParm_]:= Module[{Eg, me, gc, mh,ϵ
, μn,μp,τ,Ln, Lp 
,NC0,NV0
, W, x1,x2,ContactV,Ef1,Ef2
,q1,q2,F1,F2,G,r1,r2,H
, kB=  8.61739*10^(-5)},
{ Eg, me, gc, mh,ϵ}=SemiParm  ; 
{ μn,μp,τ,Ln,Lp}=DiffParm  ;
If[Ln==0. || TrueQ[Ln== Null], Ln=10^4*Sqrt[μn kB T τ], ];
If[Lp==0. || TrueQ[Lp ==  Null],Lp=10^4*Sqrt[μp kB T τ], ];
{NC0,NV0}= NDOS0[SemiParm] ;
Ef1=  FermiLevel[JuncDopant[[1]],T,SemiParm];
Ef2=  FermiLevel[JuncDopant[[2]],T,SemiParm];
ContactV=Eg+Sign[JuncDopant[[1,1]] ]*FermiLevel[JuncDopant[[1]],T,SemiParm]+Sign[JuncDopant[[2,1]] ]*FermiLevel[JuncDopant[[2]] ,T,SemiParm] ;
{W, x1,x2} =DepletionW[T,Vbias,JuncDopant, SemiParm] ;
F1=BandDiagram[-x1, T,0.,JuncDopant, SemiParm] ;
F2=BandDiagram[x2, T,0.,JuncDopant, SemiParm] ;
q1=If[JuncDopant[[1,1]]>0, NV0 (T^(3/2)) (E^(F1[[1]]/(kB T))), NC0 (T^(3/2)) (E^(-F1[[1]]/(kB T)))] ;
q2=If[JuncDopant[[1,1]]>0, NC0 (T^(3/2)) (E^(-F2[[2]]/(kB T))), NV0 (T^(3/2)) (E^(F2[[2]]/(kB T)))] ;
r1=  If[JuncDopant[[1,1]]>0,(mh/me)^3/2  *Exp[(F1[[1]]+F1[[2]])/(kB T)] , (me/mh)^3/2  *Exp[-(F1[[1]]+F1[[2]])/(kB T)] ] ;
r2=   If[JuncDopant[[1,1]]>0,(me/mh)^3/2  *Exp[-(F2[[1]]+F2[[2]])/(kB T)] , (mh/me)^3/2  *Exp[(F2[[1]]+F2[[2]])/(kB T)] ] ;
G=Exp[Vbias/(kB T)]-1; H=1-Exp[-2(ContactV-Vbias)/(kB T)] ;
1.602176487`*^-23*If[JuncDopant[[1,1]]>0,
( Lp q1 (1+r1 (G+1)) +Ln q2  (1+ r2 (G+1))) G  /(τ H)
,( Ln q1 (1+r1 (G+1)) +Lp q2 (1+ r2 (G+1)) ) G /(τ H)]
]  ;

Application

1. Review previous p-n junction

1.1 Review homework 3

Principle of detailed balancing. If we have the following case:

The left hand side Fermi level is different from the right. What'll happen?
Carriers diffuse, left goes right and vice versa.
The rate of left going to right = density of occupied states of left x density of UNOCCUPIED of right: 
(Subscript[N, L])[E]  (Subscript[f, L])[E]  ×(Subscript[N, R])[E]  (1-(Subscript[f, R])[E] )  
Vice versa for the other way and both MUST be equal at equilibrium
(Subscript[N, L])[E]  (Subscript[f, L])[E]  ×(Subscript[N, R])[E]  (1-(Subscript[f, R])[E] ) =(Subscript[N, R])[E]  (Subscript[f, R])[E]  ×(Subscript[N, L])[E]  (1-(Subscript[f, L])[E] )

Expand[(Subscript[N, L])[en]  (Subscript[f, L])[en]  ×(Subscript[N, R])[en]  (1-(Subscript[f, R])[en] ) - (Subscript[N, R])[en]  (Subscript[f, R])[en]  ×(Subscript[N, L])[en]  (1-(Subscript[f, L])[en] ) ==0  ]

We see that this implies: (Subscript[f, L])(en) =(Subscript[f, R])(en) 
What it means is that the Fermi Level must be equal.

How do they get to the same level?
At -∞ and +∞ we have:

The Fermi levels at  -∞ and +∞ stay the same relative to the band. So, if they level, the band MUST shift relative to each other. We'll learn how in Chapter 5.

1.2 Diffusion across a junction

Recall from Chapter 3

(Subscript[n, 0])=(Subscript[N, C]) (e^(-((Subscript[E, c])-(Subscript[E, f]))/(Subscript[k, B])T))    and  (Subscript[p, 0])=(Subscript[N, V]) (e^(-((Subscript[E, f])-(Subscript[E, v]))/(Subscript[k, B])T))
Consider just one type of carriers for simplicity.

2. Junction at equilibrium

2.1 Fermi level and contact potential

The potential energy shift (caused by internal electric field) is called contact potential at equilibrium. Example: 
Left side is p-doped: (Subscript[E, fL])=0.07 eV +(Subscript[E, V])
Right side is n-doped: (Subscript[E, fR])=-0.12 eV +(Subscript[E, C])
The difference is: (Subscript[E, fR])-(Subscript[E, fL])=-0.12 eV +(Subscript[E, C])-0.07 eV -(Subscript[E, V])
                              (Subscript[V, 0])=(Subscript[ΔE, C])=(Subscript[ΔE, F]) =(Subscript[E, fR])-(Subscript[E, fL])=(Subscript[E, g])-0.12 eV -0.07 eV =(Subscript[E, g])-0.19 eV

2.1.1 Further example

SemiParm={ 1.42, 0.0665,1, 0.5,12.5 } ;
JuncDopant={ {-1,1*10^16},{1,3*10^16} } ;
T=300. ;
Print[" Fermi level left=  ", FermiLevel[JuncDopant[[1]],T, SemiParm] ]
Print[" Fermi level Right=  ",FermiLevel[JuncDopant[[2]],T,SemiParm] ]
Print[" Contact potential=  ",SemiParm[[1]] + Sign[JuncDopant[[1,1]]] *FermiLevel[JuncDopant[[1]],T, SemiParm]+Sign[JuncDopant[[2,1]] ] *FermiLevel[JuncDopant[[2]],T, SemiParm] ]

Calculation of Fermi levels

Manipulate[
If[start==1,
NDOS0[SemiParm_]:= Module[{ Eg, me, gc, mh,ϵ},
{ Eg, me, gc, mh,ϵ}=SemiParm ;
4.829415887919019`*^15  {gc  (me^(3/2)) , (mh^(3/2))} 
];
FermiLevel[Dopant_,T_,SemiParm_]:=Module[{Eg, me, gc, mh,ϵ
, NC0,NV0,type, DopeDensity, kB=  8.61739*10^(-5)},
{ Eg, me, gc, mh,ϵ}=SemiParm  ;
{NC0,NV0}= NDOS0[SemiParm] ;
{type, DopeDensity}=Dopant ;
If[type>0  , 
kB T Log[DopeDensity/(NC0 (T^(3/2)))] 
,-kB T Log[DopeDensity/(NV0 (T^(3/2))) ] ]
] ;
DepletionW[T_,Vbias_,JuncDopant_, SemiParm_]:=Module[{Eg, me, gc, mh,ϵ
,Dopant1, Dopant2,
ContactV, V0, W,
,aB=5.29177*10^(-9)
,Ryd=13.6057},
{ Eg, me, gc, mh,ϵ}=SemiParm  ;
{Dopant1, Dopant2}=JuncDopant ;
ContactV=Eg+Sign[Dopant1[[1]] ]*FermiLevel[Dopant1,T,SemiParm]+Sign[Dopant2[[1]] ]*FermiLevel[Dopant2,T,SemiParm] ;
V0=ContactV-Vbias ;
W=Sqrt[(ϵ V0/(aB  Ryd))* (1/Dopant1[[2]] +1/Dopant2[[2]]) ]  ;
10^4* W {1, Dopant2[[2]]/(Dopant1[[2]] +Dopant2[[2]])
,Dopant1[[2]]/(Dopant1[[2]] +Dopant2[[2]])  }] ;
ϕJ[x_, T_,Vbias_,JuncDopant_, SemiParm_]:= Module[{Eg, me, gc, mh,ϵ
, ContactV, V0, W, x1,x2},
{ Eg, me, gc, mh,ϵ}=SemiParm  ; 
{W, x1,x2} =DepletionW[T,Vbias,JuncDopant, SemiParm] ;
ContactV=Eg+Sign[JuncDopant[[1,1]] ]*FermiLevel[JuncDopant[[1]],T,SemiParm]+Sign[JuncDopant[[2,1]] ]*FermiLevel[JuncDopant[[2]] ,T,SemiParm] ;
V0=ContactV-Vbias ;
Sign[JuncDopant[[1,1]] ]*If[x≤-x1,0.,If[x≤ 0., V0  (x+x1)^2 /(x1*W),
If[x≤ x2, V0*(1-(x-x2)^2/(x2*W)) ,V0]
]
]
] ;
BandDiagram[x_, T_,Vbias_,JuncDopant_, SemiParm_]:= Module[{Eg, me, gc, mh,ϵ
, ContactV, V0, W,w, x1,x2},
{ Eg, me, gc, mh,ϵ}=SemiParm  ; 
{W, x1,x2} =DepletionW[T,Vbias,JuncDopant, SemiParm] ;
ContactV=Eg+Sign[JuncDopant[[1,1]] ]*FermiLevel[JuncDopant[[1]],T,SemiParm]+Sign[JuncDopant[[2,1]] ]*FermiLevel[JuncDopant[[2]] ,T,SemiParm] ;
V0=ContactV-Vbias ;
w=Sign[JuncDopant[[1,1]] ]*If[x≤-x1,0.,If[x≤ 0., V0  (x+x1)^2 /(x1*W),
If[x≤ x2, V0*(1-(x-x2)^2/(x2*W)) ,V0]
]
] ;
w-FermiLevel[JuncDopant[[1]],T,SemiParm]
+{Sign[JuncDopant[[2,1]] ]*Eg,0.} 
] ;

FermiLine[x_, T_,Vbias_,JuncDopant_, SemiParm_]:=Module[{Eg, me, gc, mh,ϵ
, ContactV, V0, W, x1,x2},
{ Eg, me, gc, mh,ϵ}=SemiParm  ; 
{W, x1,x2} =DepletionW[T,Vbias,JuncDopant, SemiParm] ;
ContactV=Eg+Sign[JuncDopant[[1,1]] ]*FermiLevel[JuncDopant[[1]],T,SemiParm]+Sign[JuncDopant[[2,1]] ]*FermiLevel[JuncDopant[[2]] ,T,SemiParm] ;
V0=ContactV-Vbias ;
If[x≥- x1,-Sign[JuncDopant[[1,1]] ]*Vbias,  ]
];
CarrierEqui[x_, T_,JuncDopant_, SemiParm_]:= Module[{Eg, me, gc, mh,ϵ 
,NC0,NV0, F
, kB=  8.61739*10^(-5)},
{ Eg, me, gc, mh,ϵ}=SemiParm  ; 
{NC0,NV0}= NDOS0[SemiParm] ;
F=BandDiagram[x, T,0.,JuncDopant, SemiParm] ;
If[JuncDopant[[1,1]]>0, 
{NC0 (T^(3/2)) (E^(-F[[2]]/(kB T))), NV0 (T^(3/2)) (E^(F[[1]]/(kB T))), NC0 (T^(3/2)) (E^(-F[[2]]/(kB T)))  +  NV0 (T^(3/2)) (E^(F[[1]]/(kB T)))} 
, {NC0 (T^(3/2)) (E^(-F[[1]]/(kB T))), NV0 (T^(3/2)) (E^(F[[2]]/(kB T))), NC0 (T^(3/2)) (E^(-F[[1]]/(kB T)))  +  NV0 (T^(3/2)) (E^(F[[2]]/(kB T)))}
]
];
CarrierJ[x_, T_,Vbias_,JuncDopant_, SemiParm_,DiffParm_]:= Module[{Eg, me, gc, mh,ϵ
, μn,μp,τ,Ln, Lp 
,NC0,NV0
, W, x1,x2
,q1,q2,F1,F2,G
, kB=  8.61739*10^(-5)},
{ Eg, me, gc, mh,ϵ}=SemiParm  ; 
{ μn,μp,τ,Ln,Lp}=DiffParm  ;
If[Ln==0. || TrueQ[Ln== Null], Ln=10^4*Sqrt[μn kB T τ], ];
If[Lp==0. || TrueQ[Lp ==  Null],Lp=10^4*Sqrt[μp kB T τ], ];
{NC0,NV0}= NDOS0[SemiParm] ;
{W, x1,x2} =DepletionW[T,Vbias,JuncDopant, SemiParm] ;
F1=BandDiagram[-x1, T,0.,JuncDopant, SemiParm] ;
F2=BandDiagram[x2, T,0.,JuncDopant, SemiParm] ;
q1=If[JuncDopant[[1,1]]≥ 0., NV0 (T^(3/2.)) (E^(F1[[1]]/(kB T))), NC0 (T^(3/2.)) (E^(-F1[[1]]/(kB T)))] ;
q2=If[JuncDopant[[1,1]]≥ 0., NC0 (T^(3/2.)) (E^(-F2[[2]]/(kB T))), NV0 (T^(3/2.)) (E^(F2[[2]]/(kB T)))] ;
G=Exp[Vbias/(kB T)]-1;
If[JuncDopant[[1,1]]≥ 0.,
If[x≤ -x1, q1 G  (E^((x+x1)/Lp)),
If [x≥ x2, q2 G  (E^(-(x-x2)/Ln)), ]
]
, If[x≤ -x1, q1 G  (E^((x+x1)/Ln)),
If [x≥ x2, q2 G  (E^(-(x-x2)/Lp)), ]
]
]
]  ;
DiffJ[x_, T_,Vbias_,JuncDopant_, SemiParm_,DiffParm_]:= Module[{Eg, me, gc, mh,ϵ
, μn,μp,τ,Ln, Lp 
,NC0,NV0
, W, x1,x2
,q1,q2,F1,F2,G
, kB=  8.61739*10^(-5)},
{ Eg, me, gc, mh,ϵ}=SemiParm  ; 
{ μn,μp,τ,Ln,Lp}=DiffParm  ;
If[Ln==0. || TrueQ[Ln== Null], Ln=10^4*Sqrt[μn kB T τ], ];
If[Lp==0. || TrueQ[Lp ==  Null],Lp=10^4*Sqrt[μp kB T τ], ];
{NC0,NV0}= NDOS0[SemiParm] ;
{W, x1,x2} =DepletionW[T,Vbias,JuncDopant, SemiParm] ;
F1=BandDiagram[-x1, T,0.,JuncDopant, SemiParm] ;
F2=BandDiagram[x2, T,0.,JuncDopant, SemiParm] ;
q1=If[JuncDopant[[1,1]]>0, NV0 (T^(3/2)) (E^(F1[[1]]/(kB T))), NC0 (T^(3/2)) (E^(-F1[[1]]/(kB T)))] ;
q2=If[JuncDopant[[1,1]]>0, NC0 (T^(3/2)) (E^(-F2[[2]]/(kB T))), NV0 (T^(3/2)) (E^(F2[[2]]/(kB T)))] ;
G=Exp[Vbias/(kB T)]-1;
1.602176487`*^-23*If[JuncDopant[[1,1]]>0,
If[x≤ -x1,Lp q1 G  (E^((x+x1)/Lp))/τ,
If [x≥ x2,Ln q2 G  (E^(-(x-x2)/Ln))/τ, ]
]
, If[x≤ -x1,Ln q1 G  (E^((x+x1)/Ln))/τ,
If [x≥ x2,Lp q2 G  (E^(-(x-x2)/Lp))/τ, ]
]
]
]  ;
DiodeC[ T_,Vbias_,JuncDopant_, SemiParm_,DiffParm_]:= Module[{Eg, me, gc, mh,ϵ
, μn,μp,τ,Ln, Lp 
,NC0,NV0
, W, x1,x2
,q1,q2,F1,F2,G
, kB=  8.61739*10^(-5)},
{ Eg, me, gc, mh,ϵ}=SemiParm  ; 
{ μn,μp,τ,Ln,Lp}=DiffParm  ;
If[Ln==0. || TrueQ[Ln== Null], Ln=10^4*Sqrt[μn kB T τ], ];
If[Lp==0. || TrueQ[Lp ==  Null],Lp=10^4*Sqrt[μp kB T τ], ];
{NC0,NV0}= NDOS0[SemiParm] ;
{W, x1,x2} =DepletionW[T,Vbias,JuncDopant, SemiParm] ;
F1=BandDiagram[-x1, T,0.,JuncDopant, SemiParm] ;
F2=BandDiagram[x2, T,0.,JuncDopant, SemiParm] ;
q1=If[JuncDopant[[1,1]]>0, NV0 (T^(3/2)) (E^(F1[[1]]/(kB T))), NC0 (T^(3/2)) (E^(-F1[[1]]/(kB T)))] ;
q2=If[JuncDopant[[1,1]]>0, NC0 (T^(3/2)) (E^(-F2[[2]]/(kB T))), NV0 (T^(3/2)) (E^(F2[[2]]/(kB T)))] ;
G=Exp[Vbias/(kB T)]-1;
1.602176487`*^-23*If[JuncDopant[[1,1]]>0,
( Lp q1 +Ln q2 ) G  /τ ,( Ln q1 +Lp q2 ) G /τ]
]  ;
DiodeC1[ T_,Vbias_,JuncDopant_, SemiParm_,DiffParm_]:= Module[{Eg, me, gc, mh,ϵ
, μn,μp,τ,Ln, Lp 
,NC0,NV0
, W, x1,x2,ContactV,Ef1,Ef2
,q1,q2,F1,F2,G,r1,r2,H
, kB=  8.61739*10^(-5)},
{ Eg, me, gc, mh,ϵ}=SemiParm  ; 
{ μn,μp,τ,Ln,Lp}=DiffParm  ;
If[Ln==0. || TrueQ[Ln== Null], Ln=10^4*Sqrt[μn kB T τ], ];
If[Lp==0. || TrueQ[Lp ==  Null],Lp=10^4*Sqrt[μp kB T τ], ];
{NC0,NV0}= NDOS0[SemiParm] ;
Ef1=  FermiLevel[JuncDopant[[1]],T,SemiParm];
Ef2=  FermiLevel[JuncDopant[[2]],T,SemiParm];
ContactV=Eg+Sign[JuncDopant[[1,1]] ]*FermiLevel[JuncDopant[[1]],T,SemiParm]+Sign[JuncDopant[[2,1]] ]*FermiLevel[JuncDopant[[2]] ,T,SemiParm] ;
{W, x1,x2} =DepletionW[T,Vbias,JuncDopant, SemiParm] ;
F1=BandDiagram[-x1, T,0.,JuncDopant, SemiParm] ;
F2=BandDiagram[x2, T,0.,JuncDopant, SemiParm] ;
q1=If[JuncDopant[[1,1]]>0, NV0 (T^(3/2)) (E^(F1[[1]]/(kB T))), NC0 (T^(3/2)) (E^(-F1[[1]]/(kB T)))] ;
q2=If[JuncDopant[[1,1]]>0, NC0 (T^(3/2)) (E^(-F2[[2]]/(kB T))), NV0 (T^(3/2)) (E^(F2[[2]]/(kB T)))] ;
r1=  If[JuncDopant[[1,1]]>0,(mh/me)^3/2  *Exp[(F1[[1]]+F1[[2]])/(kB T)] , (me/mh)^3/2  *Exp[-(F1[[1]]+F1[[2]])/(kB T)] ] ;
r2=   If[JuncDopant[[1,1]]>0,(me/mh)^3/2  *Exp[-(F2[[1]]+F2[[2]])/(kB T)] , (mh/me)^3/2  *Exp[(F2[[1]]+F2[[2]])/(kB T)] ] ;
G=Exp[Vbias/(kB T)]-1; H=1-Exp[-2(ContactV-Vbias)/(kB T)] ;
1.602176487`*^-23*If[JuncDopant[[1,1]]>0,
( Lp q1 (1+r1 (G+1)) +Ln q2  (1+ r2 (G+1))) G  /(τ H)
,( Ln q1 (1+r1 (G+1)) +Lp q2 (1+ r2 (G+1)) ) G /(τ H)]
];

 start=0, ];
Manipulate[
SemiParm={ Eg, me,gc, mh,ϵ } ;   (* this is GaAs  *) 
Manipulate[
Plot[If[x<0,FermiLevel[{-1,10^d1},T, SemiParm], SemiParm[[1]]+FermiLevel[{1,10^d2},T, SemiParm] ],
{x,-1,1}, PlotRange-> {0.,1.5}, PlotStyle-> Thick, Filling-> {1-> {Bottom,Hue[0.35,1,1,0.5]}}
,AxesLabel->{"Position (a. u)","Energy (eV)"}],{{d1,15,"Left p-dope level 10^"},14,18},{{d2,15,"Right n-dope level 10^"},14,18}
,{{T,300,"Temperature (K)"},100,400}]
,Grid[{{ Control[{{Eg,1.42,"Bandgap (eV)"},0.3,4}]
,Control[{{ϵ,13.6,"Dielectric const."},4,20}]}
,{Control[{{me,0.0665,"Elec eff mass me*"},0.02,0.5}]
,Control[{{mh,0.5,"Hole eff mass mh*"},0.02,1}]}
,{Control[{{gc,1,"Cond band degeneracy"},{1,6}}]}
}]
]

,
{{start,1,"Click to start"},{0,1}} ]

2.2 Carrier distribution

LogLogPlot[{n, 1/n, n+ 1/n  } ,{n,0.001,1000}, Frame-> True, GridLines->Automatic, PlotStyle->{{Thick,Red},{Thick,Blue},{Thick,Hue[0.35,1,0.5]}}]

The minimum is at n=p. Total carrier density is LOWEST when there are equal electron and hole population. This is the case of the depletion region

2.3 Depletion layer

2.4 Electrostatic potential

The electrostatic potential is a function of contact potential:

Calculation of static potential energy at the junction

Manipulate[
If[start==1,
NDOS0[SemiParm_]:= Module[{ Eg, me, gc, mh,ϵ},
{ Eg, me, gc, mh,ϵ}=SemiParm ;
4.829415887919019`*^15  {gc  (me^(3/2)) , (mh^(3/2))} 
];
FermiLevel[Dopant_,T_,SemiParm_]:=Module[{Eg, me, gc, mh,ϵ
, NC0,NV0,type, DopeDensity, kB=  8.61739*10^(-5)},
{ Eg, me, gc, mh,ϵ}=SemiParm  ;
{NC0,NV0}= NDOS0[SemiParm] ;
{type, DopeDensity}=Dopant ;
If[type>0  , 
kB T Log[DopeDensity/(NC0 (T^(3/2)))] 
,-kB T Log[DopeDensity/(NV0 (T^(3/2))) ] ]
] ;
DepletionW[T_,Vbias_,JuncDopant_, SemiParm_]:=Module[{Eg, me, gc, mh,ϵ
,Dopant1, Dopant2,
ContactV, V0, W,
,aB=5.29177*10^(-9)
,Ryd=13.6057},
{ Eg, me, gc, mh,ϵ}=SemiParm  ;
{Dopant1, Dopant2}=JuncDopant ;
ContactV=Eg+Sign[Dopant1[[1]] ]*FermiLevel[Dopant1,T,SemiParm]+Sign[Dopant2[[1]] ]*FermiLevel[Dopant2,T,SemiParm] ;
V0=ContactV-Vbias ;
W=Sqrt[(ϵ V0/(aB  Ryd))* (1/Dopant1[[2]] +1/Dopant2[[2]]) ]  ;
10^4* W {1, Dopant2[[2]]/(Dopant1[[2]] +Dopant2[[2]])
,Dopant1[[2]]/(Dopant1[[2]] +Dopant2[[2]])  }] ;
ϕJ[x_, T_,Vbias_,JuncDopant_, SemiParm_]:= Module[{Eg, me, gc, mh,ϵ
, ContactV, V0, W, x1,x2},
{ Eg, me, gc, mh,ϵ}=SemiParm  ; 
{W, x1,x2} =DepletionW[T,Vbias,JuncDopant, SemiParm] ;
ContactV=Eg+Sign[JuncDopant[[1,1]] ]*FermiLevel[JuncDopant[[1]],T,SemiParm]+Sign[JuncDopant[[2,1]] ]*FermiLevel[JuncDopant[[2]] ,T,SemiParm] ;
V0=ContactV-Vbias ;
Sign[JuncDopant[[1,1]] ]*If[x≤-x1,0.,If[x≤ 0., V0  (x+x1)^2 /(x1*W),
If[x≤ x2, V0*(1-(x-x2)^2/(x2*W)) ,V0]
]
]
] ;
BandDiagram[x_, T_,Vbias_,JuncDopant_, SemiParm_]:= Module[{Eg, me, gc, mh,ϵ
, ContactV, V0, W,w, x1,x2},
{ Eg, me, gc, mh,ϵ}=SemiParm  ; 
{W, x1,x2} =DepletionW[T,Vbias,JuncDopant, SemiParm] ;
ContactV=Eg+Sign[JuncDopant[[1,1]] ]*FermiLevel[JuncDopant[[1]],T,SemiParm]+Sign[JuncDopant[[2,1]] ]*FermiLevel[JuncDopant[[2]] ,T,SemiParm] ;
V0=ContactV-Vbias ;
w=Sign[JuncDopant[[1,1]] ]*If[x≤-x1,0.,If[x≤ 0., V0  (x+x1)^2 /(x1*W),
If[x≤ x2, V0*(1-(x-x2)^2/(x2*W)) ,V0]
]
] ;
w-FermiLevel[JuncDopant[[1]],T,SemiParm]
+{Sign[JuncDopant[[2,1]] ]*Eg,0.} 
] ;

FermiLine[x_, T_,Vbias_,JuncDopant_, SemiParm_]:=Module[{Eg, me, gc, mh,ϵ
, ContactV, V0, W, x1,x2},
{ Eg, me, gc, mh,ϵ}=SemiParm  ; 
{W, x1,x2} =DepletionW[T,Vbias,JuncDopant, SemiParm] ;
ContactV=Eg+Sign[JuncDopant[[1,1]] ]*FermiLevel[JuncDopant[[1]],T,SemiParm]+Sign[JuncDopant[[2,1]] ]*FermiLevel[JuncDopant[[2]] ,T,SemiParm] ;
V0=ContactV-Vbias ;
If[x≥- x1,-Sign[JuncDopant[[1,1]] ]*Vbias,  ]
];
CarrierEqui[x_, T_,JuncDopant_, SemiParm_]:= Module[{Eg, me, gc, mh,ϵ 
,NC0,NV0, F
, kB=  8.61739*10^(-5)},
{ Eg, me, gc, mh,ϵ}=SemiParm  ; 
{NC0,NV0}= NDOS0[SemiParm] ;
F=BandDiagram[x, T,0.,JuncDopant, SemiParm] ;
If[JuncDopant[[1,1]]>0, 
{NC0 (T^(3/2)) (E^(-F[[2]]/(kB T))), NV0 (T^(3/2)) (E^(F[[1]]/(kB T))), NC0 (T^(3/2)) (E^(-F[[2]]/(kB T)))  +  NV0 (T^(3/2)) (E^(F[[1]]/(kB T)))} 
, {NC0 (T^(3/2)) (E^(-F[[1]]/(kB T))), NV0 (T^(3/2)) (E^(F[[2]]/(kB T))), NC0 (T^(3/2)) (E^(-F[[1]]/(kB T)))  +  NV0 (T^(3/2)) (E^(F[[2]]/(kB T)))}
]
];
CarrierJ[x_, T_,Vbias_,JuncDopant_, SemiParm_,DiffParm_]:= Module[{Eg, me, gc, mh,ϵ
, μn,μp,τ,Ln, Lp 
,NC0,NV0
, W, x1,x2
,q1,q2,F1,F2,G
, kB=  8.61739*10^(-5)},
{ Eg, me, gc, mh,ϵ}=SemiParm  ; 
{ μn,μp,τ,Ln,Lp}=DiffParm  ;
If[Ln==0. || TrueQ[Ln== Null], Ln=10^4*Sqrt[μn kB T τ], ];
If[Lp==0. || TrueQ[Lp ==  Null],Lp=10^4*Sqrt[μp kB T τ], ];
{NC0,NV0}= NDOS0[SemiParm] ;
{W, x1,x2} =DepletionW[T,Vbias,JuncDopant, SemiParm] ;
F1=BandDiagram[-x1, T,0.,JuncDopant, SemiParm] ;
F2=BandDiagram[x2, T,0.,JuncDopant, SemiParm] ;
q1=If[JuncDopant[[1,1]]≥ 0., NV0 (T^(3/2.)) (E^(F1[[1]]/(kB T))), NC0 (T^(3/2.)) (E^(-F1[[1]]/(kB T)))] ;
q2=If[JuncDopant[[1,1]]≥ 0., NC0 (T^(3/2.)) (E^(-F2[[2]]/(kB T))), NV0 (T^(3/2.)) (E^(F2[[2]]/(kB T)))] ;
G=Exp[Vbias/(kB T)]-1;
If[JuncDopant[[1,1]]≥ 0.,
If[x≤ -x1, q1 G  (E^((x+x1)/Lp)),
If [x≥ x2, q2 G  (E^(-(x-x2)/Ln)), ]
]
, If[x≤ -x1, q1 G  (E^((x+x1)/Ln)),
If [x≥ x2, q2 G  (E^(-(x-x2)/Lp)), ]
]
]
]  ;
DiffJ[x_, T_,Vbias_,JuncDopant_, SemiParm_,DiffParm_]:= Module[{Eg, me, gc, mh,ϵ
, μn,μp,τ,Ln, Lp 
,NC0,NV0
, W, x1,x2
,q1,q2,F1,F2,G
, kB=  8.61739*10^(-5)},
{ Eg, me, gc, mh,ϵ}=SemiParm  ; 
{ μn,μp,τ,Ln,Lp}=DiffParm  ;
If[Ln==0. || TrueQ[Ln== Null], Ln=10^4*Sqrt[μn kB T τ], ];
If[Lp==0. || TrueQ[Lp ==  Null],Lp=10^4*Sqrt[μp kB T τ], ];
{NC0,NV0}= NDOS0[SemiParm] ;
{W, x1,x2} =DepletionW[T,Vbias,JuncDopant, SemiParm] ;
F1=BandDiagram[-x1, T,0.,JuncDopant, SemiParm] ;
F2=BandDiagram[x2, T,0.,JuncDopant, SemiParm] ;
q1=If[JuncDopant[[1,1]]>0, NV0 (T^(3/2)) (E^(F1[[1]]/(kB T))), NC0 (T^(3/2)) (E^(-F1[[1]]/(kB T)))] ;
q2=If[JuncDopant[[1,1]]>0, NC0 (T^(3/2)) (E^(-F2[[2]]/(kB T))), NV0 (T^(3/2)) (E^(F2[[2]]/(kB T)))] ;
G=Exp[Vbias/(kB T)]-1;
1.602176487`*^-23*If[JuncDopant[[1,1]]>0,
If[x≤ -x1,Lp q1 G  (E^((x+x1)/Lp))/τ,
If [x≥ x2,Ln q2 G  (E^(-(x-x2)/Ln))/τ, ]
]
, If[x≤ -x1,Ln q1 G  (E^((x+x1)/Ln))/τ,
If [x≥ x2,Lp q2 G  (E^(-(x-x2)/Lp))/τ, ]
]
]
]  ;
DiodeC[ T_,Vbias_,JuncDopant_, SemiParm_,DiffParm_]:= Module[{Eg, me, gc, mh,ϵ
, μn,μp,τ,Ln, Lp 
,NC0,NV0
, W, x1,x2
,q1,q2,F1,F2,G
, kB=  8.61739*10^(-5)},
{ Eg, me, gc, mh,ϵ}=SemiParm  ; 
{ μn,μp,τ,Ln,Lp}=DiffParm  ;
If[Ln==0. || TrueQ[Ln== Null], Ln=10^4*Sqrt[μn kB T τ], ];
If[Lp==0. || TrueQ[Lp ==  Null],Lp=10^4*Sqrt[μp kB T τ], ];
{NC0,NV0}= NDOS0[SemiParm] ;
{W, x1,x2} =DepletionW[T,Vbias,JuncDopant, SemiParm] ;
F1=BandDiagram[-x1, T,0.,JuncDopant, SemiParm] ;
F2=BandDiagram[x2, T,0.,JuncDopant, SemiParm] ;
q1=If[JuncDopant[[1,1]]>0, NV0 (T^(3/2)) (E^(F1[[1]]/(kB T))), NC0 (T^(3/2)) (E^(-F1[[1]]/(kB T)))] ;
q2=If[JuncDopant[[1,1]]>0, NC0 (T^(3/2)) (E^(-F2[[2]]/(kB T))), NV0 (T^(3/2)) (E^(F2[[2]]/(kB T)))] ;
G=Exp[Vbias/(kB T)]-1;
1.602176487`*^-23*If[JuncDopant[[1,1]]>0,
( Lp q1 +Ln q2 ) G  /τ ,( Ln q1 +Lp q2 ) G /τ]
]  ;
DiodeC1[ T_,Vbias_,JuncDopant_, SemiParm_,DiffParm_]:= Module[{Eg, me, gc, mh,ϵ
, μn,μp,τ,Ln, Lp 
,NC0,NV0
, W, x1,x2,ContactV,Ef1,Ef2
,q1,q2,F1,F2,G,r1,r2,H
, kB=  8.61739*10^(-5)},
{ Eg, me, gc, mh,ϵ}=SemiParm  ; 
{ μn,μp,τ,Ln,Lp}=DiffParm  ;
If[Ln==0. || TrueQ[Ln== Null], Ln=10^4*Sqrt[μn kB T τ], ];
If[Lp==0. || TrueQ[Lp ==  Null],Lp=10^4*Sqrt[μp kB T τ], ];
{NC0,NV0}= NDOS0[SemiParm] ;
Ef1=  FermiLevel[JuncDopant[[1]],T,SemiParm];
Ef2=  FermiLevel[JuncDopant[[2]],T,SemiParm];
ContactV=Eg+Sign[JuncDopant[[1,1]] ]*FermiLevel[JuncDopant[[1]],T,SemiParm]+Sign[JuncDopant[[2,1]] ]*FermiLevel[JuncDopant[[2]] ,T,SemiParm] ;
{W, x1,x2} =DepletionW[T,Vbias,JuncDopant, SemiParm] ;
F1=BandDiagram[-x1, T,0.,JuncDopant, SemiParm] ;
F2=BandDiagram[x2, T,0.,JuncDopant, SemiParm] ;
q1=If[JuncDopant[[1,1]]>0, NV0 (T^(3/2)) (E^(F1[[1]]/(kB T))), NC0 (T^(3/2)) (E^(-F1[[1]]/(kB T)))] ;
q2=If[JuncDopant[[1,1]]>0, NC0 (T^(3/2)) (E^(-F2[[2]]/(kB T))), NV0 (T^(3/2)) (E^(F2[[2]]/(kB T)))] ;
r1=  If[JuncDopant[[1,1]]>0,(mh/me)^3/2  *Exp[(F1[[1]]+F1[[2]])/(kB T)] , (me/mh)^3/2  *Exp[-(F1[[1]]+F1[[2]])/(kB T)] ] ;
r2=   If[JuncDopant[[1,1]]>0,(me/mh)^3/2  *Exp[-(F2[[1]]+F2[[2]])/(kB T)] , (mh/me)^3/2  *Exp[(F2[[1]]+F2[[2]])/(kB T)] ] ;
G=Exp[Vbias/(kB T)]-1; H=1-Exp[-2(ContactV-Vbias)/(kB T)] ;
1.602176487`*^-23*If[JuncDopant[[1,1]]>0,
( Lp q1 (1+r1 (G+1)) +Ln q2  (1+ r2 (G+1))) G  /(τ H)
,( Ln q1 (1+r1 (G+1)) +Lp q2 (1+ r2 (G+1)) ) G /(τ H)]
];

 start=0, ];
Manipulate[
SemiParm={ Eg, me,gc, mh,ϵ } ;   (* this is GaAs  *) 
Manipulate[dtype=If[dope=="p-n",-1,1] ;
 Plot[ϕJ[x, T,0.,{ {dtype,10^d1},{-dtype,10^d2} }, SemiParm],{x,-xR,xR}, PlotRange-> All
,Frame-> True, GridLines-> Automatic
,PlotStyle->{Thick,Purple}
,FrameLabel->{"Position (μm)","Static potential energy (eV)"}
,LabelStyle->Directive[14,FontFamily-> "Arial"]]
,{{dope,"p-n"},{"p-n","n-p"},ControlType-> SetterBar}
,{{d1,17,"Left p-dope level 10^"},14,18},{{d2,17,"Right n-dope level 10^"},14,18}
,{{T,300,"Temperature (K)"},100,400}
,{{xR,2},0.1,20}
]
,Grid[{{ Control[{{Eg,1.42,"Bandgap (eV)"},0.3,4}]
,Control[{{ϵ,13.6,"Dielectric const."},4,20}]}
,{Control[{{me,0.0665,"Elec eff mass me*"},0.02,0.5}]
,Control[{{mh,0.5,"Hole eff mass mh*"},0.02,1}]}
,{Control[{{gc,1,"Cond band degeneracy"},{1,6}}]}
}]
]
,
{{start,1,"Click to start"},{0,1}} ]

2.5 Illustration a: electrostatic potential

Band diagram at the junction at equilibrium with simplified space charge

Manipulate[
If[start==1,
NDOS0[SemiParm_]:= Module[{ Eg, me, gc, mh,ϵ},
{ Eg, me, gc, mh,ϵ}=SemiParm ;
4.829415887919019`*^15  {gc  (me^(3/2)) , (mh^(3/2))} 
];
FermiLevel[Dopant_,T_,SemiParm_]:=Module[{Eg, me, gc, mh,ϵ
, NC0,NV0,type, DopeDensity, kB=  8.61739*10^(-5)},
{ Eg, me, gc, mh,ϵ}=SemiParm  ;
{NC0,NV0}= NDOS0[SemiParm] ;
{type, DopeDensity}=Dopant ;
If[type>0  , 
kB T Log[DopeDensity/(NC0 (T^(3/2)))] 
,-kB T Log[DopeDensity/(NV0 (T^(3/2))) ] ]
] ;
DepletionW[T_,Vbias_,JuncDopant_, SemiParm_]:=Module[{Eg, me, gc, mh,ϵ
,Dopant1, Dopant2,
ContactV, V0, W,
,aB=5.29177*10^(-9)
,Ryd=13.6057},
{ Eg, me, gc, mh,ϵ}=SemiParm  ;
{Dopant1, Dopant2}=JuncDopant ;
ContactV=Eg+Sign[Dopant1[[1]] ]*FermiLevel[Dopant1,T,SemiParm]+Sign[Dopant2[[1]] ]*FermiLevel[Dopant2,T,SemiParm] ;
V0=ContactV-Vbias ;
W=Sqrt[(ϵ V0/(aB  Ryd))* (1/Dopant1[[2]] +1/Dopant2[[2]]) ]  ;
10^4* W {1, Dopant2[[2]]/(Dopant1[[2]] +Dopant2[[2]])
,Dopant1[[2]]/(Dopant1[[2]] +Dopant2[[2]])  }] ;
ϕJ[x_, T_,Vbias_,JuncDopant_, SemiParm_]:= Module[{Eg, me, gc, mh,ϵ
, ContactV, V0, W, x1,x2},
{ Eg, me, gc, mh,ϵ}=SemiParm  ; 
{W, x1,x2} =DepletionW[T,Vbias,JuncDopant, SemiParm] ;
ContactV=Eg+Sign[JuncDopant[[1,1]] ]*FermiLevel[JuncDopant[[1]],T,SemiParm]+Sign[JuncDopant[[2,1]] ]*FermiLevel[JuncDopant[[2]] ,T,SemiParm] ;
V0=ContactV-Vbias ;
Sign[JuncDopant[[1,1]] ]*If[x≤-x1,0.,If[x≤ 0., V0  (x+x1)^2 /(x1*W),
If[x≤ x2, V0*(1-(x-x2)^2/(x2*W)) ,V0]
]
]
] ;
BandDiagram[x_, T_,Vbias_,JuncDopant_, SemiParm_]:= Module[{Eg, me, gc, mh,ϵ
, ContactV, V0, W,w, x1,x2},
{ Eg, me, gc, mh,ϵ}=SemiParm  ; 
{W, x1,x2} =DepletionW[T,Vbias,JuncDopant, SemiParm] ;
ContactV=Eg+Sign[JuncDopant[[1,1]] ]*FermiLevel[JuncDopant[[1]],T,SemiParm]+Sign[JuncDopant[[2,1]] ]*FermiLevel[JuncDopant[[2]] ,T,SemiParm] ;
V0=ContactV-Vbias ;
w=Sign[JuncDopant[[1,1]] ]*If[x≤-x1,0.,If[x≤ 0., V0  (x+x1)^2 /(x1*W),
If[x≤ x2, V0*(1-(x-x2)^2/(x2*W)) ,V0]
]
] ;
w-FermiLevel[JuncDopant[[1]],T,SemiParm]
+{Sign[JuncDopant[[2,1]] ]*Eg,0.} 
] ;

FermiLine[x_, T_,Vbias_,JuncDopant_, SemiParm_]:=Module[{Eg, me, gc, mh,ϵ
, ContactV, V0, W, x1,x2},
{ Eg, me, gc, mh,ϵ}=SemiParm  ; 
{W, x1,x2} =DepletionW[T,Vbias,JuncDopant, SemiParm] ;
ContactV=Eg+Sign[JuncDopant[[1,1]] ]*FermiLevel[JuncDopant[[1]],T,SemiParm]+Sign[JuncDopant[[2,1]] ]*FermiLevel[JuncDopant[[2]] ,T,SemiParm] ;
V0=ContactV-Vbias ;
If[x≥- x1,-Sign[JuncDopant[[1,1]] ]*Vbias,  ]
];
CarrierEqui[x_, T_,JuncDopant_, SemiParm_]:= Module[{Eg, me, gc, mh,ϵ 
,NC0,NV0, F
, kB=  8.61739*10^(-5)},
{ Eg, me, gc, mh,ϵ}=SemiParm  ; 
{NC0,NV0}= NDOS0[SemiParm] ;
F=BandDiagram[x, T,0.,JuncDopant, SemiParm] ;
If[JuncDopant[[1,1]]>0, 
{NC0 (T^(3/2)) (E^(-F[[2]]/(kB T))), NV0 (T^(3/2)) (E^(F[[1]]/(kB T))), NC0 (T^(3/2)) (E^(-F[[2]]/(kB T)))  +  NV0 (T^(3/2)) (E^(F[[1]]/(kB T)))} 
, {NC0 (T^(3/2)) (E^(-F[[1]]/(kB T))), NV0 (T^(3/2)) (E^(F[[2]]/(kB T))), NC0 (T^(3/2)) (E^(-F[[1]]/(kB T)))  +  NV0 (T^(3/2)) (E^(F[[2]]/(kB T)))}
]
];
CarrierJ[x_, T_,Vbias_,JuncDopant_, SemiParm_,DiffParm_]:= Module[{Eg, me, gc, mh,ϵ
, μn,μp,τ,Ln, Lp 
,NC0,NV0
, W, x1,x2
,q1,q2,F1,F2,G
, kB=  8.61739*10^(-5)},
{ Eg, me, gc, mh,ϵ}=SemiParm  ; 
{ μn,μp,τ,Ln,Lp}=DiffParm  ;
If[Ln==0. || TrueQ[Ln== Null], Ln=10^4*Sqrt[μn kB T τ], ];
If[Lp==0. || TrueQ[Lp ==  Null],Lp=10^4*Sqrt[μp kB T τ], ];
{NC0,NV0}= NDOS0[SemiParm] ;
{W, x1,x2} =DepletionW[T,Vbias,JuncDopant, SemiParm] ;
F1=BandDiagram[-x1, T,0.,JuncDopant, SemiParm] ;
F2=BandDiagram[x2, T,0.,JuncDopant, SemiParm] ;
q1=If[JuncDopant[[1,1]]≥ 0., NV0 (T^(3/2.)) (E^(F1[[1]]/(kB T))), NC0 (T^(3/2.)) (E^(-F1[[1]]/(kB T)))] ;
q2=If[JuncDopant[[1,1]]≥ 0., NC0 (T^(3/2.)) (E^(-F2[[2]]/(kB T))), NV0 (T^(3/2.)) (E^(F2[[2]]/(kB T)))] ;
G=Exp[Vbias/(kB T)]-1;
If[JuncDopant[[1,1]]≥ 0.,
If[x≤ -x1, q1 G  (E^((x+x1)/Lp)),
If [x≥ x2, q2 G  (E^(-(x-x2)/Ln)), ]
]
, If[x≤ -x1, q1 G  (E^((x+x1)/Ln)),
If [x≥ x2, q2 G  (E^(-(x-x2)/Lp)), ]
]
]
]  ;
DiffJ[x_, T_,Vbias_,JuncDopant_, SemiParm_,DiffParm_]:= Module[{Eg, me, gc, mh,ϵ
, μn,μp,τ,Ln, Lp 
,NC0,NV0
, W, x1,x2
,q1,q2,F1,F2,G
, kB=  8.61739*10^(-5)},
{ Eg, me, gc, mh,ϵ}=SemiParm  ; 
{ μn,μp,τ,Ln,Lp}=DiffParm  ;
If[Ln==0. || TrueQ[Ln== Null], Ln=10^4*Sqrt[μn kB T τ], ];
If[Lp==0. || TrueQ[Lp ==  Null],Lp=10^4*Sqrt[μp kB T τ], ];
{NC0,NV0}= NDOS0[SemiParm] ;
{W, x1,x2} =DepletionW[T,Vbias,JuncDopant, SemiParm] ;
F1=BandDiagram[-x1, T,0.,JuncDopant, SemiParm] ;
F2=BandDiagram[x2, T,0.,JuncDopant, SemiParm] ;
q1=If[JuncDopant[[1,1]]>0, NV0 (T^(3/2)) (E^(F1[[1]]/(kB T))), NC0 (T^(3/2)) (E^(-F1[[1]]/(kB T)))] ;
q2=If[JuncDopant[[1,1]]>0, NC0 (T^(3/2)) (E^(-F2[[2]]/(kB T))), NV0 (T^(3/2)) (E^(F2[[2]]/(kB T)))] ;
G=Exp[Vbias/(kB T)]-1;
1.602176487`*^-23*If[JuncDopant[[1,1]]>0,
If[x≤ -x1,Lp q1 G  (E^((x+x1)/Lp))/τ,
If [x≥ x2,Ln q2 G  (E^(-(x-x2)/Ln))/τ, ]
]
, If[x≤ -x1,Ln q1 G  (E^((x+x1)/Ln))/τ,
If [x≥ x2,Lp q2 G  (E^(-(x-x2)/Lp))/τ, ]
]
]
]  ;
DiodeC[ T_,Vbias_,JuncDopant_, SemiParm_,DiffParm_]:= Module[{Eg, me, gc, mh,ϵ
, μn,μp,τ,Ln, Lp 
,NC0,NV0
, W, x1,x2
,q1,q2,F1,F2,G
, kB=  8.61739*10^(-5)},
{ Eg, me, gc, mh,ϵ}=SemiParm  ; 
{ μn,μp,τ,Ln,Lp}=DiffParm  ;
If[Ln==0. || TrueQ[Ln== Null], Ln=10^4*Sqrt[μn kB T τ], ];
If[Lp==0. || TrueQ[Lp ==  Null],Lp=10^4*Sqrt[μp kB T τ], ];
{NC0,NV0}= NDOS0[SemiParm] ;
{W, x1,x2} =DepletionW[T,Vbias,JuncDopant, SemiParm] ;
F1=BandDiagram[-x1, T,0.,JuncDopant, SemiParm] ;
F2=BandDiagram[x2, T,0.,JuncDopant, SemiParm] ;
q1=If[JuncDopant[[1,1]]>0, NV0 (T^(3/2)) (E^(F1[[1]]/(kB T))), NC0 (T^(3/2)) (E^(-F1[[1]]/(kB T)))] ;
q2=If[JuncDopant[[1,1]]>0, NC0 (T^(3/2)) (E^(-F2[[2]]/(kB T))), NV0 (T^(3/2)) (E^(F2[[2]]/(kB T)))] ;
G=Exp[Vbias/(kB T)]-1;
1.602176487`*^-23*If[JuncDopant[[1,1]]>0,
( Lp q1 +Ln q2 ) G  /τ ,( Ln q1 +Lp q2 ) G /τ]
]  ;
DiodeC1[ T_,Vbias_,JuncDopant_, SemiParm_,DiffParm_]:= Module[{Eg, me, gc, mh,ϵ
, μn,μp,τ,Ln, Lp 
,NC0,NV0
, W, x1,x2,ContactV,Ef1,Ef2
,q1,q2,F1,F2,G,r1,r2,H
, kB=  8.61739*10^(-5)},
{ Eg, me, gc, mh,ϵ}=SemiParm  ; 
{ μn,μp,τ,Ln,Lp}=DiffParm  ;
If[Ln==0. || TrueQ[Ln== Null], Ln=10^4*Sqrt[μn kB T τ], ];
If[Lp==0. || TrueQ[Lp ==  Null],Lp=10^4*Sqrt[μp kB T τ], ];
{NC0,NV0}= NDOS0[SemiParm] ;
Ef1=  FermiLevel[JuncDopant[[1]],T,SemiParm];
Ef2=  FermiLevel[JuncDopant[[2]],T,SemiParm];
ContactV=Eg+Sign[JuncDopant[[1,1]] ]*FermiLevel[JuncDopant[[1]],T,SemiParm]+Sign[JuncDopant[[2,1]] ]*FermiLevel[JuncDopant[[2]] ,T,SemiParm] ;
{W, x1,x2} =DepletionW[T,Vbias,JuncDopant, SemiParm] ;
F1=BandDiagram[-x1, T,0.,JuncDopant, SemiParm] ;
F2=BandDiagram[x2, T,0.,JuncDopant, SemiParm] ;
q1=If[JuncDopant[[1,1]]>0, NV0 (T^(3/2)) (E^(F1[[1]]/(kB T))), NC0 (T^(3/2)) (E^(-F1[[1]]/(kB T)))] ;
q2=If[JuncDopant[[1,1]]>0, NC0 (T^(3/2)) (E^(-F2[[2]]/(kB T))), NV0 (T^(3/2)) (E^(F2[[2]]/(kB T)))] ;
r1=  If[JuncDopant[[1,1]]>0,(mh/me)^3/2  *Exp[(F1[[1]]+F1[[2]])/(kB T)] , (me/mh)^3/2  *Exp[-(F1[[1]]+F1[[2]])/(kB T)] ] ;
r2=   If[JuncDopant[[1,1]]>0,(me/mh)^3/2  *Exp[-(F2[[1]]+F2[[2]])/(kB T)] , (mh/me)^3/2  *Exp[(F2[[1]]+F2[[2]])/(kB T)] ] ;
G=Exp[Vbias/(kB T)]-1; H=1-Exp[-2(ContactV-Vbias)/(kB T)] ;
1.602176487`*^-23*If[JuncDopant[[1,1]]>0,
( Lp q1 (1+r1 (G+1)) +Ln q2  (1+ r2 (G+1))) G  /(τ H)
,( Ln q1 (1+r1 (G+1)) +Lp q2 (1+ r2 (G+1)) ) G /(τ H)]
];

 start=0, ];
Manipulate[
SemiParm={ Eg, me,gc, mh,ϵ } ;   (* this is GaAs  *) 
Manipulate[Vbias=0.;  
dtype=If[dope=="p-n",-1,1] ;Show[Plot[BandDiagram[x, T,Vbias,{ {dtype,10^d1},{-dtype,10^d2} }, SemiParm],{x,xL,xR}, PlotRange-> All, PlotStyle-> Thick
,Frame-> True, GridLines-> Automatic
,FrameLabel->{"Position (μm)","Energy (eV)"}
,LabelStyle->Directive[14,FontFamily-> "Arial"]
]
,Graphics[{If[dtype<0,Red,Blue], Rectangle[{0,0}
,{DepletionW[T,Vbias,{ {dtype,10^d1},{-dtype,10^d2} }, SemiParm][[3]],-Sign[dtype]* 10^d2/(10^d1+10^d2)}]} ]
,Graphics[ {If[dtype<0,Blue,Red],Rectangle[
{-DepletionW[T,Vbias,{ {dtype,10^d1},{-dtype,10^d2} }, SemiParm][[2]]
,Sign[dtype]*10^d1/(10^d1+10^d2)},{0,0}]}
]
, Plot[BandDiagram[x, T,Vbias,{ {dtype,10^d1},{-dtype,10^d2} }, SemiParm][[2]],{x,xL,xR}, PlotRange-> All, PlotStyle-> {Thick, Purple}]
, Plot[BandDiagram[x, T,Vbias,{ {dtype,10^d1},{-dtype,10^d2} }, SemiParm][[1]],{x,xL,xR}, PlotRange-> All, PlotStyle-> {Thick, Hue[0.4,1,0.5]}]
,PlotRange-> {{xL,xR},All}
 ]
,{{dope,"p-n"},{"p-n","n-p"}},{{d1,17,"left doping ^10"},14,18},{{d2,17,"right doping ^10"},14,18}
,{{T,300,"Temperature (K)"},100,400}
,{{xR,2," xR range (μm)"},0.1,20}
,{{xL,-2," xL range (μm)"},-20,-0.1}]
,Grid[{{ Control[{{Eg,1.42,"Bandgap (eV)"},0.3,4}]
,Control[{{ϵ,13.6,"Dielectric const."},4,20}]}
,{Control[{{me,0.0665,"Elec eff mass me*"},0.02,0.5}]
,Control[{{mh,0.5,"Hole eff mass mh*"},0.02,1}]}
,{Control[{{gc,1,"Cond band degeneracy"},{1,6}}]}
}]
]
,
{{start,1,"Click to start"},{0,1}} ]

2.6 Illustration b: carrier densities

2.6.1 Linear scale

Carrier densities at the junction at equilibrium - linear scale

Manipulate[
If[start==1,
NDOS0[SemiParm_]:= Module[{ Eg, me, gc, mh,ϵ},
{ Eg, me, gc, mh,ϵ}=SemiParm ;
4.829415887919019`*^15  {gc  (me^(3/2)) , (mh^(3/2))} 
];
FermiLevel[Dopant_,T_,SemiParm_]:=Module[{Eg, me, gc, mh,ϵ
, NC0,NV0,type, DopeDensity, kB=  8.61739*10^(-5)},
{ Eg, me, gc, mh,ϵ}=SemiParm  ;
{NC0,NV0}= NDOS0[SemiParm] ;
{type, DopeDensity}=Dopant ;
If[type>0  , 
kB T Log[DopeDensity/(NC0 (T^(3/2)))] 
,-kB T Log[DopeDensity/(NV0 (T^(3/2))) ] ]
] ;
DepletionW[T_,Vbias_,JuncDopant_, SemiParm_]:=Module[{Eg, me, gc, mh,ϵ
,Dopant1, Dopant2,
ContactV, V0, W,
,aB=5.29177*10^(-9)
,Ryd=13.6057},
{ Eg, me, gc, mh,ϵ}=SemiParm  ;
{Dopant1, Dopant2}=JuncDopant ;
ContactV=Eg+Sign[Dopant1[[1]] ]*FermiLevel[Dopant1,T,SemiParm]+Sign[Dopant2[[1]] ]*FermiLevel[Dopant2,T,SemiParm] ;
V0=ContactV-Vbias ;
W=Sqrt[(ϵ V0/(aB  Ryd))* (1/Dopant1[[2]] +1/Dopant2[[2]]) ]  ;
10^4* W {1, Dopant2[[2]]/(Dopant1[[2]] +Dopant2[[2]])
,Dopant1[[2]]/(Dopant1[[2]] +Dopant2[[2]])  }] ;
ϕJ[x_, T_,Vbias_,JuncDopant_, SemiParm_]:= Module[{Eg, me, gc, mh,ϵ
, ContactV, V0, W, x1,x2},
{ Eg, me, gc, mh,ϵ}=SemiParm  ; 
{W, x1,x2} =DepletionW[T,Vbias,JuncDopant, SemiParm] ;
ContactV=Eg+Sign[JuncDopant[[1,1]] ]*FermiLevel[JuncDopant[[1]],T,SemiParm]+Sign[JuncDopant[[2,1]] ]*FermiLevel[JuncDopant[[2]] ,T,SemiParm] ;
V0=ContactV-Vbias ;
Sign[JuncDopant[[1,1]] ]*If[x≤-x1,0.,If[x≤ 0., V0  (x+x1)^2 /(x1*W),
If[x≤ x2, V0*(1-(x-x2)^2/(x2*W)) ,V0]
]
]
] ;
BandDiagram[x_, T_,Vbias_,JuncDopant_, SemiParm_]:= Module[{Eg, me, gc, mh,ϵ
, ContactV, V0, W,w, x1,x2},
{ Eg, me, gc, mh,ϵ}=SemiParm  ; 
{W, x1,x2} =DepletionW[T,Vbias,JuncDopant, SemiParm] ;
ContactV=Eg+Sign[JuncDopant[[1,1]] ]*FermiLevel[JuncDopant[[1]],T,SemiParm]+Sign[JuncDopant[[2,1]] ]*FermiLevel[JuncDopant[[2]] ,T,SemiParm] ;
V0=ContactV-Vbias ;
w=Sign[JuncDopant[[1,1]] ]*If[x≤-x1,0.,If[x≤ 0., V0  (x+x1)^2 /(x1*W),
If[x≤ x2, V0*(1-(x-x2)^2/(x2*W)) ,V0]
]
] ;
w-FermiLevel[JuncDopant[[1]],T,SemiParm]
+{Sign[JuncDopant[[2,1]] ]*Eg,0.} 
] ;

FermiLine[x_, T_,Vbias_,JuncDopant_, SemiParm_]:=Module[{Eg, me, gc, mh,ϵ
, ContactV, V0, W, x1,x2},
{ Eg, me, gc, mh,ϵ}=SemiParm  ; 
{W, x1,x2} =DepletionW[T,Vbias,JuncDopant, SemiParm] ;
ContactV=Eg+Sign[JuncDopant[[1,1]] ]*FermiLevel[JuncDopant[[1]],T,SemiParm]+Sign[JuncDopant[[2,1]] ]*FermiLevel[JuncDopant[[2]] ,T,SemiParm] ;
V0=ContactV-Vbias ;
If[x≥- x1,-Sign[JuncDopant[[1,1]] ]*Vbias,  ]
];
CarrierEqui[x_, T_,JuncDopant_, SemiParm_]:= Module[{Eg, me, gc, mh,ϵ 
,NC0,NV0, F
, kB=  8.61739*10^(-5)},
{ Eg, me, gc, mh,ϵ}=SemiParm  ; 
{NC0,NV0}= NDOS0[SemiParm] ;
F=BandDiagram[x, T,0.,JuncDopant, SemiParm] ;
If[JuncDopant[[1,1]]>0, 
{NC0 (T^(3/2)) (E^(-F[[2]]/(kB T))), NV0 (T^(3/2)) (E^(F[[1]]/(kB T))), NC0 (T^(3/2)) (E^(-F[[2]]/(kB T)))  +  NV0 (T^(3/2)) (E^(F[[1]]/(kB T)))} 
, {NC0 (T^(3/2)) (E^(-F[[1]]/(kB T))), NV0 (T^(3/2)) (E^(F[[2]]/(kB T))), NC0 (T^(3/2)) (E^(-F[[1]]/(kB T)))  +  NV0 (T^(3/2)) (E^(F[[2]]/(kB T)))}
]
];
CarrierJ[x_, T_,Vbias_,JuncDopant_, SemiParm_,DiffParm_]:= Module[{Eg, me, gc, mh,ϵ
, μn,μp,τ,Ln, Lp 
,NC0,NV0
, W, x1,x2
,q1,q2,F1,F2,G
, kB=  8.61739*10^(-5)},
{ Eg, me, gc, mh,ϵ}=SemiParm  ; 
{ μn,μp,τ,Ln,Lp}=DiffParm  ;
If[Ln==0. || TrueQ[Ln== Null], Ln=10^4*Sqrt[μn kB T τ], ];
If[Lp==0. || TrueQ[Lp ==  Null],Lp=10^4*Sqrt[μp kB T τ], ];
{NC0,NV0}= NDOS0[SemiParm] ;
{W, x1,x2} =DepletionW[T,Vbias,JuncDopant, SemiParm] ;
F1=BandDiagram[-x1, T,0.,JuncDopant, SemiParm] ;
F2=BandDiagram[x2, T,0.,JuncDopant, SemiParm] ;
q1=If[JuncDopant[[1,1]]≥ 0., NV0 (T^(3/2.)) (E^(F1[[1]]/(kB T))), NC0 (T^(3/2.)) (E^(-F1[[1]]/(kB T)))] ;
q2=If[JuncDopant[[1,1]]≥ 0., NC0 (T^(3/2.)) (E^(-F2[[2]]/(kB T))), NV0 (T^(3/2.)) (E^(F2[[2]]/(kB T)))] ;
G=Exp[Vbias/(kB T)]-1;
If[JuncDopant[[1,1]]≥ 0.,
If[x≤ -x1, q1 G  (E^((x+x1)/Lp)),
If [x≥ x2, q2 G  (E^(-(x-x2)/Ln)), ]
]
, If[x≤ -x1, q1 G  (E^((x+x1)/Ln)),
If [x≥ x2, q2 G  (E^(-(x-x2)/Lp)), ]
]
]
]  ;
DiffJ[x_, T_,Vbias_,JuncDopant_, SemiParm_,DiffParm_]:= Module[{Eg, me, gc, mh,ϵ
, μn,μp,τ,Ln, Lp 
,NC0,NV0
, W, x1,x2
,q1,q2,F1,F2,G
, kB=  8.61739*10^(-5)},
{ Eg, me, gc, mh,ϵ}=SemiParm  ; 
{ μn,μp,τ,Ln,Lp}=DiffParm  ;
If[Ln==0. || TrueQ[Ln== Null], Ln=10^4*Sqrt[μn kB T τ], ];
If[Lp==0. || TrueQ[Lp ==  Null],Lp=10^4*Sqrt[μp kB T τ], ];
{NC0,NV0}= NDOS0[SemiParm] ;
{W, x1,x2} =DepletionW[T,Vbias,JuncDopant, SemiParm] ;
F1=BandDiagram[-x1, T,0.,JuncDopant, SemiParm] ;
F2=BandDiagram[x2, T,0.,JuncDopant, SemiParm] ;
q1=If[JuncDopant[[1,1]]>0, NV0 (T^(3/2)) (E^(F1[[1]]/(kB T))), NC0 (T^(3/2)) (E^(-F1[[1]]/(kB T)))] ;
q2=If[JuncDopant[[1,1]]>0, NC0 (T^(3/2)) (E^(-F2[[2]]/(kB T))), NV0 (T^(3/2)) (E^(F2[[2]]/(kB T)))] ;
G=Exp[Vbias/(kB T)]-1;
1.602176487`*^-23*If[JuncDopant[[1,1]]>0,
If[x≤ -x1,Lp q1 G  (E^((x+x1)/Lp))/τ,
If [x≥ x2,Ln q2 G  (E^(-(x-x2)/Ln))/τ, ]
]
, If[x≤ -x1,Ln q1 G  (E^((x+x1)/Ln))/τ,
If [x≥ x2,Lp q2 G  (E^(-(x-x2)/Lp))/τ, ]
]
]
]  ;
DiodeC[ T_,Vbias_,JuncDopant_, SemiParm_,DiffParm_]:= Module[{Eg, me, gc, mh,ϵ
, μn,μp,τ,Ln, Lp 
,NC0,NV0
, W, x1,x2
,q1,q2,F1,F2,G
, kB=  8.61739*10^(-5)},
{ Eg, me, gc, mh,ϵ}=SemiParm  ; 
{ μn,μp,τ,Ln,Lp}=DiffParm  ;
If[Ln==0. || TrueQ[Ln== Null], Ln=10^4*Sqrt[μn kB T τ], ];
If[Lp==0. || TrueQ[Lp ==  Null],Lp=10^4*Sqrt[μp kB T τ], ];
{NC0,NV0}= NDOS0[SemiParm] ;
{W, x1,x2} =DepletionW[T,Vbias,JuncDopant, SemiParm] ;
F1=BandDiagram[-x1, T,0.,JuncDopant, SemiParm] ;
F2=BandDiagram[x2, T,0.,JuncDopant, SemiParm] ;
q1=If[JuncDopant[[1,1]]>0, NV0 (T^(3/2)) (E^(F1[[1]]/(kB T))), NC0 (T^(3/2)) (E^(-F1[[1]]/(kB T)))] ;
q2=If[JuncDopant[[1,1]]>0, NC0 (T^(3/2)) (E^(-F2[[2]]/(kB T))), NV0 (T^(3/2)) (E^(F2[[2]]/(kB T)))] ;
G=Exp[Vbias/(kB T)]-1;
1.602176487`*^-23*If[JuncDopant[[1,1]]>0,
( Lp q1 +Ln q2 ) G  /τ ,( Ln q1 +Lp q2 ) G /τ]
]  ;
DiodeC1[ T_,Vbias_,JuncDopant_, SemiParm_,DiffParm_]:= Module[{Eg, me, gc, mh,ϵ
, μn,μp,τ,Ln, Lp 
,NC0,NV0
, W, x1,x2,ContactV,Ef1,Ef2
,q1,q2,F1,F2,G,r1,r2,H
, kB=  8.61739*10^(-5)},
{ Eg, me, gc, mh,ϵ}=SemiParm  ; 
{ μn,μp,τ,Ln,Lp}=DiffParm  ;
If[Ln==0. || TrueQ[Ln== Null], Ln=10^4*Sqrt[μn kB T τ], ];
If[Lp==0. || TrueQ[Lp ==  Null],Lp=10^4*Sqrt[μp kB T τ], ];
{NC0,NV0}= NDOS0[SemiParm] ;
Ef1=  FermiLevel[JuncDopant[[1]],T,SemiParm];
Ef2=  FermiLevel[JuncDopant[[2]],T,SemiParm];
ContactV=Eg+Sign[JuncDopant[[1,1]] ]*FermiLevel[JuncDopant[[1]],T,SemiParm]+Sign[JuncDopant[[2,1]] ]*FermiLevel[JuncDopant[[2]] ,T,SemiParm] ;
{W, x1,x2} =DepletionW[T,Vbias,JuncDopant, SemiParm] ;
F1=BandDiagram[-x1, T,0.,JuncDopant, SemiParm] ;
F2=BandDiagram[x2, T,0.,JuncDopant, SemiParm] ;
q1=If[JuncDopant[[1,1]]>0, NV0 (T^(3/2)) (E^(F1[[1]]/(kB T))), NC0 (T^(3/2)) (E^(-F1[[1]]/(kB T)))] ;
q2=If[JuncDopant[[1,1]]>0, NC0 (T^(3/2)) (E^(-F2[[2]]/(kB T))), NV0 (T^(3/2)) (E^(F2[[2]]/(kB T)))] ;
r1=  If[JuncDopant[[1,1]]>0,(mh/me)^3/2  *Exp[(F1[[1]]+F1[[2]])/(kB T)] , (me/mh)^3/2  *Exp[-(F1[[1]]+F1[[2]])/(kB T)] ] ;
r2=   If[JuncDopant[[1,1]]>0,(me/mh)^3/2  *Exp[-(F2[[1]]+F2[[2]])/(kB T)] , (mh/me)^3/2  *Exp[(F2[[1]]+F2[[2]])/(kB T)] ] ;
G=Exp[Vbias/(kB T)]-1; H=1-Exp[-2(ContactV-Vbias)/(kB T)] ;
1.602176487`*^-23*If[JuncDopant[[1,1]]>0,
( Lp q1 (1+r1 (G+1)) +Ln q2  (1+ r2 (G+1))) G  /(τ H)
,( Ln q1 (1+r1 (G+1)) +Lp q2 (1+ r2 (G+1)) ) G /(τ H)]
];

 start=0, ];
Manipulate[
SemiParm={ Eg, me,gc, mh,ϵ } ;   (* this is GaAs  *)
Manipulate[
dtype=If[dope=="p-n",-1,1] ;
Plot[{CarrierEqui[x, T,{ {dtype,10^d1},{-dtype,10^d2} }, SemiParm][[2]],
CarrierEqui[x, T,{ {dtype,10^d1},{-dtype,10^d2} }, SemiParm][[1]]},
{x,xL,xR}, PlotRange-> All
, Filling->{{1-> {Axis,Hue[0.6,1,1,0.6]}},{2-> {Axis,Hue[0.,1,1,0.5]}}}
,Frame-> True, GridLines-> Automatic
,FrameLabel->{"Position (μm)","Carrier density ((cm^(-3)))"}
,LabelStyle->Directive[14,FontFamily-> "Arial"]]

,{{dope,"p-n"},{"p-n","n-p"}},{{d1,17,"left doping ^10"},14,18},{{d2,17,"right doping ^10"},14,18}
,{{T,300,"Temperature (K)"},100,400}
,{{xR,2," xR range (μm)"},0.1,20},{{xL,-2," xL range (μm)"},-20,-0.1}]
,Grid[{{ Control[{{Eg,1.42,"Bandgap (eV)"},0.3,4}]
,Control[{{ϵ,13.6,"Dielectric const."},4,20}]}
,{Control[{{me,0.0665,"Elec eff mass me*"},0.02,0.5}]
,Control[{{mh,0.5,"Hole eff mass mh*"},0.02,1}]}
,{Control[{{gc,1,"Cond band degeneracy"},{1,6}}]}
}]
],
{{start,1,"Click to start"},{0,1}} ]

2.6.2 Log scale

Carrier densities at the junction at equilibrium - log scale

Manipulate[
If[start==1,
NDOS0[SemiParm_]:= Module[{ Eg, me, gc, mh,ϵ},
{ Eg, me, gc, mh,ϵ}=SemiParm ;
4.829415887919019`*^15  {gc  (me^(3/2)) , (mh^(3/2))} 
];
FermiLevel[Dopant_,T_,SemiParm_]:=Module[{Eg, me, gc, mh,ϵ
, NC0,NV0,type, DopeDensity, kB=  8.61739*10^(-5)},
{ Eg, me, gc, mh,ϵ}=SemiParm  ;
{NC0,NV0}= NDOS0[SemiParm] ;
{type, DopeDensity}=Dopant ;
If[type>0  , 
kB T Log[DopeDensity/(NC0 (T^(3/2)))] 
,-kB T Log[DopeDensity/(NV0 (T^(3/2))) ] ]
] ;
DepletionW[T_,Vbias_,JuncDopant_, SemiParm_]:=Module[{Eg, me, gc, mh,ϵ
,Dopant1, Dopant2,
ContactV, V0, W,
,aB=5.29177*10^(-9)
,Ryd=13.6057},
{ Eg, me, gc, mh,ϵ}=SemiParm  ;
{Dopant1, Dopant2}=JuncDopant ;
ContactV=Eg+Sign[Dopant1[[1]] ]*FermiLevel[Dopant1,T,SemiParm]+Sign[Dopant2[[1]] ]*FermiLevel[Dopant2,T,SemiParm] ;
V0=ContactV-Vbias ;
W=Sqrt[(ϵ V0/(aB  Ryd))* (1/Dopant1[[2]] +1/Dopant2[[2]]) ]  ;
10^4* W {1, Dopant2[[2]]/(Dopant1[[2]] +Dopant2[[2]])
,Dopant1[[2]]/(Dopant1[[2]] +Dopant2[[2]])  }] ;
ϕJ[x_, T_,Vbias_,JuncDopant_, SemiParm_]:= Module[{Eg, me, gc, mh,ϵ
, ContactV, V0, W, x1,x2},
{ Eg, me, gc, mh,ϵ}=SemiParm  ; 
{W, x1,x2} =DepletionW[T,Vbias,JuncDopant, SemiParm] ;
ContactV=Eg+Sign[JuncDopant[[1,1]] ]*FermiLevel[JuncDopant[[1]],T,SemiParm]+Sign[JuncDopant[[2,1]] ]*FermiLevel[JuncDopant[[2]] ,T,SemiParm] ;
V0=ContactV-Vbias ;
Sign[JuncDopant[[1,1]] ]*If[x≤-x1,0.,If[x≤ 0., V0  (x+x1)^2 /(x1*W),
If[x≤ x2, V0*(1-(x-x2)^2/(x2*W)) ,V0]
]
]
] ;
BandDiagram[x_, T_,Vbias_,JuncDopant_, SemiParm_]:= Module[{Eg, me, gc, mh,ϵ
, ContactV, V0, W,w, x1,x2},
{ Eg, me, gc, mh,ϵ}=SemiParm  ; 
{W, x1,x2} =DepletionW[T,Vbias,JuncDopant, SemiParm] ;
ContactV=Eg+Sign[JuncDopant[[1,1]] ]*FermiLevel[JuncDopant[[1]],T,SemiParm]+Sign[JuncDopant[[2,1]] ]*FermiLevel[JuncDopant[[2]] ,T,SemiParm] ;
V0=ContactV-Vbias ;
w=Sign[JuncDopant[[1,1]] ]*If[x≤-x1,0.,If[x≤ 0., V0  (x+x1)^2 /(x1*W),
If[x≤ x2, V0*(1-(x-x2)^2/(x2*W)) ,V0]
]
] ;
w-FermiLevel[JuncDopant[[1]],T,SemiParm]
+{Sign[JuncDopant[[2,1]] ]*Eg,0.} 
] ;

FermiLine[x_, T_,Vbias_,JuncDopant_, SemiParm_]:=Module[{Eg, me, gc, mh,ϵ
, ContactV, V0, W, x1,x2},
{ Eg, me, gc, mh,ϵ}=SemiParm  ; 
{W, x1,x2} =DepletionW[T,Vbias,JuncDopant, SemiParm] ;
ContactV=Eg+Sign[JuncDopant[[1,1]] ]*FermiLevel[JuncDopant[[1]],T,SemiParm]+Sign[JuncDopant[[2,1]] ]*FermiLevel[JuncDopant[[2]] ,T,SemiParm] ;
V0=ContactV-Vbias ;
If[x≥- x1,-Sign[JuncDopant[[1,1]] ]*Vbias,  ]
];
CarrierEqui[x_, T_,JuncDopant_, SemiParm_]:= Module[{Eg, me, gc, mh,ϵ 
,NC0,NV0, F
, kB=  8.61739*10^(-5)},
{ Eg, me, gc, mh,ϵ}=SemiParm  ; 
{NC0,NV0}= NDOS0[SemiParm] ;
F=BandDiagram[x, T,0.,JuncDopant, SemiParm] ;
If[JuncDopant[[1,1]]>0, 
{NC0 (T^(3/2)) (E^(-F[[2]]/(kB T))), NV0 (T^(3/2)) (E^(F[[1]]/(kB T))), NC0 (T^(3/2)) (E^(-F[[2]]/(kB T)))  +  NV0 (T^(3/2)) (E^(F[[1]]/(kB T)))} 
, {NC0 (T^(3/2)) (E^(-F[[1]]/(kB T))), NV0 (T^(3/2)) (E^(F[[2]]/(kB T))), NC0 (T^(3/2)) (E^(-F[[1]]/(kB T)))  +  NV0 (T^(3/2)) (E^(F[[2]]/(kB T)))}
]
];
CarrierJ[x_, T_,Vbias_,JuncDopant_, SemiParm_,DiffParm_]:= Module[{Eg, me, gc, mh,ϵ
, μn,μp,τ,Ln, Lp 
,NC0,NV0
, W, x1,x2
,q1,q2,F1,F2,G
, kB=  8.61739*10^(-5)},
{ Eg, me, gc, mh,ϵ}=SemiParm  ; 
{ μn,μp,τ,Ln,Lp}=DiffParm  ;
If[Ln==0. || TrueQ[Ln== Null], Ln=10^4*Sqrt[μn kB T τ], ];
If[Lp==0. || TrueQ[Lp ==  Null],Lp=10^4*Sqrt[μp kB T τ], ];
{NC0,NV0}= NDOS0[SemiParm] ;
{W, x1,x2} =DepletionW[T,Vbias,JuncDopant, SemiParm] ;
F1=BandDiagram[-x1, T,0.,JuncDopant, SemiParm] ;
F2=BandDiagram[x2, T,0.,JuncDopant, SemiParm] ;
q1=If[JuncDopant[[1,1]]≥ 0., NV0 (T^(3/2.)) (E^(F1[[1]]/(kB T))), NC0 (T^(3/2.)) (E^(-F1[[1]]/(kB T)))] ;
q2=If[JuncDopant[[1,1]]≥ 0., NC0 (T^(3/2.)) (E^(-F2[[2]]/(kB T))), NV0 (T^(3/2.)) (E^(F2[[2]]/(kB T)))] ;
G=Exp[Vbias/(kB T)]-1;
If[JuncDopant[[1,1]]≥ 0.,
If[x≤ -x1, q1 G  (E^((x+x1)/Lp)),
If [x≥ x2, q2 G  (E^(-(x-x2)/Ln)), ]
]
, If[x≤ -x1, q1 G  (E^((x+x1)/Ln)),
If [x≥ x2, q2 G  (E^(-(x-x2)/Lp)), ]
]
]
]  ;
DiffJ[x_, T_,Vbias_,JuncDopant_, SemiParm_,DiffParm_]:= Module[{Eg, me, gc, mh,ϵ
, μn,μp,τ,Ln, Lp 
,NC0,NV0
, W, x1,x2
,q1,q2,F1,F2,G
, kB=  8.61739*10^(-5)},
{ Eg, me, gc, mh,ϵ}=SemiParm  ; 
{ μn,μp,τ,Ln,Lp}=DiffParm  ;
If[Ln==0. || TrueQ[Ln== Null], Ln=10^4*Sqrt[μn kB T τ], ];
If[Lp==0. || TrueQ[Lp ==  Null],Lp=10^4*Sqrt[μp kB T τ], ];
{NC0,NV0}= NDOS0[SemiParm] ;
{W, x1,x2} =DepletionW[T,Vbias,JuncDopant, SemiParm] ;
F1=BandDiagram[-x1, T,0.,JuncDopant, SemiParm] ;
F2=BandDiagram[x2, T,0.,JuncDopant, SemiParm] ;
q1=If[JuncDopant[[1,1]]>0, NV0 (T^(3/2)) (E^(F1[[1]]/(kB T))), NC0 (T^(3/2)) (E^(-F1[[1]]/(kB T)))] ;
q2=If[JuncDopant[[1,1]]>0, NC0 (T^(3/2)) (E^(-F2[[2]]/(kB T))), NV0 (T^(3/2)) (E^(F2[[2]]/(kB T)))] ;
G=Exp[Vbias/(kB T)]-1;
1.602176487`*^-23*If[JuncDopant[[1,1]]>0,
If[x≤ -x1,Lp q1 G  (E^((x+x1)/Lp))/τ,
If [x≥ x2,Ln q2 G  (E^(-(x-x2)/Ln))/τ, ]
]
, If[x≤ -x1,Ln q1 G  (E^((x+x1)/Ln))/τ,
If [x≥ x2,Lp q2 G  (E^(-(x-x2)/Lp))/τ, ]
]
]
]  ;
DiodeC[ T_,Vbias_,JuncDopant_, SemiParm_,DiffParm_]:= Module[{Eg, me, gc, mh,ϵ
, μn,μp,τ,Ln, Lp 
,NC0,NV0
, W, x1,x2
,q1,q2,F1,F2,G
, kB=  8.61739*10^(-5)},
{ Eg, me, gc, mh,ϵ}=SemiParm  ; 
{ μn,μp,τ,Ln,Lp}=DiffParm  ;
If[Ln==0. || TrueQ[Ln== Null], Ln=10^4*Sqrt[μn kB T τ], ];
If[Lp==0. || TrueQ[Lp ==  Null],Lp=10^4*Sqrt[μp kB T τ], ];
{NC0,NV0}= NDOS0[SemiParm] ;
{W, x1,x2} =DepletionW[T,Vbias,JuncDopant, SemiParm] ;
F1=BandDiagram[-x1, T,0.,JuncDopant, SemiParm] ;
F2=BandDiagram[x2, T,0.,JuncDopant, SemiParm] ;
q1=If[JuncDopant[[1,1]]>0, NV0 (T^(3/2)) (E^(F1[[1]]/(kB T))), NC0 (T^(3/2)) (E^(-F1[[1]]/(kB T)))] ;
q2=If[JuncDopant[[1,1]]>0, NC0 (T^(3/2)) (E^(-F2[[2]]/(kB T))), NV0 (T^(3/2)) (E^(F2[[2]]/(kB T)))] ;
G=Exp[Vbias/(kB T)]-1;
1.602176487`*^-23*If[JuncDopant[[1,1]]>0,
( Lp q1 +Ln q2 ) G  /τ ,( Ln q1 +Lp q2 ) G /τ]
]  ;
DiodeC1[ T_,Vbias_,JuncDopant_, SemiParm_,DiffParm_]:= Module[{Eg, me, gc, mh,ϵ
, μn,μp,τ,Ln, Lp 
,NC0,NV0
, W, x1,x2,ContactV,Ef1,Ef2
,q1,q2,F1,F2,G,r1,r2,H
, kB=  8.61739*10^(-5)},
{ Eg, me, gc, mh,ϵ}=SemiParm  ; 
{ μn,μp,τ,Ln,Lp}=DiffParm  ;
If[Ln==0. || TrueQ[Ln== Null], Ln=10^4*Sqrt[μn kB T τ], ];
If[Lp==0. || TrueQ[Lp ==  Null],Lp=10^4*Sqrt[μp kB T τ], ];
{NC0,NV0}= NDOS0[SemiParm] ;
Ef1=  FermiLevel[JuncDopant[[1]],T,SemiParm];
Ef2=  FermiLevel[JuncDopant[[2]],T,SemiParm];
ContactV=Eg+Sign[JuncDopant[[1,1]] ]*FermiLevel[JuncDopant[[1]],T,SemiParm]+Sign[JuncDopant[[2,1]] ]*FermiLevel[JuncDopant[[2]] ,T,SemiParm] ;
{W, x1,x2} =DepletionW[T,Vbias,JuncDopant, SemiParm] ;
F1=BandDiagram[-x1, T,0.,JuncDopant, SemiParm] ;
F2=BandDiagram[x2, T,0.,JuncDopant, SemiParm] ;
q1=If[JuncDopant[[1,1]]>0, NV0 (T^(3/2)) (E^(F1[[1]]/(kB T))), NC0 (T^(3/2)) (E^(-F1[[1]]/(kB T)))] ;
q2=If[JuncDopant[[1,1]]>0, NC0 (T^(3/2)) (E^(-F2[[2]]/(kB T))), NV0 (T^(3/2)) (E^(F2[[2]]/(kB T)))] ;
r1=  If[JuncDopant[[1,1]]>0,(mh/me)^3/2  *Exp[(F1[[1]]+F1[[2]])/(kB T)] , (me/mh)^3/2  *Exp[-(F1[[1]]+F1[[2]])/(kB T)] ] ;
r2=   If[JuncDopant[[1,1]]>0,(me/mh)^3/2  *Exp[-(F2[[1]]+F2[[2]])/(kB T)] , (mh/me)^3/2  *Exp[(F2[[1]]+F2[[2]])/(kB T)] ] ;
G=Exp[Vbias/(kB T)]-1; H=1-Exp[-2(ContactV-Vbias)/(kB T)] ;
1.602176487`*^-23*If[JuncDopant[[1,1]]>0,
( Lp q1 (1+r1 (G+1)) +Ln q2  (1+ r2 (G+1))) G  /(τ H)
,( Ln q1 (1+r1 (G+1)) +Lp q2 (1+ r2 (G+1)) ) G /(τ H)]
];

 start=0, ];
Manipulate[
SemiParm={ Eg, me,gc, mh,ϵ } ;   (* this is GaAs  *)
Manipulate[
dtype=If[dope=="p-n",-1,1] ;
LogPlot[{CarrierEqui[x, T,{ {dtype,10^d1},{-dtype,10^d2} }, SemiParm][[2]]
,
CarrierEqui[x, T,{ {dtype,10^d1},{-dtype,10^d2} }, SemiParm][[1]]},
{x,xL,xR}, PlotRange-> All
, Filling->{{1-> {Bottom,Hue[0.6,1,1,0.6]}},{2-> {Bottom,Hue[0.,1,1,0.5]}}}
,Frame-> True, GridLines-> Automatic
,FrameLabel->{"Position (μm)","Carrier density ((cm^(-3)))"}
,LabelStyle->Directive[14,FontFamily-> "Arial"]]

,{{dope,"p-n"},{"p-n","n-p"}},{{d1,17,"left doping ^10"},14,18},{{d2,17,"right doping ^10"},14,18}
,{{T,300,"Temperature (K)"},100,400}
,{{xR,2," xR range (μm)"},0.1,20},{{xL,-2," xL range (μm)"},-20,-0.1}]
,Grid[{{ Control[{{Eg,1.42,"Bandgap (eV)"},0.3,4}]
,Control[{{ϵ,13.6,"Dielectric const."},4,20}]}
,{Control[{{me,0.0665,"Elec eff mass me*"},0.02,0.5}]
,Control[{{mh,0.5,"Hole eff mass mh*"},0.02,1}]}
,{Control[{{gc,1,"Cond band degeneracy"},{1,6}}]}
}]
],
{{start,1,"Click to start"},{0,1}} ]

2.6.3 Illustration for junction at equilibrium

Band structure with carrier densities on Bel-(cm^(-3)) scale.

Band structure with carrier densities on Bel-(cm^(-3)) scale

Manipulate[
If[start==1,
NDOS0[SemiParm_]:= Module[{ Eg, me, gc, mh,ϵ},
{ Eg, me, gc, mh,ϵ}=SemiParm ;
4.829415887919019`*^15  {gc  (me^(3/2)) , (mh^(3/2))} 
];
FermiLevel[Dopant_,T_,SemiParm_]:=Module[{Eg, me, gc, mh,ϵ
, NC0,NV0,type, DopeDensity, kB=  8.61739*10^(-5)},
{ Eg, me, gc, mh,ϵ}=SemiParm  ;
{NC0,NV0}= NDOS0[SemiParm] ;
{type, DopeDensity}=Dopant ;
If[type>0  , 
kB T Log[DopeDensity/(NC0 (T^(3/2)))] 
,-kB T Log[DopeDensity/(NV0 (T^(3/2))) ] ]
] ;
DepletionW[T_,Vbias_,JuncDopant_, SemiParm_]:=Module[{Eg, me, gc, mh,ϵ
,Dopant1, Dopant2,
ContactV, V0, W,
,aB=5.29177*10^(-9)
,Ryd=13.6057},
{ Eg, me, gc, mh,ϵ}=SemiParm  ;
{Dopant1, Dopant2}=JuncDopant ;
ContactV=Eg+Sign[Dopant1[[1]] ]*FermiLevel[Dopant1,T,SemiParm]+Sign[Dopant2[[1]] ]*FermiLevel[Dopant2,T,SemiParm] ;
V0=ContactV-Vbias ;
W=Sqrt[(ϵ V0/(aB  Ryd))* (1/Dopant1[[2]] +1/Dopant2[[2]]) ]  ;
10^4* W {1, Dopant2[[2]]/(Dopant1[[2]] +Dopant2[[2]])
,Dopant1[[2]]/(Dopant1[[2]] +Dopant2[[2]])  }] ;
ϕJ[x_, T_,Vbias_,JuncDopant_, SemiParm_]:= Module[{Eg, me, gc, mh,ϵ
, ContactV, V0, W, x1,x2},
{ Eg, me, gc, mh,ϵ}=SemiParm  ; 
{W, x1,x2} =DepletionW[T,Vbias,JuncDopant, SemiParm] ;
ContactV=Eg+Sign[JuncDopant[[1,1]] ]*FermiLevel[JuncDopant[[1]],T,SemiParm]+Sign[JuncDopant[[2,1]] ]*FermiLevel[JuncDopant[[2]] ,T,SemiParm] ;
V0=ContactV-Vbias ;
Sign[JuncDopant[[1,1]] ]*If[x≤-x1,0.,If[x≤ 0., V0  (x+x1)^2 /(x1*W),
If[x≤ x2, V0*(1-(x-x2)^2/(x2*W)) ,V0]
]
]
] ;
BandDiagram[x_, T_,Vbias_,JuncDopant_, SemiParm_]:= Module[{Eg, me, gc, mh,ϵ
, ContactV, V0, W,w, x1,x2},
{ Eg, me, gc, mh,ϵ}=SemiParm  ; 
{W, x1,x2} =DepletionW[T,Vbias,JuncDopant, SemiParm] ;
ContactV=Eg+Sign[JuncDopant[[1,1]] ]*FermiLevel[JuncDopant[[1]],T,SemiParm]+Sign[JuncDopant[[2,1]] ]*FermiLevel[JuncDopant[[2]] ,T,SemiParm] ;
V0=ContactV-Vbias ;
w=Sign[JuncDopant[[1,1]] ]*If[x≤-x1,0.,If[x≤ 0., V0  (x+x1)^2 /(x1*W),
If[x≤ x2, V0*(1-(x-x2)^2/(x2*W)) ,V0]
]
] ;
w-FermiLevel[JuncDopant[[1]],T,SemiParm]
+{Sign[JuncDopant[[2,1]] ]*Eg,0.} 
] ;

FermiLine[x_, T_,Vbias_,JuncDopant_, SemiParm_]:=Module[{Eg, me, gc, mh,ϵ
, ContactV, V0, W, x1,x2},
{ Eg, me, gc, mh,ϵ}=SemiParm  ; 
{W, x1,x2} =DepletionW[T,Vbias,JuncDopant, SemiParm] ;
ContactV=Eg+Sign[JuncDopant[[1,1]] ]*FermiLevel[JuncDopant[[1]],T,SemiParm]+Sign[JuncDopant[[2,1]] ]*FermiLevel[JuncDopant[[2]] ,T,SemiParm] ;
V0=ContactV-Vbias ;
If[x≥- x1,-Sign[JuncDopant[[1,1]] ]*Vbias,  ]
];
CarrierEqui[x_, T_,JuncDopant_, SemiParm_]:= Module[{Eg, me, gc, mh,ϵ 
,NC0,NV0, F
, kB=  8.61739*10^(-5)},
{ Eg, me, gc, mh,ϵ}=SemiParm  ; 
{NC0,NV0}= NDOS0[SemiParm] ;
F=BandDiagram[x, T,0.,JuncDopant, SemiParm] ;
If[JuncDopant[[1,1]]>0, 
{NC0 (T^(3/2)) (E^(-F[[2]]/(kB T))), NV0 (T^(3/2)) (E^(F[[1]]/(kB T))), NC0 (T^(3/2)) (E^(-F[[2]]/(kB T)))  +  NV0 (T^(3/2)) (E^(F[[1]]/(kB T)))} 
, {NC0 (T^(3/2)) (E^(-F[[1]]/(kB T))), NV0 (T^(3/2)) (E^(F[[2]]/(kB T))), NC0 (T^(3/2)) (E^(-F[[1]]/(kB T)))  +  NV0 (T^(3/2)) (E^(F[[2]]/(kB T)))}
]
];
CarrierJ[x_, T_,Vbias_,JuncDopant_, SemiParm_,DiffParm_]:= Module[{Eg, me, gc, mh,ϵ
, μn,μp,τ,Ln, Lp 
,NC0,NV0
, W, x1,x2
,q1,q2,F1,F2,G
, kB=  8.61739*10^(-5)},
{ Eg, me, gc, mh,ϵ}=SemiParm  ; 
{ μn,μp,τ,Ln,Lp}=DiffParm  ;
If[Ln==0. || TrueQ[Ln== Null], Ln=10^4*Sqrt[μn kB T τ], ];
If[Lp==0. || TrueQ[Lp ==  Null],Lp=10^4*Sqrt[μp kB T τ], ];
{NC0,NV0}= NDOS0[SemiParm] ;
{W, x1,x2} =DepletionW[T,Vbias,JuncDopant, SemiParm] ;
F1=BandDiagram[-x1, T,0.,JuncDopant, SemiParm] ;
F2=BandDiagram[x2, T,0.,JuncDopant, SemiParm] ;
q1=If[JuncDopant[[1,1]]≥ 0., NV0 (T^(3/2.)) (E^(F1[[1]]/(kB T))), NC0 (T^(3/2.)) (E^(-F1[[1]]/(kB T)))] ;
q2=If[JuncDopant[[1,1]]≥ 0., NC0 (T^(3/2.)) (E^(-F2[[2]]/(kB T))), NV0 (T^(3/2.)) (E^(F2[[2]]/(kB T)))] ;
G=Exp[Vbias/(kB T)]-1;
If[JuncDopant[[1,1]]≥ 0.,
If[x≤ -x1, q1 G  (E^((x+x1)/Lp)),
If [x≥ x2, q2 G  (E^(-(x-x2)/Ln)), ]
]
, If[x≤ -x1, q1 G  (E^((x+x1)/Ln)),
If [x≥ x2, q2 G  (E^(-(x-x2)/Lp)), ]
]
]
]  ;
DiffJ[x_, T_,Vbias_,JuncDopant_, SemiParm_,DiffParm_]:= Module[{Eg, me, gc, mh,ϵ
, μn,μp,τ,Ln, Lp 
,NC0,NV0
, W, x1,x2
,q1,q2,F1,F2,G
, kB=  8.61739*10^(-5)},
{ Eg, me, gc, mh,ϵ}=SemiParm  ; 
{ μn,μp,τ,Ln,Lp}=DiffParm  ;
If[Ln==0. || TrueQ[Ln== Null], Ln=10^4*Sqrt[μn kB T τ], ];
If[Lp==0. || TrueQ[Lp ==  Null],Lp=10^4*Sqrt[μp kB T τ], ];
{NC0,NV0}= NDOS0[SemiParm] ;
{W, x1,x2} =DepletionW[T,Vbias,JuncDopant, SemiParm] ;
F1=BandDiagram[-x1, T,0.,JuncDopant, SemiParm] ;
F2=BandDiagram[x2, T,0.,JuncDopant, SemiParm] ;
q1=If[JuncDopant[[1,1]]>0, NV0 (T^(3/2)) (E^(F1[[1]]/(kB T))), NC0 (T^(3/2)) (E^(-F1[[1]]/(kB T)))] ;
q2=If[JuncDopant[[1,1]]>0, NC0 (T^(3/2)) (E^(-F2[[2]]/(kB T))), NV0 (T^(3/2)) (E^(F2[[2]]/(kB T)))] ;
G=Exp[Vbias/(kB T)]-1;
1.602176487`*^-23*If[JuncDopant[[1,1]]>0,
If[x≤ -x1,Lp q1 G  (E^((x+x1)/Lp))/τ,
If [x≥ x2,Ln q2 G  (E^(-(x-x2)/Ln))/τ, ]
]
, If[x≤ -x1,Ln q1 G  (E^((x+x1)/Ln))/τ,
If [x≥ x2,Lp q2 G  (E^(-(x-x2)/Lp))/τ, ]
]
]
]  ;
DiodeC[ T_,Vbias_,JuncDopant_, SemiParm_,DiffParm_]:= Module[{Eg, me, gc, mh,ϵ
, μn,μp,τ,Ln, Lp 
,NC0,NV0
, W, x1,x2
,q1,q2,F1,F2,G
, kB=  8.61739*10^(-5)},
{ Eg, me, gc, mh,ϵ}=SemiParm  ; 
{ μn,μp,τ,Ln,Lp}=DiffParm  ;
If[Ln==0. || TrueQ[Ln== Null], Ln=10^4*Sqrt[μn kB T τ], ];
If[Lp==0. || TrueQ[Lp ==  Null],Lp=10^4*Sqrt[μp kB T τ], ];
{NC0,NV0}= NDOS0[SemiParm] ;
{W, x1,x2} =DepletionW[T,Vbias,JuncDopant, SemiParm] ;
F1=BandDiagram[-x1, T,0.,JuncDopant, SemiParm] ;
F2=BandDiagram[x2, T,0.,JuncDopant, SemiParm] ;
q1=If[JuncDopant[[1,1]]>0, NV0 (T^(3/2)) (E^(F1[[1]]/(kB T))), NC0 (T^(3/2)) (E^(-F1[[1]]/(kB T)))] ;
q2=If[JuncDopant[[1,1]]>0, NC0 (T^(3/2)) (E^(-F2[[2]]/(kB T))), NV0 (T^(3/2)) (E^(F2[[2]]/(kB T)))] ;
G=Exp[Vbias/(kB T)]-1;
1.602176487`*^-23*If[JuncDopant[[1,1]]>0,
( Lp q1 +Ln q2 ) G  /τ ,( Ln q1 +Lp q2 ) G /τ]
]  ;
DiodeC1[ T_,Vbias_,JuncDopant_, SemiParm_,DiffParm_]:= Module[{Eg, me, gc, mh,ϵ
, μn,μp,τ,Ln, Lp 
,NC0,NV0
, W, x1,x2,ContactV,Ef1,Ef2
,q1,q2,F1,F2,G,r1,r2,H
, kB=  8.61739*10^(-5)},
{ Eg, me, gc, mh,ϵ}=SemiParm  ; 
{ μn,μp,τ,Ln,Lp}=DiffParm  ;
If[Ln==0. || TrueQ[Ln== Null], Ln=10^4*Sqrt[μn kB T τ], ];
If[Lp==0. || TrueQ[Lp ==  Null],Lp=10^4*Sqrt[μp kB T τ], ];
{NC0,NV0}= NDOS0[SemiParm] ;
Ef1=  FermiLevel[JuncDopant[[1]],T,SemiParm];
Ef2=  FermiLevel[JuncDopant[[2]],T,SemiParm];
ContactV=Eg+Sign[JuncDopant[[1,1]] ]*FermiLevel[JuncDopant[[1]],T,SemiParm]+Sign[JuncDopant[[2,1]] ]*FermiLevel[JuncDopant[[2]] ,T,SemiParm] ;
{W, x1,x2} =DepletionW[T,Vbias,JuncDopant, SemiParm] ;
F1=BandDiagram[-x1, T,0.,JuncDopant, SemiParm] ;
F2=BandDiagram[x2, T,0.,JuncDopant, SemiParm] ;
q1=If[JuncDopant[[1,1]]>0, NV0 (T^(3/2)) (E^(F1[[1]]/(kB T))), NC0 (T^(3/2)) (E^(-F1[[1]]/(kB T)))] ;
q2=If[JuncDopant[[1,1]]>0, NC0 (T^(3/2)) (E^(-F2[[2]]/(kB T))), NV0 (T^(3/2)) (E^(F2[[2]]/(kB T)))] ;
r1=  If[JuncDopant[[1,1]]>0,(mh/me)^3/2  *Exp[(F1[[1]]+F1[[2]])/(kB T)] , (me/mh)^3/2  *Exp[-(F1[[1]]+F1[[2]])/(kB T)] ] ;
r2=   If[JuncDopant[[1,1]]>0,(me/mh)^3/2  *Exp[-(F2[[1]]+F2[[2]])/(kB T)] , (mh/me)^3/2  *Exp[(F2[[1]]+F2[[2]])/(kB T)] ] ;
G=Exp[Vbias/(kB T)]-1; H=1-Exp[-2(ContactV-Vbias)/(kB T)] ;
1.602176487`*^-23*If[JuncDopant[[1,1]]>0,
( Lp q1 (1+r1 (G+1)) +Ln q2  (1+ r2 (G+1))) G  /(τ H)
,( Ln q1 (1+r1 (G+1)) +Lp q2 (1+ r2 (G+1)) ) G /(τ H)]
];

 start=0, ];
Manipulate[
SemiParm={ Eg, me,gc, mh,ϵ } ;   (* this is GaAs  *) 
Manipulate[ Vbias=0.;  
dtype=If[dope=="p-n",-1,1] ;Show[Plot[BandDiagram[x, T,Vbias,{ {dtype,10^d1},{-dtype,10^d2} }, SemiParm],{x,xL,xR}, PlotRange-> All, PlotStyle-> Thick
,Frame-> True, GridLines-> None
,FrameLabel->{"Position (μm)","Energy (eV)"}
,LabelStyle->Directive[14,FontFamily-> "Arial"]]
,Graphics[{If[dtype<0,Red,Blue], Rectangle[{0,0}
,{DepletionW[T,Vbias,{ {dtype,10^d1},{-dtype,10^d2} }, SemiParm][[3]],-Sign[dtype]* 10^d2/(10^d1+10^d2)}]} ]
,Graphics[ {If[dtype<0,Blue,Red],Rectangle[
{-DepletionW[T,Vbias,{ {dtype,10^d1},{-dtype,10^d2} }, SemiParm][[2]]
,Sign[dtype]*10^d1/(10^d1+10^d2)},{0,0}]}
]
,If[CarrierON=="ON",
{Plot[Log[10, CarrierEqui[x, T,{ {dtype,10^d1},{-dtype,10^d2} }, SemiParm][[2]]  ]/18.,
{x,xL,xR}, PlotRange-> All, Filling-> Bottom,FillingStyle-> Directive[Hue[0.55,1,1,0.25] ]]
,Plot[Log[10,CarrierEqui[x, T,{ {dtype,10^d1},{-dtype,10^d2} }, SemiParm][[1]]]/18.,
{x,xL,xR}, PlotRange-> All, Filling-> Bottom
,FillingStyle->Directive[Hue[0.1,1,1,0.4] ] ]},Graphics[Point[{0,0}] ] ]
, Plot[BandDiagram[x, T,Vbias,{ {dtype,10^d1},{-dtype,10^d2} }, SemiParm][[2]],{x,xL,xR}, PlotRange-> All, PlotStyle-> {Thick, Purple}]
, Plot[BandDiagram[x, T,Vbias,{ {dtype,10^d1},{-dtype,10^d2} }, SemiParm][[1]],{x,xL,xR}, PlotRange-> All, PlotStyle-> {Thick, Hue[0.4,1,0.5]}]
,PlotRange-> {{xL,xR},All}
 ]
,{{CarrierON,"ON"},{"ON","OFF"}}
,{{dope,"p-n"},{"p-n","n-p"}},{{d1,17,"left doping ^10"},14,18},{{d2,17,"right doping ^10"},14,18}
,{{T,300,"Temperature (K)"},100,400}
,{{xR,2," xR range (μm)"},0.1,20},{{xL,-2," xL range (μm)"},-20,-0.1}]
,Grid[{{ Control[{{Eg,1.42,"Bandgap (eV)"},0.3,4}]
,Control[{{ϵ,13.6,"Dielectric const."},4,20}]}
,{Control[{{me,0.0665,"Elec eff mass me*"},0.02,0.5}]
,Control[{{mh,0.5,"Hole eff mass mh*"},0.02,1}]}
,{Control[{{gc,1,"Cond band degeneracy"},{1,6}}]}
}]
],
{{start,1,"Click to start"},{0,1}} ]

Band structure with carrier densities on linear scale.

Band structure with carrier densities on linear scale

Manipulate[
If[start==1,
NDOS0[SemiParm_]:= Module[{ Eg, me, gc, mh,ϵ},
{ Eg, me, gc, mh,ϵ}=SemiParm ;
4.829415887919019`*^15  {gc  (me^(3/2)) , (mh^(3/2))} 
];
FermiLevel[Dopant_,T_,SemiParm_]:=Module[{Eg, me, gc, mh,ϵ
, NC0,NV0,type, DopeDensity, kB=  8.61739*10^(-5)},
{ Eg, me, gc, mh,ϵ}=SemiParm  ;
{NC0,NV0}= NDOS0[SemiParm] ;
{type, DopeDensity}=Dopant ;
If[type>0  , 
kB T Log[DopeDensity/(NC0 (T^(3/2)))] 
,-kB T Log[DopeDensity/(NV0 (T^(3/2))) ] ]
] ;
DepletionW[T_,Vbias_,JuncDopant_, SemiParm_]:=Module[{Eg, me, gc, mh,ϵ
,Dopant1, Dopant2,
ContactV, V0, W,
,aB=5.29177*10^(-9)
,Ryd=13.6057},
{ Eg, me, gc, mh,ϵ}=SemiParm  ;
{Dopant1, Dopant2}=JuncDopant ;
ContactV=Eg+Sign[Dopant1[[1]] ]*FermiLevel[Dopant1,T,SemiParm]+Sign[Dopant2[[1]] ]*FermiLevel[Dopant2,T,SemiParm] ;
V0=ContactV-Vbias ;
W=Sqrt[(ϵ V0/(aB  Ryd))* (1/Dopant1[[2]] +1/Dopant2[[2]]) ]  ;
10^4* W {1, Dopant2[[2]]/(Dopant1[[2]] +Dopant2[[2]])
,Dopant1[[2]]/(Dopant1[[2]] +Dopant2[[2]])  }] ;
ϕJ[x_, T_,Vbias_,JuncDopant_, SemiParm_]:= Module[{Eg, me, gc, mh,ϵ
, ContactV, V0, W, x1,x2},
{ Eg, me, gc, mh,ϵ}=SemiParm  ; 
{W, x1,x2} =DepletionW[T,Vbias,JuncDopant, SemiParm] ;
ContactV=Eg+Sign[JuncDopant[[1,1]] ]*FermiLevel[JuncDopant[[1]],T,SemiParm]+Sign[JuncDopant[[2,1]] ]*FermiLevel[JuncDopant[[2]] ,T,SemiParm] ;
V0=ContactV-Vbias ;
Sign[JuncDopant[[1,1]] ]*If[x≤-x1,0.,If[x≤ 0., V0  (x+x1)^2 /(x1*W),
If[x≤ x2, V0*(1-(x-x2)^2/(x2*W)) ,V0]
]
]
] ;
BandDiagram[x_, T_,Vbias_,JuncDopant_, SemiParm_]:= Module[{Eg, me, gc, mh,ϵ
, ContactV, V0, W,w, x1,x2},
{ Eg, me, gc, mh,ϵ}=SemiParm  ; 
{W, x1,x2} =DepletionW[T,Vbias,JuncDopant, SemiParm] ;
ContactV=Eg+Sign[JuncDopant[[1,1]] ]*FermiLevel[JuncDopant[[1]],T,SemiParm]+Sign[JuncDopant[[2,1]] ]*FermiLevel[JuncDopant[[2]] ,T,SemiParm] ;
V0=ContactV-Vbias ;
w=Sign[JuncDopant[[1,1]] ]*If[x≤-x1,0.,If[x≤ 0., V0  (x+x1)^2 /(x1*W),
If[x≤ x2, V0*(1-(x-x2)^2/(x2*W)) ,V0]
]
] ;
w-FermiLevel[JuncDopant[[1]],T,SemiParm]
+{Sign[JuncDopant[[2,1]] ]*Eg,0.} 
] ;

FermiLine[x_, T_,Vbias_,JuncDopant_, SemiParm_]:=Module[{Eg, me, gc, mh,ϵ
, ContactV, V0, W, x1,x2},
{ Eg, me, gc, mh,ϵ}=SemiParm  ; 
{W, x1,x2} =DepletionW[T,Vbias,JuncDopant, SemiParm] ;
ContactV=Eg+Sign[JuncDopant[[1,1]] ]*FermiLevel[JuncDopant[[1]],T,SemiParm]+Sign[JuncDopant[[2,1]] ]*FermiLevel[JuncDopant[[2]] ,T,SemiParm] ;
V0=ContactV-Vbias ;
If[x≥- x1,-Sign[JuncDopant[[1,1]] ]*Vbias,  ]
];
CarrierEqui[x_, T_,JuncDopant_, SemiParm_]:= Module[{Eg, me, gc, mh,ϵ 
,NC0,NV0, F
, kB=  8.61739*10^(-5)},
{ Eg, me, gc, mh,ϵ}=SemiParm  ; 
{NC0,NV0}= NDOS0[SemiParm] ;
F=BandDiagram[x, T,0.,JuncDopant, SemiParm] ;
If[JuncDopant[[1,1]]>0, 
{NC0 (T^(3/2)) (E^(-F[[2]]/(kB T))), NV0 (T^(3/2)) (E^(F[[1]]/(kB T))), NC0 (T^(3/2)) (E^(-F[[2]]/(kB T)))  +  NV0 (T^(3/2)) (E^(F[[1]]/(kB T)))} 
, {NC0 (T^(3/2)) (E^(-F[[1]]/(kB T))), NV0 (T^(3/2)) (E^(F[[2]]/(kB T))), NC0 (T^(3/2)) (E^(-F[[1]]/(kB T)))  +  NV0 (T^(3/2)) (E^(F[[2]]/(kB T)))}
]
];
CarrierJ[x_, T_,Vbias_,JuncDopant_, SemiParm_,DiffParm_]:= Module[{Eg, me, gc, mh,ϵ
, μn,μp,τ,Ln, Lp 
,NC0,NV0
, W, x1,x2
,q1,q2,F1,F2,G
, kB=  8.61739*10^(-5)},
{ Eg, me, gc, mh,ϵ}=SemiParm  ; 
{ μn,μp,τ,Ln,Lp}=DiffParm  ;
If[Ln==0. || TrueQ[Ln== Null], Ln=10^4*Sqrt[μn kB T τ], ];
If[Lp==0. || TrueQ[Lp ==  Null],Lp=10^4*Sqrt[μp kB T τ], ];
{NC0,NV0}= NDOS0[SemiParm] ;
{W, x1,x2} =DepletionW[T,Vbias,JuncDopant, SemiParm] ;
F1=BandDiagram[-x1, T,0.,JuncDopant, SemiParm] ;
F2=BandDiagram[x2, T,0.,JuncDopant, SemiParm] ;
q1=If[JuncDopant[[1,1]]≥ 0., NV0 (T^(3/2.)) (E^(F1[[1]]/(kB T))), NC0 (T^(3/2.)) (E^(-F1[[1]]/(kB T)))] ;
q2=If[JuncDopant[[1,1]]≥ 0., NC0 (T^(3/2.)) (E^(-F2[[2]]/(kB T))), NV0 (T^(3/2.)) (E^(F2[[2]]/(kB T)))] ;
G=Exp[Vbias/(kB T)]-1;
If[JuncDopant[[1,1]]≥ 0.,
If[x≤ -x1, q1 G  (E^((x+x1)/Lp)),
If [x≥ x2, q2 G  (E^(-(x-x2)/Ln)), ]
]
, If[x≤ -x1, q1 G  (E^((x+x1)/Ln)),
If [x≥ x2, q2 G  (E^(-(x-x2)/Lp)), ]
]
]
]  ;
DiffJ[x_, T_,Vbias_,JuncDopant_, SemiParm_,DiffParm_]:= Module[{Eg, me, gc, mh,ϵ
, μn,μp,τ,Ln, Lp 
,NC0,NV0
, W, x1,x2
,q1,q2,F1,F2,G
, kB=  8.61739*10^(-5)},
{ Eg, me, gc, mh,ϵ}=SemiParm  ; 
{ μn,μp,τ,Ln,Lp}=DiffParm  ;
If[Ln==0. || TrueQ[Ln== Null], Ln=10^4*Sqrt[μn kB T τ], ];
If[Lp==0. || TrueQ[Lp ==  Null],Lp=10^4*Sqrt[μp kB T τ], ];
{NC0,NV0}= NDOS0[SemiParm] ;
{W, x1,x2} =DepletionW[T,Vbias,JuncDopant, SemiParm] ;
F1=BandDiagram[-x1, T,0.,JuncDopant, SemiParm] ;
F2=BandDiagram[x2, T,0.,JuncDopant, SemiParm] ;
q1=If[JuncDopant[[1,1]]>0, NV0 (T^(3/2)) (E^(F1[[1]]/(kB T))), NC0 (T^(3/2)) (E^(-F1[[1]]/(kB T)))] ;
q2=If[JuncDopant[[1,1]]>0, NC0 (T^(3/2)) (E^(-F2[[2]]/(kB T))), NV0 (T^(3/2)) (E^(F2[[2]]/(kB T)))] ;
G=Exp[Vbias/(kB T)]-1;
1.602176487`*^-23*If[JuncDopant[[1,1]]>0,
If[x≤ -x1,Lp q1 G  (E^((x+x1)/Lp))/τ,
If [x≥ x2,Ln q2 G  (E^(-(x-x2)/Ln))/τ, ]
]
, If[x≤ -x1,Ln q1 G  (E^((x+x1)/Ln))/τ,
If [x≥ x2,Lp q2 G  (E^(-(x-x2)/Lp))/τ, ]
]
]
]  ;
DiodeC[ T_,Vbias_,JuncDopant_, SemiParm_,DiffParm_]:= Module[{Eg, me, gc, mh,ϵ
, μn,μp,τ,Ln, Lp 
,NC0,NV0
, W, x1,x2
,q1,q2,F1,F2,G
, kB=  8.61739*10^(-5)},
{ Eg, me, gc, mh,ϵ}=SemiParm  ; 
{ μn,μp,τ,Ln,Lp}=DiffParm  ;
If[Ln==0. || TrueQ[Ln== Null], Ln=10^4*Sqrt[μn kB T τ], ];
If[Lp==0. || TrueQ[Lp ==  Null],Lp=10^4*Sqrt[μp kB T τ], ];
{NC0,NV0}= NDOS0[SemiParm] ;
{W, x1,x2} =DepletionW[T,Vbias,JuncDopant, SemiParm] ;
F1=BandDiagram[-x1, T,0.,JuncDopant, SemiParm] ;
F2=BandDiagram[x2, T,0.,JuncDopant, SemiParm] ;
q1=If[JuncDopant[[1,1]]>0, NV0 (T^(3/2)) (E^(F1[[1]]/(kB T))), NC0 (T^(3/2)) (E^(-F1[[1]]/(kB T)))] ;
q2=If[JuncDopant[[1,1]]>0, NC0 (T^(3/2)) (E^(-F2[[2]]/(kB T))), NV0 (T^(3/2)) (E^(F2[[2]]/(kB T)))] ;
G=Exp[Vbias/(kB T)]-1;
1.602176487`*^-23*If[JuncDopant[[1,1]]>0,
( Lp q1 +Ln q2 ) G  /τ ,( Ln q1 +Lp q2 ) G /τ]
]  ;
DiodeC1[ T_,Vbias_,JuncDopant_, SemiParm_,DiffParm_]:= Module[{Eg, me, gc, mh,ϵ
, μn,μp,τ,Ln, Lp 
,NC0,NV0
, W, x1,x2,ContactV,Ef1,Ef2
,q1,q2,F1,F2,G,r1,r2,H
, kB=  8.61739*10^(-5)},
{ Eg, me, gc, mh,ϵ}=SemiParm  ; 
{ μn,μp,τ,Ln,Lp}=DiffParm  ;
If[Ln==0. || TrueQ[Ln== Null], Ln=10^4*Sqrt[μn kB T τ], ];
If[Lp==0. || TrueQ[Lp ==  Null],Lp=10^4*Sqrt[μp kB T τ], ];
{NC0,NV0}= NDOS0[SemiParm] ;
Ef1=  FermiLevel[JuncDopant[[1]],T,SemiParm];
Ef2=  FermiLevel[JuncDopant[[2]],T,SemiParm];
ContactV=Eg+Sign[JuncDopant[[1,1]] ]*FermiLevel[JuncDopant[[1]],T,SemiParm]+Sign[JuncDopant[[2,1]] ]*FermiLevel[JuncDopant[[2]] ,T,SemiParm] ;
{W, x1,x2} =DepletionW[T,Vbias,JuncDopant, SemiParm] ;
F1=BandDiagram[-x1, T,0.,JuncDopant, SemiParm] ;
F2=BandDiagram[x2, T,0.,JuncDopant, SemiParm] ;
q1=If[JuncDopant[[1,1]]>0, NV0 (T^(3/2)) (E^(F1[[1]]/(kB T))), NC0 (T^(3/2)) (E^(-F1[[1]]/(kB T)))] ;
q2=If[JuncDopant[[1,1]]>0, NC0 (T^(3/2)) (E^(-F2[[2]]/(kB T))), NV0 (T^(3/2)) (E^(F2[[2]]/(kB T)))] ;
r1=  If[JuncDopant[[1,1]]>0,(mh/me)^3/2  *Exp[(F1[[1]]+F1[[2]])/(kB T)] , (me/mh)^3/2  *Exp[-(F1[[1]]+F1[[2]])/(kB T)] ] ;
r2=   If[JuncDopant[[1,1]]>0,(me/mh)^3/2  *Exp[-(F2[[1]]+F2[[2]])/(kB T)] , (mh/me)^3/2  *Exp[(F2[[1]]+F2[[2]])/(kB T)] ] ;
G=Exp[Vbias/(kB T)]-1; H=1-Exp[-2(ContactV-Vbias)/(kB T)] ;
1.602176487`*^-23*If[JuncDopant[[1,1]]>0,
( Lp q1 (1+r1 (G+1)) +Ln q2  (1+ r2 (G+1))) G  /(τ H)
,( Ln q1 (1+r1 (G+1)) +Lp q2 (1+ r2 (G+1)) ) G /(τ H)]
];

 start=0, ];
Manipulate[
SemiParm={ Eg, me,gc, mh,ϵ } ;   (* this is GaAs  *) 
Manipulate[Vbias=0.;dtype=If[dope=="p-n",-1,1] ;Show[Plot[BandDiagram[x, T,Vbias,{ {dtype,10^d1},{-dtype,10^d2} }, SemiParm],{x,xL,xR}, PlotRange-> All, PlotStyle-> Thick
,Frame-> True, GridLines-> None
,FrameLabel->{"Position (μm)","Energy (eV)"}
,LabelStyle->Directive[14,FontFamily-> "Arial"]]
,Graphics[{If[dtype<0,Red,Blue], Rectangle[{0,0}
,{DepletionW[T,Vbias,{ {dtype,10^d1},{-dtype,10^d2} }, SemiParm][[3]],-Sign[dtype]* 10^d2/(10^d1+10^d2)}]} ]
,Graphics[ {If[dtype<0,Blue,Red],Rectangle[
{-DepletionW[T,Vbias,{ {dtype,10^d1},{-dtype,10^d2} }, SemiParm][[2]]
,Sign[dtype]*10.^d1/(10^d1+10^d2)},{0,0}]}
]
,If[ CarrierON== "ON",
{Plot[ s*CarrierEqui[x, T,{ {dtype,10^d1},{-dtype,10^d2} }, SemiParm][[2]] *10^-18,
{x,xL,xR}, PlotRange-> All, Filling-> Bottom,FillingStyle-> Directive[Hue[0.55,1,1,0.25] ]]
,Plot[s CarrierEqui[x, T,{ {dtype,10^d1},{-dtype,10^d2} }, SemiParm][[1]]*10^-18,
{x,xL,xR}, PlotRange-> All, Filling-> Bottom
,FillingStyle->Directive[Hue[0.1,1,1,0.4] ] ]}, Graphics[Point[{0,0}] ]]
, Plot[BandDiagram[x, T,Vbias,{ {dtype,10^d1},{-dtype,10^d2} }, SemiParm][[2]],{x,xL,xR}, PlotRange-> All, PlotStyle-> {Thick, Purple}]
, Plot[BandDiagram[x, T,Vbias,{ {dtype,10^d1},{-dtype,10^d2} }, SemiParm][[1]],{x,xL,xR}, PlotRange-> All, PlotStyle-> {Thick, Hue[0.4,1,0.5]},PlotRange-> {{xL,xR},All}]
 ]
,{{CarrierON,"ON"},{"ON","OFF"}}
,{{dope,"p-n"},{"p-n","n-p"}},{{d1,17,"left doping ^10"},14,18},{{d2,17,"right doping ^10"},14,18}
,{{T,300,"Temperature (K)"},100,400},{{xR,2," xR range (μm)"},0.1,20},{{xL,-2," xL range (μm)"},-20,-0.1},{{s,5},1,10}]
,Grid[{{ Control[{{Eg,1.42,"Bandgap (eV)"},0.3,4}]
,Control[{{ϵ,13.6,"Dielectric const."},4,20}]}
,{Control[{{me,0.0665,"Elec eff mass me*"},0.02,0.5}]
,Control[{{mh,0.5,"Hole eff mass mh*"},0.02,1}]}
,{Control[{{gc,1,"Cond band degeneracy"},{1,6}}]}
}]
],
{{start,1,"Click to start"},{0,1}} ]

3 Junction under bias

3.1 Junction electrostatic potential

The bias can INCREASE (reverse bias) or DECREASE (forward bias) the junction electrostatic potential.
The depletion width correspondingly increases or decreases.
In the following, the convention is that a positive Vbias means forward bias, negative Vbias means reverse bias. Vbias voltage is NOT relative with respect to the left side or right side.

Junction electrostatic potential with bias

Manipulate[
If[start==1,
NDOS0[SemiParm_]:= Module[{ Eg, me, gc, mh,ϵ},
{ Eg, me, gc, mh,ϵ}=SemiParm ;
4.829415887919019`*^15  {gc  (me^(3/2)) , (mh^(3/2))} 
];
FermiLevel[Dopant_,T_,SemiParm_]:=Module[{Eg, me, gc, mh,ϵ
, NC0,NV0,type, DopeDensity, kB=  8.61739*10^(-5)},
{ Eg, me, gc, mh,ϵ}=SemiParm  ;
{NC0,NV0}= NDOS0[SemiParm] ;
{type, DopeDensity}=Dopant ;
If[type>0  , 
kB T Log[DopeDensity/(NC0 (T^(3/2)))] 
,-kB T Log[DopeDensity/(NV0 (T^(3/2))) ] ]
] ;
DepletionW[T_,Vbias_,JuncDopant_, SemiParm_]:=Module[{Eg, me, gc, mh,ϵ
,Dopant1, Dopant2,
ContactV, V0, W,
,aB=5.29177*10^(-9)
,Ryd=13.6057},
{ Eg, me, gc, mh,ϵ}=SemiParm  ;
{Dopant1, Dopant2}=JuncDopant ;
ContactV=Eg+Sign[Dopant1[[1]] ]*FermiLevel[Dopant1,T,SemiParm]+Sign[Dopant2[[1]] ]*FermiLevel[Dopant2,T,SemiParm] ;
V0=ContactV-Vbias ;
W=Sqrt[(ϵ V0/(aB  Ryd))* (1/Dopant1[[2]] +1/Dopant2[[2]]) ]  ;
10^4* W {1, Dopant2[[2]]/(Dopant1[[2]] +Dopant2[[2]])
,Dopant1[[2]]/(Dopant1[[2]] +Dopant2[[2]])  }] ;
ϕJ[x_, T_,Vbias_,JuncDopant_, SemiParm_]:= Module[{Eg, me, gc, mh,ϵ
, ContactV, V0, W, x1,x2},
{ Eg, me, gc, mh,ϵ}=SemiParm  ; 
{W, x1,x2} =DepletionW[T,Vbias,JuncDopant, SemiParm] ;
ContactV=Eg+Sign[JuncDopant[[1,1]] ]*FermiLevel[JuncDopant[[1]],T,SemiParm]+Sign[JuncDopant[[2,1]] ]*FermiLevel[JuncDopant[[2]] ,T,SemiParm] ;
V0=ContactV-Vbias ;
Sign[JuncDopant[[1,1]] ]*If[x≤-x1,0.,If[x≤ 0., V0  (x+x1)^2 /(x1*W),
If[x≤ x2, V0*(1-(x-x2)^2/(x2*W)) ,V0]
]
]
] ;
BandDiagram[x_, T_,Vbias_,JuncDopant_, SemiParm_]:= Module[{Eg, me, gc, mh,ϵ
, ContactV, V0, W,w, x1,x2},
{ Eg, me, gc, mh,ϵ}=SemiParm  ; 
{W, x1,x2} =DepletionW[T,Vbias,JuncDopant, SemiParm] ;
ContactV=Eg+Sign[JuncDopant[[1,1]] ]*FermiLevel[JuncDopant[[1]],T,SemiParm]+Sign[JuncDopant[[2,1]] ]*FermiLevel[JuncDopant[[2]] ,T,SemiParm] ;
V0=ContactV-Vbias ;
w=Sign[JuncDopant[[1,1]] ]*If[x≤-x1,0.,If[x≤ 0., V0  (x+x1)^2 /(x1*W),
If[x≤ x2, V0*(1-(x-x2)^2/(x2*W)) ,V0]
]
] ;
w-FermiLevel[JuncDopant[[1]],T,SemiParm]
+{Sign[JuncDopant[[2,1]] ]*Eg,0.} 
] ;

FermiLine[x_, T_,Vbias_,JuncDopant_, SemiParm_]:=Module[{Eg, me, gc, mh,ϵ
, ContactV, V0, W, x1,x2},
{ Eg, me, gc, mh,ϵ}=SemiParm  ; 
{W, x1,x2} =DepletionW[T,Vbias,JuncDopant, SemiParm] ;
ContactV=Eg+Sign[JuncDopant[[1,1]] ]*FermiLevel[JuncDopant[[1]],T,SemiParm]+Sign[JuncDopant[[2,1]] ]*FermiLevel[JuncDopant[[2]] ,T,SemiParm] ;
V0=ContactV-Vbias ;
If[x≥- x1,-Sign[JuncDopant[[1,1]] ]*Vbias,  ]
];
CarrierEqui[x_, T_,JuncDopant_, SemiParm_]:= Module[{Eg, me, gc, mh,ϵ 
,NC0,NV0, F
, kB=  8.61739*10^(-5)},
{ Eg, me, gc, mh,ϵ}=SemiParm  ; 
{NC0,NV0}= NDOS0[SemiParm] ;
F=BandDiagram[x, T,0.,JuncDopant, SemiParm] ;
If[JuncDopant[[1,1]]>0, 
{NC0 (T^(3/2)) (E^(-F[[2]]/(kB T))), NV0 (T^(3/2)) (E^(F[[1]]/(kB T))), NC0 (T^(3/2)) (E^(-F[[2]]/(kB T)))  +  NV0 (T^(3/2)) (E^(F[[1]]/(kB T)))} 
, {NC0 (T^(3/2)) (E^(-F[[1]]/(kB T))), NV0 (T^(3/2)) (E^(F[[2]]/(kB T))), NC0 (T^(3/2)) (E^(-F[[1]]/(kB T)))  +  NV0 (T^(3/2)) (E^(F[[2]]/(kB T)))}
]
];
CarrierJ[x_, T_,Vbias_,JuncDopant_, SemiParm_,DiffParm_]:= Module[{Eg, me, gc, mh,ϵ
, μn,μp,τ,Ln, Lp 
,NC0,NV0
, W, x1,x2
,q1,q2,F1,F2,G
, kB=  8.61739*10^(-5)},
{ Eg, me, gc, mh,ϵ}=SemiParm  ; 
{ μn,μp,τ,Ln,Lp}=DiffParm  ;
If[Ln==0. || TrueQ[Ln== Null], Ln=10^4*Sqrt[μn kB T τ], ];
If[Lp==0. || TrueQ[Lp ==  Null],Lp=10^4*Sqrt[μp kB T τ], ];
{NC0,NV0}= NDOS0[SemiParm] ;
{W, x1,x2} =DepletionW[T,Vbias,JuncDopant, SemiParm] ;
F1=BandDiagram[-x1, T,0.,JuncDopant, SemiParm] ;
F2=BandDiagram[x2, T,0.,JuncDopant, SemiParm] ;
q1=If[JuncDopant[[1,1]]≥ 0., NV0 (T^(3/2.)) (E^(F1[[1]]/(kB T))), NC0 (T^(3/2.)) (E^(-F1[[1]]/(kB T)))] ;
q2=If[JuncDopant[[1,1]]≥ 0., NC0 (T^(3/2.)) (E^(-F2[[2]]/(kB T))), NV0 (T^(3/2.)) (E^(F2[[2]]/(kB T)))] ;
G=Exp[Vbias/(kB T)]-1;
If[JuncDopant[[1,1]]≥ 0.,
If[x≤ -x1, q1 G  (E^((x+x1)/Lp)),
If [x≥ x2, q2 G  (E^(-(x-x2)/Ln)), ]
]
, If[x≤ -x1, q1 G  (E^((x+x1)/Ln)),
If [x≥ x2, q2 G  (E^(-(x-x2)/Lp)), ]
]
]
]  ;
DiffJ[x_, T_,Vbias_,JuncDopant_, SemiParm_,DiffParm_]:= Module[{Eg, me, gc, mh,ϵ
, μn,μp,τ,Ln, Lp 
,NC0,NV0
, W, x1,x2
,q1,q2,F1,F2,G
, kB=  8.61739*10^(-5)},
{ Eg, me, gc, mh,ϵ}=SemiParm  ; 
{ μn,μp,τ,Ln,Lp}=DiffParm  ;
If[Ln==0. || TrueQ[Ln== Null], Ln=10^4*Sqrt[μn kB T τ], ];
If[Lp==0. || TrueQ[Lp ==  Null],Lp=10^4*Sqrt[μp kB T τ], ];
{NC0,NV0}= NDOS0[SemiParm] ;
{W, x1,x2} =DepletionW[T,Vbias,JuncDopant, SemiParm] ;
F1=BandDiagram[-x1, T,0.,JuncDopant, SemiParm] ;
F2=BandDiagram[x2, T,0.,JuncDopant, SemiParm] ;
q1=If[JuncDopant[[1,1]]>0, NV0 (T^(3/2)) (E^(F1[[1]]/(kB T))), NC0 (T^(3/2)) (E^(-F1[[1]]/(kB T)))] ;
q2=If[JuncDopant[[1,1]]>0, NC0 (T^(3/2)) (E^(-F2[[2]]/(kB T))), NV0 (T^(3/2)) (E^(F2[[2]]/(kB T)))] ;
G=Exp[Vbias/(kB T)]-1;
1.602176487`*^-23*If[JuncDopant[[1,1]]>0,
If[x≤ -x1,Lp q1 G  (E^((x+x1)/Lp))/τ,
If [x≥ x2,Ln q2 G  (E^(-(x-x2)/Ln))/τ, ]
]
, If[x≤ -x1,Ln q1 G  (E^((x+x1)/Ln))/τ,
If [x≥ x2,Lp q2 G  (E^(-(x-x2)/Lp))/τ, ]
]
]
]  ;
DiodeC[ T_,Vbias_,JuncDopant_, SemiParm_,DiffParm_]:= Module[{Eg, me, gc, mh,ϵ
, μn,μp,τ,Ln, Lp 
,NC0,NV0
, W, x1,x2
,q1,q2,F1,F2,G
, kB=  8.61739*10^(-5)},
{ Eg, me, gc, mh,ϵ}=SemiParm  ; 
{ μn,μp,τ,Ln,Lp}=DiffParm  ;
If[Ln==0. || TrueQ[Ln== Null], Ln=10^4*Sqrt[μn kB T τ], ];
If[Lp==0. || TrueQ[Lp ==  Null],Lp=10^4*Sqrt[μp kB T τ], ];
{NC0,NV0}= NDOS0[SemiParm] ;
{W, x1,x2} =DepletionW[T,Vbias,JuncDopant, SemiParm] ;
F1=BandDiagram[-x1, T,0.,JuncDopant, SemiParm] ;
F2=BandDiagram[x2, T,0.,JuncDopant, SemiParm] ;
q1=If[JuncDopant[[1,1]]>0, NV0 (T^(3/2)) (E^(F1[[1]]/(kB T))), NC0 (T^(3/2)) (E^(-F1[[1]]/(kB T)))] ;
q2=If[JuncDopant[[1,1]]>0, NC0 (T^(3/2)) (E^(-F2[[2]]/(kB T))), NV0 (T^(3/2)) (E^(F2[[2]]/(kB T)))] ;
G=Exp[Vbias/(kB T)]-1;
1.602176487`*^-23*If[JuncDopant[[1,1]]>0,
( Lp q1 +Ln q2 ) G  /τ ,( Ln q1 +Lp q2 ) G /τ]
]  ;
DiodeC1[ T_,Vbias_,JuncDopant_, SemiParm_,DiffParm_]:= Module[{Eg, me, gc, mh,ϵ
, μn,μp,τ,Ln, Lp 
,NC0,NV0
, W, x1,x2,ContactV,Ef1,Ef2
,q1,q2,F1,F2,G,r1,r2,H
, kB=  8.61739*10^(-5)},
{ Eg, me, gc, mh,ϵ}=SemiParm  ; 
{ μn,μp,τ,Ln,Lp}=DiffParm  ;
If[Ln==0. || TrueQ[Ln== Null], Ln=10^4*Sqrt[μn kB T τ], ];
If[Lp==0. || TrueQ[Lp ==  Null],Lp=10^4*Sqrt[μp kB T τ], ];
{NC0,NV0}= NDOS0[SemiParm] ;
Ef1=  FermiLevel[JuncDopant[[1]],T,SemiParm];
Ef2=  FermiLevel[JuncDopant[[2]],T,SemiParm];
ContactV=Eg+Sign[JuncDopant[[1,1]] ]*FermiLevel[JuncDopant[[1]],T,SemiParm]+Sign[JuncDopant[[2,1]] ]*FermiLevel[JuncDopant[[2]] ,T,SemiParm] ;
{W, x1,x2} =DepletionW[T,Vbias,JuncDopant, SemiParm] ;
F1=BandDiagram[-x1, T,0.,JuncDopant, SemiParm] ;
F2=BandDiagram[x2, T,0.,JuncDopant, SemiParm] ;
q1=If[JuncDopant[[1,1]]>0, NV0 (T^(3/2)) (E^(F1[[1]]/(kB T))), NC0 (T^(3/2)) (E^(-F1[[1]]/(kB T)))] ;
q2=If[JuncDopant[[1,1]]>0, NC0 (T^(3/2)) (E^(-F2[[2]]/(kB T))), NV0 (T^(3/2)) (E^(F2[[2]]/(kB T)))] ;
r1=  If[JuncDopant[[1,1]]>0,(mh/me)^3/2  *Exp[(F1[[1]]+F1[[2]])/(kB T)] , (me/mh)^3/2  *Exp[-(F1[[1]]+F1[[2]])/(kB T)] ] ;
r2=   If[JuncDopant[[1,1]]>0,(me/mh)^3/2  *Exp[-(F2[[1]]+F2[[2]])/(kB T)] , (mh/me)^3/2  *Exp[(F2[[1]]+F2[[2]])/(kB T)] ] ;
G=Exp[Vbias/(kB T)]-1; H=1-Exp[-2(ContactV-Vbias)/(kB T)] ;
1.602176487`*^-23*If[JuncDopant[[1,1]]>0,
( Lp q1 (1+r1 (G+1)) +Ln q2  (1+ r2 (G+1))) G  /(τ H)
,( Ln q1 (1+r1 (G+1)) +Lp q2 (1+ r2 (G+1)) ) G /(τ H)]
];

 start=0, ];
Manipulate[
SemiParm={ Eg, me,gc, mh,ϵ } ;   (* this is GaAs  *) 
Manipulate[
dtype=If[dope=="p-n",-1,1] ;
ContactV=Eg+dtype*FermiLevel[{dtype,10^d1},T,SemiParm]-dtype*FermiLevel[{-dtype,10^d2},T,SemiParm] ; 
Plot[ϕJ[x, T,Min[Vbias,ContactV],{ {dtype,10^d1},{-dtype,10^d2} }, SemiParm],{x,xL,xR}, PlotRange-> {{xL,xR},{-2,2}}
,Frame-> True, GridLines-> Automatic
,PlotStyle->{Thick,Purple}
,FrameLabel->{"Position (μm)","Static potential energy (eV)"}
,LabelStyle->Directive[14,FontFamily-> "Arial"]]
,{{dope,"p-n"},{"p-n","n-p"}},{{d1,17,"left doping ^10"},14,18},{{d2,17,"right doping ^10"},14,18}
,{{T,300,"Temperature (K)"},100,400},{{xR,2," xR range (μm)"},0.1,20},{{xL,-2," xL range (μm)"},-20,-0.1},{{Vbias,0},-0.4,0.4}]
,Grid[{{ Control[{{Eg,1.42,"Bandgap (eV)"},0.3,4}]
,Control[{{ϵ,13.6,"Dielectric const."},4,20}]}
,{Control[{{me,0.0665,"Elec eff mass me*"},0.02,0.5}]
,Control[{{mh,0.5,"Hole eff mass mh*"},0.02,1}]}
,{Control[{{gc,1,"Cond band degeneracy"},{1,6}}]}
}]
],
{{start,1,"Click to start"},{0,1}} ]

Band structure with bias

Manipulate[
If[start==1,
NDOS0[SemiParm_]:= Module[{ Eg, me, gc, mh,ϵ},
{ Eg, me, gc, mh,ϵ}=SemiParm ;
4.829415887919019`*^15  {gc  (me^(3/2)) , (mh^(3/2))} 
];
FermiLevel[Dopant_,T_,SemiParm_]:=Module[{Eg, me, gc, mh,ϵ
, NC0,NV0,type, DopeDensity, kB=  8.61739*10^(-5)},
{ Eg, me, gc, mh,ϵ}=SemiParm  ;
{NC0,NV0}= NDOS0[SemiParm] ;
{type, DopeDensity}=Dopant ;
If[type>0  , 
kB T Log[DopeDensity/(NC0 (T^(3/2)))] 
,-kB T Log[DopeDensity/(NV0 (T^(3/2))) ] ]
] ;
DepletionW[T_,Vbias_,JuncDopant_, SemiParm_]:=Module[{Eg, me, gc, mh,ϵ
,Dopant1, Dopant2,
ContactV, V0, W,
,aB=5.29177*10^(-9)
,Ryd=13.6057},
{ Eg, me, gc, mh,ϵ}=SemiParm  ;
{Dopant1, Dopant2}=JuncDopant ;
ContactV=Eg+Sign[Dopant1[[1]] ]*FermiLevel[Dopant1,T,SemiParm]+Sign[Dopant2[[1]] ]*FermiLevel[Dopant2,T,SemiParm] ;
V0=ContactV-Vbias ;
W=Sqrt[(ϵ V0/(aB  Ryd))* (1/Dopant1[[2]] +1/Dopant2[[2]]) ]  ;
10^4* W {1, Dopant2[[2]]/(Dopant1[[2]] +Dopant2[[2]])
,Dopant1[[2]]/(Dopant1[[2]] +Dopant2[[2]])  }] ;
ϕJ[x_, T_,Vbias_,JuncDopant_, SemiParm_]:= Module[{Eg, me, gc, mh,ϵ
, ContactV, V0, W, x1,x2},
{ Eg, me, gc, mh,ϵ}=SemiParm  ; 
{W, x1,x2} =DepletionW[T,Vbias,JuncDopant, SemiParm] ;
ContactV=Eg+Sign[JuncDopant[[1,1]] ]*FermiLevel[JuncDopant[[1]],T,SemiParm]+Sign[JuncDopant[[2,1]] ]*FermiLevel[JuncDopant[[2]] ,T,SemiParm] ;
V0=ContactV-Vbias ;
Sign[JuncDopant[[1,1]] ]*If[x≤-x1,0.,If[x≤ 0., V0  (x+x1)^2 /(x1*W),
If[x≤ x2, V0*(1-(x-x2)^2/(x2*W)) ,V0]
]
]
] ;
BandDiagram[x_, T_,Vbias_,JuncDopant_, SemiParm_]:= Module[{Eg, me, gc, mh,ϵ
, ContactV, V0, W,w, x1,x2},
{ Eg, me, gc, mh,ϵ}=SemiParm  ; 
{W, x1,x2} =DepletionW[T,Vbias,JuncDopant, SemiParm] ;
ContactV=Eg+Sign[JuncDopant[[1,1]] ]*FermiLevel[JuncDopant[[1]],T,SemiParm]+Sign[JuncDopant[[2,1]] ]*FermiLevel[JuncDopant[[2]] ,T,SemiParm] ;
V0=ContactV-Vbias ;
w=Sign[JuncDopant[[1,1]] ]*If[x≤-x1,0.,If[x≤ 0., V0  (x+x1)^2 /(x1*W),
If[x≤ x2, V0*(1-(x-x2)^2/(x2*W)) ,V0]
]
] ;
w-FermiLevel[JuncDopant[[1]],T,SemiParm]
+{Sign[JuncDopant[[2,1]] ]*Eg,0.} 
] ;

FermiLine[x_, T_,Vbias_,JuncDopant_, SemiParm_]:=Module[{Eg, me, gc, mh,ϵ
, ContactV, V0, W, x1,x2},
{ Eg, me, gc, mh,ϵ}=SemiParm  ; 
{W, x1,x2} =DepletionW[T,Vbias,JuncDopant, SemiParm] ;
ContactV=Eg+Sign[JuncDopant[[1,1]] ]*FermiLevel[JuncDopant[[1]],T,SemiParm]+Sign[JuncDopant[[2,1]] ]*FermiLevel[JuncDopant[[2]] ,T,SemiParm] ;
V0=ContactV-Vbias ;
If[x≥- x1,-Sign[JuncDopant[[1,1]] ]*Vbias,  ]
];
CarrierEqui[x_, T_,JuncDopant_, SemiParm_]:= Module[{Eg, me, gc, mh,ϵ 
,NC0,NV0, F
, kB=  8.61739*10^(-5)},
{ Eg, me, gc, mh,ϵ}=SemiParm  ; 
{NC0,NV0}= NDOS0[SemiParm] ;
F=BandDiagram[x, T,0.,JuncDopant, SemiParm] ;
If[JuncDopant[[1,1]]>0, 
{NC0 (T^(3/2)) (E^(-F[[2]]/(kB T))), NV0 (T^(3/2)) (E^(F[[1]]/(kB T))), NC0 (T^(3/2)) (E^(-F[[2]]/(kB T)))  +  NV0 (T^(3/2)) (E^(F[[1]]/(kB T)))} 
, {NC0 (T^(3/2)) (E^(-F[[1]]/(kB T))), NV0 (T^(3/2)) (E^(F[[2]]/(kB T))), NC0 (T^(3/2)) (E^(-F[[1]]/(kB T)))  +  NV0 (T^(3/2)) (E^(F[[2]]/(kB T)))}
]
];
CarrierJ[x_, T_,Vbias_,JuncDopant_, SemiParm_,DiffParm_]:= Module[{Eg, me, gc, mh,ϵ
, μn,μp,τ,Ln, Lp 
,NC0,NV0
, W, x1,x2
,q1,q2,F1,F2,G
, kB=  8.61739*10^(-5)},
{ Eg, me, gc, mh,ϵ}=SemiParm  ; 
{ μn,μp,τ,Ln,Lp}=DiffParm  ;
If[Ln==0. || TrueQ[Ln== Null], Ln=10^4*Sqrt[μn kB T τ], ];
If[Lp==0. || TrueQ[Lp ==  Null],Lp=10^4*Sqrt[μp kB T τ], ];
{NC0,NV0}= NDOS0[SemiParm] ;
{W, x1,x2} =DepletionW[T,Vbias,JuncDopant, SemiParm] ;
F1=BandDiagram[-x1, T,0.,JuncDopant, SemiParm] ;
F2=BandDiagram[x2, T,0.,JuncDopant, SemiParm] ;
q1=If[JuncDopant[[1,1]]≥ 0., NV0 (T^(3/2.)) (E^(F1[[1]]/(kB T))), NC0 (T^(3/2.)) (E^(-F1[[1]]/(kB T)))] ;
q2=If[JuncDopant[[1,1]]≥ 0., NC0 (T^(3/2.)) (E^(-F2[[2]]/(kB T))), NV0 (T^(3/2.)) (E^(F2[[2]]/(kB T)))] ;
G=Exp[Vbias/(kB T)]-1;
If[JuncDopant[[1,1]]≥ 0.,
If[x≤ -x1, q1 G  (E^((x+x1)/Lp)),
If [x≥ x2, q2 G  (E^(-(x-x2)/Ln)), ]
]
, If[x≤ -x1, q1 G  (E^((x+x1)/Ln)),
If [x≥ x2, q2 G  (E^(-(x-x2)/Lp)), ]
]
]
]  ;
DiffJ[x_, T_,Vbias_,JuncDopant_, SemiParm_,DiffParm_]:= Module[{Eg, me, gc, mh,ϵ
, μn,μp,τ,Ln, Lp 
,NC0,NV0
, W, x1,x2
,q1,q2,F1,F2,G
, kB=  8.61739*10^(-5)},
{ Eg, me, gc, mh,ϵ}=SemiParm  ; 
{ μn,μp,τ,Ln,Lp}=DiffParm  ;
If[Ln==0. || TrueQ[Ln== Null], Ln=10^4*Sqrt[μn kB T τ], ];
If[Lp==0. || TrueQ[Lp ==  Null],Lp=10^4*Sqrt[μp kB T τ], ];
{NC0,NV0}= NDOS0[SemiParm] ;
{W, x1,x2} =DepletionW[T,Vbias,JuncDopant, SemiParm] ;
F1=BandDiagram[-x1, T,0.,JuncDopant, SemiParm] ;
F2=BandDiagram[x2, T,0.,JuncDopant, SemiParm] ;
q1=If[JuncDopant[[1,1]]>0, NV0 (T^(3/2)) (E^(F1[[1]]/(kB T))), NC0 (T^(3/2)) (E^(-F1[[1]]/(kB T)))] ;
q2=If[JuncDopant[[1,1]]>0, NC0 (T^(3/2)) (E^(-F2[[2]]/(kB T))), NV0 (T^(3/2)) (E^(F2[[2]]/(kB T)))] ;
G=Exp[Vbias/(kB T)]-1;
1.602176487`*^-23*If[JuncDopant[[1,1]]>0,
If[x≤ -x1,Lp q1 G  (E^((x+x1)/Lp))/τ,
If [x≥ x2,Ln q2 G  (E^(-(x-x2)/Ln))/τ, ]
]
, If[x≤ -x1,Ln q1 G  (E^((x+x1)/Ln))/τ,
If [x≥ x2,Lp q2 G  (E^(-(x-x2)/Lp))/τ, ]
]
]
]  ;
DiodeC[ T_,Vbias_,JuncDopant_, SemiParm_,DiffParm_]:= Module[{Eg, me, gc, mh,ϵ
, μn,μp,τ,Ln, Lp 
,NC0,NV0
, W, x1,x2
,q1,q2,F1,F2,G
, kB=  8.61739*10^(-5)},
{ Eg, me, gc, mh,ϵ}=SemiParm  ; 
{ μn,μp,τ,Ln,Lp}=DiffParm  ;
If[Ln==0. || TrueQ[Ln== Null], Ln=10^4*Sqrt[μn kB T τ], ];
If[Lp==0. || TrueQ[Lp ==  Null],Lp=10^4*Sqrt[μp kB T τ], ];
{NC0,NV0}= NDOS0[SemiParm] ;
{W, x1,x2} =DepletionW[T,Vbias,JuncDopant, SemiParm] ;
F1=BandDiagram[-x1, T,0.,JuncDopant, SemiParm] ;
F2=BandDiagram[x2, T,0.,JuncDopant, SemiParm] ;
q1=If[JuncDopant[[1,1]]>0, NV0 (T^(3/2)) (E^(F1[[1]]/(kB T))), NC0 (T^(3/2)) (E^(-F1[[1]]/(kB T)))] ;
q2=If[JuncDopant[[1,1]]>0, NC0 (T^(3/2)) (E^(-F2[[2]]/(kB T))), NV0 (T^(3/2)) (E^(F2[[2]]/(kB T)))] ;
G=Exp[Vbias/(kB T)]-1;
1.602176487`*^-23*If[JuncDopant[[1,1]]>0,
( Lp q1 +Ln q2 ) G  /τ ,( Ln q1 +Lp q2 ) G /τ]
]  ;
DiodeC1[ T_,Vbias_,JuncDopant_, SemiParm_,DiffParm_]:= Module[{Eg, me, gc, mh,ϵ
, μn,μp,τ,Ln, Lp 
,NC0,NV0
, W, x1,x2,ContactV,Ef1,Ef2
,q1,q2,F1,F2,G,r1,r2,H
, kB=  8.61739*10^(-5)},
{ Eg, me, gc, mh,ϵ}=SemiParm  ; 
{ μn,μp,τ,Ln,Lp}=DiffParm  ;
If[Ln==0. || TrueQ[Ln== Null], Ln=10^4*Sqrt[μn kB T τ], ];
If[Lp==0. || TrueQ[Lp ==  Null],Lp=10^4*Sqrt[μp kB T τ], ];
{NC0,NV0}= NDOS0[SemiParm] ;
Ef1=  FermiLevel[JuncDopant[[1]],T,SemiParm];
Ef2=  FermiLevel[JuncDopant[[2]],T,SemiParm];
ContactV=Eg+Sign[JuncDopant[[1,1]] ]*FermiLevel[JuncDopant[[1]],T,SemiParm]+Sign[JuncDopant[[2,1]] ]*FermiLevel[JuncDopant[[2]] ,T,SemiParm] ;
{W, x1,x2} =DepletionW[T,Vbias,JuncDopant, SemiParm] ;
F1=BandDiagram[-x1, T,0.,JuncDopant, SemiParm] ;
F2=BandDiagram[x2, T,0.,JuncDopant, SemiParm] ;
q1=If[JuncDopant[[1,1]]>0, NV0 (T^(3/2)) (E^(F1[[1]]/(kB T))), NC0 (T^(3/2)) (E^(-F1[[1]]/(kB T)))] ;
q2=If[JuncDopant[[1,1]]>0, NC0 (T^(3/2)) (E^(-F2[[2]]/(kB T))), NV0 (T^(3/2)) (E^(F2[[2]]/(kB T)))] ;
r1=  If[JuncDopant[[1,1]]>0,(mh/me)^3/2  *Exp[(F1[[1]]+F1[[2]])/(kB T)] , (me/mh)^3/2  *Exp[-(F1[[1]]+F1[[2]])/(kB T)] ] ;
r2=   If[JuncDopant[[1,1]]>0,(me/mh)^3/2  *Exp[-(F2[[1]]+F2[[2]])/(kB T)] , (mh/me)^3/2  *Exp[(F2[[1]]+F2[[2]])/(kB T)] ] ;
G=Exp[Vbias/(kB T)]-1; H=1-Exp[-2(ContactV-Vbias)/(kB T)] ;
1.602176487`*^-23*If[JuncDopant[[1,1]]>0,
( Lp q1 (1+r1 (G+1)) +Ln q2  (1+ r2 (G+1))) G  /(τ H)
,( Ln q1 (1+r1 (G+1)) +Lp q2 (1+ r2 (G+1)) ) G /(τ H)]
];

 start=0, ];
Manipulate[
If[ONOFF=="ON",
Manipulate[
SemiParm={ Eg, me,gc, mh,ϵ } ;   (* this is GaAs  *)
Manipulate[
dtype=If[dope=="p-n",-1,1] ;
ContactV=Eg+dtype*FermiLevel[{dtype,10^d1},T,SemiParm]-dtype*FermiLevel[{-dtype,10^d2},T,SemiParm] ; 
VbiasL=Min[Vbias,ContactV] ;Show[Plot[BandDiagram[x, T,VbiasL,{ {dtype,10^d1},{-dtype,10^d2} }, SemiParm],{x,xL,xR}, PlotRange-> All, PlotStyle-> Thick
,Frame-> True, GridLines-> Automatic
,FrameLabel->{"Position (μm)","Energy (eV)"}
,LabelStyle->Directive[14,FontFamily-> "Arial"]]
,Graphics[{If[dtype<0,Red,Blue], Rectangle[{0,0}
,{DepletionW[T,VbiasL,{ {dtype,10^d1},{-dtype,10^d2} }, SemiParm][[3]],-Sign[dtype]* 10^d2/(10^d1+10^d2)}]} ]
,Graphics[ {If[dtype<0,Blue,Red],Rectangle[
{-DepletionW[T,VbiasL,{ {dtype,10^d1},{-dtype,10^d2} }, SemiParm][[2]]
,Sign[dtype]*10^d1/(10^d1+10^d2)},{0,0}]}
]
, Plot[BandDiagram[x, T,VbiasL,{ {dtype,10^d1},{-dtype,10^d2} }, SemiParm][[2]],{x,xL,xR}, PlotRange-> All, PlotStyle-> {Thick, Purple}]
, Plot[BandDiagram[x, T,VbiasL,{ {dtype,10^d1},{-dtype,10^d2} }, SemiParm][[1]],{x,xL,xR}, PlotRange-> All, PlotStyle-> {Thick, Hue[0.4,1,0.5]}
,PlotRange-> {{xL,xR},All}] 
,Plot[FermiLine[x, T,VbiasL,{ {dtype,10^d1},{-dtype,10^d2} }, SemiParm],{x,xL,xR}, PlotRange-> All, PlotStyle-> {Thick,Dashed,Black}
,PlotRange-> {{xL,xR},All}] 
 ],
{{dope,"p-n"},{"p-n","n-p"}},{{d1,17,"left doping ^10"},14,18},{{d2,17,"right doping ^10"},14,18}
,{{T,300,"Temperature (K)"},100,400},{{xR,2," xR range (μm)"},0.1,20},{{xL,-2," xL range (μm)"},-20,-0.1},{{Vbias,0},-1,1}]
,Grid[{{ Control[{{Eg,1.42,"Bandgap (eV)"},0.3,4}]
,Control[{{ϵ,13.6,"Dielectric const."},4,20}]}
,{Control[{{me,0.0665,"Elec eff mass me*"},0.02,0.5}]
,Control[{{mh,0.5,"Hole eff mass mh*"},0.02,1}]}
,{Control[{{gc,1,"Cond band degeneracy"},{1,6}}]}
}]
], ]
,{{ONOFF,"ON","Click OFF if not used"},{"ON","OFF"}}
],
{{start,1,"Click to start"},{0,1}} ]

3.2 Carrier density

Reviewing of the diffusion model in Chapter 4

Using the model of diffusion, the carrier excess density near the junction has the form:
                           (Subscript[p, n;e])[x]:=(Subscript[p, n;e])[(Subscript[x, n])] (e^(-(x-(Subscript[x, n]))/(Subscript[L, p])))                 (1)
We need to find (Subscript[p, n;e])[(Subscript[x, n])]=(Subscript[p, n])[(Subscript[x, n])]-(Subscript[p, n;0])[(Subscript[x, n])]                   (2)
We know that          (Subscript[p, n])[(Subscript[x, n])]=(Subscript[N, V])(e^(-((Subscript[E, f;1])-(Subscript[E, V;2]))/(Subscript[k, B])T))            (3)
 At equilibrium:    (Subscript[p, n;0])[(Subscript[x, n])]=(Subscript[N, V])(e^(-((Subscript[E, f;2])-(Subscript[E, V;2]))/(Subscript[k, B])T))              (4)
 Thus:                  (Subscript[p, n;e])[(Subscript[x, n])]=(Subscript[N, V]) ((e^(-((Subscript[E, f;1])-(Subscript[E, V;2]))/(Subscript[k, B])T))-(e^(-((Subscript[E, f;2])-(Subscript[E, V;2]))/(Subscript[k, B])T))) 
                            (Subscript[p, n;e])[(Subscript[x, n])]=(Subscript[p, n;0])[(Subscript[x, n])] ((e^(-((Subscript[E, f;1])-(Subscript[E, f;2]))/(Subscript[k, B])T))-1)=(Subscript[p, n;0])[(Subscript[x, n])] ((e^(e (Subscript[V, b])/(Subscript[k, B])T))-1)           (5)
 Subs (5) in (1):
                              (Subscript[p, n;e])[x]:=(Subscript[p, n;0])[(Subscript[x, n])] ((e^(e (Subscript[V, b])/(Subscript[k, B])T))-1) (e^(-(x-(Subscript[x, n]))/(Subscript[L, p])))                 (6)
 Similarly:               (Subscript[n, p;e])[x]:=(Subscript[n, p;0])[-(Subscript[x, p])] ((e^(e (Subscript[V, b])/(Subscript[k, B])T))-1) (e^((x+(Subscript[x, n]))/(Subscript[L, n])))                (7)

3.2.1 Excess carrier density under bias: linear scale plotting

Let’s plot excess carrier densities:

Excess carrier densities - linear scale

Manipulate[
If[start==1,
NDOS0[SemiParm_]:= Module[{ Eg, me, gc, mh,ϵ},
{ Eg, me, gc, mh,ϵ}=SemiParm ;
4.829415887919019`*^15  {gc  (me^(3/2)) , (mh^(3/2))} 
];
FermiLevel[Dopant_,T_,SemiParm_]:=Module[{Eg, me, gc, mh,ϵ
, NC0,NV0,type, DopeDensity, kB=  8.61739*10^(-5)},
{ Eg, me, gc, mh,ϵ}=SemiParm  ;
{NC0,NV0}= NDOS0[SemiParm] ;
{type, DopeDensity}=Dopant ;
If[type>0  , 
kB T Log[DopeDensity/(NC0 (T^(3/2)))] 
,-kB T Log[DopeDensity/(NV0 (T^(3/2))) ] ]
] ;
DepletionW[T_,Vbias_,JuncDopant_, SemiParm_]:=Module[{Eg, me, gc, mh,ϵ
,Dopant1, Dopant2,
ContactV, V0, W,
,aB=5.29177*10^(-9)
,Ryd=13.6057},
{ Eg, me, gc, mh,ϵ}=SemiParm  ;
{Dopant1, Dopant2}=JuncDopant ;
ContactV=Eg+Sign[Dopant1[[1]] ]*FermiLevel[Dopant1,T,SemiParm]+Sign[Dopant2[[1]] ]*FermiLevel[Dopant2,T,SemiParm] ;
V0=ContactV-Vbias ;
W=Sqrt[(ϵ V0/(aB  Ryd))* (1/Dopant1[[2]] +1/Dopant2[[2]]) ]  ;
10^4* W {1, Dopant2[[2]]/(Dopant1[[2]] +Dopant2[[2]])
,Dopant1[[2]]/(Dopant1[[2]] +Dopant2[[2]])  }] ;
ϕJ[x_, T_,Vbias_,JuncDopant_, SemiParm_]:= Module[{Eg, me, gc, mh,ϵ
, ContactV, V0, W, x1,x2},
{ Eg, me, gc, mh,ϵ}=SemiParm  ; 
{W, x1,x2} =DepletionW[T,Vbias,JuncDopant, SemiParm] ;
ContactV=Eg+Sign[JuncDopant[[1,1]] ]*FermiLevel[JuncDopant[[1]],T,SemiParm]+Sign[JuncDopant[[2,1]] ]*FermiLevel[JuncDopant[[2]] ,T,SemiParm] ;
V0=ContactV-Vbias ;
Sign[JuncDopant[[1,1]] ]*If[x≤-x1,0.,If[x≤ 0., V0  (x+x1)^2 /(x1*W),
If[x≤ x2, V0*(1-(x-x2)^2/(x2*W)) ,V0]
]
]
] ;
BandDiagram[x_, T_,Vbias_,JuncDopant_, SemiParm_]:= Module[{Eg, me, gc, mh,ϵ
, ContactV, V0, W,w, x1,x2},
{ Eg, me, gc, mh,ϵ}=SemiParm  ; 
{W, x1,x2} =DepletionW[T,Vbias,JuncDopant, SemiParm] ;
ContactV=Eg+Sign[JuncDopant[[1,1]] ]*FermiLevel[JuncDopant[[1]],T,SemiParm]+Sign[JuncDopant[[2,1]] ]*FermiLevel[JuncDopant[[2]] ,T,SemiParm] ;
V0=ContactV-Vbias ;
w=Sign[JuncDopant[[1,1]] ]*If[x≤-x1,0.,If[x≤ 0., V0  (x+x1)^2 /(x1*W),
If[x≤ x2, V0*(1-(x-x2)^2/(x2*W)) ,V0]
]
] ;
w-FermiLevel[JuncDopant[[1]],T,SemiParm]
+{Sign[JuncDopant[[2,1]] ]*Eg,0.} 
] ;

FermiLine[x_, T_,Vbias_,JuncDopant_, SemiParm_]:=Module[{Eg, me, gc, mh,ϵ
, ContactV, V0, W, x1,x2},
{ Eg, me, gc, mh,ϵ}=SemiParm  ; 
{W, x1,x2} =DepletionW[T,Vbias,JuncDopant, SemiParm] ;
ContactV=Eg+Sign[JuncDopant[[1,1]] ]*FermiLevel[JuncDopant[[1]],T,SemiParm]+Sign[JuncDopant[[2,1]] ]*FermiLevel[JuncDopant[[2]] ,T,SemiParm] ;
V0=ContactV-Vbias ;
If[x≥- x1,-Sign[JuncDopant[[1,1]] ]*Vbias,  ]
];
CarrierEqui[x_, T_,JuncDopant_, SemiParm_]:= Module[{Eg, me, gc, mh,ϵ 
,NC0,NV0, F
, kB=  8.61739*10^(-5)},
{ Eg, me, gc, mh,ϵ}=SemiParm  ; 
{NC0,NV0}= NDOS0[SemiParm] ;
F=BandDiagram[x, T,0.,JuncDopant, SemiParm] ;
If[JuncDopant[[1,1]]>0, 
{NC0 (T^(3/2)) (E^(-F[[2]]/(kB T))), NV0 (T^(3/2)) (E^(F[[1]]/(kB T))), NC0 (T^(3/2)) (E^(-F[[2]]/(kB T)))  +  NV0 (T^(3/2)) (E^(F[[1]]/(kB T)))} 
, {NC0 (T^(3/2)) (E^(-F[[1]]/(kB T))), NV0 (T^(3/2)) (E^(F[[2]]/(kB T))), NC0 (T^(3/2)) (E^(-F[[1]]/(kB T)))  +  NV0 (T^(3/2)) (E^(F[[2]]/(kB T)))}
]
];
CarrierJ[x_, T_,Vbias_,JuncDopant_, SemiParm_,DiffParm_]:= Module[{Eg, me, gc, mh,ϵ
, μn,μp,τ,Ln, Lp 
,NC0,NV0
, W, x1,x2
,q1,q2,F1,F2,G
, kB=  8.61739*10^(-5)},
{ Eg, me, gc, mh,ϵ}=SemiParm  ; 
{ μn,μp,τ,Ln,Lp}=DiffParm  ;
If[Ln==0. || TrueQ[Ln== Null], Ln=10^4*Sqrt[μn kB T τ], ];
If[Lp==0. || TrueQ[Lp ==  Null],Lp=10^4*Sqrt[μp kB T τ], ];
{NC0,NV0}= NDOS0[SemiParm] ;
{W, x1,x2} =DepletionW[T,Vbias,JuncDopant, SemiParm] ;
F1=BandDiagram[-x1, T,0.,JuncDopant, SemiParm] ;
F2=BandDiagram[x2, T,0.,JuncDopant, SemiParm] ;
q1=If[JuncDopant[[1,1]]≥ 0., NV0 (T^(3/2.)) (E^(F1[[1]]/(kB T))), NC0 (T^(3/2.)) (E^(-F1[[1]]/(kB T)))] ;
q2=If[JuncDopant[[1,1]]≥ 0., NC0 (T^(3/2.)) (E^(-F2[[2]]/(kB T))), NV0 (T^(3/2.)) (E^(F2[[2]]/(kB T)))] ;
G=Exp[Vbias/(kB T)]-1;
If[JuncDopant[[1,1]]≥ 0.,
If[x≤ -x1, q1 G  (E^((x+x1)/Lp)),
If [x≥ x2, q2 G  (E^(-(x-x2)/Ln)), ]
]
, If[x≤ -x1, q1 G  (E^((x+x1)/Ln)),
If [x≥ x2, q2 G  (E^(-(x-x2)/Lp)), ]
]
]
]  ;
DiffJ[x_, T_,Vbias_,JuncDopant_, SemiParm_,DiffParm_]:= Module[{Eg, me, gc, mh,ϵ
, μn,μp,τ,Ln, Lp 
,NC0,NV0
, W, x1,x2
,q1,q2,F1,F2,G
, kB=  8.61739*10^(-5)},
{ Eg, me, gc, mh,ϵ}=SemiParm  ; 
{ μn,μp,τ,Ln,Lp}=DiffParm  ;
If[Ln==0. || TrueQ[Ln== Null], Ln=10^4*Sqrt[μn kB T τ], ];
If[Lp==0. || TrueQ[Lp ==  Null],Lp=10^4*Sqrt[μp kB T τ], ];
{NC0,NV0}= NDOS0[SemiParm] ;
{W, x1,x2} =DepletionW[T,Vbias,JuncDopant, SemiParm] ;
F1=BandDiagram[-x1, T,0.,JuncDopant, SemiParm] ;
F2=BandDiagram[x2, T,0.,JuncDopant, SemiParm] ;
q1=If[JuncDopant[[1,1]]>0, NV0 (T^(3/2)) (E^(F1[[1]]/(kB T))), NC0 (T^(3/2)) (E^(-F1[[1]]/(kB T)))] ;
q2=If[JuncDopant[[1,1]]>0, NC0 (T^(3/2)) (E^(-F2[[2]]/(kB T))), NV0 (T^(3/2)) (E^(F2[[2]]/(kB T)))] ;
G=Exp[Vbias/(kB T)]-1;
1.602176487`*^-23*If[JuncDopant[[1,1]]>0,
If[x≤ -x1,Lp q1 G  (E^((x+x1)/Lp))/τ,
If [x≥ x2,Ln q2 G  (E^(-(x-x2)/Ln))/τ, ]
]
, If[x≤ -x1,Ln q1 G  (E^((x+x1)/Ln))/τ,
If [x≥ x2,Lp q2 G  (E^(-(x-x2)/Lp))/τ, ]
]
]
]  ;
DiodeC[ T_,Vbias_,JuncDopant_, SemiParm_,DiffParm_]:= Module[{Eg, me, gc, mh,ϵ
, μn,μp,τ,Ln, Lp 
,NC0,NV0
, W, x1,x2
,q1,q2,F1,F2,G
, kB=  8.61739*10^(-5)},
{ Eg, me, gc, mh,ϵ}=SemiParm  ; 
{ μn,μp,τ,Ln,Lp}=DiffParm  ;
If[Ln==0. || TrueQ[Ln== Null], Ln=10^4*Sqrt[μn kB T τ], ];
If[Lp==0. || TrueQ[Lp ==  Null],Lp=10^4*Sqrt[μp kB T τ], ];
{NC0,NV0}= NDOS0[SemiParm] ;
{W, x1,x2} =DepletionW[T,Vbias,JuncDopant, SemiParm] ;
F1=BandDiagram[-x1, T,0.,JuncDopant, SemiParm] ;
F2=BandDiagram[x2, T,0.,JuncDopant, SemiParm] ;
q1=If[JuncDopant[[1,1]]>0, NV0 (T^(3/2)) (E^(F1[[1]]/(kB T))), NC0 (T^(3/2)) (E^(-F1[[1]]/(kB T)))] ;
q2=If[JuncDopant[[1,1]]>0, NC0 (T^(3/2)) (E^(-F2[[2]]/(kB T))), NV0 (T^(3/2)) (E^(F2[[2]]/(kB T)))] ;
G=Exp[Vbias/(kB T)]-1;
1.602176487`*^-23*If[JuncDopant[[1,1]]>0,
( Lp q1 +Ln q2 ) G  /τ ,( Ln q1 +Lp q2 ) G /τ]
]  ;
DiodeC1[ T_,Vbias_,JuncDopant_, SemiParm_,DiffParm_]:= Module[{Eg, me, gc, mh,ϵ
, μn,μp,τ,Ln, Lp 
,NC0,NV0
, W, x1,x2,ContactV,Ef1,Ef2
,q1,q2,F1,F2,G,r1,r2,H
, kB=  8.61739*10^(-5)},
{ Eg, me, gc, mh,ϵ}=SemiParm  ; 
{ μn,μp,τ,Ln,Lp}=DiffParm  ;
If[Ln==0. || TrueQ[Ln== Null], Ln=10^4*Sqrt[μn kB T τ], ];
If[Lp==0. || TrueQ[Lp ==  Null],Lp=10^4*Sqrt[μp kB T τ], ];
{NC0,NV0}= NDOS0[SemiParm] ;
Ef1=  FermiLevel[JuncDopant[[1]],T,SemiParm];
Ef2=  FermiLevel[JuncDopant[[2]],T,SemiParm];
ContactV=Eg+Sign[JuncDopant[[1,1]] ]*FermiLevel[JuncDopant[[1]],T,SemiParm]+Sign[JuncDopant[[2,1]] ]*FermiLevel[JuncDopant[[2]] ,T,SemiParm] ;
{W, x1,x2} =DepletionW[T,Vbias,JuncDopant, SemiParm] ;
F1=BandDiagram[-x1, T,0.,JuncDopant, SemiParm] ;
F2=BandDiagram[x2, T,0.,JuncDopant, SemiParm] ;
q1=If[JuncDopant[[1,1]]>0, NV0 (T^(3/2)) (E^(F1[[1]]/(kB T))), NC0 (T^(3/2)) (E^(-F1[[1]]/(kB T)))] ;
q2=If[JuncDopant[[1,1]]>0, NC0 (T^(3/2)) (E^(-F2[[2]]/(kB T))), NV0 (T^(3/2)) (E^(F2[[2]]/(kB T)))] ;
r1=  If[JuncDopant[[1,1]]>0,(mh/me)^3/2  *Exp[(F1[[1]]+F1[[2]])/(kB T)] , (me/mh)^3/2  *Exp[-(F1[[1]]+F1[[2]])/(kB T)] ] ;
r2=   If[JuncDopant[[1,1]]>0,(me/mh)^3/2  *Exp[-(F2[[1]]+F2[[2]])/(kB T)] , (mh/me)^3/2  *Exp[(F2[[1]]+F2[[2]])/(kB T)] ] ;
G=Exp[Vbias/(kB T)]-1; H=1-Exp[-2(ContactV-Vbias)/(kB T)] ;
1.602176487`*^-23*If[JuncDopant[[1,1]]>0,
( Lp q1 (1+r1 (G+1)) +Ln q2  (1+ r2 (G+1))) G  /(τ H)
,( Ln q1 (1+r1 (G+1)) +Lp q2 (1+ r2 (G+1)) ) G /(τ H)]
];

 start=0, ];
Manipulate[
If[ONOFF=="ON",
Manipulate[
SemiParm={ Eg, me,gc, mh,ϵ } ;  
Manipulate[
DiffParm ={μn,μp,10^τ,Ln,Lp};
dtype=If[dope=="p-n",-1,1] ;
ContactV=Eg+dtype*FermiLevel[{dtype,10^d1},T,SemiParm]-dtype*FermiLevel[{-dtype,10^d2},T,SemiParm] ; 
VbiasL=Min[Vbias,ContactV] ;
Show[Plot[CarrierJ[x, T,VbiasL,{ {dtype,10.^d1},{-dtype,10.^d2} }, SemiParm, DiffParm],
{x,xL,0},PlotRange-> {{xL,xR},{-(10.^-Mm),10.^Mp}}
,Frame-> True, GridLines-> Automatic
, Filling-> {1-> {Axis,If[dtype==1,Hue[0.6,1,1,0.4],Hue[0,1,1,0.3] ] }}
,PlotStyle->{Thick,If[dtype==1,Blue, Red] }
,FrameLabel->{"Position (μm)","Excess carrier density ((cm^(-3)) )"}
,LabelStyle->Directive[14,FontFamily-> "Arial"] ]
,Plot[CarrierJ[x, T,VbiasL,{ {dtype,10.^d1},{-dtype,10.^d2} }, SemiParm, DiffParm],
{x,0,xR},PlotRange-> {{xL,xR},{-(10.^-Mm),10.^Mp}}
,Frame-> True, GridLines-> Automatic
, Filling-> {1-> {Axis,If[dtype==1,Hue[0,1,1,0.3],Hue[0.6,1,1,0.4] ] }}
,PlotStyle->{Thick,If[dtype==1, Red,Blue] }
,FrameLabel->{"Position (μm)","Excess carrier density ((cm^(-3)) )"}
,LabelStyle->Directive[14,FontFamily-> "Arial"] ]
],
{{dope,"p-n"},{"p-n","n-p"}},{{d1,17,"left doping ^10"},14,18},{{d2,17,"right doping ^10"},14,18}
,{{T,300,"Temperature (K)"},100,400}
,{{ Ln,0.,"e diff length (μm)"},1.,100.}
,{{ Lp,0.,"h diff length (μm)"},1.,100.}
,{{xR,10," xR range (μm)"},5,50},{{xL,-10," xL range (μm)"},-50,-5},{{Mp,13,"Max positive"},-10,22},{{Mm,0,"Max negative"},0,10},{{Vbias,0},-1,1}]
,Grid[{{ Control[{{Eg,1.42,"Bandgap (eV)"},0.3,4}]
,Control[{{ϵ,13.6,"Dielectric const."},4,20}]}
,{Control[{{me,0.0665,"Elec eff mass me*"},0.02,0.5}]
,Control[{{mh,0.5,"Hole eff mass mh*"},0.02,1}]}
,{Control[{{gc,1,"Cond band degeneracy"},{1,6}}]}
,{Control[{{ μn,3000.,"e mobility"},100.,10000.}]
,Control[{{ μp,200.,"h mobility"},10.,1000.}]
,Control[{{ τ,-9,"carrier lifetime (10^)"},-12,-6}]
}
}]
], ]
,{{ONOFF,"ON","Click OFF if not used"},{"ON","OFF"}}
],
{{start,1,"Click to start"},{0,1}} ]

3.2.2 Excess carrier density under bias: Log scale plotting

(positive bias only)

Excess carrier densities - log scale

Manipulate[
If[start==1,
NDOS0[SemiParm_]:= Module[{ Eg, me, gc, mh,ϵ},
{ Eg, me, gc, mh,ϵ}=SemiParm ;
4.829415887919019`*^15  {gc  (me^(3/2)) , (mh^(3/2))} 
];
FermiLevel[Dopant_,T_,SemiParm_]:=Module[{Eg, me, gc, mh,ϵ
, NC0,NV0,type, DopeDensity, kB=  8.61739*10^(-5)},
{ Eg, me, gc, mh,ϵ}=SemiParm  ;
{NC0,NV0}= NDOS0[SemiParm] ;
{type, DopeDensity}=Dopant ;
If[type>0  , 
kB T Log[DopeDensity/(NC0 (T^(3/2)))] 
,-kB T Log[DopeDensity/(NV0 (T^(3/2))) ] ]
] ;
DepletionW[T_,Vbias_,JuncDopant_, SemiParm_]:=Module[{Eg, me, gc, mh,ϵ
,Dopant1, Dopant2,
ContactV, V0, W,
,aB=5.29177*10^(-9)
,Ryd=13.6057},
{ Eg, me, gc, mh,ϵ}=SemiParm  ;
{Dopant1, Dopant2}=JuncDopant ;
ContactV=Eg+Sign[Dopant1[[1]] ]*FermiLevel[Dopant1,T,SemiParm]+Sign[Dopant2[[1]] ]*FermiLevel[Dopant2,T,SemiParm] ;
V0=ContactV-Vbias ;
W=Sqrt[(ϵ V0/(aB  Ryd))* (1/Dopant1[[2]] +1/Dopant2[[2]]) ]  ;
10^4* W {1, Dopant2[[2]]/(Dopant1[[2]] +Dopant2[[2]])
,Dopant1[[2]]/(Dopant1[[2]] +Dopant2[[2]])  }] ;
ϕJ[x_, T_,Vbias_,JuncDopant_, SemiParm_]:= Module[{Eg, me, gc, mh,ϵ
, ContactV, V0, W, x1,x2},
{ Eg, me, gc, mh,ϵ}=SemiParm  ; 
{W, x1,x2} =DepletionW[T,Vbias,JuncDopant, SemiParm] ;
ContactV=Eg+Sign[JuncDopant[[1,1]] ]*FermiLevel[JuncDopant[[1]],T,SemiParm]+Sign[JuncDopant[[2,1]] ]*FermiLevel[JuncDopant[[2]] ,T,SemiParm] ;
V0=ContactV-Vbias ;
Sign[JuncDopant[[1,1]] ]*If[x≤-x1,0.,If[x≤ 0., V0  (x+x1)^2 /(x1*W),
If[x≤ x2, V0*(1-(x-x2)^2/(x2*W)) ,V0]
]
]
] ;
BandDiagram[x_, T_,Vbias_,JuncDopant_, SemiParm_]:= Module[{Eg, me, gc, mh,ϵ
, ContactV, V0, W,w, x1,x2},
{ Eg, me, gc, mh,ϵ}=SemiParm  ; 
{W, x1,x2} =DepletionW[T,Vbias,JuncDopant, SemiParm] ;
ContactV=Eg+Sign[JuncDopant[[1,1]] ]*FermiLevel[JuncDopant[[1]],T,SemiParm]+Sign[JuncDopant[[2,1]] ]*FermiLevel[JuncDopant[[2]] ,T,SemiParm] ;
V0=ContactV-Vbias ;
w=Sign[JuncDopant[[1,1]] ]*If[x≤-x1,0.,If[x≤ 0., V0  (x+x1)^2 /(x1*W),
If[x≤ x2, V0*(1-(x-x2)^2/(x2*W)) ,V0]
]
] ;
w-FermiLevel[JuncDopant[[1]],T,SemiParm]
+{Sign[JuncDopant[[2,1]] ]*Eg,0.} 
] ;

FermiLine[x_, T_,Vbias_,JuncDopant_, SemiParm_]:=Module[{Eg, me, gc, mh,ϵ
, ContactV, V0, W, x1,x2},
{ Eg, me, gc, mh,ϵ}=SemiParm  ; 
{W, x1,x2} =DepletionW[T,Vbias,JuncDopant, SemiParm] ;
ContactV=Eg+Sign[JuncDopant[[1,1]] ]*FermiLevel[JuncDopant[[1]],T,SemiParm]+Sign[JuncDopant[[2,1]] ]*FermiLevel[JuncDopant[[2]] ,T,SemiParm] ;
V0=ContactV-Vbias ;
If[x≥- x1,-Sign[JuncDopant[[1,1]] ]*Vbias,  ]
];
CarrierEqui[x_, T_,JuncDopant_, SemiParm_]:= Module[{Eg, me, gc, mh,ϵ 
,NC0,NV0, F
, kB=  8.61739*10^(-5)},
{ Eg, me, gc, mh,ϵ}=SemiParm  ; 
{NC0,NV0}= NDOS0[SemiParm] ;
F=BandDiagram[x, T,0.,JuncDopant, SemiParm] ;
If[JuncDopant[[1,1]]>0, 
{NC0 (T^(3/2)) (E^(-F[[2]]/(kB T))), NV0 (T^(3/2)) (E^(F[[1]]/(kB T))), NC0 (T^(3/2)) (E^(-F[[2]]/(kB T)))  +  NV0 (T^(3/2)) (E^(F[[1]]/(kB T)))} 
, {NC0 (T^(3/2)) (E^(-F[[1]]/(kB T))), NV0 (T^(3/2)) (E^(F[[2]]/(kB T))), NC0 (T^(3/2)) (E^(-F[[1]]/(kB T)))  +  NV0 (T^(3/2)) (E^(F[[2]]/(kB T)))}
]
];
CarrierJ[x_, T_,Vbias_,JuncDopant_, SemiParm_,DiffParm_]:= Module[{Eg, me, gc, mh,ϵ
, μn,μp,τ,Ln, Lp 
,NC0,NV0
, W, x1,x2
,q1,q2,F1,F2,G
, kB=  8.61739*10^(-5)},
{ Eg, me, gc, mh,ϵ}=SemiParm  ; 
{ μn,μp,τ,Ln,Lp}=DiffParm  ;
If[Ln==0. || TrueQ[Ln== Null], Ln=10^4*Sqrt[μn kB T τ], ];
If[Lp==0. || TrueQ[Lp ==  Null],Lp=10^4*Sqrt[μp kB T τ], ];
{NC0,NV0}= NDOS0[SemiParm] ;
{W, x1,x2} =DepletionW[T,Vbias,JuncDopant, SemiParm] ;
F1=BandDiagram[-x1, T,0.,JuncDopant, SemiParm] ;
F2=BandDiagram[x2, T,0.,JuncDopant, SemiParm] ;
q1=If[JuncDopant[[1,1]]≥ 0., NV0 (T^(3/2.)) (E^(F1[[1]]/(kB T))), NC0 (T^(3/2.)) (E^(-F1[[1]]/(kB T)))] ;
q2=If[JuncDopant[[1,1]]≥ 0., NC0 (T^(3/2.)) (E^(-F2[[2]]/(kB T))), NV0 (T^(3/2.)) (E^(F2[[2]]/(kB T)))] ;
G=Exp[Vbias/(kB T)]-1;
If[JuncDopant[[1,1]]≥ 0.,
If[x≤ -x1, q1 G  (E^((x+x1)/Lp)),
If [x≥ x2, q2 G  (E^(-(x-x2)/Ln)), ]
]
, If[x≤ -x1, q1 G  (E^((x+x1)/Ln)),
If [x≥ x2, q2 G  (E^(-(x-x2)/Lp)), ]
]
]
]  ;
DiffJ[x_, T_,Vbias_,JuncDopant_, SemiParm_,DiffParm_]:= Module[{Eg, me, gc, mh,ϵ
, μn,μp,τ,Ln, Lp 
,NC0,NV0
, W, x1,x2
,q1,q2,F1,F2,G
, kB=  8.61739*10^(-5)},
{ Eg, me, gc, mh,ϵ}=SemiParm  ; 
{ μn,μp,τ,Ln,Lp}=DiffParm  ;
If[Ln==0. || TrueQ[Ln== Null], Ln=10^4*Sqrt[μn kB T τ], ];
If[Lp==0. || TrueQ[Lp ==  Null],Lp=10^4*Sqrt[μp kB T τ], ];
{NC0,NV0}= NDOS0[SemiParm] ;
{W, x1,x2} =DepletionW[T,Vbias,JuncDopant, SemiParm] ;
F1=BandDiagram[-x1, T,0.,JuncDopant, SemiParm] ;
F2=BandDiagram[x2, T,0.,JuncDopant, SemiParm] ;
q1=If[JuncDopant[[1,1]]>0, NV0 (T^(3/2)) (E^(F1[[1]]/(kB T))), NC0 (T^(3/2)) (E^(-F1[[1]]/(kB T)))] ;
q2=If[JuncDopant[[1,1]]>0, NC0 (T^(3/2)) (E^(-F2[[2]]/(kB T))), NV0 (T^(3/2)) (E^(F2[[2]]/(kB T)))] ;
G=Exp[Vbias/(kB T)]-1;
1.602176487`*^-23*If[JuncDopant[[1,1]]>0,
If[x≤ -x1,Lp q1 G  (E^((x+x1)/Lp))/τ,
If [x≥ x2,Ln q2 G  (E^(-(x-x2)/Ln))/τ, ]
]
, If[x≤ -x1,Ln q1 G  (E^((x+x1)/Ln))/τ,
If [x≥ x2,Lp q2 G  (E^(-(x-x2)/Lp))/τ, ]
]
]
]  ;
DiodeC[ T_,Vbias_,JuncDopant_, SemiParm_,DiffParm_]:= Module[{Eg, me, gc, mh,ϵ
, μn,μp,τ,Ln, Lp 
,NC0,NV0
, W, x1,x2
,q1,q2,F1,F2,G
, kB=  8.61739*10^(-5)},
{ Eg, me, gc, mh,ϵ}=SemiParm  ; 
{ μn,μp,τ,Ln,Lp}=DiffParm  ;
If[Ln==0. || TrueQ[Ln== Null], Ln=10^4*Sqrt[μn kB T τ], ];
If[Lp==0. || TrueQ[Lp ==  Null],Lp=10^4*Sqrt[μp kB T τ], ];
{NC0,NV0}= NDOS0[SemiParm] ;
{W, x1,x2} =DepletionW[T,Vbias,JuncDopant, SemiParm] ;
F1=BandDiagram[-x1, T,0.,JuncDopant, SemiParm] ;
F2=BandDiagram[x2, T,0.,JuncDopant, SemiParm] ;
q1=If[JuncDopant[[1,1]]>0, NV0 (T^(3/2)) (E^(F1[[1]]/(kB T))), NC0 (T^(3/2)) (E^(-F1[[1]]/(kB T)))] ;
q2=If[JuncDopant[[1,1]]>0, NC0 (T^(3/2)) (E^(-F2[[2]]/(kB T))), NV0 (T^(3/2)) (E^(F2[[2]]/(kB T)))] ;
G=Exp[Vbias/(kB T)]-1;
1.602176487`*^-23*If[JuncDopant[[1,1]]>0,
( Lp q1 +Ln q2 ) G  /τ ,( Ln q1 +Lp q2 ) G /τ]
]  ;
DiodeC1[ T_,Vbias_,JuncDopant_, SemiParm_,DiffParm_]:= Module[{Eg, me, gc, mh,ϵ
, μn,μp,τ,Ln, Lp 
,NC0,NV0
, W, x1,x2,ContactV,Ef1,Ef2
,q1,q2,F1,F2,G,r1,r2,H
, kB=  8.61739*10^(-5)},
{ Eg, me, gc, mh,ϵ}=SemiParm  ; 
{ μn,μp,τ,Ln,Lp}=DiffParm  ;
If[Ln==0. || TrueQ[Ln== Null], Ln=10^4*Sqrt[μn kB T τ], ];
If[Lp==0. || TrueQ[Lp ==  Null],Lp=10^4*Sqrt[μp kB T τ], ];
{NC0,NV0}= NDOS0[SemiParm] ;
Ef1=  FermiLevel[JuncDopant[[1]],T,SemiParm];
Ef2=  FermiLevel[JuncDopant[[2]],T,SemiParm];
ContactV=Eg+Sign[JuncDopant[[1,1]] ]*FermiLevel[JuncDopant[[1]],T,SemiParm]+Sign[JuncDopant[[2,1]] ]*FermiLevel[JuncDopant[[2]] ,T,SemiParm] ;
{W, x1,x2} =DepletionW[T,Vbias,JuncDopant, SemiParm] ;
F1=BandDiagram[-x1, T,0.,JuncDopant, SemiParm] ;
F2=BandDiagram[x2, T,0.,JuncDopant, SemiParm] ;
q1=If[JuncDopant[[1,1]]>0, NV0 (T^(3/2)) (E^(F1[[1]]/(kB T))), NC0 (T^(3/2)) (E^(-F1[[1]]/(kB T)))] ;
q2=If[JuncDopant[[1,1]]>0, NC0 (T^(3/2)) (E^(-F2[[2]]/(kB T))), NV0 (T^(3/2)) (E^(F2[[2]]/(kB T)))] ;
r1=  If[JuncDopant[[1,1]]>0,(mh/me)^3/2  *Exp[(F1[[1]]+F1[[2]])/(kB T)] , (me/mh)^3/2  *Exp[-(F1[[1]]+F1[[2]])/(kB T)] ] ;
r2=   If[JuncDopant[[1,1]]>0,(me/mh)^3/2  *Exp[-(F2[[1]]+F2[[2]])/(kB T)] , (mh/me)^3/2  *Exp[(F2[[1]]+F2[[2]])/(kB T)] ] ;
G=Exp[Vbias/(kB T)]-1; H=1-Exp[-2(ContactV-Vbias)/(kB T)] ;
1.602176487`*^-23*If[JuncDopant[[1,1]]>0,
( Lp q1 (1+r1 (G+1)) +Ln q2  (1+ r2 (G+1))) G  /(τ H)
,( Ln q1 (1+r1 (G+1)) +Lp q2 (1+ r2 (G+1)) ) G /(τ H)]
];

 start=0, ];
Manipulate[
If[ONOFF=="ON",
Manipulate[
SemiParm={ Eg, me,gc, mh,ϵ } ;  

Manipulate[
DiffParm ={μn,μp,10^τ,Ln,Lp};
dtype=If[dope=="p-n",-1,1] ;
ContactV=Eg+dtype*FermiLevel[{dtype,10^d1},T,SemiParm]-dtype*FermiLevel[{-dtype,10^d2},T,SemiParm] ; 
VbiasL=Min[Vbias,ContactV] ;
Show[LogPlot[CarrierJ[x, T,VbiasL,{ {dtype,10.^d1},{-dtype,10.^d2} }, SemiParm, DiffParm],
{x,xL,0},PlotRange-> {{xL,xR},{1,10^M}}
,Frame-> True, GridLines-> Automatic
, Filling-> {1-> {Bottom,If[dtype==1,Hue[0.6,1,1,0.4],Hue[0,1,1,0.3] ] }}
,PlotStyle->{Thick,If[dtype==1,Blue, Red] }
,FrameLabel->{"Position (μm)","Excess carrier density ((cm^(-3)) )"}
,LabelStyle->Directive[14,FontFamily-> "Arial"] ]
,LogPlot[CarrierJ[x, T,VbiasL,{ {dtype,10.^d1},{-dtype,10.^d2} }, SemiParm, DiffParm],
{x,0,xR},PlotRange-> {{xL,xR},{1.,10^M}}
,Frame-> True, GridLines-> Automatic
, Filling-> {1-> {Bottom,If[dtype==1,Hue[0,1,1,0.3],Hue[0.6,1,1,0.4] ] }}
,PlotStyle->{Thick,If[dtype==1, Red,Blue] }
,FrameLabel->{"Position (μm)","Excess carrier density ((cm^(-3)) )"}
,LabelStyle->Directive[14,FontFamily-> "Arial"] ]
],
{{dope,"p-n"},{"p-n","n-p"}},{{d1,17,"left doping ^10"},14,18},{{d2,17,"right doping ^10"},14,18}
,{{T,300,"Temperature (K)"},100,400}
,{{ Ln,0.,"e diff length (μm)"},1.,100.}
,{{ Lp,0.,"h diff length (μm)"},1.,100.}
,{{xR,10," xR range (μm)"},5,50}
,{{xL,-10," xL range (μm)"},-50,-5}
,{{M,10,"Max positive"},-10,22}
,{{Vbias,0},0,1}]
,Grid[{{ Control[{{Eg,1.42,"Bandgap (eV)"},0.3,4}]
,Control[{{ϵ,13.6,"Dielectric const."},4,20}]}
,{Control[{{me,0.0665,"Elec eff mass me*"},0.02,0.5}]
,Control[{{mh,0.5,"Hole eff mass mh*"},0.02,1}]}
,{Control[{{gc,1,"Cond band degeneracy"},{1,6}}]}
,{Control[{{ μn,3000.,"e mobility"},100.,10000.}]
,Control[{{ μp,200.,"h mobility"},10.,1000.}]
,Control[{{ τ,-9,"carrier lifetime (10^)"},-12,-6}]
}
}]
], ]
,{{ONOFF,"ON","Click OFF if not used"},{"ON","OFF"}}
],
{{start,1,"Click to start"},{0,1}} ]

3.3 Junction diffusion current

Now we can plot the junction diffusion current using the simple formula:
              (Subscript[J, n])=-e (Subscript[F, n]) =e (Subscript[D, n]) ((dn)/(dx))   ;        (Subscript[J, p])=e (Subscript[F, p]) =-e (Subscript[D, p]) ((dp)/(dx))

3.3.1 Junction diffusion currents: Linear scale plotting

Junction diffusion currents - linear scale

Manipulate[
If[start==1,
NDOS0[SemiParm_]:= Module[{ Eg, me, gc, mh,ϵ},
{ Eg, me, gc, mh,ϵ}=SemiParm ;
4.829415887919019`*^15  {gc  (me^(3/2)) , (mh^(3/2))} 
];
FermiLevel[Dopant_,T_,SemiParm_]:=Module[{Eg, me, gc, mh,ϵ
, NC0,NV0,type, DopeDensity, kB=  8.61739*10^(-5)},
{ Eg, me, gc, mh,ϵ}=SemiParm  ;
{NC0,NV0}= NDOS0[SemiParm] ;
{type, DopeDensity}=Dopant ;
If[type>0  , 
kB T Log[DopeDensity/(NC0 (T^(3/2)))] 
,-kB T Log[DopeDensity/(NV0 (T^(3/2))) ] ]
] ;
DepletionW[T_,Vbias_,JuncDopant_, SemiParm_]:=Module[{Eg, me, gc, mh,ϵ
,Dopant1, Dopant2,
ContactV, V0, W,
,aB=5.29177*10^(-9)
,Ryd=13.6057},
{ Eg, me, gc, mh,ϵ}=SemiParm  ;
{Dopant1, Dopant2}=JuncDopant ;
ContactV=Eg+Sign[Dopant1[[1]] ]*FermiLevel[Dopant1,T,SemiParm]+Sign[Dopant2[[1]] ]*FermiLevel[Dopant2,T,SemiParm] ;
V0=ContactV-Vbias ;
W=Sqrt[(ϵ V0/(aB  Ryd))* (1/Dopant1[[2]] +1/Dopant2[[2]]) ]  ;
10^4* W {1, Dopant2[[2]]/(Dopant1[[2]] +Dopant2[[2]])
,Dopant1[[2]]/(Dopant1[[2]] +Dopant2[[2]])  }] ;
ϕJ[x_, T_,Vbias_,JuncDopant_, SemiParm_]:= Module[{Eg, me, gc, mh,ϵ
, ContactV, V0, W, x1,x2},
{ Eg, me, gc, mh,ϵ}=SemiParm  ; 
{W, x1,x2} =DepletionW[T,Vbias,JuncDopant, SemiParm] ;
ContactV=Eg+Sign[JuncDopant[[1,1]] ]*FermiLevel[JuncDopant[[1]],T,SemiParm]+Sign[JuncDopant[[2,1]] ]*FermiLevel[JuncDopant[[2]] ,T,SemiParm] ;
V0=ContactV-Vbias ;
Sign[JuncDopant[[1,1]] ]*If[x≤-x1,0.,If[x≤ 0., V0  (x+x1)^2 /(x1*W),
If[x≤ x2, V0*(1-(x-x2)^2/(x2*W)) ,V0]
]
]
] ;
BandDiagram[x_, T_,Vbias_,JuncDopant_, SemiParm_]:= Module[{Eg, me, gc, mh,ϵ
, ContactV, V0, W,w, x1,x2},
{ Eg, me, gc, mh,ϵ}=SemiParm  ; 
{W, x1,x2} =DepletionW[T,Vbias,JuncDopant, SemiParm] ;
ContactV=Eg+Sign[JuncDopant[[1,1]] ]*FermiLevel[JuncDopant[[1]],T,SemiParm]+Sign[JuncDopant[[2,1]] ]*FermiLevel[JuncDopant[[2]] ,T,SemiParm] ;
V0=ContactV-Vbias ;
w=Sign[JuncDopant[[1,1]] ]*If[x≤-x1,0.,If[x≤ 0., V0  (x+x1)^2 /(x1*W),
If[x≤ x2, V0*(1-(x-x2)^2/(x2*W)) ,V0]
]
] ;
w-FermiLevel[JuncDopant[[1]],T,SemiParm]
+{Sign[JuncDopant[[2,1]] ]*Eg,0.} 
] ;

FermiLine[x_, T_,Vbias_,JuncDopant_, SemiParm_]:=Module[{Eg, me, gc, mh,ϵ
, ContactV, V0, W, x1,x2},
{ Eg, me, gc, mh,ϵ}=SemiParm  ; 
{W, x1,x2} =DepletionW[T,Vbias,JuncDopant, SemiParm] ;
ContactV=Eg+Sign[JuncDopant[[1,1]] ]*FermiLevel[JuncDopant[[1]],T,SemiParm]+Sign[JuncDopant[[2,1]] ]*FermiLevel[JuncDopant[[2]] ,T,SemiParm] ;
V0=ContactV-Vbias ;
If[x≥- x1,-Sign[JuncDopant[[1,1]] ]*Vbias,  ]
];
CarrierEqui[x_, T_,JuncDopant_, SemiParm_]:= Module[{Eg, me, gc, mh,ϵ 
,NC0,NV0, F
, kB=  8.61739*10^(-5)},
{ Eg, me, gc, mh,ϵ}=SemiParm  ; 
{NC0,NV0}= NDOS0[SemiParm] ;
F=BandDiagram[x, T,0.,JuncDopant, SemiParm] ;
If[JuncDopant[[1,1]]>0, 
{NC0 (T^(3/2)) (E^(-F[[2]]/(kB T))), NV0 (T^(3/2)) (E^(F[[1]]/(kB T))), NC0 (T^(3/2)) (E^(-F[[2]]/(kB T)))  +  NV0 (T^(3/2)) (E^(F[[1]]/(kB T)))} 
, {NC0 (T^(3/2)) (E^(-F[[1]]/(kB T))), NV0 (T^(3/2)) (E^(F[[2]]/(kB T))), NC0 (T^(3/2)) (E^(-F[[1]]/(kB T)))  +  NV0 (T^(3/2)) (E^(F[[2]]/(kB T)))}
]
];
CarrierJ[x_, T_,Vbias_,JuncDopant_, SemiParm_,DiffParm_]:= Module[{Eg, me, gc, mh,ϵ
, μn,μp,τ,Ln, Lp 
,NC0,NV0
, W, x1,x2
,q1,q2,F1,F2,G
, kB=  8.61739*10^(-5)},
{ Eg, me, gc, mh,ϵ}=SemiParm  ; 
{ μn,μp,τ,Ln,Lp}=DiffParm  ;
If[Ln==0. || TrueQ[Ln== Null], Ln=10^4*Sqrt[μn kB T τ], ];
If[Lp==0. || TrueQ[Lp ==  Null],Lp=10^4*Sqrt[μp kB T τ], ];
{NC0,NV0}= NDOS0[SemiParm] ;
{W, x1,x2} =DepletionW[T,Vbias,JuncDopant, SemiParm] ;
F1=BandDiagram[-x1, T,0.,JuncDopant, SemiParm] ;
F2=BandDiagram[x2, T,0.,JuncDopant, SemiParm] ;
q1=If[JuncDopant[[1,1]]≥ 0., NV0 (T^(3/2.)) (E^(F1[[1]]/(kB T))), NC0 (T^(3/2.)) (E^(-F1[[1]]/(kB T)))] ;
q2=If[JuncDopant[[1,1]]≥ 0., NC0 (T^(3/2.)) (E^(-F2[[2]]/(kB T))), NV0 (T^(3/2.)) (E^(F2[[2]]/(kB T)))] ;
G=Exp[Vbias/(kB T)]-1;
If[JuncDopant[[1,1]]≥ 0.,
If[x≤ -x1, q1 G  (E^((x+x1)/Lp)),
If [x≥ x2, q2 G  (E^(-(x-x2)/Ln)), ]
]
, If[x≤ -x1, q1 G  (E^((x+x1)/Ln)),
If [x≥ x2, q2 G  (E^(-(x-x2)/Lp)), ]
]
]
]  ;
DiffJ[x_, T_,Vbias_,JuncDopant_, SemiParm_,DiffParm_]:= Module[{Eg, me, gc, mh,ϵ
, μn,μp,τ,Ln, Lp 
,NC0,NV0
, W, x1,x2
,q1,q2,F1,F2,G
, kB=  8.61739*10^(-5)},
{ Eg, me, gc, mh,ϵ}=SemiParm  ; 
{ μn,μp,τ,Ln,Lp}=DiffParm  ;
If[Ln==0. || TrueQ[Ln== Null], Ln=10^4*Sqrt[μn kB T τ], ];
If[Lp==0. || TrueQ[Lp ==  Null],Lp=10^4*Sqrt[μp kB T τ], ];
{NC0,NV0}= NDOS0[SemiParm] ;
{W, x1,x2} =DepletionW[T,Vbias,JuncDopant, SemiParm] ;
F1=BandDiagram[-x1, T,0.,JuncDopant, SemiParm] ;
F2=BandDiagram[x2, T,0.,JuncDopant, SemiParm] ;
q1=If[JuncDopant[[1,1]]>0, NV0 (T^(3/2)) (E^(F1[[1]]/(kB T))), NC0 (T^(3/2)) (E^(-F1[[1]]/(kB T)))] ;
q2=If[JuncDopant[[1,1]]>0, NC0 (T^(3/2)) (E^(-F2[[2]]/(kB T))), NV0 (T^(3/2)) (E^(F2[[2]]/(kB T)))] ;
G=Exp[Vbias/(kB T)]-1;
1.602176487`*^-23*If[JuncDopant[[1,1]]>0,
If[x≤ -x1,Lp q1 G  (E^((x+x1)/Lp))/τ,
If [x≥ x2,Ln q2 G  (E^(-(x-x2)/Ln))/τ, ]
]
, If[x≤ -x1,Ln q1 G  (E^((x+x1)/Ln))/τ,
If [x≥ x2,Lp q2 G  (E^(-(x-x2)/Lp))/τ, ]
]
]
]  ;
DiodeC[ T_,Vbias_,JuncDopant_, SemiParm_,DiffParm_]:= Module[{Eg, me, gc, mh,ϵ
, μn,μp,τ,Ln, Lp 
,NC0,NV0
, W, x1,x2
,q1,q2,F1,F2,G
, kB=  8.61739*10^(-5)},
{ Eg, me, gc, mh,ϵ}=SemiParm  ; 
{ μn,μp,τ,Ln,Lp}=DiffParm  ;
If[Ln==0. || TrueQ[Ln== Null], Ln=10^4*Sqrt[μn kB T τ], ];
If[Lp==0. || TrueQ[Lp ==  Null],Lp=10^4*Sqrt[μp kB T τ], ];
{NC0,NV0}= NDOS0[SemiParm] ;
{W, x1,x2} =DepletionW[T,Vbias,JuncDopant, SemiParm] ;
F1=BandDiagram[-x1, T,0.,JuncDopant, SemiParm] ;
F2=BandDiagram[x2, T,0.,JuncDopant, SemiParm] ;
q1=If[JuncDopant[[1,1]]>0, NV0 (T^(3/2)) (E^(F1[[1]]/(kB T))), NC0 (T^(3/2)) (E^(-F1[[1]]/(kB T)))] ;
q2=If[JuncDopant[[1,1]]>0, NC0 (T^(3/2)) (E^(-F2[[2]]/(kB T))), NV0 (T^(3/2)) (E^(F2[[2]]/(kB T)))] ;
G=Exp[Vbias/(kB T)]-1;
1.602176487`*^-23*If[JuncDopant[[1,1]]>0,
( Lp q1 +Ln q2 ) G  /τ ,( Ln q1 +Lp q2 ) G /τ]
]  ;
DiodeC1[ T_,Vbias_,JuncDopant_, SemiParm_,DiffParm_]:= Module[{Eg, me, gc, mh,ϵ
, μn,μp,τ,Ln, Lp 
,NC0,NV0
, W, x1,x2,ContactV,Ef1,Ef2
,q1,q2,F1,F2,G,r1,r2,H
, kB=  8.61739*10^(-5)},
{ Eg, me, gc, mh,ϵ}=SemiParm  ; 
{ μn,μp,τ,Ln,Lp}=DiffParm  ;
If[Ln==0. || TrueQ[Ln== Null], Ln=10^4*Sqrt[μn kB T τ], ];
If[Lp==0. || TrueQ[Lp ==  Null],Lp=10^4*Sqrt[μp kB T τ], ];
{NC0,NV0}= NDOS0[SemiParm] ;
Ef1=  FermiLevel[JuncDopant[[1]],T,SemiParm];
Ef2=  FermiLevel[JuncDopant[[2]],T,SemiParm];
ContactV=Eg+Sign[JuncDopant[[1,1]] ]*FermiLevel[JuncDopant[[1]],T,SemiParm]+Sign[JuncDopant[[2,1]] ]*FermiLevel[JuncDopant[[2]] ,T,SemiParm] ;
{W, x1,x2} =DepletionW[T,Vbias,JuncDopant, SemiParm] ;
F1=BandDiagram[-x1, T,0.,JuncDopant, SemiParm] ;
F2=BandDiagram[x2, T,0.,JuncDopant, SemiParm] ;
q1=If[JuncDopant[[1,1]]>0, NV0 (T^(3/2)) (E^(F1[[1]]/(kB T))), NC0 (T^(3/2)) (E^(-F1[[1]]/(kB T)))] ;
q2=If[JuncDopant[[1,1]]>0, NC0 (T^(3/2)) (E^(-F2[[2]]/(kB T))), NV0 (T^(3/2)) (E^(F2[[2]]/(kB T)))] ;
r1=  If[JuncDopant[[1,1]]>0,(mh/me)^3/2  *Exp[(F1[[1]]+F1[[2]])/(kB T)] , (me/mh)^3/2  *Exp[-(F1[[1]]+F1[[2]])/(kB T)] ] ;
r2=   If[JuncDopant[[1,1]]>0,(me/mh)^3/2  *Exp[-(F2[[1]]+F2[[2]])/(kB T)] , (mh/me)^3/2  *Exp[(F2[[1]]+F2[[2]])/(kB T)] ] ;
G=Exp[Vbias/(kB T)]-1; H=1-Exp[-2(ContactV-Vbias)/(kB T)] ;
1.602176487`*^-23*If[JuncDopant[[1,1]]>0,
( Lp q1 (1+r1 (G+1)) +Ln q2  (1+ r2 (G+1))) G  /(τ H)
,( Ln q1 (1+r1 (G+1)) +Lp q2 (1+ r2 (G+1)) ) G /(τ H)]
];

 start=0, ];
Manipulate[
If[ONOFF=="ON",
Manipulate[
SemiParm={ Eg, me,gc, mh,ϵ } ;  

Manipulate[
DiffParm ={μn,μp,10^τ,Ln,Lp};
dtype=If[dope=="p-n",-1,1] ;
ContactV=Eg+dtype*FermiLevel[{dtype,10^d1},T,SemiParm]-dtype*FermiLevel[{-dtype,10^d2},T,SemiParm] ; 
VbiasL=Min[Vbias,ContactV] ;
Show[Plot[DiffJ[x, T,VbiasL,{ {dtype,10.^d1},{-dtype,10.^d2} }, SemiParm, DiffParm],
{x,xL,0},PlotRange-> {{xL,xR},{-10^Mr,10^Mf}}
,Frame-> True, GridLines-> Automatic
, Filling-> {1-> {Axis,If[dtype==1,Hue[0.6,1,1,0.4],Hue[0,1,1,0.3] ] }}
,PlotStyle->{Thick,If[dtype==1,Blue, Red] }
,FrameLabel->{"Position (μm)","Diffusion current density (A/(cm^2))"}
,LabelStyle->Directive[14,FontFamily-> "Arial"] ]
,Plot[DiffJ[x, T,VbiasL,{ {dtype,10.^d1},{-dtype,10.^d2} }, SemiParm, DiffParm],
{x,0,xR},PlotRange-> {{xL,xR},{-10^Mr,10^Mf}}
,Frame-> True, GridLines-> Automatic
, Filling-> {1-> {Axis,If[dtype==1,Hue[0,1,1,0.3],Hue[0.6,1,1,0.4] ] }}
,PlotStyle->{Thick,If[dtype==1, Red,Blue] }
,FrameLabel->{"Position (μm)","Diffusion current density (A/(cm^2))"}
,LabelStyle->Directive[14,FontFamily-> "Arial"] ]
],
{{dope,"p-n"},{"p-n","n-p"}},{{d1,17,"left doping ^10"},14,18},{{d2,17,"right doping ^10"},14,18}
,{{T,300,"Temperature (K)"},100,400}
,{{ Ln,0.,"e diff length (μm)"},1.,100.}
,{{ Lp,0.,"h diff length (μm)"},1.,100.}
,{{xR,10," xR range (μm)"},5,50},{{xL,-10," xL range (μm)"},-50,-5}
,{{Mf,10,"Max forward"},1,20},{{Mr,4,"Max reverse"},1,10},{{Vbias,0},-1,1}]
,Grid[{{ Control[{{Eg,1.42,"Bandgap (eV)"},0.3,4}]
,Control[{{ϵ,13.6,"Dielectric const."},4,20}]}
,{Control[{{me,0.0665,"Elec eff mass me*"},0.02,0.5}]
,Control[{{mh,0.5,"Hole eff mass mh*"},0.02,1}]}
,{Control[{{gc,1,"Cond band degeneracy"},{1,6}}]}
,{Control[{{ μn,3000.,"e mobility"},100.,10000.}]
,Control[{{ μp,200.,"h mobility"},10.,1000.}]
,Control[{{ τ,-9,"carrier lifetime (10^)"},-12,-6}]
}
}]
], ]
,{{ONOFF,"ON","Click OFF if not used"},{"ON","OFF"}}
],
{{start,1,"Click to start"},{0,1}} ]

3.4 Diode behavior

The total diffusion current at the junction is:

Ideal diode I-V characteristic at low bias and low current density

Manipulate[
If[start==1,
NDOS0[SemiParm_]:= Module[{ Eg, me, gc, mh,ϵ},
{ Eg, me, gc, mh,ϵ}=SemiParm ;
4.829415887919019`*^15  {gc  (me^(3/2)) , (mh^(3/2))} 
];
FermiLevel[Dopant_,T_,SemiParm_]:=Module[{Eg, me, gc, mh,ϵ
, NC0,NV0,type, DopeDensity, kB=  8.61739*10^(-5)},
{ Eg, me, gc, mh,ϵ}=SemiParm  ;
{NC0,NV0}= NDOS0[SemiParm] ;
{type, DopeDensity}=Dopant ;
If[type>0  , 
kB T Log[DopeDensity/(NC0 (T^(3/2)))] 
,-kB T Log[DopeDensity/(NV0 (T^(3/2))) ] ]
] ;
DepletionW[T_,Vbias_,JuncDopant_, SemiParm_]:=Module[{Eg, me, gc, mh,ϵ
,Dopant1, Dopant2,
ContactV, V0, W,
,aB=5.29177*10^(-9)
,Ryd=13.6057},
{ Eg, me, gc, mh,ϵ}=SemiParm  ;
{Dopant1, Dopant2}=JuncDopant ;
ContactV=Eg+Sign[Dopant1[[1]] ]*FermiLevel[Dopant1,T,SemiParm]+Sign[Dopant2[[1]] ]*FermiLevel[Dopant2,T,SemiParm] ;
V0=ContactV-Vbias ;
W=Sqrt[(ϵ V0/(aB  Ryd))* (1/Dopant1[[2]] +1/Dopant2[[2]]) ]  ;
10^4* W {1, Dopant2[[2]]/(Dopant1[[2]] +Dopant2[[2]])
,Dopant1[[2]]/(Dopant1[[2]] +Dopant2[[2]])  }] ;
ϕJ[x_, T_,Vbias_,JuncDopant_, SemiParm_]:= Module[{Eg, me, gc, mh,ϵ
, ContactV, V0, W, x1,x2},
{ Eg, me, gc, mh,ϵ}=SemiParm  ; 
{W, x1,x2} =DepletionW[T,Vbias,JuncDopant, SemiParm] ;
ContactV=Eg+Sign[JuncDopant[[1,1]] ]*FermiLevel[JuncDopant[[1]],T,SemiParm]+Sign[JuncDopant[[2,1]] ]*FermiLevel[JuncDopant[[2]] ,T,SemiParm] ;
V0=ContactV-Vbias ;
Sign[JuncDopant[[1,1]] ]*If[x≤-x1,0.,If[x≤ 0., V0  (x+x1)^2 /(x1*W),
If[x≤ x2, V0*(1-(x-x2)^2/(x2*W)) ,V0]
]
]
] ;
BandDiagram[x_, T_,Vbias_,JuncDopant_, SemiParm_]:= Module[{Eg, me, gc, mh,ϵ
, ContactV, V0, W,w, x1,x2},
{ Eg, me, gc, mh,ϵ}=SemiParm  ; 
{W, x1,x2} =DepletionW[T,Vbias,JuncDopant, SemiParm] ;
ContactV=Eg+Sign[JuncDopant[[1,1]] ]*FermiLevel[JuncDopant[[1]],T,SemiParm]+Sign[JuncDopant[[2,1]] ]*FermiLevel[JuncDopant[[2]] ,T,SemiParm] ;
V0=ContactV-Vbias ;
w=Sign[JuncDopant[[1,1]] ]*If[x≤-x1,0.,If[x≤ 0., V0  (x+x1)^2 /(x1*W),
If[x≤ x2, V0*(1-(x-x2)^2/(x2*W)) ,V0]
]
] ;
w-FermiLevel[JuncDopant[[1]],T,SemiParm]
+{Sign[JuncDopant[[2,1]] ]*Eg,0.} 
] ;

FermiLine[x_, T_,Vbias_,JuncDopant_, SemiParm_]:=Module[{Eg, me, gc, mh,ϵ
, ContactV, V0, W, x1,x2},
{ Eg, me, gc, mh,ϵ}=SemiParm  ; 
{W, x1,x2} =DepletionW[T,Vbias,JuncDopant, SemiParm] ;
ContactV=Eg+Sign[JuncDopant[[1,1]] ]*FermiLevel[JuncDopant[[1]],T,SemiParm]+Sign[JuncDopant[[2,1]] ]*FermiLevel[JuncDopant[[2]] ,T,SemiParm] ;
V0=ContactV-Vbias ;
If[x≥- x1,-Sign[JuncDopant[[1,1]] ]*Vbias,  ]
];
CarrierEqui[x_, T_,JuncDopant_, SemiParm_]:= Module[{Eg, me, gc, mh,ϵ 
,NC0,NV0, F
, kB=  8.61739*10^(-5)},
{ Eg, me, gc, mh,ϵ}=SemiParm  ; 
{NC0,NV0}= NDOS0[SemiParm] ;
F=BandDiagram[x, T,0.,JuncDopant, SemiParm] ;
If[JuncDopant[[1,1]]>0, 
{NC0 (T^(3/2)) (E^(-F[[2]]/(kB T))), NV0 (T^(3/2)) (E^(F[[1]]/(kB T))), NC0 (T^(3/2)) (E^(-F[[2]]/(kB T)))  +  NV0 (T^(3/2)) (E^(F[[1]]/(kB T)))} 
, {NC0 (T^(3/2)) (E^(-F[[1]]/(kB T))), NV0 (T^(3/2)) (E^(F[[2]]/(kB T))), NC0 (T^(3/2)) (E^(-F[[1]]/(kB T)))  +  NV0 (T^(3/2)) (E^(F[[2]]/(kB T)))}
]
];
CarrierJ[x_, T_,Vbias_,JuncDopant_, SemiParm_,DiffParm_]:= Module[{Eg, me, gc, mh,ϵ
, μn,μp,τ,Ln, Lp 
,NC0,NV0
, W, x1,x2
,q1,q2,F1,F2,G
, kB=  8.61739*10^(-5)},
{ Eg, me, gc, mh,ϵ}=SemiParm  ; 
{ μn,μp,τ,Ln,Lp}=DiffParm  ;
If[Ln==0. || TrueQ[Ln== Null], Ln=10^4*Sqrt[μn kB T τ], ];
If[Lp==0. || TrueQ[Lp ==  Null],Lp=10^4*Sqrt[μp kB T τ], ];
{NC0,NV0}= NDOS0[SemiParm] ;
{W, x1,x2} =DepletionW[T,Vbias,JuncDopant, SemiParm] ;
F1=BandDiagram[-x1, T,0.,JuncDopant, SemiParm] ;
F2=BandDiagram[x2, T,0.,JuncDopant, SemiParm] ;
q1=If[JuncDopant[[1,1]]≥ 0., NV0 (T^(3/2.)) (E^(F1[[1]]/(kB T))), NC0 (T^(3/2.)) (E^(-F1[[1]]/(kB T)))] ;
q2=If[JuncDopant[[1,1]]≥ 0., NC0 (T^(3/2.)) (E^(-F2[[2]]/(kB T))), NV0 (T^(3/2.)) (E^(F2[[2]]/(kB T)))] ;
G=Exp[Vbias/(kB T)]-1;
If[JuncDopant[[1,1]]≥ 0.,
If[x≤ -x1, q1 G  (E^((x+x1)/Lp)),
If [x≥ x2, q2 G  (E^(-(x-x2)/Ln)), ]
]
, If[x≤ -x1, q1 G  (E^((x+x1)/Ln)),
If [x≥ x2, q2 G  (E^(-(x-x2)/Lp)), ]
]
]
]  ;
DiffJ[x_, T_,Vbias_,JuncDopant_, SemiParm_,DiffParm_]:= Module[{Eg, me, gc, mh,ϵ
, μn,μp,τ,Ln, Lp 
,NC0,NV0
, W, x1,x2
,q1,q2,F1,F2,G
, kB=  8.61739*10^(-5)},
{ Eg, me, gc, mh,ϵ}=SemiParm  ; 
{ μn,μp,τ,Ln,Lp}=DiffParm  ;
If[Ln==0. || TrueQ[Ln== Null], Ln=10^4*Sqrt[μn kB T τ], ];
If[Lp==0. || TrueQ[Lp ==  Null],Lp=10^4*Sqrt[μp kB T τ], ];
{NC0,NV0}= NDOS0[SemiParm] ;
{W, x1,x2} =DepletionW[T,Vbias,JuncDopant, SemiParm] ;
F1=BandDiagram[-x1, T,0.,JuncDopant, SemiParm] ;
F2=BandDiagram[x2, T,0.,JuncDopant, SemiParm] ;
q1=If[JuncDopant[[1,1]]>0, NV0 (T^(3/2)) (E^(F1[[1]]/(kB T))), NC0 (T^(3/2)) (E^(-F1[[1]]/(kB T)))] ;
q2=If[JuncDopant[[1,1]]>0, NC0 (T^(3/2)) (E^(-F2[[2]]/(kB T))), NV0 (T^(3/2)) (E^(F2[[2]]/(kB T)))] ;
G=Exp[Vbias/(kB T)]-1;

1.602176487*^-23*If[JuncDopant[[1,1]]>0,
If[x≤ -x1,Lp q1 G  (E^((x+x1)/Lp))/τ,
If [x≥ x2,Ln q2 G  (E^(-(x-x2)/Ln))/τ, ]
]
, If[x≤ -x1,Ln q1 G  (E^((x+x1)/Ln))/τ,
If [x≥ x2,Lp q2 G  (E^(-(x-x2)/Lp))/τ, ]
]
]
]  ;
DiodeC[ T_,Vbias_,JuncDopant_, SemiParm_,DiffParm_]:= Module[{Eg, me, gc, mh,ϵ
, μn,μp,τ,Ln, Lp 
,NC0,NV0
, W, x1,x2
,q1,q2,F1,F2,G
, kB=  8.61739*10^(-5)},
{ Eg, me, gc, mh,ϵ}=SemiParm  ; 
{ μn,μp,τ,Ln,Lp}=DiffParm  ;
If[Ln==0. || TrueQ[Ln== Null], Ln=10^4*Sqrt[μn kB T τ], ];
If[Lp==0. || TrueQ[Lp ==  Null],Lp=10^4*Sqrt[μp kB T τ], ];
{NC0,NV0}= NDOS0[SemiParm] ;
{W, x1,x2} =DepletionW[T,Vbias,JuncDopant, SemiParm] ;
F1=BandDiagram[-x1, T,0.,JuncDopant, SemiParm] ;
F2=BandDiagram[x2, T,0.,JuncDopant, SemiParm] ;
q1=If[JuncDopant[[1,1]]>0, NV0 (T^(3/2)) (E^(F1[[1]]/(kB T))), NC0 (T^(3/2)) (E^(-F1[[1]]/(kB T)))] ;
q2=If[JuncDopant[[1,1]]>0, NC0 (T^(3/2)) (E^(-F2[[2]]/(kB T))), NV0 (T^(3/2)) (E^(F2[[2]]/(kB T)))] ;
G=Exp[Vbias/(kB T)]-1;
1.602176487`*^-23*If[JuncDopant[[1,1]]>0,
( Lp q1 +Ln q2 ) G  /τ ,( Ln q1 +Lp q2 ) G /τ]
]  ;
DiodeC1[ T_,Vbias_,JuncDopant_, SemiParm_,DiffParm_]:= Module[{Eg, me, gc, mh,ϵ
, μn,μp,τ,Ln, Lp 
,NC0,NV0
, W, x1,x2,ContactV,Ef1,Ef2
,q1,q2,F1,F2,G,r1,r2,H
, kB=  8.61739*10^(-5)},
{ Eg, me, gc, mh,ϵ}=SemiParm  ; 
{ μn,μp,τ,Ln,Lp}=DiffParm  ;
If[Ln==0. || TrueQ[Ln== Null], Ln=10^4*Sqrt[μn kB T τ], ];
If[Lp==0. || TrueQ[Lp ==  Null],Lp=10^4*Sqrt[μp kB T τ], ];
{NC0,NV0}= NDOS0[SemiParm] ;
Ef1=  FermiLevel[JuncDopant[[1]],T,SemiParm];
Ef2=  FermiLevel[JuncDopant[[2]],T,SemiParm];
ContactV=Eg+Sign[JuncDopant[[1,1]] ]*FermiLevel[JuncDopant[[1]],T,SemiParm]+Sign[JuncDopant[[2,1]] ]*FermiLevel[JuncDopant[[2]] ,T,SemiParm] ;
{W, x1,x2} =DepletionW[T,Vbias,JuncDopant, SemiParm] ;
F1=BandDiagram[-x1, T,0.,JuncDopant, SemiParm] ;
F2=BandDiagram[x2, T,0.,JuncDopant, SemiParm] ;
q1=If[JuncDopant[[1,1]]>0, NV0 (T^(3/2)) (E^(F1[[1]]/(kB T))), NC0 (T^(3/2)) (E^(-F1[[1]]/(kB T)))] ;
q2=If[JuncDopant[[1,1]]>0, NC0 (T^(3/2)) (E^(-F2[[2]]/(kB T))), NV0 (T^(3/2)) (E^(F2[[2]]/(kB T)))] ;
r1=  If[JuncDopant[[1,1]]>0,(mh/me)^3/2  *Exp[(F1[[1]]+F1[[2]])/(kB T)] , (me/mh)^3/2  *Exp[-(F1[[1]]+F1[[2]])/(kB T)] ] ;
r2=   If[JuncDopant[[1,1]]>0,(me/mh)^3/2  *Exp[-(F2[[1]]+F2[[2]])/(kB T)] , (mh/me)^3/2  *Exp[(F2[[1]]+F2[[2]])/(kB T)] ] ;
G=Exp[Vbias/(kB T)]-1; H=1-Exp[-2(ContactV-Vbias)/(kB T)] ;
1.602176487`*^-23*If[JuncDopant[[1,1]]>0,
( Lp q1 (1+r1 (G+1)) +Ln q2  (1+ r2 (G+1))) G  /(τ H)
,( Ln q1 (1+r1 (G+1)) +Lp q2 (1+ r2 (G+1)) ) G /(τ H)]
];

 start=0, ];
Manipulate[
If[ONOFF=="ON",
Manipulate[
SemiParm={ Eg, me,gc, mh,ϵ } ;  
Manipulate[DiffParm ={μn,μp,10^τ,Ln,Lp};
dtype=If[dope=="p-n",-1,1] ;
ContactV=Eg+dtype*FermiLevel[{dtype,10^d1},T,SemiParm]-dtype*FermiLevel[{-dtype,10^d2},T,SemiParm] ;
 
Plot[DiodeC[ T,Vbias,{ {dtype,10.^d1},{-dtype,10.^d2} }, SemiParm, DiffParm],
{Vbias,Vr,Vf},PlotRange-> All
,Frame-> True, GridLines-> Automatic
(* , Filling-> {1-> {Axis,Hue[0.35,1,1,0.4] }} *)
,PlotStyle->{Thick,Black }
,FrameLabel->{"Bias voltage (V)","Current density (A/(cm^2))"}
,LabelStyle->Directive[14,FontFamily-> "Arial"]
 ],
{{dope,"p-n"},{"p-n","n-p"}},{{d1,17},14,18},{{d2,17},14,18},{{T,300,"Temperature (K)"},250,400}
,{{ Ln,0.,"e diff length (μm)"},1.,100.}
,{{ Lp,0.,"h diff length (μm)"},1.,100.}
,{{ Vr,-0.1,"Vbias rev (V)"},-3,0.}
,{{ Vf,0.1,"Vbias forw (V)"},0,0.2}]
,Grid[{{ Control[{{Eg,1.42,"Bandgap (eV)"},0.3,4}]
,Control[{{ϵ,13.6,"Dielectric const."},4,20}]}
,{Control[{{me,0.0665,"Elec eff mass me*"},0.02,0.5}]
,Control[{{mh,0.5,"Hole eff mass mh*"},0.02,1}]}
,{Control[{{gc,1,"Cond band degeneracy"},{1,6}}]}
,{Control[{{ μn,3000.,"e mobility"},100.,10000.}]
,Control[{{ μp,200.,"h mobility"},10.,1000.}]
,Control[{{ τ,-9,"carrier lifetime (10^)"},-12,-6}]
}
}]
], ]
,{{ONOFF,"ON","Click OFF if not used"},{"ON","OFF"}}
],
{{start,1,"Click to start"},{0,1}} ]

3.5 Drift and diffusion

Total current is constant every where in the diode. But diffusion current is not a constant, then what? 
                                                           (Subscript[I, drift])=(Subscript[I, total]) -(Subscript[I, diff])

Drift and diffusion currents

Manipulate[
If[start==1,
NDOS0[SemiParm_]:= Module[{ Eg, me, gc, mh,ϵ},
{ Eg, me, gc, mh,ϵ}=SemiParm ;
4.829415887919019`*^15  {gc  (me^(3/2)) , (mh^(3/2))} 
];
FermiLevel[Dopant_,T_,SemiParm_]:=Module[{Eg, me, gc, mh,ϵ
, NC0,NV0,type, DopeDensity, kB=  8.61739*10^(-5)},
{ Eg, me, gc, mh,ϵ}=SemiParm  ;
{NC0,NV0}= NDOS0[SemiParm] ;
{type, DopeDensity}=Dopant ;
If[type>0  , 
kB T Log[DopeDensity/(NC0 (T^(3/2)))] 
,-kB T Log[DopeDensity/(NV0 (T^(3/2))) ] ]
] ;
DepletionW[T_,Vbias_,JuncDopant_, SemiParm_]:=Module[{Eg, me, gc, mh,ϵ
,Dopant1, Dopant2,
ContactV, V0, W,
,aB=5.29177*10^(-9)
,Ryd=13.6057},
{ Eg, me, gc, mh,ϵ}=SemiParm  ;
{Dopant1, Dopant2}=JuncDopant ;
ContactV=Eg+Sign[Dopant1[[1]] ]*FermiLevel[Dopant1,T,SemiParm]+Sign[Dopant2[[1]] ]*FermiLevel[Dopant2,T,SemiParm] ;
V0=ContactV-Vbias ;
W=Sqrt[(ϵ V0/(aB  Ryd))* (1/Dopant1[[2]] +1/Dopant2[[2]]) ]  ;
10^4* W {1, Dopant2[[2]]/(Dopant1[[2]] +Dopant2[[2]])
,Dopant1[[2]]/(Dopant1[[2]] +Dopant2[[2]])  }] ;
ϕJ[x_, T_,Vbias_,JuncDopant_, SemiParm_]:= Module[{Eg, me, gc, mh,ϵ
, ContactV, V0, W, x1,x2},
{ Eg, me, gc, mh,ϵ}=SemiParm  ; 
{W, x1,x2} =DepletionW[T,Vbias,JuncDopant, SemiParm] ;
ContactV=Eg+Sign[JuncDopant[[1,1]] ]*FermiLevel[JuncDopant[[1]],T,SemiParm]+Sign[JuncDopant[[2,1]] ]*FermiLevel[JuncDopant[[2]] ,T,SemiParm] ;
V0=ContactV-Vbias ;
Sign[JuncDopant[[1,1]] ]*If[x≤-x1,0.,If[x≤ 0., V0  (x+x1)^2 /(x1*W),
If[x≤ x2, V0*(1-(x-x2)^2/(x2*W)) ,V0]
]
]
] ;
BandDiagram[x_, T_,Vbias_,JuncDopant_, SemiParm_]:= Module[{Eg, me, gc, mh,ϵ
, ContactV, V0, W,w, x1,x2},
{ Eg, me, gc, mh,ϵ}=SemiParm  ; 
{W, x1,x2} =DepletionW[T,Vbias,JuncDopant, SemiParm] ;
ContactV=Eg+Sign[JuncDopant[[1,1]] ]*FermiLevel[JuncDopant[[1]],T,SemiParm]+Sign[JuncDopant[[2,1]] ]*FermiLevel[JuncDopant[[2]] ,T,SemiParm] ;
V0=ContactV-Vbias ;
w=Sign[JuncDopant[[1,1]] ]*If[x≤-x1,0.,If[x≤ 0., V0  (x+x1)^2 /(x1*W),
If[x≤ x2, V0*(1-(x-x2)^2/(x2*W)) ,V0]
]
] ;
w-FermiLevel[JuncDopant[[1]],T,SemiParm]
+{Sign[JuncDopant[[2,1]] ]*Eg,0.} 
] ;

FermiLine[x_, T_,Vbias_,JuncDopant_, SemiParm_]:=Module[{Eg, me, gc, mh,ϵ
, ContactV, V0, W, x1,x2},
{ Eg, me, gc, mh,ϵ}=SemiParm  ; 
{W, x1,x2} =DepletionW[T,Vbias,JuncDopant, SemiParm] ;
ContactV=Eg+Sign[JuncDopant[[1,1]] ]*FermiLevel[JuncDopant[[1]],T,SemiParm]+Sign[JuncDopant[[2,1]] ]*FermiLevel[JuncDopant[[2]] ,T,SemiParm] ;
V0=ContactV-Vbias ;
If[x≥- x1,-Sign[JuncDopant[[1,1]] ]*Vbias,  ]
];
CarrierEqui[x_, T_,JuncDopant_, SemiParm_]:= Module[{Eg, me, gc, mh,ϵ 
,NC0,NV0, F
, kB=  8.61739*10^(-5)},
{ Eg, me, gc, mh,ϵ}=SemiParm  ; 
{NC0,NV0}= NDOS0[SemiParm] ;
F=BandDiagram[x, T,0.,JuncDopant, SemiParm] ;
If[JuncDopant[[1,1]]>0, 
{NC0 (T^(3/2)) (E^(-F[[2]]/(kB T))), NV0 (T^(3/2)) (E^(F[[1]]/(kB T))), NC0 (T^(3/2)) (E^(-F[[2]]/(kB T)))  +  NV0 (T^(3/2)) (E^(F[[1]]/(kB T)))} 
, {NC0 (T^(3/2)) (E^(-F[[1]]/(kB T))), NV0 (T^(3/2)) (E^(F[[2]]/(kB T))), NC0 (T^(3/2)) (E^(-F[[1]]/(kB T)))  +  NV0 (T^(3/2)) (E^(F[[2]]/(kB T)))}
]
];
CarrierJ[x_, T_,Vbias_,JuncDopant_, SemiParm_,DiffParm_]:= Module[{Eg, me, gc, mh,ϵ
, μn,μp,τ,Ln, Lp 
,NC0,NV0
, W, x1,x2
,q1,q2,F1,F2,G
, kB=  8.61739*10^(-5)},
{ Eg, me, gc, mh,ϵ}=SemiParm  ; 
{ μn,μp,τ,Ln,Lp}=DiffParm  ;
If[Ln==0. || TrueQ[Ln== Null], Ln=10^4*Sqrt[μn kB T τ], ];
If[Lp==0. || TrueQ[Lp ==  Null],Lp=10^4*Sqrt[μp kB T τ], ];
{NC0,NV0}= NDOS0[SemiParm] ;
{W, x1,x2} =DepletionW[T,Vbias,JuncDopant, SemiParm] ;
F1=BandDiagram[-x1, T,0.,JuncDopant, SemiParm] ;
F2=BandDiagram[x2, T,0.,JuncDopant, SemiParm] ;
q1=If[JuncDopant[[1,1]]≥ 0., NV0 (T^(3/2.)) (E^(F1[[1]]/(kB T))), NC0 (T^(3/2.)) (E^(-F1[[1]]/(kB T)))] ;
q2=If[JuncDopant[[1,1]]≥ 0., NC0 (T^(3/2.)) (E^(-F2[[2]]/(kB T))), NV0 (T^(3/2.)) (E^(F2[[2]]/(kB T)))] ;
G=Exp[Vbias/(kB T)]-1;
If[JuncDopant[[1,1]]≥ 0.,
If[x≤ -x1, q1 G  (E^((x+x1)/Lp)),
If [x≥ x2, q2 G  (E^(-(x-x2)/Ln)), ]
]
, If[x≤ -x1, q1 G  (E^((x+x1)/Ln)),
If [x≥ x2, q2 G  (E^(-(x-x2)/Lp)), ]
]
]
]  ;
DiffJ[x_, T_,Vbias_,JuncDopant_, SemiParm_,DiffParm_]:= Module[{Eg, me, gc, mh,ϵ
, μn,μp,τ,Ln, Lp 
,NC0,NV0
, W, x1,x2
,q1,q2,F1,F2,G
, kB=  8.61739*10^(-5)},
{ Eg, me, gc, mh,ϵ}=SemiParm  ; 
{ μn,μp,τ,Ln,Lp}=DiffParm  ;
If[Ln==0. || TrueQ[Ln== Null], Ln=10^4*Sqrt[μn kB T τ], ];
If[Lp==0. || TrueQ[Lp ==  Null],Lp=10^4*Sqrt[μp kB T τ], ];
{NC0,NV0}= NDOS0[SemiParm] ;
{W, x1,x2} =DepletionW[T,Vbias,JuncDopant, SemiParm] ;
F1=BandDiagram[-x1, T,0.,JuncDopant, SemiParm] ;
F2=BandDiagram[x2, T,0.,JuncDopant, SemiParm] ;
q1=If[JuncDopant[[1,1]]>0, NV0 (T^(3/2)) (E^(F1[[1]]/(kB T))), NC0 (T^(3/2)) (E^(-F1[[1]]/(kB T)))] ;
q2=If[JuncDopant[[1,1]]>0, NC0 (T^(3/2)) (E^(-F2[[2]]/(kB T))), NV0 (T^(3/2)) (E^(F2[[2]]/(kB T)))] ;
G=Exp[Vbias/(kB T)]-1;
1.602176487`*^-23*If[JuncDopant[[1,1]]>0,
If[x≤ -x1,Lp q1 G  (E^((x+x1)/Lp))/τ,
If [x≥ x2,Ln q2 G  (E^(-(x-x2)/Ln))/τ, ]
]
, If[x≤ -x1,Ln q1 G  (E^((x+x1)/Ln))/τ,
If [x≥ x2,Lp q2 G  (E^(-(x-x2)/Lp))/τ, ]
]
]
]  ;
DiodeC[ T_,Vbias_,JuncDopant_, SemiParm_,DiffParm_]:= Module[{Eg, me, gc, mh,ϵ
, μn,μp,τ,Ln, Lp 
,NC0,NV0
, W, x1,x2
,q1,q2,F1,F2,G
, kB=  8.61739*10^(-5)},
{ Eg, me, gc, mh,ϵ}=SemiParm  ; 
{ μn,μp,τ,Ln,Lp}=DiffParm  ;
If[Ln==0. || TrueQ[Ln== Null], Ln=10^4*Sqrt[μn kB T τ], ];
If[Lp==0. || TrueQ[Lp ==  Null],Lp=10^4*Sqrt[μp kB T τ], ];
{NC0,NV0}= NDOS0[SemiParm] ;
{W, x1,x2} =DepletionW[T,Vbias,JuncDopant, SemiParm] ;
F1=BandDiagram[-x1, T,0.,JuncDopant, SemiParm] ;
F2=BandDiagram[x2, T,0.,JuncDopant, SemiParm] ;
q1=If[JuncDopant[[1,1]]>0, NV0 (T^(3/2)) (E^(F1[[1]]/(kB T))), NC0 (T^(3/2)) (E^(-F1[[1]]/(kB T)))] ;
q2=If[JuncDopant[[1,1]]>0, NC0 (T^(3/2)) (E^(-F2[[2]]/(kB T))), NV0 (T^(3/2)) (E^(F2[[2]]/(kB T)))] ;
G=Exp[Vbias/(kB T)]-1;
1.602176487`*^-23*If[JuncDopant[[1,1]]>0,
( Lp q1 +Ln q2 ) G  /τ ,( Ln q1 +Lp q2 ) G /τ]
]  ;
DiodeC1[ T_,Vbias_,JuncDopant_, SemiParm_,DiffParm_]:= Module[{Eg, me, gc, mh,ϵ
, μn,μp,τ,Ln, Lp 
,NC0,NV0
, W, x1,x2,ContactV,Ef1,Ef2
,q1,q2,F1,F2,G,r1,r2,H
, kB=  8.61739*10^(-5)},
{ Eg, me, gc, mh,ϵ}=SemiParm  ; 
{ μn,μp,τ,Ln,Lp}=DiffParm  ;
If[Ln==0. || TrueQ[Ln== Null], Ln=10^4*Sqrt[μn kB T τ], ];
If[Lp==0. || TrueQ[Lp ==  Null],Lp=10^4*Sqrt[μp kB T τ], ];
{NC0,NV0}= NDOS0[SemiParm] ;
Ef1=  FermiLevel[JuncDopant[[1]],T,SemiParm];
Ef2=  FermiLevel[JuncDopant[[2]],T,SemiParm];
ContactV=Eg+Sign[JuncDopant[[1,1]] ]*FermiLevel[JuncDopant[[1]],T,SemiParm]+Sign[JuncDopant[[2,1]] ]*FermiLevel[JuncDopant[[2]] ,T,SemiParm] ;
{W, x1,x2} =DepletionW[T,Vbias,JuncDopant, SemiParm] ;
F1=BandDiagram[-x1, T,0.,JuncDopant, SemiParm] ;
F2=BandDiagram[x2, T,0.,JuncDopant, SemiParm] ;
q1=If[JuncDopant[[1,1]]>0, NV0 (T^(3/2)) (E^(F1[[1]]/(kB T))), NC0 (T^(3/2)) (E^(-F1[[1]]/(kB T)))] ;
q2=If[JuncDopant[[1,1]]>0, NC0 (T^(3/2)) (E^(-F2[[2]]/(kB T))), NV0 (T^(3/2)) (E^(F2[[2]]/(kB T)))] ;
r1=  If[JuncDopant[[1,1]]>0,(mh/me)^3/2  *Exp[(F1[[1]]+F1[[2]])/(kB T)] , (me/mh)^3/2  *Exp[-(F1[[1]]+F1[[2]])/(kB T)] ] ;
r2=   If[JuncDopant[[1,1]]>0,(me/mh)^3/2  *Exp[-(F2[[1]]+F2[[2]])/(kB T)] , (mh/me)^3/2  *Exp[(F2[[1]]+F2[[2]])/(kB T)] ] ;
G=Exp[Vbias/(kB T)]-1; H=1-Exp[-2(ContactV-Vbias)/(kB T)] ;
1.602176487`*^-23*If[JuncDopant[[1,1]]>0,
( Lp q1 (1+r1 (G+1)) +Ln q2  (1+ r2 (G+1))) G  /(τ H)
,( Ln q1 (1+r1 (G+1)) +Lp q2 (1+ r2 (G+1)) ) G /(τ H)]
];

 start=0, ];
Manipulate[
If[ONOFF=="ON",
Manipulate[
SemiParm={ Eg, me,gc, mh,ϵ } ;  

Manipulate[DiffParm ={μn,μp,10^τ,Ln,Lp};
dtype=If[dope=="p-n",-1,1] ;Plot[{DiffJ[x, T,Vbias,{ {dtype,10^d1},{-dtype,10^d2} }, SemiParm, DiffParm],
DiodeC[ T,Vbias,{ {dtype,10^d1},{-dtype,10^d2} }, SemiParm, DiffParm]
-DiffJ[x, T,Vbias,{ {dtype,10^d1},{-dtype,10^d2} }, SemiParm, DiffParm]},
{x,xL,xR},PlotRange-> {{xL,xR},All}
,Frame-> True, GridLines-> Automatic
, Filling->{ {1->{Bottom,Hue[0.15,1,1,0.4] }}
,{ 2->{ Top,Hue[0.45,1,1,0.4] }}}
,PlotStyle->{{Thick,Hue[0.15,1,0.6]},{Thick,Hue[0.45,1,0.8]}}
,FrameLabel->{"Position (μm)","Current density (A/(cm^2))"}
,LabelStyle->Directive[14,FontFamily-> "Arial"]
 ],
{{dope,"p-n"},{"p-n","n-p"}},{{d1,17},14,18},{{d2,17},14,18}
,{{T,300,"Temperature (K)"},250,400}
,{{ Ln,0.,"e diff length (μm)"},1.,100.}
,{{ Lp,0.,"h diff length (μm)"},1.,100.}
,{{xR,10," xR range (μm)"},5,50},{{xL,-10," xL range (μm)"},-50,-5},{{Vbias,1},-1,1}]
,Grid[{{ Control[{{Eg,1.42,"Bandgap (eV)"},0.3,4}]
,Control[{{ϵ,13.6,"Dielectric const."},4,20}]}
,{Control[{{me,0.0665,"Elec eff mass me*"},0.02,0.5}]
,Control[{{mh,0.5,"Hole eff mass mh*"},0.02,1}]}
,{Control[{{gc,1,"Cond band degeneracy"},{1,6}}]}
,{Control[{{ μn,3000.,"e mobility"},100.,10000.}]
,Control[{{ μp,200.,"h mobility"},10.,1000.}]
,Control[{{ τ,-9,"carrier lifetime (10^)"},-12,-6}]
}
}]
], ]
,{{ONOFF,"ON","Click OFF if not used"},{"ON","OFF"}}
],
{{start,1,"Click to start"},{0,1}} ]

4 Junction capacitance

We recall the space charge at a p-n junction:

Q=e A ND xn  /. xn->W  NA/(NA+ND)

Q /. W-> (Sqrt[2 ϵ (V0-V)*(1/ND+1/NA)/e])

Q[V_]:=(((Sqrt[2]) A e  NA  ND   (Sqrt[((ϵ  ((1/NA)+(1/ND)) (V0 - V))/e)]))/(NA+ND))

(∂_V)Q[V]

FullSimplify[-((A NA ND ϵ ((1/NA)+(1/ND)))/((Sqrt[2]) (NA+ND) (Sqrt[((ϵ ((1/NA)+(1/ND)) (V0-V))/e)])))]

-A (Sqrt[((e ϵ)/(2 (V0-V))) (((NA ND)/(NA+ND)))])

Plot[(Sqrt[(1/(2 (1+V))) ]),{V,-3,0.5}, Frame-> True, GridLines-> Automatic]

5. Modification of ideal diode behavior

Realistic diode is different from the ideal diode model because of the effect of contact potential. It is given as (See ppt lecture file):

Note the extra term:  (1/(1-(e^(-2 (Subscript[ΔE, b])/(Subscript[k, B])T )))) where
                         (Subscript[ΔE, b])=(Subscript[V, 0])-(Subscript[V, b])
What this means is that the bias cannot be greater than the contact potential because the current would be infinite.
This is the behavior of that term: in essence, it gives “infinite current” at contact potential bias: the band is completely flattened out and the whole carrier population contribute to the current. Of course, this doesnot happen in realistic device either, because there will be resistivity limit on the drift current, which is the basic resistance of each segment, p and n.
In real life, the power supply will max out its current output capability. And if it can give a sufficiently large current that results in a power exceeding the diode power handling capability, the diode would be burned up.

5.1 Linear scale plot - see contact potential effect

Modified diode I-V characteristic with contact potential effect - linear scale

Manipulate[
If[start==1,
NDOS0[SemiParm_]:= Module[{ Eg, me, gc, mh,ϵ},
{ Eg, me, gc, mh,ϵ}=SemiParm ;
4.829415887919019`*^15  {gc  (me^(3/2)) , (mh^(3/2))} 
];
FermiLevel[Dopant_,T_,SemiParm_]:=Module[{Eg, me, gc, mh,ϵ
, NC0,NV0,type, DopeDensity, kB=  8.61739*10^(-5)},
{ Eg, me, gc, mh,ϵ}=SemiParm  ;
{NC0,NV0}= NDOS0[SemiParm] ;
{type, DopeDensity}=Dopant ;
If[type>0  , 
kB T Log[DopeDensity/(NC0 (T^(3/2)))] 
,-kB T Log[DopeDensity/(NV0 (T^(3/2))) ] ]
] ;
DepletionW[T_,Vbias_,JuncDopant_, SemiParm_]:=Module[{Eg, me, gc, mh,ϵ
,Dopant1, Dopant2,
ContactV, V0, W,
,aB=5.29177*10^(-9)
,Ryd=13.6057},
{ Eg, me, gc, mh,ϵ}=SemiParm  ;
{Dopant1, Dopant2}=JuncDopant ;
ContactV=Eg+Sign[Dopant1[[1]] ]*FermiLevel[Dopant1,T,SemiParm]+Sign[Dopant2[[1]] ]*FermiLevel[Dopant2,T,SemiParm] ;
V0=ContactV-Vbias ;
W=Sqrt[(ϵ V0/(aB  Ryd))* (1/Dopant1[[2]] +1/Dopant2[[2]]) ]  ;
10^4* W {1, Dopant2[[2]]/(Dopant1[[2]] +Dopant2[[2]])
,Dopant1[[2]]/(Dopant1[[2]] +Dopant2[[2]])  }] ;
ϕJ[x_, T_,Vbias_,JuncDopant_, SemiParm_]:= Module[{Eg, me, gc, mh,ϵ
, ContactV, V0, W, x1,x2},
{ Eg, me, gc, mh,ϵ}=SemiParm  ; 
{W, x1,x2} =DepletionW[T,Vbias,JuncDopant, SemiParm] ;
ContactV=Eg+Sign[JuncDopant[[1,1]] ]*FermiLevel[JuncDopant[[1]],T,SemiParm]+Sign[JuncDopant[[2,1]] ]*FermiLevel[JuncDopant[[2]] ,T,SemiParm] ;
V0=ContactV-Vbias ;
Sign[JuncDopant[[1,1]] ]*If[x≤-x1,0.,If[x≤ 0., V0  (x+x1)^2 /(x1*W),
If[x≤ x2, V0*(1-(x-x2)^2/(x2*W)) ,V0]
]
]
] ;
BandDiagram[x_, T_,Vbias_,JuncDopant_, SemiParm_]:= Module[{Eg, me, gc, mh,ϵ
, ContactV, V0, W,w, x1,x2},
{ Eg, me, gc, mh,ϵ}=SemiParm  ; 
{W, x1,x2} =DepletionW[T,Vbias,JuncDopant, SemiParm] ;
ContactV=Eg+Sign[JuncDopant[[1,1]] ]*FermiLevel[JuncDopant[[1]],T,SemiParm]+Sign[JuncDopant[[2,1]] ]*FermiLevel[JuncDopant[[2]] ,T,SemiParm] ;
V0=ContactV-Vbias ;
w=Sign[JuncDopant[[1,1]] ]*If[x≤-x1,0.,If[x≤ 0., V0  (x+x1)^2 /(x1*W),
If[x≤ x2, V0*(1-(x-x2)^2/(x2*W)) ,V0]
]
] ;
w-FermiLevel[JuncDopant[[1]],T,SemiParm]
+{Sign[JuncDopant[[2,1]] ]*Eg,0.} 
] ;

FermiLine[x_, T_,Vbias_,JuncDopant_, SemiParm_]:=Module[{Eg, me, gc, mh,ϵ
, ContactV, V0, W, x1,x2},
{ Eg, me, gc, mh,ϵ}=SemiParm  ; 
{W, x1,x2} =DepletionW[T,Vbias,JuncDopant, SemiParm] ;
ContactV=Eg+Sign[JuncDopant[[1,1]] ]*FermiLevel[JuncDopant[[1]],T,SemiParm]+Sign[JuncDopant[[2,1]] ]*FermiLevel[JuncDopant[[2]] ,T,SemiParm] ;
V0=ContactV-Vbias ;
If[x≥- x1,-Sign[JuncDopant[[1,1]] ]*Vbias,  ]
];
CarrierEqui[x_, T_,JuncDopant_, SemiParm_]:= Module[{Eg, me, gc, mh,ϵ 
,NC0,NV0, F
, kB=  8.61739*10^(-5)},
{ Eg, me, gc, mh,ϵ}=SemiParm  ; 
{NC0,NV0}= NDOS0[SemiParm] ;
F=BandDiagram[x, T,0.,JuncDopant, SemiParm] ;
If[JuncDopant[[1,1]]>0, 
{NC0 (T^(3/2)) (E^(-F[[2]]/(kB T))), NV0 (T^(3/2)) (E^(F[[1]]/(kB T))), NC0 (T^(3/2)) (E^(-F[[2]]/(kB T)))  +  NV0 (T^(3/2)) (E^(F[[1]]/(kB T)))} 
, {NC0 (T^(3/2)) (E^(-F[[1]]/(kB T))), NV0 (T^(3/2)) (E^(F[[2]]/(kB T))), NC0 (T^(3/2)) (E^(-F[[1]]/(kB T)))  +  NV0 (T^(3/2)) (E^(F[[2]]/(kB T)))}
]
];
CarrierJ[x_, T_,Vbias_,JuncDopant_, SemiParm_,DiffParm_]:= Module[{Eg, me, gc, mh,ϵ
, μn,μp,τ,Ln, Lp 
,NC0,NV0
, W, x1,x2
,q1,q2,F1,F2,G
, kB=  8.61739*10^(-5)},
{ Eg, me, gc, mh,ϵ}=SemiParm  ; 
{ μn,μp,τ,Ln,Lp}=DiffParm  ;
If[Ln==0. || TrueQ[Ln== Null], Ln=10^4*Sqrt[μn kB T τ], ];
If[Lp==0. || TrueQ[Lp ==  Null],Lp=10^4*Sqrt[μp kB T τ], ];
{NC0,NV0}= NDOS0[SemiParm] ;
{W, x1,x2} =DepletionW[T,Vbias,JuncDopant, SemiParm] ;
F1=BandDiagram[-x1, T,0.,JuncDopant, SemiParm] ;
F2=BandDiagram[x2, T,0.,JuncDopant, SemiParm] ;
q1=If[JuncDopant[[1,1]]≥ 0., NV0 (T^(3/2.)) (E^(F1[[1]]/(kB T))), NC0 (T^(3/2.)) (E^(-F1[[1]]/(kB T)))] ;
q2=If[JuncDopant[[1,1]]≥ 0., NC0 (T^(3/2.)) (E^(-F2[[2]]/(kB T))), NV0 (T^(3/2.)) (E^(F2[[2]]/(kB T)))] ;
G=Exp[Vbias/(kB T)]-1;
If[JuncDopant[[1,1]]≥ 0.,
If[x≤ -x1, q1 G  (E^((x+x1)/Lp)),
If [x≥ x2, q2 G  (E^(-(x-x2)/Ln)), ]
]
, If[x≤ -x1, q1 G  (E^((x+x1)/Ln)),
If [x≥ x2, q2 G  (E^(-(x-x2)/Lp)), ]
]
]
]  ;
DiffJ[x_, T_,Vbias_,JuncDopant_, SemiParm_,DiffParm_]:= Module[{Eg, me, gc, mh,ϵ
, μn,μp,τ,Ln, Lp 
,NC0,NV0
, W, x1,x2
,q1,q2,F1,F2,G
, kB=  8.61739*10^(-5)},
{ Eg, me, gc, mh,ϵ}=SemiParm  ; 
{ μn,μp,τ,Ln,Lp}=DiffParm  ;
If[Ln==0. || TrueQ[Ln== Null], Ln=10^4*Sqrt[μn kB T τ], ];
If[Lp==0. || TrueQ[Lp ==  Null],Lp=10^4*Sqrt[μp kB T τ], ];
{NC0,NV0}= NDOS0[SemiParm] ;
{W, x1,x2} =DepletionW[T,Vbias,JuncDopant, SemiParm] ;
F1=BandDiagram[-x1, T,0.,JuncDopant, SemiParm] ;
F2=BandDiagram[x2, T,0.,JuncDopant, SemiParm] ;
q1=If[JuncDopant[[1,1]]>0, NV0 (T^(3/2)) (E^(F1[[1]]/(kB T))), NC0 (T^(3/2)) (E^(-F1[[1]]/(kB T)))] ;
q2=If[JuncDopant[[1,1]]>0, NC0 (T^(3/2)) (E^(-F2[[2]]/(kB T))), NV0 (T^(3/2)) (E^(F2[[2]]/(kB T)))] ;
G=Exp[Vbias/(kB T)]-1;
1.602176487`*^-23*If[JuncDopant[[1,1]]>0,
If[x≤ -x1,Lp q1 G  (E^((x+x1)/Lp))/τ,
If [x≥ x2,Ln q2 G  (E^(-(x-x2)/Ln))/τ, ]
]
, If[x≤ -x1,Ln q1 G  (E^((x+x1)/Ln))/τ,
If [x≥ x2,Lp q2 G  (E^(-(x-x2)/Lp))/τ, ]
]
]
]  ;
DiodeC[ T_,Vbias_,JuncDopant_, SemiParm_,DiffParm_]:= Module[{Eg, me, gc, mh,ϵ
, μn,μp,τ,Ln, Lp 
,NC0,NV0
, W, x1,x2
,q1,q2,F1,F2,G
, kB=  8.61739*10^(-5)},
{ Eg, me, gc, mh,ϵ}=SemiParm  ; 
{ μn,μp,τ,Ln,Lp}=DiffParm  ;
If[Ln==0. || TrueQ[Ln== Null], Ln=10^4*Sqrt[μn kB T τ], ];
If[Lp==0. || TrueQ[Lp ==  Null],Lp=10^4*Sqrt[μp kB T τ], ];
{NC0,NV0}= NDOS0[SemiParm] ;
{W, x1,x2} =DepletionW[T,Vbias,JuncDopant, SemiParm] ;
F1=BandDiagram[-x1, T,0.,JuncDopant, SemiParm] ;
F2=BandDiagram[x2, T,0.,JuncDopant, SemiParm] ;
q1=If[JuncDopant[[1,1]]>0, NV0 (T^(3/2)) (E^(F1[[1]]/(kB T))), NC0 (T^(3/2)) (E^(-F1[[1]]/(kB T)))] ;
q2=If[JuncDopant[[1,1]]>0, NC0 (T^(3/2)) (E^(-F2[[2]]/(kB T))), NV0 (T^(3/2)) (E^(F2[[2]]/(kB T)))] ;
G=Exp[Vbias/(kB T)]-1;
1.602176487`*^-23*If[JuncDopant[[1,1]]>0,
( Lp q1 +Ln q2 ) G  /τ ,( Ln q1 +Lp q2 ) G /τ]
]  ;
DiodeC1[ T_,Vbias_,JuncDopant_, SemiParm_,DiffParm_]:= Module[{Eg, me, gc, mh,ϵ
, μn,μp,τ,Ln, Lp 
,NC0,NV0
, W, x1,x2,ContactV,Ef1,Ef2
,q1,q2,F1,F2,G,r1,r2,H
, kB=  8.61739*10^(-5)},
{ Eg, me, gc, mh,ϵ}=SemiParm  ; 
{ μn,μp,τ,Ln,Lp}=DiffParm  ;
If[Ln==0. || TrueQ[Ln== Null], Ln=10^4*Sqrt[μn kB T τ], ];
If[Lp==0. || TrueQ[Lp ==  Null],Lp=10^4*Sqrt[μp kB T τ], ];
{NC0,NV0}= NDOS0[SemiParm] ;
Ef1=  FermiLevel[JuncDopant[[1]],T,SemiParm];
Ef2=  FermiLevel[JuncDopant[[2]],T,SemiParm];
ContactV=Eg+Sign[JuncDopant[[1,1]] ]*FermiLevel[JuncDopant[[1]],T,SemiParm]+Sign[JuncDopant[[2,1]] ]*FermiLevel[JuncDopant[[2]] ,T,SemiParm] ;
{W, x1,x2} =DepletionW[T,Vbias,JuncDopant, SemiParm] ;
F1=BandDiagram[-x1, T,0.,JuncDopant, SemiParm] ;
F2=BandDiagram[x2, T,0.,JuncDopant, SemiParm] ;
q1=If[JuncDopant[[1,1]]>0, NV0 (T^(3/2)) (E^(F1[[1]]/(kB T))), NC0 (T^(3/2)) (E^(-F1[[1]]/(kB T)))] ;
q2=If[JuncDopant[[1,1]]>0, NC0 (T^(3/2)) (E^(-F2[[2]]/(kB T))), NV0 (T^(3/2)) (E^(F2[[2]]/(kB T)))] ;
r1=  If[JuncDopant[[1,1]]>0,(mh/me)^3/2  *Exp[(F1[[1]]+F1[[2]])/(kB T)] , (me/mh)^3/2  *Exp[-(F1[[1]]+F1[[2]])/(kB T)] ] ;
r2=   If[JuncDopant[[1,1]]>0,(me/mh)^3/2  *Exp[-(F2[[1]]+F2[[2]])/(kB T)] , (mh/me)^3/2  *Exp[(F2[[1]]+F2[[2]])/(kB T)] ] ;
G=Exp[Vbias/(kB T)]-1; H=1-Exp[-2(ContactV-Vbias)/(kB T)] ;
1.602176487`*^-23*If[JuncDopant[[1,1]]>0,
( Lp q1 (1+r1 (G+1)) +Ln q2  (1+ r2 (G+1))) G  /(τ H)
,( Ln q1 (1+r1 (G+1)) +Lp q2 (1+ r2 (G+1)) ) G /(τ H)]
];

 start=0, ];
Manipulate[
If[ONOFF=="ON",
Manipulate[
SemiParm={ Eg, me,gc, mh,ϵ } ;  

Manipulate[
DiffParm ={μn,μp,10^τ,Ln,Lp};
dtype=If[dope=="p-n",-1,1] ;
ContactV=Eg+dtype*FermiLevel[{dtype,10^d1},T,SemiParm]-dtype*FermiLevel[{-dtype,10^d2},T,SemiParm] ; 

Plot[DiodeC1[ T,Vbias,{ {dtype,10^d1},{-dtype,10^d2} }, SemiParm, DiffParm],
{Vbias,VBr,Min[VBf,ContactV]},PlotRange-> All
,Frame-> True, GridLines-> Automatic
, Filling-> {1-> {Axis,Hue[0.35,1,1,0.4] }}
,PlotStyle->{Thick,Black }
,FrameLabel->{"V bias (V)","Current density (A/(cm^2))"}
,LabelStyle->Directive[14,FontFamily-> "Arial"]
 ]

,
{{dope,"p-n"},{"p-n","n-p"}},{{d1,17},14,18},{{d2,17},14,18},{{T,300,"Temperature (K)"},250,400}
,{{ Ln,0.,"e diff length (μm)"},1.,100.}
,{{ Lp,0.,"h diff length (μm)"},1.,100.}
,{{VBr,-0.1,"Reverse bias (V)"},-3,0}
,{{VBf,0.8,"Forward bias (V)"},0.1,1.4}]
,Grid[{{ Control[{{Eg,1.42,"Bandgap (eV)"},0.3,4}]
,Control[{{ϵ,13.6,"Dielectric const."},4,20}]}
,{Control[{{me,0.0665,"Elec eff mass me*"},0.02,0.5}]
,Control[{{mh,0.5,"Hole eff mass mh*"},0.02,1}]}
,{Control[{{gc,1,"Cond band degeneracy"},{1,6}}]}
,{Control[{{ μn,3000.,"e mobility"},100.,10000.}]
,Control[{{ μp,200.,"h mobility"},10.,1000.}]
,Control[{{ τ,-9,"carrier lifetime (10^)"},-12,-6}]
}
}]
], ]
,{{ONOFF,"ON","Click OFF if not used"},{"ON","OFF"}}
],
{{start,1,"Click to start"},{0,1}} ]

5.2 Log scale plot

On log scale we can see the turn-on bias kink when excess minority current is significant before the ultimate limit of contact potential.

Modified diode I-V characteristic - log scale

Manipulate[
If[start==1,
NDOS0[SemiParm_]:= Module[{ Eg, me, gc, mh,ϵ},
{ Eg, me, gc, mh,ϵ}=SemiParm ;
4.829415887919019`*^15  {gc  (me^(3/2)) , (mh^(3/2))} 
];
FermiLevel[Dopant_,T_,SemiParm_]:=Module[{Eg, me, gc, mh,ϵ
, NC0,NV0,type, DopeDensity, kB=  8.61739*10^(-5)},
{ Eg, me, gc, mh,ϵ}=SemiParm  ;
{NC0,NV0}= NDOS0[SemiParm] ;
{type, DopeDensity}=Dopant ;
If[type>0  , 
kB T Log[DopeDensity/(NC0 (T^(3/2)))] 
,-kB T Log[DopeDensity/(NV0 (T^(3/2))) ] ]
] ;
DepletionW[T_,Vbias_,JuncDopant_, SemiParm_]:=Module[{Eg, me, gc, mh,ϵ
,Dopant1, Dopant2,
ContactV, V0, W,
,aB=5.29177*10^(-9)
,Ryd=13.6057},
{ Eg, me, gc, mh,ϵ}=SemiParm  ;
{Dopant1, Dopant2}=JuncDopant ;
ContactV=Eg+Sign[Dopant1[[1]] ]*FermiLevel[Dopant1,T,SemiParm]+Sign[Dopant2[[1]] ]*FermiLevel[Dopant2,T,SemiParm] ;
V0=ContactV-Vbias ;
W=Sqrt[(ϵ V0/(aB  Ryd))* (1/Dopant1[[2]] +1/Dopant2[[2]]) ]  ;
10^4* W {1, Dopant2[[2]]/(Dopant1[[2]] +Dopant2[[2]])
,Dopant1[[2]]/(Dopant1[[2]] +Dopant2[[2]])  }] ;
ϕJ[x_, T_,Vbias_,JuncDopant_, SemiParm_]:= Module[{Eg, me, gc, mh,ϵ
, ContactV, V0, W, x1,x2},
{ Eg, me, gc, mh,ϵ}=SemiParm  ; 
{W, x1,x2} =DepletionW[T,Vbias,JuncDopant, SemiParm] ;
ContactV=Eg+Sign[JuncDopant[[1,1]] ]*FermiLevel[JuncDopant[[1]],T,SemiParm]+Sign[JuncDopant[[2,1]] ]*FermiLevel[JuncDopant[[2]] ,T,SemiParm] ;
V0=ContactV-Vbias ;
Sign[JuncDopant[[1,1]] ]*If[x≤-x1,0.,If[x≤ 0., V0  (x+x1)^2 /(x1*W),
If[x≤ x2, V0*(1-(x-x2)^2/(x2*W)) ,V0]
]
]
] ;
BandDiagram[x_, T_,Vbias_,JuncDopant_, SemiParm_]:= Module[{Eg, me, gc, mh,ϵ
, ContactV, V0, W,w, x1,x2},
{ Eg, me, gc, mh,ϵ}=SemiParm  ; 
{W, x1,x2} =DepletionW[T,Vbias,JuncDopant, SemiParm] ;
ContactV=Eg+Sign[JuncDopant[[1,1]] ]*FermiLevel[JuncDopant[[1]],T,SemiParm]+Sign[JuncDopant[[2,1]] ]*FermiLevel[JuncDopant[[2]] ,T,SemiParm] ;
V0=ContactV-Vbias ;
w=Sign[JuncDopant[[1,1]] ]*If[x≤-x1,0.,If[x≤ 0., V0  (x+x1)^2 /(x1*W),
If[x≤ x2, V0*(1-(x-x2)^2/(x2*W)) ,V0]
]
] ;
w-FermiLevel[JuncDopant[[1]],T,SemiParm]
+{Sign[JuncDopant[[2,1]] ]*Eg,0.} 
] ;

FermiLine[x_, T_,Vbias_,JuncDopant_, SemiParm_]:=Module[{Eg, me, gc, mh,ϵ
, ContactV, V0, W, x1,x2},
{ Eg, me, gc, mh,ϵ}=SemiParm  ; 
{W, x1,x2} =DepletionW[T,Vbias,JuncDopant, SemiParm] ;
ContactV=Eg+Sign[JuncDopant[[1,1]] ]*FermiLevel[JuncDopant[[1]],T,SemiParm]+Sign[JuncDopant[[2,1]] ]*FermiLevel[JuncDopant[[2]] ,T,SemiParm] ;
V0=ContactV-Vbias ;
If[x≥- x1,-Sign[JuncDopant[[1,1]] ]*Vbias,  ]
];
CarrierEqui[x_, T_,JuncDopant_, SemiParm_]:= Module[{Eg, me, gc, mh,ϵ 
,NC0,NV0, F
, kB=  8.61739*10^(-5)},
{ Eg, me, gc, mh,ϵ}=SemiParm  ; 
{NC0,NV0}= NDOS0[SemiParm] ;
F=BandDiagram[x, T,0.,JuncDopant, SemiParm] ;
If[JuncDopant[[1,1]]>0, 
{NC0 (T^(3/2)) (E^(-F[[2]]/(kB T))), NV0 (T^(3/2)) (E^(F[[1]]/(kB T))), NC0 (T^(3/2)) (E^(-F[[2]]/(kB T)))  +  NV0 (T^(3/2)) (E^(F[[1]]/(kB T)))} 
, {NC0 (T^(3/2)) (E^(-F[[1]]/(kB T))), NV0 (T^(3/2)) (E^(F[[2]]/(kB T))), NC0 (T^(3/2)) (E^(-F[[1]]/(kB T)))  +  NV0 (T^(3/2)) (E^(F[[2]]/(kB T)))}
]
];
CarrierJ[x_, T_,Vbias_,JuncDopant_, SemiParm_,DiffParm_]:= Module[{Eg, me, gc, mh,ϵ
, μn,μp,τ,Ln, Lp 
,NC0,NV0
, W, x1,x2
,q1,q2,F1,F2,G
, kB=  8.61739*10^(-5)},
{ Eg, me, gc, mh,ϵ}=SemiParm  ; 
{ μn,μp,τ,Ln,Lp}=DiffParm  ;
If[Ln==0. || TrueQ[Ln== Null], Ln=10^4*Sqrt[μn kB T τ], ];
If[Lp==0. || TrueQ[Lp ==  Null],Lp=10^4*Sqrt[μp kB T τ], ];
{NC0,NV0}= NDOS0[SemiParm] ;
{W, x1,x2} =DepletionW[T,Vbias,JuncDopant, SemiParm] ;
F1=BandDiagram[-x1, T,0.,JuncDopant, SemiParm] ;
F2=BandDiagram[x2, T,0.,JuncDopant, SemiParm] ;
q1=If[JuncDopant[[1,1]]≥ 0., NV0 (T^(3/2.)) (E^(F1[[1]]/(kB T))), NC0 (T^(3/2.)) (E^(-F1[[1]]/(kB T)))] ;
q2=If[JuncDopant[[1,1]]≥ 0., NC0 (T^(3/2.)) (E^(-F2[[2]]/(kB T))), NV0 (T^(3/2.)) (E^(F2[[2]]/(kB T)))] ;
G=Exp[Vbias/(kB T)]-1;
If[JuncDopant[[1,1]]≥ 0.,
If[x≤ -x1, q1 G  (E^((x+x1)/Lp)),
If [x≥ x2, q2 G  (E^(-(x-x2)/Ln)), ]
]
, If[x≤ -x1, q1 G  (E^((x+x1)/Ln)),
If [x≥ x2, q2 G  (E^(-(x-x2)/Lp)), ]
]
]
]  ;
DiffJ[x_, T_,Vbias_,JuncDopant_, SemiParm_,DiffParm_]:= Module[{Eg, me, gc, mh,ϵ
, μn,μp,τ,Ln, Lp 
,NC0,NV0
, W, x1,x2
,q1,q2,F1,F2,G
, kB=  8.61739*10^(-5)},
{ Eg, me, gc, mh,ϵ}=SemiParm  ; 
{ μn,μp,τ,Ln,Lp}=DiffParm  ;
If[Ln==0. || TrueQ[Ln== Null], Ln=10^4*Sqrt[μn kB T τ], ];
If[Lp==0. || TrueQ[Lp ==  Null],Lp=10^4*Sqrt[μp kB T τ], ];
{NC0,NV0}= NDOS0[SemiParm] ;
{W, x1,x2} =DepletionW[T,Vbias,JuncDopant, SemiParm] ;
F1=BandDiagram[-x1, T,0.,JuncDopant, SemiParm] ;
F2=BandDiagram[x2, T,0.,JuncDopant, SemiParm] ;
q1=If[JuncDopant[[1,1]]>0, NV0 (T^(3/2)) (E^(F1[[1]]/(kB T))), NC0 (T^(3/2)) (E^(-F1[[1]]/(kB T)))] ;
q2=If[JuncDopant[[1,1]]>0, NC0 (T^(3/2)) (E^(-F2[[2]]/(kB T))), NV0 (T^(3/2)) (E^(F2[[2]]/(kB T)))] ;
G=Exp[Vbias/(kB T)]-1;
1.602176487`*^-23*If[JuncDopant[[1,1]]>0,
If[x≤ -x1,Lp q1 G  (E^((x+x1)/Lp))/τ,
If [x≥ x2,Ln q2 G  (E^(-(x-x2)/Ln))/τ, ]
]
, If[x≤ -x1,Ln q1 G  (E^((x+x1)/Ln))/τ,
If [x≥ x2,Lp q2 G  (E^(-(x-x2)/Lp))/τ, ]
]
]
]  ;
DiodeC[ T_,Vbias_,JuncDopant_, SemiParm_,DiffParm_]:= Module[{Eg, me, gc, mh,ϵ
, μn,μp,τ,Ln, Lp 
,NC0,NV0
, W, x1,x2
,q1,q2,F1,F2,G
, kB=  8.61739*10^(-5)},
{ Eg, me, gc, mh,ϵ}=SemiParm  ; 
{ μn,μp,τ,Ln,Lp}=DiffParm  ;
If[Ln==0. || TrueQ[Ln== Null], Ln=10^4*Sqrt[μn kB T τ], ];
If[Lp==0. || TrueQ[Lp ==  Null],Lp=10^4*Sqrt[μp kB T τ], ];
{NC0,NV0}= NDOS0[SemiParm] ;
{W, x1,x2} =DepletionW[T,Vbias,JuncDopant, SemiParm] ;
F1=BandDiagram[-x1, T,0.,JuncDopant, SemiParm] ;
F2=BandDiagram[x2, T,0.,JuncDopant, SemiParm] ;
q1=If[JuncDopant[[1,1]]>0, NV0 (T^(3/2)) (E^(F1[[1]]/(kB T))), NC0 (T^(3/2)) (E^(-F1[[1]]/(kB T)))] ;
q2=If[JuncDopant[[1,1]]>0, NC0 (T^(3/2)) (E^(-F2[[2]]/(kB T))), NV0 (T^(3/2)) (E^(F2[[2]]/(kB T)))] ;
G=Exp[Vbias/(kB T)]-1;
1.602176487`*^-23*If[JuncDopant[[1,1]]>0,
( Lp q1 +Ln q2 ) G  /τ ,( Ln q1 +Lp q2 ) G /τ]
]  ;
DiodeC1[ T_,Vbias_,JuncDopant_, SemiParm_,DiffParm_]:= Module[{Eg, me, gc, mh,ϵ
, μn,μp,τ,Ln, Lp 
,NC0,NV0
, W, x1,x2,ContactV,Ef1,Ef2
,q1,q2,F1,F2,G,r1,r2,H
, kB=  8.61739*10^(-5)},
{ Eg, me, gc, mh,ϵ}=SemiParm  ; 
{ μn,μp,τ,Ln,Lp}=DiffParm  ;
If[Ln==0. || TrueQ[Ln== Null], Ln=10^4*Sqrt[μn kB T τ], ];
If[Lp==0. || TrueQ[Lp ==  Null],Lp=10^4*Sqrt[μp kB T τ], ];
{NC0,NV0}= NDOS0[SemiParm] ;
Ef1=  FermiLevel[JuncDopant[[1]],T,SemiParm];
Ef2=  FermiLevel[JuncDopant[[2]],T,SemiParm];
ContactV=Eg+Sign[JuncDopant[[1,1]] ]*FermiLevel[JuncDopant[[1]],T,SemiParm]+Sign[JuncDopant[[2,1]] ]*FermiLevel[JuncDopant[[2]] ,T,SemiParm] ;
{W, x1,x2} =DepletionW[T,Vbias,JuncDopant, SemiParm] ;
F1=BandDiagram[-x1, T,0.,JuncDopant, SemiParm] ;
F2=BandDiagram[x2, T,0.,JuncDopant, SemiParm] ;
q1=If[JuncDopant[[1,1]]>0, NV0 (T^(3/2)) (E^(F1[[1]]/(kB T))), NC0 (T^(3/2)) (E^(-F1[[1]]/(kB T)))] ;
q2=If[JuncDopant[[1,1]]>0, NC0 (T^(3/2)) (E^(-F2[[2]]/(kB T))), NV0 (T^(3/2)) (E^(F2[[2]]/(kB T)))] ;
r1=  If[JuncDopant[[1,1]]>0,(mh/me)^3/2  *Exp[(F1[[1]]+F1[[2]])/(kB T)] , (me/mh)^3/2  *Exp[-(F1[[1]]+F1[[2]])/(kB T)] ] ;
r2=   If[JuncDopant[[1,1]]>0,(me/mh)^3/2  *Exp[-(F2[[1]]+F2[[2]])/(kB T)] , (mh/me)^3/2  *Exp[(F2[[1]]+F2[[2]])/(kB T)] ] ;
G=Exp[Vbias/(kB T)]-1; H=1-Exp[-2(ContactV-Vbias)/(kB T)] ;
1.602176487`*^-23*If[JuncDopant[[1,1]]>0,
( Lp q1 (1+r1 (G+1)) +Ln q2  (1+ r2 (G+1))) G  /(τ H)
,( Ln q1 (1+r1 (G+1)) +Lp q2 (1+ r2 (G+1)) ) G /(τ H)]
];

 start=0, ];
Manipulate[
If[ONOFF=="ON",
Manipulate[
SemiParm={ Eg, me,gc, mh,ϵ } ;  

Manipulate[DiffParm ={μn,μp,10^τ,Ln,Lp};
dtype=If[dope=="p-n",-1,1] ;
ContactV=Eg+dtype*FermiLevel[{dtype,10^d1},T,SemiParm]-dtype*FermiLevel[{-dtype,10^d2},T,SemiParm] ; 

LogPlot[DiodeC1[ T,Vbias,{ {dtype,10^d1},{-dtype,10^d2} }, SemiParm, DiffParm],
{Vbias,-0.1,Min[VBf,ContactV]},PlotRange-> All
,Frame-> True, GridLines-> Automatic
, Filling-> {1-> {Axis,Hue[0.35,1,1,0.4] }}
,PlotStyle->{Thick,Black }
,FrameLabel->{"V bias (V)","Current density (A/(cm^2))"}
,LabelStyle->Directive[14,FontFamily-> "Arial"]
 ]

,
{{dope,"p-n"},{"p-n","n-p"}},{{d1,17},14,18},{{d2,17},14,18},{{T,300,"Temperature (K)"},250,400}
,{{ Ln,0.,"e diff length (μm)"},1.,100.}
,{{ Lp,0.,"h diff length (μm)"},1.,100.}
,{{VBf,1.2},0.1,1.4}]
,Grid[{{ Control[{{Eg,1.42,"Bandgap (eV)"},0.3,4}]
,Control[{{ϵ,13.6,"Dielectric const."},4,20}]}
,{Control[{{me,0.0665,"Elec eff mass me*"},0.02,0.5}]
,Control[{{mh,0.5,"Hole eff mass mh*"},0.02,1}]}
,{Control[{{gc,1,"Cond band degeneracy"},{1,6}}]}
,{Control[{{ μn,3000.,"e mobility"},100.,10000.}]
,Control[{{ μp,200.,"h mobility"},10.,1000.}]
,Control[{{ τ,-9,"carrier lifetime (10^)"},-12,-6}]
}
}]
], ]
,{{ONOFF,"ON","Click OFF if not used"},{"ON","OFF"}}
],
{{start,1,"Click to start"},{0,1}} ]