In [1]:

```
from __future__ import division
#Given data
Co= 20 # in pF
Vr= 5 # in V
V_T= 26 # in mV
V_T= V_T*10**-3 # in V
C_T= Co/(1+(Vr/V_T)) # in pF
print " The transition capacitance of diode = %0.2f pF" %C_T
```

In [2]:

```
#Given data
toh= 10**-6 # in sec
I=10 # in mA
I=I*10**-3 # in A
n=1
V_T= 26 # in mV
V_T= V_T*10**-3 # in V
C_D= toh*I/(n*V_T) # in F
print " The diffusion capacitance in p-n junction diode = %0.f nF" %(C_D*10**9)
# Note: There are two mistake in the book. First one is this that they put the wrong value of I to evaluating
# the value of C_D because the value of I is given 10mA (i.e. 10*10**-3= 10**-2 amp) but they put 10**-3 at place
# of 10**-2 and second one is calculation error. So the answer in the book is wrong.
```

In [3]:

```
from math import exp
#Given data
T=300 # in K
V_T= T/11600 # in V
v= 0.3 # forward bias voltage in volt
I= 10 # leakage current in micro amp
I=I*10**-6 # in amp
id= I*(exp(v/V_T)) # in amp
print " The diode current = %0.2f amp" %id
```

In [5]:

```
from math import log
#Given data
Vd_1= 0.3 # in V
V_T= 25 # in mV
V_T= V_T*10**-3 # in V
# when Id_1= 1 mA
Id_1= 1 # in mA
Id_1=Id_1*10**-3 # in A
# Formula Id_1= Io*[%e**(Vd/(n*V_T))-1]= Io*[e**(Vd/(n*V_T))]
# Id_1= Io*[e**(Vd_1/(n*V_T))] (i)
# when Id_2= 200 mA
Id_2= 200 # in mA
Id_2=Id_2*10**-3 # in A
Vd_2= 0.45 # in V
# Id_2= Io*[e**(Vd_2/(n*V_T))] (ii)
# Dividing (ii) by (i), we have
n= (Vd_2-Vd_1)/(log(Id_2/Id_1)*V_T)
print " The value of the constant for the diode = %0.2f " %n
```

In [6]:

```
#Given data
T=300 # in K
V_T= T/11600 # in V
n=1 # assuming value
Jd=10**5 # in A/m**2
Jo=250 # in mA/m**2
Jo= Jo*10**-3 # in A/m**2
#Formula Id= Io*(%e**(Vd/V_T)-1) and after dividing both the sides by area of the junction, we have
# Jd= Jo*(%e**(Vd/V_T)) # approx by neglecting 1
Vd= V_T*log(Jd/Jo) # in volt
print " Voltage to be applied across a p-n junction = %0.2f volt" %Vd
```

In [12]:

```
from math import log
#Given data
J=10**4 # in A/m**2
Jo=200 # in mA/m**2
Jo= Jo*10**-3 # in A/m**2
T=300 # in K
V_T= T/11600 # in V
e=1.6*10**-19 # electrone charge
k= 1.38*10**-23
n=1 # assuming value
#Formula I= Io*(%e**(e*V/(n*k*T))-1) and after dividing both the sides by area of the junction, we have
# J= Jo*(%e**(e*V/(n*k*T))) # approx by neglecting 1
V= n*k*log(J/Jo)/e
print " Voltage to be applied across the junction = %0.2e volts" %V
```

In [10]:

```
#Given data
n=2
V_T=26 # in mV
Io= 30 # in mA
# (i) when
I_D= 0.1 # in mA
V_D= n*V_T*log(I_D/Io) # in mV
print " (i) When I_D is 0.1 mA, The junction forward-bias voltage = %0.f mV" %V_D
# (ii) when
I_D= 10 # in mA
V_D= n*V_T*log(I_D/Io) # in mV
print " (ii) When I_D is 10 mA, The junction forward-bias voltage = %0.f mV" %V_D
# Note: There is calculation error in the book so answer in the book is wrong.
```

In [14]:

```
#Given data
I_by_Io= -0.9
V_T=26 # in mV
V_T=V_T*10**-3 #in V
n=1
# From Diode equation I= Io*[e**(e*V/(n*V_T))-1]
V= n*V_T*log(1+I_by_Io) # in volt
print "The value of voltage = %0.1f mV " %(V*10**3)
```

In [19]:

```
#Given data
nita= 2
T1= 25 # in °C
T2= 150 # in °C
k= 8.62*10**-5
V_T150= k*(T2+273) # in V
V_T25= k*(T1+273) # in V
V= 0.4 # in V
# Io150= Io25*2**(T2-T1)
Io150byIo25= 2**((T2-T1)/10)
I150byI25= Io150byIo25 *(exp(V/(nita*V_T150))-1)/(exp(V/(nita*V_T25))-1)
print " The value of factor = %0.f" %I150byI25
# Note : There is some difference between coding and the answer of the book because in the book
# the values of ( Io150byIo25, V_T150, V_T25 )
# are putted (respectively 5800, 0.0364, 0.026) whereas the accurate values of these are
# 5792.6188 , 0.0364626 and 0.0256876
```

