In [1]:

```
#(a) I,Vo
#(b) I,Vo
print "Part (a)"
# Applying Thevnin's theorem at XX', in Fig. 2.5(a)
Vth=15*20e3/(10e3+20e3)# # Thevnin equivalent voltage in volts
Zth=10e3*20e3/(10e3+20e3)# # Thevnin equivalent resistance in ohms
# From the figure 2.5(c)
I=Vth/(Zth+20e3)# # Labelled current in amperes
Vo=I*20e3# # Labelled voltage in volts
I=I*1e3# # Labelled current in miliamperes
print "Labelled current I = %0.2f mA"%I
print "Labelled voltage Vo = %0.2f V"%Vo
print "Part (b)"
# Applying Thevnin's theorem at XX' and YY', in Fig. 2.5(b)
Vth1=15*10e3/(10e3+10e3)# # Thevnin equivalent voltage at XX' in volts
Zth1=10e3*10e3/(10e3+10e3)# # Thevnin equivalent resistance at YY' in ohms
Vth2=5# # Thevnin equivalent voltage at YY' in volts
Zth2=5e3# # Thevnin equivalent resistance at YY' in ohms
# From the figure 2.5(d)
I=0# # Labelled current in amperes
Vo=5-7.5# # Labelled voltage in volts
print "Labelled current I = %0.2f A"%I
print "Labelled voltage Vo = %0.2f V"%Vo
```

In [2]:

```
from math import log
#Change in diode voltage
ID1=1# # Let the initial diode current be 1 A
ID2=15*ID1# # Final diode current
VT=25e-3# # Voltage equivalent to temperatue at room temperature in volts
eta=1# # for Ge
deltaVD=eta*VT*log(ID2/ID1)# # Change in diode voltage in volts
deltaVD=deltaVD*1e3# # Change in diode voltage in milivolts
print "Change in diode voltage (for Ge)= %0.2f mV"%deltaVD
eta=2# # for Si
deltaVD=eta*VT*log(ID2/ID1)# # Change in diode voltage in volts
deltaVD=deltaVD*1e3# # Change in diode voltage in milivolts
print "Change in diode voltage (for Si) = %0.2f mV"%deltaVD
```

In [3]:

```
from __future__ import division
from math import exp,log
#(a) Voltage
#(b) Ratio of current in forward bias to that in reverse bias
#(c) Forward current
print "Part (a)"
eta=1# # for Ge
T=300# # Room temperature in kelvins
VT=T/11600# # Voltage equivalent to temperatue at room temperature in volts
IS=1# # Let reverse saturation current be 1 A
I=-0.9*IS# # Reverse current
V=eta*VT*log(1+(I/IS))# # Voltagei in volts
V=V*1e3# # Voltage in milivolts
print "Voltage = %0.2f mV"%V
print "Part (b)"
V=0.05# # Voltage in volts
If_Ir=(exp(V/(eta*VT))-1)/(exp(-V/(eta*VT))-1)# # Ratio of current in forward bias to that in reverse bias
print "Ratio of current in forward bias to that in reverse bias = %0.2f "%If_Ir
print "Part (c)"
IS=10e-6# # Reverse saturation current in amperes
V=0.1# # Voltage in volts
ID=IS*(exp(V/(eta*VT))-1)# # Forward current for 0.1 V in amperes
ID=ID*1e6# # Forward current for 0.1 V in micro-amperes
print "Forward current for 0.1 V = %0.2f μA"%ID
V=0.2# # Voltage in volts
ID=IS*(exp(V/(eta*VT))-1)# # Forward current for 0.1 V in amperes
ID=ID*1e3# # Forward current for 0.1 V in miliamperes
print "Forward current for 0.1 V = %0.2f mA"%ID
V=0.3# # Voltage in volts
ID=IS*(exp(V/(eta*VT))-1)# # Forward current for 0.1 V in amperes
print "Forward current for 0.1 V (A) = %0.2f A"%ID
# ans is wrong in the book.
```

In [4]:

```
from math import exp
from __future__ import division
# (a) Current
# (b) Current
# (C) Current
IS=10e-6# # Reverse saturation current in amperes
eta=1# # for Ge
VT=25e-3# # Voltage equivalent to temperatue at room temperature in volts
print "Part (a)"
VD=-24# # Reverse bias in volts
ID=IS*(exp(VD/(eta*VT))-1)# # Current in amperes
ID=ID*1e6# # Current in micro-amperes
print "Current = %0.2f μA"%ID
print "Part (b)"
VD=-0.02# # Reverse bias in volts
ID=IS*(exp(VD/(eta*VT))-1)# # Current in amperes
ID=ID*1e6# # Current in micro-amperes
print "Current = %0.4f μA"%ID
print "Part (c)"
VD=0.3# # Forward bias in volts
ID=IS*(exp(VD/(eta*VT))-1)# # Current in amperes
print "Current = %0.4f A"%ID
```

In [1]:

