#Gain Impedence and ac load
import math
#Variable declaration
ib=10.0 #in uA
ic=1.0 #in mA
ic=ic*10**3 #in uA
vi=0.02 #in Volt
RC=5.0 #in kohm
RL=10.0 #in kohm
#Calculations
#Part (i)
Ai=-ic/ib #unitless
Beta=Ai #unitless
#Part (ii)
Rie=vi/(ib*10**-6) #in Ohm
#Part (iii)
Rac=RC*RL/(RC+RL) #in kohm
#Part (iv)
Av=-Rac*10**3*Beta/Rie #unitless
#Part (v)
PowerGain=Av*Ai #unitless
#Result
print("(i)\tCurrent gain : %.2f"%Ai)
print("(ii)\tInput impedence in kohm :%.0f"%(Rie*10**-3))
print("(iii)\tAC load in kohm : %.1f"%Rac)
print("(iv)\tVoltage gain :%.3f"%Av)
print("(v)\tPower Gain is : %.3f"%PowerGain)
#Note : Ans of Av and Power gain is wrong in the book.
#Gain input and output impedence
import math
#Varible declaration
RL=10.0 #in kohm
RS=1.0 #in kohm
hie=1.1 #in kOhm
hre=2.5*10**-4 #unitless
hfe=50.0 #unitless
hoe=25.0 #in u mho
#Calculations
Aie=-hfe/(1+hoe*10**-6*RL*10**3)#unitless
Zie=hie+hre*Aie*RL #in kOhm
Zie=math.ceil(Zie)
Ave=Aie*RL/Zie #unitless
Avs_e=Ave*Zie/(Zie+RS)
deltah=hoe*10**-6*hie*10**3-hfe*hre
Zoe=(hie*10**3+RS*10**3)/(hoe*10**-6*RS*10**3+deltah)
Ais_e=Aie*RS/(Zie+RS)
Ape=Ave*Aie
Aps_e=Avs_e*Ais_e
#Result
print("Current gain :%.0f "%Aie)
print("\nCurrent gain with source resistance : %.0f"%Ais_e)
print("\nVoltage gain : %.0f"%Ave)
print("\nVoltage gain with source resistance : %.0f"%Avs_e)
print("\nPower gain :%.0f "%Ape)
print("\nPower gain with source resistance :%.0f "%Aps_e)
print("\nInput impedence in kohm :%.1f"%Zie)
print("\nOutput impedence in kohm :%.1f"%(Zoe/10**3))
#Input Output impedence and output voltage
import math
#Variable declaration
InputVoltage=1.0 #in mV
RL=5.6 #in kohm
RS=600.0 #in ohm
hre=6.5*10**-4 #unitless
hie=1.7 #in kOhm
hfe=125.0 #unitless
hoe=80.0 #in uA/V
#Calculations
deltah=hoe*10**-6*hie*10**3-hfe*hre
Zie=(hie*10**3+RL*10**3*deltah)/(1+hoe*10**-6*RL*10**3)
Zoe=(hie*10**3+RS)/(hoe*10**-6*RS+deltah)
Ave=-(hfe*RL*10**3)/(hie*10**3+RL*10**3*deltah)
Avs_e=Ave*Zie/(Zie+RS)
OutputVoltage=Avs_e*InputVoltage
#Result
print("Input impedence in kohm :%.3f"%(Zie/1000))
print("Output impedence in kohm :%.3f"%(Zoe/10**3))
print("Voltage gain : %.3f"%Ave)
print("Voltage gain with source resistance : %.3f"%Avs_e)
print("Output Voltage in mV :%.3f "%OutputVoltage)
#Note : Answers are wrong in the book.
#Net voltage gain in dB
import math
#variable declaration
A1=100.0 #unitless
A2=200.0 #unitless
A3=400.0 #unitless
#calculations
A1=20*math.log10(A1) #in dB
A2=20*math.log10(A2) #in dB
A3=20*math.log10(A3) #in dB
NetVoltageGain=A1+A2+A3 #in dB
#Result
print("Net Voltage Gain in decibels :%.3f"%NetVoltageGain)
#Note : Answer in the book is wrong.
#Bandwidth and cut off frequencies
import math
#Variable declaration
MaxGain=1000.0 #unitless(at 2kHz)
f1=50.0 #in Hz
f2=10.0 #in KHz
#Result
print("Bandwidth is from %.0f Hz to %.0f kHz"%(f1,f2))
print("Lower cutoff frequency %.0f Hz"%f1)
print("Upper cutoff frequency %.0f kHz"%f2)
#Overall voltage gain
import math
#Variable declaration
RC=10.0 #in kohm
hfe=330.0 #unitless
hie=4.5 #in kOhm
#Calculation
#RS<<hie
AVM=hfe*RC*10**3/(hie*10**3+RC*10**3)
AVM1=AVM #Gain of 1st stage
AVM2=AVM #Gain of 2nd stage
AVM3=hfe*RC*10**3/(hie*10**3) #unitless(//Gain of 3rd stage)
OverallGain=AVM1*AVM2*AVM3 #unitless
#Result
print("Gain in mid frequeny range : %.1f"%AVM)
print("This is the gain of 1st and 2nd stage.")
print("Overall Voltage gain for mid frequency range : %.1f * 10^7"%(OverallGain/10**7))
#Couopling capacitor
import math
#variable declaration
RC=5.5 #in kohm
hfe=330.0 #unitless
hie=4.5 #in kohm
f1=30.0 #in Hz
#Calculation
#Formula : f1=1/(2*%pi*C*(hie+RC))
C=1/(2*math.pi*f1*(hie*10**3+RC*10**3))
#Result
print("Value of coupling capacitor in micro farad : %.2f"%(C*10**6))
#Voltage gain
import math
#Variable declaration
RC=10.0 #in kohm
Rin=1.0 #in kohm
Beta=100.0 #unitless
RL=100.0 #in ohm
#Calculation
RCdash=RC*10**3*RL/(RC*10**3+RL)
VoltageGain=Beta*RCdash/(Rin*10**3)
#Result
print("Voltage Gain :%.2f "%VoltageGain)
#Inductance of primary and secondary
import math
#variable declaration
Rout=10.0 #in kohm
Rin=2.5 #in kohm
f=200.0 #in Hz
#Calculations
#Formula : Rout=omega*Lp=2*%pi*f*Lp
Lp=Rout*10**3/(2*math.pi*f) #in H
#Formula : Rin=omega*Ls=2*%pi*f*Ls
Ls=Rin*10**3/(2*math.pi*f) #in H
#Result
print("Inductance of primary in Henry : %.0f"%Lp)
print("Inductance of seondary in Henry : %.0f"%Ls)
#Turn ratio of transformer
import math
#variable declaration
ZL=10.0 #in ohm
ZP=1000.0 #in ohm
#For max power : ZP=n^2*ZL
n=math.sqrt(ZP/ZL) #turn ratio
#Result
print("Turn ratio : %.0f"%n)
#Collector eficieny and power rating
import math
#Variable declaration
Po_dc=10.0 #in watt
Po_ac=3.5 #in watt
#calculation
ETAcollector=Po_ac/Po_dc #unitless
ETAcollector=ETAcollector*100 #collector efficiency in %
#Result
print("Collector Efficiency : %.0f%%"%ETAcollector)
print("\nZero signal condition represents maximum power loss.")
print("Therefore, all the 10 W power is dissipated by it. Hence Powe Rating of transistor in Watt : %.0f"%Po_dc)
#Power and eficiency
import math
#variable declaration
VCC=20.0 #in volt
RC=20.0 #in ohm
VCEQ=10.0 #in volt
ICQ=500.0 #in mA
#calculations
#part (i) :
Pin_dc=VCC*ICQ*10**-3 #in watt
#part (ii) :
PRc_dc=ICQ**2*10**-6*RC #in watt
#part (iii) :
Io=250 #in mA(maximum value of output ac current)
Irms=Io/math.sqrt(2) #in mA
Po_ac=Irms**2*10**-6*RC #in watt
#part (iv) :
Ptr_dc=Pin_dc-PRc_dc #in watt
#part (v) :
PC_dc=Pin_dc-PRc_dc-Po_ac #in watt
#part (vi) :
ETAoverall=Po_ac*100/Pin_dc #Overall Efficiency (in %)
#part (vii) :
ETAcollector=Po_ac*100/PRc_dc#Collector Efficiency (in %)
#Result
print("(i)\nTotal dc power taken by the circuit in Watt : %.0f"%Pin_dc)
print("\n(ii)\ndc power dissipated by the collector load in Watt : %.0f"%PRc_dc)
print("\n(iii)\nPower developed across the load in Watt :%.3f "%Po_ac)
print("\n((iv)\ndc power dissipated by the collector load in Watt :%.0f "%Ptr_dc)
print("\n(v)\ndc power dissipated by the collector load in Watt : %.3f"%PC_dc)
print("\n(vi)\nOverall Efficiency :%.3f%%"%ETAoverall)
print("\n(vii)\nCollector Efficiency :%.2f%%"%ETAcollector)
#Maximum ac power output
import math
#variable declaration
n=10.0 #turn ratio
RL=100.0 #in ohm
ICQ=100.0 #in mA
#calculations
RLdash=n**2*RL
MaxPowerOut=(ICQ*10**-3)**2*RLdash/2
#result
print("Maximum Power output in watt : %.0f"%MaxPowerOut)
#Maximum permissible power dissipation
import math
#Part (i) : without heat sink
#variable declaration
ThetaMax=90.0 #in degree C
Theta_o=30.0 #in degree C
R=300.0 #in degree C/W
#calculation
Pr=(ThetaMax-Theta_o)/R #in watt
#Result
print("Without heat sink, Maximum permissible power dissipatio in watt :%.1f"%Pr)
#Part (ii) : with heat sink
#variable declaration
ThetaMax=90.0 #in degree C
Theta_o=30.0 #in degree C
R=60.0 #in degree C/W
#calculation
Pr=(ThetaMax-Theta_o)/R #in watt
#Result
print("With heat sink, Maximum permissible power dissipatio in watt :%.0f"%Pr)