In [20]:

```
#Given data
I_F= 100 # in mA
I_F=I_F*10**-3 # in A
V_F= 0.75 # in V
R_F= V_F/I_F # in ohm
print " Forward resistance = %0.1f ohm " %R_F
# At
V_R= 50 # in V
I_R= 100 # in nA
I_R= I_R*10**-9 # in A
R_R= V_R/I_R # in ohm
print " Reverse resistance = %0.f Mohm " %(R_R*10**-6)
```

In [21]:

```
#Given data
I_F= 70 # in mA
V_F= 26 # in mV
delta_I_F= 60 # in mA
delta_I_F=delta_I_F*10**-3 # in A
delta_V_F= 0.025 # in V
r_d= delta_V_F/delta_I_F # in ohm
print " Dynamic resistance = %0.2f ohm" %r_d
# and the stimated value of the dynamic resistance is
r_d= V_F/I_F # in ohm
print " The estimated value of the Dynamic resistance = %0.2f ohm" %r_d
```

In [23]:

```
#Given data
Io= 1 # in micro amp
Io=Io*10**-6 # in amp
V_F= 0.52 # in V
V_R= -0.52 # in V
nita= 1
T=300 # in K
V_T= T/11600 # in volt
V_T=round(V_T*10**3) # in mV
# (i)
r_F= nita*V_T*10**-3/(Io*exp(V_F/(nita*V_T*10**-3)))
print "(i) : Dynamic resistance in the forward biased condition = %0.2e ohm" %r_F
# (ii)
r_r= nita*V_T*10**-3/(Io*exp(V_R/(nita*V_T*10**-3)))
print "(ii) : Dynamic resistance in the reverse biased condition = %0.2e ohm" %r_r
```

In [25]:

```
#Given data
V_F= 0.2 # in V
T=300 # in K
V_T= T/11600 # in volt
Io= 1 # in micro amp
Io=Io*10**-6 # in amp
Id= Io*(exp(V_F/V_T)-1)
I_F=Id
r_dc= V_F/I_F # in ohm
print " Dynamic resistance = %0.1f ohm" %r_dc
r_ac= .026/I_F # in ohm
print " Static resistance = %0.1f ohm" %r_ac
```

In [27]:

```
#Given data
# Part (i)
I_D=2 # in mA
I_D=I_D*10**-3 # in amp
V_D= 0.5 # in volt
R_DC= V_D/I_D # in ohm
print "(i) : DC resistance levels for the diode = %0.f ohm" %R_DC
# Part (ii)
I_D=20 # in mA
I_D=I_D*10**-3 # in amp
V_D= 0.8 # in volt
R_DC= V_D/I_D # in ohm
print "(ii) : DC resistance levels for the diode = %0.f ohm" %R_DC
# Part (iii)
I_D=-1 # in micro amp
I_D=I_D*10**-6 # in amp
V_D= -10 # in volt
R_DC= V_D/I_D # in ohm
print "(iii) : DC resistance levels for the diode = %0.f Mohm" %(R_DC*10**-6)
```

In [28]:

```
#Given data
T1= 25 # in °C
T2= 100 # in °C
deltaT= T2-T1 # in °C
deltaV_F= -1.8*10**-3 # in mV/°C
I_F= 26 # in mA
V_F1= 0.7 # in V (at T1)
V_F2= V_F1+(deltaT*deltaV_F) # in V (at T2)
# At 25°C
T= 25+273 # in K
rd= 26/I_F*T/298 # in Ω
print " Junction dynamic resistance at 25°C = %0.f Ω " %rd
# At 100°C
T= 100+273 # in K
rd= 26/I_F*T/298 # in Ω
print " Junction dynamic resistance at 100°C = %0.2f Ω " %rd
```

In [30]:

```
#Given data
I= 2 # in mA
I=I*10**-3 # in A
V_T= 25 # in mV
V_T= V_T*10**-3 # in V
nita= 1
r_F= nita*V_T/I # in Ω
print " The dynamic resistance of a diode = %0.1f Ω" %r_F
```

In [32]:

```
#Given data
I= 30 # in µA
I=I*10**-6 # in A
T=125+273 # in K
r_F= T/(11600*I*exp(-0.32/T)*11600) # in Ω
print " The dynamic resistance = %0.3f mΩ" %(r_F*10**3)
# Note: There are two error in this example in the book.
# First one is this that putted value of T in first term of calculation
# (i.e 3.98/11600) is wrong (correct value is 398 not 3.98).
# and second one error is this that calculaiton is also wrong for putted value
```