from __future__ import division
import math
import cmath
#initializing the variables:
z1 = 12 + 5j;
z2 = -40j;
r3 = 30;
theta3 = 60;# in degrees
r4 = 2.20E6;
theta4 = -30;# in degrees
f = 50;# in Hz
#calculation:
#for an R-L series circuit, impedance
# Z = R + iXL
Ra = z1.real
XLa = z1.imag
La = XLa/(2*math.pi*f)
#for a purely capacitive circuit, impedance Z = -iXc
Xcb = abs(z2.imag)
Cb = 1/(2*math.pi*f*Xcb)
z3 = r3*cmath.cos(theta3*math.pi/180) + (r3*cmath.sin(theta3*math.pi/180))*1j
Rc = z3.real
XLc = z3.imag
Lc = XLc/(2*math.pi*f)
z4 = r4*cmath.cos(theta4*math.pi/180) + (r4*cmath.sin(theta4*math.pi/180))*1j
Rd = z4.real
Xcd = abs(z4.imag)
Cd = 1/(2*math.pi*f*Xcd)
#Results
print "\n\n Result \n\n"
print "\n (a)an impedance (12 + i5)ohm represents a resistance of ",round( Ra,2)," ohm "
print "in series with an inductance of ",round(La*1000,2),"mH"
print "\n (b)an impedance -40i ohm represents a pure capacitor of capacitance ",round(Cb*1E6,2),"uF"
print "\n (c)an impedance 30/_60deg ohm represents a resistance of ",round(Rc,2)," ohm "
print "in series with an inductance of ",round(Lc*1000,2),"mH"
print "\n (d)an impedance 2.20 x 10^6 /_-30deg ohm represents a resistance of ",round(Rd/1000,2),"kohm "
print " in series with a capacitor of capacitance ",round(Cd*1E9,2),"nF"
Result (a)an impedance (12 + i5)ohm represents a resistance of 12.0 ohm in series with an inductance of 15.92 mH (b)an impedance -40i ohm represents a pure capacitor of capacitance 79.58 uF (c)an impedance 30/_60deg ohm represents a resistance of 15.0 ohm in series with an inductance of 82.7 mH (d)an impedance 2.20 x 10^6 /_-30deg ohm represents a resistance of 1905.26 kohm in series with a capacitor of capacitance 2.89 nF
from __future__ import division
import math
import cmath
#initializing the variables:
L = 0.1592 ;# in Henry
V = 250;# in Volts
f = 50;# in Hz
R = 0;# in ohms
#calculation:
#for an R–L series circuit, impedance
# Z = R + iXL
XL = 2*math.pi*f*L
Z = R + 1j*XL
I = V/Z
x = I.real
y = I.imag
r = (x**2 + y**2)**0.5
if ((x==0)&(y<0)):
theta = -90
elif ((x==0)&(y>0)):
theta = +90
else:
theta = cmath.phase(complex(x,y))*180/math.pi
#Results
print "\n\n Result \n\n"
print "\n current is (",round(r,2),"/_",theta,"deg) A"
Result current is ( 5.0 /_ -90 deg) A
from __future__ import division
import math
import cmath
#initializing the variables:
C = 3E-6 ;# in farad
f = 1000;# in Hz
ri = 2.83;
thetai = 90;# in degrees
#calculation:
#Capacitive reactance Xc
Xc = 1/(2*math.pi*f*C)
# circuit impedance Z
Z = -1*1j*Xc
I = ri*math.cos(thetai*math.pi/180) + 1j*ri*math.sin(thetai*math.pi/180)
V = I*Z
x = V.real
y = V.imag
#Results
print "\n\n Result \n\n"
print "\n supply p.d. is ",round(abs(V),0),"V"
Result supply p.d. is 150.0 V
from __future__ import division
import math
import cmath
#initializing the variables:
V = 240;# in Volts
f = 50;# in Hz
Z = 30 - 50j;
#calculation:
#Since impedance Z = 30 - i50,
#resistance
R = Z.real
#capacitive reactance
Xc = abs(Z.imag)
#capacitance
C = 1/(2*math.pi*f*Xc)
#modulus of impedance
modZ = (R**2 + Xc**2)**0.5
I = V/Z
x = I.real
y = I.imag
r = (x**2 + y**2)**0.5
theta = cmath.phase(complex(x,y))*180/math.pi
#Results
print "\n\n Result \n\n"
print "\n (a)resistance is ",round( R,2)," ohm"
print "\n (b)capacitance is ",round(C*1E6,2),"uFarad"
print "\n (c)modulus of impedance is ",round(modZ,2)," ohm"
print "\n (d)current flowing and its phase angle is (",round( r,2),"/_",round( theta,2),"deg) A"
Result (a)resistance is 30.0 ohm (b)capacitance is 63.66 uFarad (c)modulus of impedance is 58.31 ohm (d)current flowing and its phase angle is ( 4.12 /_ 59.04 deg) A
from __future__ import division
import math
import cmath
#initializing the variables:
V = 200;# in Volts
f = 50;# in Hz
R = 32;# in ohms
L = 0.15;# in Henry
#calculation:
#Inductive reactance XL
XL = 2*math.pi*f*L
#impedance, Z
Z = R + 1j*XL
#Current I
I = V/Z
xi = I.real
yi = I.imag
ri = (xi**2 + yi**2)**0.5
if ((xi==0)&(yi<0)):
thetai = -90
elif ((xi==0)&(yi>0)):
thetai = +90
else:
thetai = cmath.phase(complex(xi,yi))*180/math.pi
#P.d. across the resistor
VR = I*R
xr = VR.real
yr = VR.imag
rr = (xr**2 + yr**2)**0.5
thetar = cmath.phase(complex(xr,yr))*180/math.pi
#P.d. across the coil, VL
VL = I*1j*XL
xl = VL.real
yl = VL.imag
rl = (xl**2 + yl**2)**0.5
thetal = cmath.phase(complex(xl,yl))*180/math.pi
#Results
print "\n\n Result \n\n"
print "\n (a)impedance is ",round(Z.real,2)," + ",round( Z.imag,2),")i ohm"
print "\n (b)current flowing and its phase angle is lagging the voltage = (",round( ri,2),"/_",round( thetai,2),"deg) A"
print "\n (c)P.d. across the resistor is (",round(rr,2),"/_",round(thetar,2),"deg) V"
print "\n (d)P.d. across the coil, VL is (",round(rl,2),"/_",round(thetal,2),"deg) V"
Result (a)impedance is 32.0 + 47.12 )i ohm (b)current flowing and its phase angle is lagging the voltage = ( 3.51 /_ -55.82 deg) A (c)P.d. across the resistor is ( 112.36 /_ -55.82 deg) V (d)P.d. across the coil, VL is ( 165.46 /_ 34.18 deg) V
from __future__ import division
import math
#initializing the variables:
V = 120 + 200j;# in Volts
f = 5E6;# in Hz
I = 7 + 16j;# in amperes
#calculation:
#impedance, Z
Z = V/I
R = Z.real
X = Z.imag
if ((R>0)&(X<0)):
C = -1/(2*math.pi*f*X)
#Results
print "\n\n Result \n\n"
print "\n The series circuit thus consists of a resistor of resistance ",round(R,2)," ohm "
print "and a capacitor of capacitive reactance", round(X*-1,3),"ohm and capacitance is",round(C*1E9,2)," nFarad\n"
elif ((R>0)&(X>0)):
L = 2*math.pi*f*X
#Results
print "\n\n Result \n\n"
print "\n The series circuit thus consists of a resistor of resistance ",round(R,2)," ohm "
print " and a inductor of insuctance ",round(L*100,2)," mHenry\n"
Result The series circuit thus consists of a resistor of resistance 13.25 ohm and a capacitor of capacitive reactance 1.705 ohm and capacitance is 18.67 nFarad
from __future__ import division
import math
import cmath
#initializing the variables:
rv = 70;# in volts
thetav = 30;# in degrees
ri = 3.5;# in amperes
thetai = -20;# in degrees
#z1 consist of two resistance
R1 = 4.36;# in ohms
R2 = -2.1j;# in ohms
#calculation:
V = rv*math.cos(thetav*math.pi/180) + 1j*rv*math.sin(thetav*math.pi/180)
I = ri*math.cos(thetai*math.pi/180) + 1j*ri*math.sin(thetai*math.pi/180)
#impedance, Z
Z = V/I
#Total impedance Z = z1 + z2
Z1 = R1 + R2
Z2 = Z - Z1
x = Z2.real
y = Z2.imag
#Results
print "\n\n Result \n\n"
print "\n impedance Z2 is ",round(x,2)," + (",round(y,2),")i ohm\n"
Result impedance Z2 is 8.5 + ( 17.42 )i ohm
from __future__ import division
import math
import cmath
#initializing the variables:
R = 90;# in ohms
XL = 150;# in ohms
ri = 1.35;# in amperes
thetai = 0;# in degrees
#calculation:
I = ri*math.cos(thetai*math.pi/180) + 1j*ri*math.sin(thetai*math.pi/180)
#Circuit impedance Z
Z = R + 1j*XL
#Supply voltage, V
V = I*Z
#Voltage across 90 ohm? resistor
VR = V.real
#Voltage across inductance, VL
VL = V.imag
xv = V.real
yv = V.imag
rv = (xv**2 + yv**2)**0.5
thetav = cmath.phase(complex(xv,yv))*180/math.pi
phi = thetav - thetai
#Results
print "\n\n Result \n\n"
print "\n (a)Supply voltage, V is ",xv," + (",yv,")i V\n"
print "\n (b)Voltage across 90 ohm resistor, VR is ",VR," V\n"
print "\n (c)Voltage across inductance, VL is ",VL," V\n"
print "\n (d)Circuit phase angle is ",round(phi,2),"deg lagging\n"
Result (a)Supply voltage, V is 121.5 + ( 202.5 )i V (b)Voltage across 90 ohm resistor, VR is 121.5 V (c)Voltage across inductance, VL is 202.5 V (d)Circuit phase angle is 59.04 deg lagging
from __future__ import division
import math
import cmath
#initializing the variables:
R = 25;# in ohms
L = 0.02;# in henry
Vm = 282.8;# in volts
w = 628.4;# in rad/sec
phiv = math.pi/3;# phase angle
#calculation:
#rms voltage
Vrms = 0.707*Vm*math.cos(phiv) + 0.707*Vm*math.sin(phiv)*1j
#frequency
f = w/(2*math.pi)
#Inductive reactance XL
XL = 2*math.pi*f*L
#Circuit impedance Z
Z = R + XL*1j
#Rms current
Irms = Vrms/Z
phii = cmath.phase(complex(Irms.real, Irms.imag))*180/math.pi
phi = phiv*180/math.pi - phii
#Results
print "\n\n Result \n\n"
print "\n (a)the rms value of voltage is ",round(Vrms.real,2)," + (",round( Vrms.imag,2),")i V\n"
print "\n (b)the circuit impedance is ",round(R,2)," + (",round( XL,2),")i ohm\n"
print "\n (c)the rms current flowing is ",round(Irms.real,2)," + (",round( Irms.imag,2),")i A\n"
print "\n (d)Circuit phase angle is ",round(phi,2),"deg lagging\n"
Result (a)the rms value of voltage is 99.97 + ( 173.15 )i V (b)the circuit impedance is 25.0 + ( 12.57 )i ohm (c)the rms current flowing is 5.97 + ( 3.92 )i A (d)Circuit phase angle is 26.69 deg lagging
from __future__ import division
import math
import cmath
#initializing the variables:
R = 12;# in ohms
L = 0.10;# in henry
C = 120E-6;# in Farads
f = 50;# in Hz
V = 240;# in volts
#calculation:
#Inductive reactance, XL
XL = 2*math.pi*f*L
#Capacitive reactance, Xc
Xc = 1/(2*math.pi*f*C)
#Circuit impedance Z
Z = R + 1j*(XL - Xc)
I = V/Z
phii = cmath.phase(complex(I.real, I.imag))*180/math.pi
phiv = 0# in degrees
phi = phiv - phii
#Results
print "\n\n Result \n\n"
print "\n the current flowing is ",round(abs(I),1),"/_",round(cmath.phase(complex(I.real,I.imag))*180/math.pi,1),"deg A\n"
print "and Circuit phase angle is ",round(phi,1),"deg lagging\n"
Result the current flowing is 18.5 /_ -22.2 deg A and Circuit phase angle is 22.2 deg lagging
from __future__ import division
import math
import cmath
#initializing the variables:
C = 50E-6;# in Farads
f = 50;# in Hz
V = 225;# in volts
ri = 1.5;# in Amperes
thetai = -30;# in degrees
#calculation:
I = ri*math.cos(thetai*math.pi/180) + 1j*ri*math.sin(thetai*math.pi/180)
#Capacitive reactance, Xc
Xc = 1/(2*math.pi*f*C)
#Circuit impedance Z
Z = V/I
R = Z.real
XL = Z.imag + Xc
#inductance L
L = XL/(2*math.pi*f)
#Voltage across coil
Zcoil = R + 1j*XL
Vcoil = I*Zcoil
#Voltage across capacitor,
Vc = I*(-1j*Xc)
#Results
print "\n\n Result \n\n"
print "\n (a)resistance is ",round(R,2)," ohm and inductance is ",round( L,3)," H\n"
print "\n (b)voltage across the coil is ",round(Vcoil.real,2)," + (",round( Vcoil.imag,2),")i V\n"
print "\n (c)voltage across the capacitor is ",round(Vc.real,2)," + (",round( Vc.imag,2),")i V\n"
Result (a)resistance is 129.9 ohm and inductance is 0.441 H (b)voltage across the coil is 272.75 + ( 82.7 )i V (c)voltage across the capacitor is -47.75 + ( -82.7 )i V
from __future__ import division
import math
import cmath
#initializing the variables:
C = 2.653E-6;# in Farads
R1 = 8;# in ohms
R2 = 5;# in ohms
L = 0.477E-3;# in Henry
f = 4000;# in Hz
ri = 6;# in Amperes
thetai = 0;# in degrees
#calculation:
I = ri*math.cos(thetai*math.pi/180) + 1j*ri*math.sin(thetai*math.pi/180)
#Capacitive reactance, Xc
Xc = 1/(2*math.pi*f*C)
#impedance Z1
Z1 = R1 - 1j*Xc
#inductive reactance XL
XL = 2*math.pi*f*L
#impedance Z2,
Z2 = R2 + 1j*XL
#voltage V1
V1 = I*Z1
#voltage V2
V2 = I*Z2
#Supply voltage, V
V = V1 + V2
phiv = cmath.phase(complex(V.real, V.imag))*180/math.pi
phi = phiv - thetai
#Results
print "\n\n Result \n\n"
print "\n supply voltage is ",round(V.real,2)," + (",round( V.imag,2),")i V\n"
print "and Circuit phase angle is ",round(phi,2),"deg leading"
Result supply voltage is 78.0 + ( -18.06 )i V and Circuit phase angle is -13.03 deg leading