from numpy import arange
%matplotlib inline
from matplotlib.pyplot import plot,title,xlabel,ylabel,show
V_ss=2#
R=1*10**3#
V_D=arange(0,2+0.001,0.001)
I_D=[]
for x in V_D:
I_D.append(10**3*(V_ss-x)/R)
plot(V_D,I_D)
title('load line plot')
xlabel('voltage in volts')
ylabel('current in milli-amperes') #milli-10**-3
show()
#we use the equation V_ss=R*i_D+V_D
#at point B
i_D=V_ss/R# #as V_D=0
#at point A
V_D=V_ss# #as i_D=0
#now we see intersection of load line with characteristic and we get following at operating point
V_DQ=0.7# #voltage
I_DQ=1.3*10**-3# #current
#diode characteristic cannot be plotted
print 'diode voltage at operating point = %0.2f volts'%V_DQ
print I_DQ*10**3,'current at opeating point = %0.2f milli-amperes'%(I_DQ*10**3) #milli-10**-3
from numpy import arange
%matplotlib inline
from matplotlib.pyplot import plot,title,xlabel,ylabel,show
V_ss=10#
R=10*10**3#
V_D=arange(0,2+0.001,0.001)
I_D=[]
for x in V_D:
I_D.append(10**3*(V_ss-x)/R)
plot(V_D,I_D)
title('load line plot')
xlabel('voltage in volts')
ylabel('current in milli-amperes') #milli-10**-3
show()
#we use the equation V_ss=R*i_D+V_D
#at point C
i_D=V_ss/R# #as V_D=0
#now if we take i_D=0, we get V_D=10 which plots at a point far off the page
#so we take the value on the right-hand edge of V-axis i.e.,V_D=2
#at point D
V_D=2#
i_D=(V_ss-V_D)/R#
#from the intersection of load line with characteristic
V_DQ=0.68#
I_DQ=0.93*10**-3#
#diode characteristic cannot be plotted
print 'diode voltage at operating point = %0.2f volts'%V_DQ
print 'current at opeating point = %0.2f milli-amperes'%(I_DQ*10**3) #milli-10**-3
from numpy import arange
R=1*10**3#
#diode characteristic cannot be plotted
#case a)V_ss=15
V_ss=15#
V_D=arange(-15,0+0.001,0.001)
#from the intersection of load line and diode characteristic
V_o=10#
print 'output voltage for Vss=15 = %0.2f volts'%V_o
#case b)V_ss=20
V_ss=20#
V_D=arange(-20,0+0.001,0.001)
#from the intersection of load line and diode characteristic
V_o=10.5#
print 'output voltage for Vss=20 = %0.2f volts'%V_o
V_ss=24#
R=1.2*10**3#
R_L=6*10**3#
#by grouping linear elements together on left side of diode
V_T=V_ss*R_L/(R+R_L)# #thevenin voltage
#zeroing sources
R_T=1/((1/R)+(1/R_L))# #thevenin resistance
#load-line equation is V_T+R_T*i_D+V_D=0
#locating the operating point
V_D=-10#
V_L=-V_D# #load voltage
I_s=(V_ss-V_L)/R# #source current
#diode characteristic cannot be plotted
print " All the values in the textbook are approximated hence the values in this code differ from those of Textbook"
print 'load voltage = %0.2f volts'%V_L
print 'source current = %0.2f amperes'%I_s #milli-10**-3
V_1=10#
V_2=3#
R_1=4*10**3#
R_2=6*10**3#
#1)analysis by assuming D1 off and D2 on
I_D_2=V_2/R_2# #ohm's law
#applying KVL
V_D_1=7# #contradiction to 'D1 is off'
#this assumption is not correct
#2)analysis by assuming D1 on and D2 off
I_D_1=V_1/R_1# #ohm's law
#applying KVL
V_D_2=-V_1+V_2+I_D_1*R_1#
#we get V_D_2 which is consistent
print 'correct assumption is D2 off and D1 on'
V_1=3#
R_1=20#
#As given voltage source results in forward bias, we assume operating point is on line segment A
#replacing diode with the equivalent circuit
V_2=0.6#
R_2=10#
i_D=(V_1-V_2)/(R_1+R_2)# #KVL around the circuit
print 'current in the circuit = %0.2f milli-amperes'%(i_D*10**3) #milli-10**-3