#Calculate saturation voltage and saturation current
#given
Vp=-4.#V #pinch off voltage
Idss=12.*10.**-3.;#A #drain to source current with gate shorted
Vgs=-2.;#V #gate to source voltage
Vds=Vgs-Vp;
Id=Idss*(Vds/Vp)**2.;
print '%s %.f %s' %("Saturation Voltage is =",Vds,"V\n");
print '%s %.f %s' %("Saturation current is =",Id*10**3,"mA");
#Find the value of drain current
#given
Vgso=-5.;#V #gate to source cut off voltage
Idss=20.*10.**-3.;#A #drain to source current with gate shorted
#At vgs = -2 V
vgs=-2.;#V input voltage
Id=Idss*(1.-(vgs/Vgso))**2.; #Schockleys equation
print '%s %.1f %s' %("Drain current is (At vgs = -2 V) =",Id*10**3,"mA\n");
#At vgs = -4 V
vgs=-4.;#V input voltage
Id=Idss*(1.-(vgs/Vgso))**2.; #Schockleys equation
print '%s %.1f %s' %("Drain current is (At vgs = -4 V) =",Id*10**3,"mA\n");
#At vgs = -8 V
print '%s' %("Drain current is 0 A (At vgs = -8 V) because gate is biased beyond cut off ");
#Calculate Vgs and Vds saturation
#given
import math
Vp=5.#V #pinch off voltage
Idss=-15.*10.**-3.;#A #drain to source current with gate shorted
Id=-3.*10.**-3.;#A #saturation current
Vgs=Vp*(1.-math.sqrt(Id/Idss));
Vds=Vgs-Vp;
print '%s %.3f %s' %("The gate to source voltage (Vgs) is =",Vgs,"V\n");
print '%s %.3f %s' %("The saturation voltage is Vds(sat) =",Vds,"V");
print '\nThe value of Vgs = 2.115V and Vds= -2.885V in book because of the calculation error'
#Calculate drain current Id for N channel
#given
Vp=5.#V #pinch off voltage
Idss=18.*10.**-3.;#A #drain to source current with gate shorted
#For Vgs= - 3 V
Vgs=-3.;#V
Id=Idss*(1.-(Vgs/(-Vp)))**2.;
print '%s %.2f %s' %("The drain current Id(For Vgs= -3V) =",Id*10**3,"mA\n");
#For Vgs= 2.5 V
Vgs=2.5;#V
Id=Idss*(1.-(Vgs/(-Vp)))**2.;
print '%s %.1f %s' %("The drain current Id(For Vgs= 2.5V) =",Id*10**3,"mA");
#Calculate drain current Id for P channel
#given
Vp=-5.#V #pinch off voltage
Idss=18.*10.**-3.;#A #drain to source current with gate shorted
#For Vgs= -3V
Vgs=-3.;#V
Id=Idss*(1.-(Vgs/(-Vp)))**2.;
print '%s %.2f %s' %("The drain current Id (For Vgs= -3V) =",Id*10**3,"mA\n");
#For Vgs= 2.5V
Vgs=2.5;#V
Id=Idss*(1.-(Vgs/(-Vp)))**2.;
print '%s %.1f %s' %("The drain current Id (For Vgs= 2.5V) =",Id*10**3,"mA");
#Find the value of drain current
#given
Vt=2.;#V #threshold voltage
K=0.25*10.**-3.;# A/V**2 #conductivity parameter
Vgs=3.;#V #gate supply
Vds=2.;#V #saturation voltage
Vdsm=Vgs-Vt; #minimum voltage required to pinch off
# Vds > Vdsm therefore the device is in saturation region
Id=K*(Vgs-Vt)**2.;
print '%s %.2f %s' %("The drain current is =",Id*1000,"mA");
#Find the value of Id
#given
Vt=1.5;#V #threshold voltage
Id=2.*10.**-3.;#A
Vgs=3.;#V #gate supply
Vds=5.;#V #saturation voltage
Vdsm=Vgs-Vt; #minimum voltage required to pinch off
# Vds > Vdsm therefore the device is in saturation region
# Calculating K
K=Id/((Vgs-Vt)**2.); # A/V**2 #conductivity parameter
#Calculating Id for Vgs= 5 V and Vds= 6 V
Vgs=5;#V #gate supply
Vds=6;#V #saturation voltage
Id=K*((Vgs-Vt)**2);
print '%s %.2f %s' %("The drain current is =",Id*1000,"mA");
#Calculate the dynamic drain resistance
#given
gm=200.*10.**-6.;#S transconductance
u=80.;#amplification factor
rd=u/gm;
print '%s %.f %s' %("The dynamic drain resistance is =",rd/1000,"k ohm");