#Question:
"""Finding the power factor and the average power dissipated."""
from math import sqrt,pi,cos,degrees
from cmath import rect,phase
#Variable Declaration:
Vm=141.0 #Peak value of supply voltage(in Volts)
ang_freq=100.0*pi #Angular frequency(in radians per second)
R=3.0 #Resistance(in Ohms)
L=0.0127 #Self-inductance of the coil(in Henry)
#Calcultaions:
Vrms=Vm/sqrt(2.0)
V=rect(Vrms,0.0)
X_L=ang_freq*L
Z=R+ (X_L*1j)
I=V/Z
ang_I=degrees(phase(I))
P=Vrms*abs(I)*cos(phase(I))
pf=cos(phase(I))
#Result:
print "(a)The rms value of the steady-state current is %.2f A and the relative phase angle is %.2f degrees." %(abs(I),-ang_I)
print "(b)The expression for the instantaneous current is i=%.3f sin(100*pi*t%.2f degrees) A." %((sqrt(2)*abs(I)),ang_I)
print "(c)The average power dissipated in the circuit is %.2f W." %(P)
print "(d)The power factor is %.3f lagging." %(pf)
#Question:
"""Finding the capacitance required,the phase angle,the power factor,the apparent power,and the reactive power."""
from math import sqrt,pi,degrees,acos,cos,sin
#Variable Declaration:
V=230.0 #Rms value of supply voltage(in Volts)
f=50.0 #Frequency of supply(in Hertz)
P_lamp=750.0 #Power rating of the lamp(in Watts)
V_lamp=100.0 #Voltage rating of the lamp(in Volts)
#Calculations:
I_rated=P_lamp/V_lamp
Vc=sqrt((V*V)-(V_lamp*V_lamp))
Xc=Vc/I_rated
C=1/(2*pi*f*Xc)
phase_angle=acos(V_lamp/V)
pf=cos(phase_angle)
app_P=V*I_rated
rea_P=V*I_rated*sin(phase_angle)
#Result:
print "(a)The required capacitance is %e F." %(C)
print "(b)The phase angle is %.3f degrees." %(degrees(phase_angle))
print "(c)The power factor is %.3f leading." %(pf)
print "(d)The apparent power is %.3f VA." %(app_P)
print "(e)The reactive power is %.3f VAr." %(rea_P)
#Question:
"""Finding the impedance,the power factor,supply voltage,voltage across resistor,apparent power and reactive power."""
from cmath import rect,phase
from math import pi,cos,sin,degrees
#Variable Declaration:
I=rect(0.9,0) #Current in the circuit(in Amperes)
R=120.0 #Resistance of the resistor(in Ohms)
Xc=250.0 #Reactance of the capacitor(in Ohms)
#Calculations:
Z=R- Xc*1j
pf=cos(phase(Z))
V=I*Z
V_R=I*R
V_C=I*Xc
act_P=abs(V)*abs(I)*cos(phase(Z))
app_P=abs(V)*abs(I)
rea_P=abs(V)*abs(I)*sin(phase(Z))
#Result:
print "The impedance is %.3f ohm at a phase angle of %.3f degrees." %(abs(Z),degrees(phase(Z)))
print "The power factor is %.3f leading." %(pf)
print "The supply voltage is %.3f V at a phase angle of %.3f degrees." %(abs(V),degrees(phase(V)))
print "The voltage across resistor is %.3f V at a phase angle of %.3f degrees." %(abs(V_R),degrees(phase(V_R)))
print "The voltage across capacitor is %.3f V at a phase angle of %.3f degrees." %(abs(V_C),-90)
print "The apparent power is %.3f VA." %(app_P)
print "The active power is %.3f W." %(act_P)
print "The reactive power is %.3f VAr." %(rea_P)
print "Note: Negative sign indicates the capacitor supplies reactive power."
#Question:
"""Finding the impedance of the circuit and state whether it is inductive or capacitive."""
from cmath import phase,rect
from math import pi,degrees,radians,cos,sin
#Variable Declaration:
V=160.0 +120.0*1j #ac sinusoidal voltage(in Volts)
I=-4.0+10.0*1j #Current in circuit(in Amperes)
#Calculations:
Z=V/I
if Z.imag>0:
print("The nature of circuit is inductive\n")
pf_type="lagging"
elif Z.imag<0:
print("The nature of circuit is capacitive\n")
pf_type="leading"
else:
print("The nature of circuit is resistive\n")
pf=cos(phase(Z))
act_P=abs(V)*abs(I)*pf
rea_P=abs(V)*abs(I)*sin(pi+phase(Z))
#Result:
print "The power factor is %.3f %s." %(pf,pf_type)
print "The active power is %.2f W." %(act_P)
print "The reactive power is %.2f VAr." %(rea_P)
#Question:
"""Finding the values of the two circuit elements."""
from math import pi
#Variable Declaration:
f=50 #Frequency of the source(in Hertz)
Z=10+10*1j #Impedance of the circuit(in Ohm)
#Calculations:
ang_freq=2*pi*f
R=Z.real
X_L=Z.imag
L=X_L/ang_freq
#Result:
print "The nature of the impedance indicates that the circiut is inductive.\n"
print "The values of the two elements are: \n(a)Resistance(R)=%.2f ohm \n(b)Inductance(C)=%e H." %(R,L)
#Question:
"""Finding the values of the two circuit elements."""
from math import pi
#Variable Declaration:
f=50.0 #Frequency of the source(in Hertz)
Z=10.0-10.0*1j #Impedance of the circuit(in Ohm)
#Calculations:
ang_freq=2.0*pi*f
Y=1.0/Z
R=1/Y.real
C=Y.imag/ang_freq
#Result:
print "The nature of the impedance indicates that the circiut is capacitive.\n"
print "The values of the two elements are: \n(a)Resistance(R)=%.2f ohm \n(b)Capacitance(C)=%e F." %(R,C)
#Question:
"""Finding the impedance,the current,the phase angle,the voltage across each element and power factor."""
from cmath import rect,phase
from math import cos,pi,degrees
#Variable Declaration:
R=12.0 #Resistance of the resistor(in Ohms)
L=0.15 #Self-inductance of the inductor(in Henry)
C=100e-06 #Capacitance of the capacitor(in Farad)
f=50 #Frequency of the source(in Hertz)
V=rect(100,0) #Supply voltage(in Volts)
#Calculations:
ang_freq=2*pi*f
X_L=ang_freq*L
X_C=1/(ang_freq*C)
Z=R + (X_L-X_C)*1j
if Z.imag>0:
pf_type="lagging"
elif Z.imag<0:
pf_type="leading"
else:
print("The nature of circuit is resistive\n")
I=V/Z
V_R=abs(I)*R
V_C=abs(I)*X_C
V_L=abs(I)*X_L
pf=cos(phase(I))
app_P=abs(V)*abs(I)
avg_P=abs(V)*abs(I)*pf
#Result:
print "(a)The impedance is %.3f ohm at a phase angle of %.3f degrees." %(abs(Z),degrees(phase(Z)))
print "(b)The current is %.3f A at a phase angle of %.3f degrees." %(abs(I),degrees(phase(I)))
print "(c)The phase angle is %.3f degrees." %(degrees(phase(I)))
print "(d)The voltage across the resistor is %.2f V." %(V_R)
print " The voltage across the capacitor is %.2f V.\n The voltage across the inductor is %.2f V." %(V_C,V_L)
print "(e)The power factor is %.3f %s." %(pf,pf_type)
print "(f)The apparent power is %.3f VA." %(app_P)
print "(g)The average power is %.3f W." %(avg_P)
#Question:
"""Finding the voltage across the capacitor by applying Thevenin's theorem."""
from math import sqrt,degrees
from cmath import rect,phase
#Variable Declaration:
""" Note: All the impedances are expresssed in kilo ohm."""
ang_freq=3000.0 #Angular frequency(in radians per second)
Vs_m=40.0 #Peak value of the supply voltage(in Volts)
#Calculations:
Vs_rms=Vs_m/sqrt(2.0)
Vs=rect(Vs_rms,0)
Zeq=1.5 + ((1.0-(2.0*1j))/(1j+1.0-2.0*1j))*1.0j
I=Vs/Zeq
Im=abs(I)*sqrt(2)
V_Th=Vs*(1j/(1.5+1j))
Z_Th=1+ ((1.5*1j)/(1.5+1j))
Vc=V_Th*((-2*1j)/(Z_Th-2*1j))
Z_L=Z_Th.real-Z_Th.imag*1j
C=1/(ang_freq*abs(Z_L.imag)*1000)
#Result:
print "(a)The expression for i(t) can be written as i(t)=%.1f sin(%dt%.2fdegrees) mA." %(Im,ang_freq,degrees(phase(I)))
print "(b)The voltage across the capacitor by applying Thevenin's theorem is %.3f V at a phase angle of %.3f degrees." %(abs(Vc),degrees(phase(Vc)))
print "(c)The values of the two elements of the load impedance that consumes maximum power are R=%e kilo Ohms and C=%e F." %(Z_L.real,C)
#Question:
"""Finding the value of resistance for a desired power factor."""
from math import sqrt
from cmath import atan
#Variable Declaration:
pf=0.8 #Power factor of the circuit
X_C=60.0 #Capacitive reactance(in Ohms)
#Calculations:
sin_ang=sqrt(1-(pf*pf))
tan_ang=sin_ang/pf
R=X_C/tan_ang
#Result:
print "The value of R for which the power factor of the circuit is 0.8 is %.2f Ohms." %(R)
#Question:
"""Finding the resistance and the inductance of the coil."""
from math import sqrt,pi
#Variable Declaration:
Vdc=20.0 #Supply dc voltage(in Volts)
Idc=4.0 #Current drawn by the coil(in Amperes)
f=50.0 #Frequency of supply voltage(in Hertz)
Vs=65.0 #Ac supply voltage(in Volts)
I=5.0 #Current drawn by the choke when connected ac supply(in Amperes)
#Calculations:
R=Vdc/Idc
Z=Vs/I
X_L=sqrt((Z*Z)-(R*R))
L=X_L/(2*pi*f)
pf=R/Z
P=Vs*I*pf
#Result:
print "(a)The resistance of the coil is %.2f Ohms and the inductance of the coil is %.5f H." %(R,L)
print "(b)The power factor is %.3f lagging." %(pf)
print "(c)The power(real) drawn by the coil is %.3f W." %(P)
#Question:
"""Finding the resistance and inductance of the coil."""
from math import pi,pow,sqrt
#Variable Declaration:
Vs=240.0 #AC supply voltage(in Volts)
f1=50.0 #Frequency of the ac supply voltage(in Hertz)
I1=60.0 #First reading of the ammeter(in Amperes)
f2=100.0 #Frequency of the ac supply voltage(in Hertz)
I2=40.0 #Second reading of the ammeter(in Amperes)
#Calculations:
Z1=Vs/I1
Z2=Vs/I2
L=sqrt(((Z2*Z2)-(Z1*Z1))/((pow((200*pi),2.0))-(pow((100*pi),2.0))))
X1=2*pi*f1*L
R=sqrt((Z1*Z1)-(X1*X1))
#Result:
print "The resistance of the coil is %.2f Ohms." %(R)
print "The inductance of the coil is %.5f H." %(L)
#Question:
"""Finding the power consumed by the choke coil."""
#Variable Declaration:
R=100.0 #Resistance of the resistor(in Ohms)
V_R=200.0 #Voltage across resistor(in Volts)
V_Ch=300.0 #Voltage across choke coil(in Volts)
Vs=440.0 #Supply voltage(in Volts)
#Calculations:
pf=((Vs*Vs)-(V_R*V_R)-(V_Ch*V_Ch))/(2*V_R*V_Ch)
I=V_R/R
P=V_Ch*I*pf
#Result:
print "The power consumed by the choke coil is %.2f W." %(P)
#Question:
"""Finding the power dissipated in each coil."""
from math import pi
from cmath import phase
#Variable Declaration:
R1=15.0 #Resistance of the first coil(in Ohms)
L1=0.2 #Inductance of the first coil(in Henry)
R2=25.0 #Resistance of the second coil(in Ohms)
L2=0.04 #Inductance of the second coil(in Henry)
V=230.0 #Supply voltage(in Volts)
f=50.0 #Frequency of supply voltage(in Hertz)
#Calculations:
X1=2*pi*f*L1
X2=2*pi*f*L2
Z1=R1+(1j*X1)
Z2=R2+(1j*X2)
Z=Z1+Z2
I=V/Z
V1=abs(I)*abs(Z1)
V2=abs(I)*abs(Z2)
P1=abs(I)*abs(I)*R1
P2=abs(I)*abs(I)*R2
pf=cos(phase(I))
#Result:
print "(a)The voltage across the first coil is %.2f V and the voltage across the second coil is %.2f V." %(V1,V2)
print "(b)The power dissipated by the first coil is %.2f W and power dissipated by the second coil is %.2f W." %(P1,P2)
print "(c)The power factor of the whole circuit is %.3f lagging." %(pf)
#Question:
"""Finding the current and power drawn from the source."""
from math import sqrt,pi
#Variable Declaration:
I_A=8.0 #Current through coil A(in Amperes)
I_B=10.0 #Current through coil B(in Amperes)
V=100.0 #Voltage of the source(in Volts)
f=50.0 #Frequency of the supply(in Hertz)
P_A=120.0 #Power delivered to coil A(in Watts)
P_B=500.0 #Power delivered to coil B(in Watts)
#Calculations:
Z_A=V/I_A
Z_B=V/I_B
R_A=P_A/(I_A*I_A)
R_B=P_B/(I_B*I_B)
X_A=sqrt((Z_A*Z_A)-(R_A*R_A))
X_B=sqrt((Z_B*Z_B)-(R_B*R_B))
R=R_A+R_B
X=X_A+X_B
Z=sqrt((R*R)+(X*X))
I=V/Z
P=I*I*R
#Result:
print "The current when the two coils are in series is %.2f A and the power taken from the source is %.2f W." %(I,P)
#Question:
"""Finding the voltage drop across each coil."""
from math import sqrt,pi
#Variable Declaration:
V=240.0 #Voltage of the source(in Volts)
f=50.0 #Frequency of the supply(in Hertz)
R_A=5.0 #Resistance of coil A(in Ohms)
L_B=0.015 #Inductance of the coil B(in Henry)
P=3e03 #Active power(in Watts)
Q=2e03 #Reactive power(in VAr)
#Calculations:
S=sqrt((P*P)+(Q*Q))
I=S/V
R_B=(P/(I*I))-R_A
X_B=2*pi*f*L_B
X_A=(Q/(I*I))-X_B
L_A=X_A/(2*pi*f)
Z_A=sqrt((R_A*R_A)+(X_A*X_A))
Z_B=sqrt((R_B*R_B)+(X_B*X_B))
V_A=Z_A*I
V_B=Z_B*I
#Result:
print "(a)The resistance of coil B is %.2f Ohms." %(R_B)
print "(b)The inductance of coil A is %.5f Henry." %(L_A)
print "(c)The voltage drop across coil A is %.2f V and across coil B is %.2f V." %(V_A,V_B)
#Question:
"""Finding the total power consumed by the circuit and the power factor of the circuit."""
from math import pi
#Variable Declaration:
P=100.0 #Power rating of the bulb(in Watts)
V=120.0 #Voltage rating of the bulb(in Volts)
Vs=240.0 #Supply voltage(in Volts)
f=50.0 #Frequency of the supply(in Hertz)
#Calculations:
I=P/V
V_R=Vs-V
R=V_R/I
pf_a=1.0
Pt_a=Vs*I
V_C=sqrt((Vs*Vs)-(V*V))
X_C=V_C/I
C=1/(2*pi*X_C*f)
pf_b=V/Vs
Pt_b=Vs*I*pf_b
Vr=I*10.0
V_L=sqrt((Vs*Vs)-((V+Vr)*(V+Vr)))
X_L=V_L/I
L=X_L/(2*pi*f)
V_R_c=V+Vr
pf_c=V_R_c/Vs
Pt_c=Vs*I*pf_c
#Result:
print "(a)The value of the component used R=%.2f Ohms." %(R)
print " The total power consumed is %.2f W." %(Pt_a)
print " The power factor is %.2f." %(pf_a)
print "(b)The value of the component used C=%e Farad." %(C)
print " The total power consumed is %.2f W." %(Pt_b)
print " The power factor is %.2f leading." %(pf_b)
print "(c)The value of the component used R=10 Ohms and L=%.3f Henry." %(L)
print " The total power consumed is %.2f W." %(Pt_c)
print " The power factor is %.3f lagging." %(pf_c)
#Question:
"""Finding the value of capacitance C in the cirucit."""
#Variable Declaration:
R=20.0 #Resistance connected in series(in Ohms)
L=15e-03 #Pure inductance in parallel with the capacitor(in Henry)
ang_fre=1000.0 #Angular frequency of voltage source(in radians per second)
#Calculations:
X_L=ang_fre*L
X=R*tan(pi/4.0)
"""Case 1:(X is inductive)"""
X_C1=1.0/((1.0/X_L)-(1.0/X))
C1=1.0/(ang_fre*X_C1)
"""Case 2:(X is capacitive)"""
X_C2=1.0/((1.0/X_L)+(1.0/X))
C2=1.0/(ang_fre*X_C2)
#Result:
print "The value of capacitance is:"
print "Case 1: If net reactance X is inductive, C=%e Farad." %(C1)
print "Case 2: If net reactance X is capacitive, C=%e Farad." %(C2)
#Question:
"""Finding total current in the circuit."""
from cmath import phase
from math import degrees
#Variable Declaration:
Z1=(12+1j*15) #Impedance of the first branch(in Ohms)
Z2=(8-1j*4) #Impedance of the second branch(in Ohms)
V=(230+1j*0) #Potential difference across the parallel combination(in Volts)
#Calculations:
I1=V/Z1
I2=V/Z2
I=I1+I2
P=abs(V)*abs(I)*cos(phase(I))
P1=abs(I1)*abs(I1)*(Z1.real)
P2=abs(I2)*abs(I2)*(Z2.real)
pf1=Z1.real/abs(Z1)
pf2=Z2.real/abs(Z2)
pf=cos(phase(I))
#Result:
print "(a)The current supplied to branch 1 is %.2f A at a phase angle of %.2f degrees." %(abs(I1),degrees(phase(I1)))
print " The current supplied to branch 2 is %.2f A at a phase angle of %.2f degrees." %(abs(I2),degrees(phase(I2)))
print " The total current is %.2f A at a phase angle of %.2f degrees.\n" %(abs(I),degrees(phase(I)))
print "(b)The power consumed by branch 1 is %.2f W." %(P1)
print " The power consumed by branch 2 is %.2f W." %(P2)
print " The total power consumed is %.2f W.\n" %(P)
print "(c)The power factor of branch 1 is %.4f lagging." %(pf1)
print " The power factor of branch 2 is %.4f leading." %(pf2)
print " The overall power factor of the circuit is %.4f leading." %(pf)
#Question:
"""Finding the resistance and inductance of a coil."""
from math import acos
#Variable Declaration:
V=230.0 #Voltage of the supply(in Volts)
f=50.0 #Frequency of the supply ac voltage(in Hertz)
R=50.0 #Reistance in series with the coil(in Ohms)
V_coil=180.0 #Voltage across coil(in Volts)
V_R=130.0 #Voltage across resistance(in Volts)
#Calculations:
I=V_R/R
"""From parallelogram OACB,the angle theta is calculated."""
cos_theta=((V*V)-(V_R*V_R)-(V_coil*V_coil))/(2*V_R*V_coil)
theta=acos(cos_theta)
V_L=V_coil*sin(theta)
V_r=V_coil*cos(theta)
L=V_L/(I*2*pi*f)
r=V_r/I
P=I*V_r
#Result:
print "(a)The resistance of the coil is %.2f Ohms and the inductance is %.2f H." %(r,L)
print "(b)The power dissipated in the coil is %.2f W." %(P)
#Question:
"""Finding the component values of the circuit."""
from math import pi,sqrt,radians,cos
#Variable Declaration:
Vm=141.4 #Peak value of supply voltage(in Volts)
Im=7.07 #Peak value of current in the series circuit(in Amperes)
ang_fre=2000.0 #Angular frequency of the ac signal(in radians per second)
#Calculations:
V=Vm/sqrt(2.0)
I=Im/sqrt(2.0)
Z=V/I
""" We know that V=I*Z;
100=5*sqrt((R*R)+(X_C*X_C));
(R*R)+(X_C*X_C)=400;
From the triangle OAB,
cos(36.87)=V_R/V; """
R=(V*cos(radians(36.87)))/I
X_C=sqrt((Z*Z)-(R*R))
C=1.0/(ang_fre*X_C)
#Result:
print "The elements of the circuit are R=%.2f Ohms and C=%e Farad." %(R,C)
#Question:
"""Finding the voltage and current by Thevenin's theorem."""
from cmath import rect,phase
from math import degrees,radians
#Variable Declaration:
Vs=rect(100,radians(20))
#Calculations:
"""Using voltage divider rule,"""
Z2=((1j*20)*(15-1j*30))/((1j*20)+(15-1j*30))
Z=10+Z2
I=Vs/Z
V2_div=Vs*(Z2/(10+Z2))
V1_div=V2_div*((-1j*30)/(15-1j*30))
"""Using Thevenin's theorem,"""
V_Th=Vs*((15-1j*30)/(10+15-1j*30))
Z_Th=(10*(15-1j*30))/(10+(15-1j*30))
V2=V_Th*((1j*20)/(Z_Th+1j*20))
V_Th=Vs*((1j*20)/(10+1j*20))
Z_Th=15+(1.0/((1.0/10)+(1.0/(1j*20))))
V1=V_Th*((-1j*30)/(Z_Th-1j*30))
#Result:
print "(a)By voltage divider rule,"
print "(i)The current I is %.2f A at an angle of %.2f degrees." %(abs(I),degrees(phase(I)))
print "(ii)The voltage V1 is %.2f V at an angle of %.2f degrees." %(abs(V1_div),degrees(phase(V1_div)))
print "(b)By applying Thevenin's theorem,"
print "(i)The voltage V1 is %.2f V at an angle of %.2f degrees." %(abs(V1),degrees(phase(V1)))
print "(ii)The voltage V2 is %.2f V at an angle of %.2f degrees." %(abs(V2),degrees(phase(V2)))
#Question:
"""Finding the current by Norton's theorem."""
from cmath import rect,phase
from math import degrees,radians
#Variable Declaration:
Is=rect(20,radians(45)) #Current supplied by current source(in Amperes)
#Calculations:
"""Using current divider rule,"""
Z2=(1j*3)+1.0/((1.0/4)+(1.0/(-1j*5)))
I=Is*(2/(Z2+2))
I_R_div=I*((-1j*5)/(4-1j*5))
"""Using Norton's theorem,"""
I_N=Is*(2/(2+1j*3))
Z_N=1.0/((1.0/(2+1j*3))+(1.0/(-1j*5)))
I_R=I_N*(Z_N/(Z_N+4))
#Result:
print "(a)By current divider rule,"
print " The current I_R is %.2f A at an angle of %.2f degrees." %(abs(I_R_div),degrees(phase(I_R_div)))
print "(a)By Norton's theorem,"
print " The current I_R is %.2f A at an angle of %.2f degrees." %(abs(I_R),degrees(phase(I_R)))
#Question:
"""Finding the voltage by Thevenin's theorem."""
from cmath import rect,phase
from math import radians,degrees
#Variable Declaration:
Vs=rect(200,radians(30.0))
#Calculations:
Z2=((40)*(20+1j*50))/(40+(20+1j*50))
V2=(Vs*Z2)/(Z2-1j*20)
V_div=V2*(20/(20+1j*50))
V_Th=Vs*(40/(40-1j*20))
Z_Th=(1j*50)+1.0/((1.0/(-1j*20))+(1.0/40))
V=(V_Th*20)/(Z_Th+20)
#Result:
print "(a)V using voltage divider rule is %.2f V at an angle of %.2f degrees." %(abs(V_div),degrees(phase(V_div)))
print "(b)The voltage V using Thevenin's theorem is %.2f V at an angle of %.2f degrees." %(abs(V),degrees(phase(V)))