```
from math import log
#Change in diode voltage
T=300# # Operating temperature in kelvins
VT=T/11600# # Voltage equivalent to temperatue at room temperature in volts
ID1=1# # Let the initial diode current be 1 A
ID2=10*ID1# # Final diode current
eta=1# # for Ge
deltaVD=eta*VT*log(ID2/ID1)# # Change in diode voltage in volts
deltaVD=deltaVD*1e3# # Change in diode voltage in milivolts
print "Change in diode voltage (for Ge) = %0.f mV"%deltaVD
eta=2# # for Si
deltaVD=eta*VT*log(ID2/ID1)# # Change in diode voltage in volts
deltaVD=deltaVD*1e3# # Change in diode voltage in milivolts
print "Change in diode voltage (for Si) = %0.f mV"%deltaVD
```

In [2]:

```
from math import exp,log
## R
# In the circuit given in Fig. 2.7
V=50e-3# # Output voltage
VD1=0.7# # Voltage across diode 1 in volts
I1=10e-3# # Current through diode 1 at 0.7 V in amperes
VD2=0.8# # Voltage across diode 2 in volts
I2=100e-3# # Current through diode 2 at 0.8 V in amperes
eta_VT=(VD2-VD1)/log(I2/I1)# # Product of η and VT
I=10e-3/(exp(V/eta_VT)+1)# # Current through diode 1 in amperes
R=V/I#
print "R = %0.2f Ω"%R
```

In [2]:

```
from math import exp,log
#Current, Diode voltage
VDD=5# # Applied voltage in volts
VD=0.7# # Diode voltage in volts
I1=1e-3# # Current in amperes at diode voltage = 0.7 V
R=1000# # R in ohms
deltaVD=0.1# # Change in diode voltage in volts for every decade change in current
ratioI=10# # Decade change in current
eta_VT=deltaVD/log(ratioI)# # Product of η and VT
ID=(VDD-VD)/R# # Diode current in amperes
VD2=VD+eta_VT*log(ID/I1)# # Diode voltage in volts
ID=ID*1e3# # Diode current in miliamperes
print "Diode current = %0.4f mA"%ID
print "Diode voltage = %0.4f V"%VD2
```

In [1]:

```
# (a) Output voltage
# (b) Output voltage
# (c) Output voltage
print "Part (a)"
# Since both the diodes are in OFF state
Vo=5# # Output voltage in volts
print "Output voltage = %0.2f V"%Vo,
print "Part (b)"
#Since diode D1 is in OFF state and diode D2 is in ON state
# From Fig. 2.16(C)
I=(5-0.6)/(4.7e3+300)# # Current flowing through the diode D2 in amperes
Vo=5-I*4.7e3# # Output voltage in volts
print "Output voltage = %0.3f V"%Vo
print "Part (c)"
# Since both diodes are in ON state
# Applying KVL in Fig. 2.16(d)
I=(5-0.6)/(2*4.7e3+300)# # Current flowing through diode D1 or diode D2 in amperes
Vo=5-2*I*4.7e3# # Output voltage in volts
print "Output voltage = %0.3f V"%Vo
```

In [2]:

```
# (a) Output voltage, Diode currents
# (b) Output voltage, Diode currents
Vy=0.7# # Cut-in voltage in volts
# In the Fig. 2.17
R1=5e3#
R2=10e3#
print "Part (a)"
# Since diode D1 is OFF and diode D2 is ON
ID2=(5-Vy-(-5))/(R1+R2)# # Current through diode D2 in amperes
Vo=5-ID2*R1# # Output voltage
ID2=ID2*1e3# # Current through diode D2 in miliamperes
print "Output voltage = %0.f V"%Vo
print "Current through diode D1 = %0.f A"%0
print "Current through diode D2 = %0.2f mA "%ID2
print "Part (b)"
# Since both the diodes are ON
VA=4-Vy# # In the fig.
Vo=VA+Vy# # Output voltage
ID2=(5-Vo)/R1# # Current through diode D2 in amperes
IR2=(VA-(-5))/R2# # Current through diode R2 in amperes
ID1=IR2-ID2# # Current through diode D1 in amperes
ID1=ID1*1e3# # Current through diode D1 in miliamperes
ID2=ID2*1e3# # Current through diode D2 in miliamperes
print "Output voltage = %0.2f V"%Vo
print "Current through diode D1 = %0.2f mA"%ID1
print "Current through diode D2 = %0.2f mA"%ID2
```

In [3]:

