IPython QtConsole 3.2.0
Python 2.7.10 |Anaconda 2.3.0 (64-bit)| (default, May 28 2015, 16:44:52) [MSC v.1500 64 bit (AMD64)]
Type "copyright", "credits" or "license" for more information.
IPython 3.2.0 -- An enhanced Interactive Python.
Anaconda is brought to you by Continuum Analytics.
Please check out: http://continuum.io/thanks and https://anaconda.org
? -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help -> Python's own help system.
object? -> Details about 'object', use 'object??' for extra details.
%guiref -> A brief reference about the graphical user interface.
In [1]: import math
...:
...: #(a)
...: #initialisation of variables
...:
...: E=10 #E in V
...: R=1 #R in Kohm
...:
...:
...: #Calculations
...:
...: Id=E/R #Eq.(2.2)
...: Vd=E
...: print "The current Ic is= %fmA "%(Id),";Vd=0V"
...: print "The diode voltage is= %fV"%(Vd),";Id=0A"
...: print "The resulting load line appears in Fig. 2.4. The intersection between the load line and the characteristic curve defines the Q-point as"
...: print "The level of VD is certainly an estimate, and the accuracy of ID is limited by the chosenscale. A higher degree of accuracy would require a plot that would be much large and perhaps unwieldy"
...:
...:
...: #(B)
...: print "(B)"
...: Ir=9.25 #Ir in mA
...: Vdq=0.78 #Vdq in v
...: Vr=Ir*R
...: print "Vr = Ir*R = Idq*R %d="%(Vr),"or"
...: Vr = E-Vdq
...: print "Vr = E-Vdq = %f" %(Vr)
...: print "The difference in results is due to the accuracy with which the graph can be read. Ideally,the results obtained either way should be the same."
...:
...: #Graph solution to example 2.1
...:
...: import numpy as np
...: import matplotlib.pyplot as plt
...:
...: Vd = np.linspace(0.0,10.0)
...: Id = np.linspace(0.0,10.0)
...: Id= -Vd + 10
...: plt.plot(Vd, Id)
...: Vd = [0,0,0.1,0.1,0.2,0.2,0.3,0.3,0.3,0.3,0.4,0.5,0.6,0.7]
...: Id = [0,0,0,0,0,0,0,0,0.1,0.1,0.3,0.7,2.0,10.0]
...:
...: plt.plot(Vd, Id,'yo-')
...:
...: plt.xlabel('Voltage (v)')
...: plt.ylabel('current (mA)')
...: plt.title('About as simple as it gets, folks')
...: plt.grid(True)
...: plt.savefig("test.png")
...:
...: plt.show()
...:
...: print "example 2.2:"
...: print "repeat the example 2.1 for R =2"
...:
The current Ic is= 10.000000mA ;Vd=0V
The diode voltage is= 10.000000V ;Id=0A
The resulting load line appears in Fig. 2.4. The intersection between the load line and the characteristic curve defines the Q-point as
The level of VD is certainly an estimate, and the accuracy of ID is limited by the chosenscale. A higher degree of accuracy would require a plot that would be much large and perhaps unwieldy
(B)
Vr = Ir*R = Idq*R 9= or
Vr = E-Vdq = 9.220000
The difference in results is due to the accuracy with which the graph can be read. Ideally,the results obtained either way should be the same.
example 2.2:
repeat the example 2.1 for R =2
In [2]: