#Variable declaration
ND=2*10**21#ND=donor concentration in m**-3 of an n-channel silicon JFET
e=1.6*10**-19#e=charge of an electron
E=12*8.854*10**-12#E=permittivity of the material where 12=dielectric constant of silicon(given)
a=(4*10**-6)/2#2*a=channel width in metres and 2*a=4*10**-6
#Calculations&Results
Vp=(e*ND*(a**2))/(2*E)
print "The pinch-off voltage is = %.2f V"%Vp
VGS=-2#VGS=gate source voltage
#Vp=VDsat-VGS where VDsat=saturation voltage
VDsat=Vp+VGS
print "The saturation voltage is = %.2f V"%VDsat
#Variable declaration
VGS=-1.5#VGS=gate-to-source voltage of a JFET
IDsat=5*10**-3#IDsat=drain saturation current in Ampere
#Calculations
RS=(abs(VGS))/(abs(IDsat))#RS=resistance to be calculated=|VGS| / |IDsat|
#Result
print "Resistance to be calculated is = %.f ohm"%RS
#Variable declaration
VGS1=-1
VGS2=-1.5#VGS1,VGS2=change in VGS(gate-to-source voltage) from VGS1 to VGS2 keeping VDS(drain-to-source voltage) constant
ID1=7.*10**-3
ID2=5*10**-3#ID1,ID2=change in ID(drain current) in Ampere from ID1 to ID2
#Calculations&Results
#gm=(id/vgs)|VDS=constant where gm=transconductance
id=ID1-ID2
vgs=VGS1-VGS2
gm=id/vgs
print "The transconductance of the FET is = %.f mA/V"%(gm*10**3)
rd=200*10**3#rd=ac drain resistance in ohms
u=rd*gm#u=amplification factor
print "The amplification factor of the FET is = %.f"%u
#Variable declaration
RL=250*10**3#RL=load resistance in ohms in a FET amplifier
rd=100*10**3#rd=ac drain resistance in ohms
gm=0.5*10**-3#gm=transconductance in A/V
#Calculations&Results
u=rd*gm#u=amplification factor
AV=-(u*RL)/(rd+RL)#AV=voltage gain
print "The voltage gain of FET amplifier is = %.2f"%AV
print "The output resistance excluding RL is rd=%.f kohm"%(rd/1000)
ro=(rd*RL)/(rd+RL)#ro=output resistance including RL
print "Including RL,the output resistance is=%.f k ohms"%(ro/1000)
#Variable declaration
#For n-channel JFET
IDSS=12*10**-3#IDSS=saturation drain current in Ampere when VGS(gate-to-source voltage)=0V
Vp=-4#Vp=pinch-off voltage
VGS=-2#VGS=gate-to-source voltage
#Calculations&Results
#By Shockley's equation
IDS=IDSS*(1-(VGS/Vp))**2#IDS=saturation drain current to be calculated for given value of VGS
print "The drain current for given value of VGS is=%.f mA"%(IDS/10**-3)
gmo=4*10**-3#gmo=transconductance in A/V of a JFET when VGS=0V
#gmo=-(2*IDSS)/Vp
Vp=-(2*IDSS)/gmo#Vp=pinch-off voltage to be calculated for given value of transconductance
print "The pinch-off voltage for given value of gmo is = %.f V"%Vp
import math
#Variable declaration
IDSS=12*10**-3#IDSS=saturation drain current in Ampere when VGS(gate-to-source voltage)=0V
Vp=-4#Vp=pinch-off voltage
VDD=30#VDD=drain supply voltage
RL=5*10**3#RL=load resistance in ohms
Rs=600#Rs=resistance connected to source terminal in ohms
Rg=1.5*10**6#Rg=resistance connected to gate terminal in ohms
#Calculations&Results
#By Shockley's equation
#IDS=IDSS*(1-(VGS/Vp))**2 where IDS=saturation drain current to be calculated for given value of VGS
#Substituting VGS=(-ID*Rs) we get ID=IDS
#ID=IDSS*(1+((ID*Rs)/Vp))**2
#ID=12*(1+((0.6*ID)/-4))**2 where ID is obtained in mA
#(0.27*ID**2)-(4.6*ID)+12=0.........(1)
ID1=(4.6+math.sqrt((4.6**2)-(48*0.27)))/(2*0.27)
ID2=(4.6-math.sqrt((4.6**2)-(48*0.27)))/(2*0.27)#ID1,ID2 are the 2 roots of the above equation (1)
print "ID1=%.2f mA"%ID1
print "ID2=%.2f mA"%ID2
if (ID1>(IDSS/10**-3)):#IDSS is converted in terms of mA
print "As ID1>IDSS ,the value rejected is ID1=%.2f mA"%ID1
if (ID2>(IDSS/10**-3)):#IDSS is converted in terms of mA
print "As ID2>IDSS ,the value rejected is ID2=%.2f mA"%ID2
print "Therefore,the drain current is = %.2f mA"%ID2
ID=ID2*10**-3#converting ID2 in terms of Ampere
VDS=VDD-ID*(RL+Rs)#VDS=drain-to-source voltage
print "The value of drain-to-source voltage VDS is = %.f V"%VDS
VGS=-ID*Rs#VGS=gate-to-source voltage
print "The value of gate-to-source voltage VGS is=%.2f V"%VGS
if(Vp<0 and VDS>(VGS-Vp)):
print "As Vp=(-4)<VGS<0V and VDS=12V>(VGS-Vp),it is verified that the JFET is in the saturation region of the drain characteristics"
import math
#Variable declaration
IDSS=10*10**-3#IDSS=saturation drain current in Ampere when VGS(gate-to-source voltage)=0V
Vp=-2#Vp=pinch-off voltage
VDD=20#VDD=drain supply voltage
RL=1*10**3#RL=load resistance in ohms
Rs=2*1000#Rs=resistance connected to source terminal in ohms
R1=12*10**6#R1=resistance in the voltage divider network in ohms
R2=8*10**6#R2=resistance in the voltage divider network in ohms
#Calculations&Results
VT=(R2/(R1+R2))*VDD#VT=Thevenin voltage
#VGS=VT-(ID*Rs)
#By Shockley's equation
#IDS=IDSS*(1-(VGS/Vp))**2 where IDS=saturation drain current to be calculated for given value of VGS
#Substituting VGS=(VGS-ID*Rs) we get ID=IDS
#(10*ID**2)-(101*ID)+250=0.........(1)where ID is obtained in mA
ID1=(101+math.sqrt((101**2)-(40*250)))/(2*10)
ID2=(101-math.sqrt((101**2)-(40*250)))/(2*10)#ID1,ID2 are the 2 roots of the above equation (1)
print "ID1=%.2f mA"%ID1
print "ID2=%.2f mA"%ID2
#For ID1
VGS=VT-(ID1*Rs)#VGS=gate-to-source voltage calculated for ID1
if (Vp>VGS):
print "As Vp>(VGS calculated using ID1), the value rejected is ID1=%.2f mA"%ID1
print "Therefore,the drain current is = %.2f mA"%ID2
ID=ID2*10**-3#converting ID2 in terms of Amperes
VGS=VT-(ID*Rs)#VGS=gate-to-source voltage
print "VGS=%.2f V"%VGS
VDS=VDD-(ID*(RL+Rs))#VDS=drain-to-source voltage
print "VDS=%.f V"%VDS
if(Vp<VGS and VDS>(VGS-Vp)):
print "As Vp=(-2)<(VGS=-0.68V) and VDS=7V>(VGS-Vp),it is checked that the JFET operates in the saturation region "
#Variable declaration
#For a n-channel JFET
IDSS=10*10**-3#IDSS=saturation drain current in Ampere when VGS(gate-to-source voltage)=0V
Vp=(-4)#Vp=pinch-off voltage
VGS=(-2.5)#VGS=gate-to-source voltage
#Calculations&Results
#By Shockley's equation
IDS=IDSS*(1-(VGS/Vp))**2#IDS=saturation drain current to be calculated for given value of VGS
print "The drain current for given value of VGS is=%.1f mA"%(IDS/10**-3)#converting IDS in terms of mA
VDSmin=VGS-Vp#VDSmin=minimum value of drain-to-source voltage for the onset of the saturation region
print "The minimum value of VDS for saturation is=%.1f V"%VDSmin
import math
#Variable declaration
VDD=20#VDD=drain supply voltage
IDS=0.9#IDS=drain saturation current in terms of mA
Vp=-3.#Vp=pinch-off voltage
IDSS=8#IDSS=saturation drain current in mA when VGS(gate-to-source voltage)=0V
#Calculations&Results
#By Shockley's equation
#IDS=IDSS*(1-(VGS/Vp))^2
VGS=Vp*(1-math.sqrt(IDS/IDSS))#VGS=gate-to-source voltage
print "The gate-to-source voltage VGS is=%.f V"%VGS
#gm=(dIDS/dVGS)|VDS=constant where gm=transconductance
gm=-((2*IDSS)/Vp)*(1-(VGS/Vp))
print "The value of transconductance is=%.2f mS"%gm
import math
#Variable declaration
IDS=-15.#IDS=drain saturation current in terms of mA
Vp=5#Vp=pinch-off voltage
IDSS=-40#IDSS=saturation drain current in mA when VGS(gate-to-source voltage)=0V
#Calculations
#By Shockley's equation
#IDS=IDSS*(1-(VGS/Vp))^2
VGS=Vp*(1-math.sqrt(IDS/IDSS))#VGS=gate-to-source voltage
#Result
print "The gate-to-source voltage VGS is=%.2f V"%VGS
import math
#Variable declaration
IDSS=10*10**-3#IDSS=saturation drain current in Ampere when VGS(gate-to-source voltage)=0V
Vp=-5.#Vp=pinch-off voltage
VDD=24.#VDD=drain supply voltage
VDS=8#VDS=drain-to-source voltage
ID=4.*10**-3#ID=drain current in Ampere
R1=2.*10**6#R1=resistance in the voltage divider network in ohms
R2=1*10**6#R2=resistance in the voltage divider network in ohms
#Calculations&Results
VT=(R2/(R1+R2))*VDD#VT=Thevenin voltage
#By Shockley's equation
#ID=IDS=IDSS*(1-(VGS/Vp))**2
VGS=Vp*(1-math.sqrt(ID/IDSS))#VGS=gate-to-source voltage
#VGS=VT-(ID*Rs) where Rs=resistance connected at the source terminal
Rs=(VT-VGS)/ID
print "The value of Rs = %.2f k ohm"%(Rs/10**3)#converting Rs in terms of kilo-ohm
Rch=VDS/ID#Rch=channel resistance at the Q-point
print "The channel resistance at the Q-point is=%.f k ohm"%(Rch/10**3)#converting Rch in terms of kilo-ohm
#Variable declaration
ID=5#ID=saturation drain current in terms of mA in an n-channel enhancement mode MOSFET
VGS=8.#VGS=gate-to-source voltage
VT=4#VT=Threshold voltage
VGS2=10#VGS2=gate-to-source voltage for which saturation drain current is to be calculated
#Calculations&Results
#ID=K*(VGS-VT)**2 where K=(IDSS/(Vp**2)) and Vp=pinch-off voltage ,IDSS=drain saturation current for VGS=0 V
K=ID/((VGS-VT)**2)
ID1=K*(VGS2-VT)**2#ID1=The saturation drain current for gate-source voltage of 10V i e VGS2
print "The saturation drain current for gate-source voltage of 10V is = %.1f mA"%ID1
#Variable declaration
#For n-channel enhancement mode MOSFET operating in active region
VT=2#VT=Threshold voltage
K=0.5#K=(IDSS/(Vp**2)) in terms of mA/V**2
VDD=15#VDD=drain supply voltage
RL=1#RL=load resistance in kilo ohm
R1=200*10**3#R1=resistance in the voltage divider network in terms of ohms
R2=100.*10**3#R2=resistance in the voltage divider network in terms of ohms
#Calculations&Results
VGS=(R2/(R1+R2))*VDD#VGS=gate-to-source voltage
print "Threshold voltage is = %.f V"%VT
print "The gate-to-source voltage VGS is = %.f V"%VGS
ID=K*(VGS-VT)**2#ID=drain current in mA
print "The value of drain current ID is = %.1f mA"%ID
VDS=VDD-(ID*RL)#VDS=drain-to-source voltage
print "The value of drain-to-source voltage VDS is=%.1f V"%VDS
if (VDS>(VGS-VT)):
print "As VDS>(VGS-VT),(i.e. 10.5>(5-2)),the operation is indeed in the active region "
#Variable declaration
#For n-channel MOSFET operating in the depletion mode
VDD=18#VDD=drain supply voltage
VGS=0#VGS=gate-to-source voltage
RL=600#RL=load resistance in ohms
IDSS=18.#IDSS=drain saturation current in mA for gate-to-source voltage (VGS)=0V
Vp=-5#Vp=pinch-off voltage
#Calculations&Results
#Assuming that the operation is in the active region
#ID=IDS=IDSS*(1-(VGS/Vp))**2
#ID=(IDSS/Vp**2)(VGS-Vp)**2
K=IDSS/(Vp**2)
print "The value of K is = %.2f mA/V^2"%K
ID=IDSS#ID=drain current
print "Since VGS=0,the value of ID=IDSS is=%.f mA"%ID
VDS=VDD-(ID*(RL/10**3))#VDS=drain-to-source voltage and also converting RL in terms of kilo ohm
print "The value of VDS is = %.f V"%VDS
print "Pinch off voltage Vp is = %.f V"%Vp
print "Gate to source voltage VGS is = %.f V"%VGS
if (VDS>(VGS-Vp)):
print "As VDS>(VGS-Vp),(i.e.7.5>(0-(-5))),the MOSFET is actually in the active region "
import math
#Variable declaration
#r given in textbook is taken as rd afterwards.Hence r=rd
rd=100*10**3#rd=drain resistance in ohms
gm=3500*10**-6#gm=transconductance in terms of A/V (or S)
RL=5*10**3#RL=load resistance in ohms
#Calculations&Results
u=rd*gm#u=amplification factor
AV=(u*RL)/(((u+1)*RL)+rd)#AV=voltage gain
print "The voltage gain is=%.3f"%AV
Ro=rd/(u+1)#Ro=output resistance excluding RL
print "The output resistance excluding RL is = %.f ohm"%Ro
Ro1=(rd*RL)/(rd+((u+1)*RL))#Ro1=Ro'=output resistance including RL
print "The output resistance including RL is=%.f ohm"%(math.floor(Ro1))
#Variable declaration
#In a FET used in a CS amplifier
IDSS=4.#IDSS=drain saturation current in mA for gate-to-source voltage (VGS)=0V
Vp=-3#Vp=pinch-off voltage
RL=10#RL=load resistance in kilo ohms
VGS=-0.7#VGS=gate-to-source voltage
#Calculations
gmo=-(2*IDSS)/Vp#gmo=transconductance in A/V of a JFET when VGS=0V
gm=gmo*(1-(VGS/Vp))#gm=transconductance
AV=-gm*RL#AV=the small signal voltage gain
#Result
print "The small signal voltage gain is = %.1f"%AV
#Decimal term in the answer displayed in textbook is incorrect as 2.04*10=20.4 and not 20.04.