```
# (a) Alternating component of voltage acroos load resistance
# (b) Total voltage across load resistance
# (c) Total current
T=293# # Operating temperature in kelvins
VT=T/11600# # Voltage equivalent to temperatue at room temperature in volts
# In the Fig. 2.21(a)
VAA=9# # in volts
Vm=0.2# # in volts
RL=2e3# # Load resistance in ohms
Vy=0.6# # Cut-in voltage in volts
Rf=10# # Forward resistance of diode in ohms
eta=2#
print "Part (a)"
# From DC model in Fig. 2.21(b)
IDQ=(VAA-Vy)/(RL+Rf)# # DC current through diode or load resistance in amperes
rd=eta*VT/IDQ# # Dynamic resistance in ohms
# This dynamic resistance is used in AC model in Fig. 2.21(c)
Vom=Vm*RL/(RL+rd)# # Amplitude of alternating component of the voltage across load resistance in volts
print "Amplitude of alternating component of the voltage across load resistance = %0.2f V"%Vom
print "Therefore, the alternating component of the voltage across load resistance is 0.199 sin ωt V"
print "Part (b)"
VDQ=IDQ*RL# # DC component of voltage across load resistance in volts
print "DC component of voltage across load resistance = %0.2f V"%VDQ
print "Therefore, total voltage across load resistance is (8.36 + 0.199 sin ωt) V"
print "Part (C)"
IDQ=IDQ*1e3# # DC current through load resistance in miliamperes
idm=Vm/(RL+rd)# # Amplitude of alternating component of the current across load resistance in amperes
idm=idm*1e3# # Amplitude of alternating component of the current across load resistance in miliamperes
print "DC component of current across load resistance = %0.2f mA "%IDQ
print "Amplitude of alternating component of the current across load resistance = %0.2f mA"%idm
print "Therefore, total current across load resistance is (4.18 + 0.099 sin ωt) mA"
```

In [4]:

```
## (b) Vo
#(c) I
print "Part (b)"
# In the Fig. 2.22 (a)
vs=10e-3# # in volts
Rs=1e3# # in ohms
eta=2#
VT=25e-3# # Voltage equivalent to temperatue at room temperature in volts
I=1e-3# # in amperes
Vo=vs*eta*VT/(eta*VT+I*Rs)# # in volts
Vo=Vo*1e3# # in milivolts
print "Vo for I= 1 mA = %0.3f mV"%Vo
I=0.1e-3# # in amperes
Vo=vs*eta*VT/(eta*VT+I*Rs)# # in volts
Vo=Vo*1e3# # in milivolts
print "Vo for I= 0.1 mA = %0.2f mV"%Vo
I=1e-6# # in amperes
Vo=vs*eta*VT/(eta*VT+I*Rs)# # in volts
Vo=Vo*1e3# # in milivolts
print "Vo for I= 1 μA = %0.3f mV"%Vo
print "Part (c)"
Vo=vs/2# # in volts
I=eta*VT*(vs-Vo)/(Vo*Rs)# # in amperes
I=I*1e6# # in micro-amperes
print "I = %0.2f μA"%I
```

In [5]:

```
from math import pi
#Barrier capacitance
A=1e-3*1e-3# # Area of p-n junction in metres square
W=2e-6# # Space charge thickness in metres
E=16# # Dielectric constant of Ge
Eo=1/(36*pi*1e9)# # Absolute permittivity of air
C=E*Eo*A/W# # Barrier capacitance in farads
C=C*1e12# # Barrier capacitance in pico-farads
print "Barrier capacitance = %0.2f pF"%C
```

In [6]:

```
from math import sqrt
# (a) Change in capacitance
# (b) Change in capacitance
C=4e-12# # Depletion capacitance in farads
V=4# # in volts
K=C*sqrt(V)# # a constant
print "Part (a)"
V=4+0.5# # in volts
C_new=K/sqrt(V)# # in farads
deltaC=C_new-C# # Change in capacitande in farads
deltaC=deltaC*1e12# # Change in capacitande in pico-farads
print "Change in capacitance = %0.3f pF"%deltaC
print "Part (b)"
V=4-0.5# # in volts
C_new=K/sqrt(V)# # in farads
deltaC=C_new-C# # Change in capacitande in farads
deltaC=deltaC*1e12# # Change in capacitande in pico-farads
print "Change in capacitance = %0.3f pF"%deltaC
```

In [7]:

```
from math import sqrt
#Diffusion length
I=1e-3# # Forward bias current in amperes
C=1e-6# # Diffusion capacitance in farads
Dp=13# # Diffusion constant for Si
eta=2# # for Si
VT=26e-3# # Voltage equivalent to temperatue at room temperature in volts
Lp=sqrt(C*Dp*eta*VT/I)# # Diffusion length in metres
Lp=Lp*1e2# # Diffusion length in centimetres
print "Diffusion length = %0.2f cm"%Lp
```

In [18]:

```
from math import log,exp
# (a) Vd1 and Vd2
# (b) Current in the circuit
eta_VT=0.026# # Product of η and VT
print "Part (a)"
# From the Fig. 2.19(a)
Is=5e-6# # Reverse saturation current through diode D2 in amperes
Id1=Is# # Forward current through diode D1 in amperes
Vd1=eta_VT*log(1+(Id1/Is))# # in volts
Vd2=5-Vd1# # in volts
print "Vd1 = %0.4f V"%Vd1
print "Vd2 = %0.4f V"%Vd2
print "Part (b)"
# From the Fig. 2.19(b)
Vz=4.9# # Zener voltage in volts
Vd1=5-Vz# # in volts
I=Is*(exp(Vd1/eta_VT)-1)# # Current in the circuit in amperes
I=I*1e6# # Current in the circuit in micro-amperes
print "Current in the circuit = %0.f μA"%I
```