t=3*10**-3; #Assigning values to parameters
w=314;
Im=141.4*sin(math.pi/2);
f=w/(2*math.pi);
T=1/f;
t=3*(10**-3);
i=141.4*sin(w*t);
print"Maximum value of current",round(Im,2),"A"
print"Frequency",round(f,1),"HZ"
print"Time period",round(T,2),"sec"
print"Instantaneous value of current at t=3 msec",round(i,2),"A"
f=60.0; #Assigning values to parameters
Im=12.0;
i=Im*sin(377/360)
print"Current at t=1/360 sec",round(i,2),"A"
i1=9.6;
t=math.asin(i1/Im)/377;
print"Time taken to reach i1",round(t,5),"sec"
w=942.0; #Assigning values to parameters
Vm=10.0;
V=6.0;
t=math.asin(V/Vm)/w;
f=w/(2*math.pi);
T=1.0/f;
t2=t+T;
print"Time taken to reach 6V second time=",round(t2*1000,2),"msec"
from scipy import integrate
import math
V=integrate.quad(lambda t:20*sin(t),0,math.pi)
V1=V[0]
Vavg=V1/(2*math.pi)
print"the average value of voltage is Vavg=",round(Vavg,3),"volts"
from scipy import integrate
#y=10*t,the current equation
T=4;
Res=integrate.quad(lambda t:10*t,0,2,)
Res=Res[0]/T
print"Average current value",round(Res,2),"A"
from scipy import integrate
#y=6*t,the voltage equation
T=3;
Res=integrate.quad(lambda t:6*t,0,3)
Res=Res[0]/T
print"Average voltage value is Res=",round(Res,2),"Volts"
from scipy import integrate
Vm=1; #Assuming Vm=1
#y=Vm*sin(t),the voltage Equation
#y1=0.866*Vm*sin(t)
T=math.pi;
Res1=integrate.quad(lambda t:Vm*sin(t),0,math.pi/3)
Res1=Res1[0]
Res2= integrate.quad(lambda t:0.866*Vm*sin(t),math.pi/3,math.pi/2)
Res2=Res2[0]
Res3=integrate.quad(lambda t:Vm*sin(t),math.pi/2,math.pi)
Res3=Res3[0]
Res=(Res1+Res2+Res3)/T
print"Average voltage value",round(Res,2),"volts"
from scipy import integrate
Vm=1; #Assuming Vm=1;
#y=Vm*sin(t) #Defining voltage equation
T=math.pi;
Res=integrate.quad(lambda t:Vm*sin(t),math.pi/6,math.pi)
Res=Res[0]/T
print"Average voltage value",round(Res,3),"Volts"
from scipy import integrate
Vm=1; #Assuming Vm=1
#y=Vm*Vm*sin(t)*sin(t), #Defining Voltage Equation
T=2*math.pi;
Res=(integrate.quad(lambda t:Vm*Vm*sin(t),0,math.pi))
Res=sqrt(Res[0]/T)
print"Rms value of voltage",round(Res,2),"Volts"
from scipy import integrate
Vm=1; #Assuming Vm=1
#y=Vm*Vm*sin(t)*sin(t) #Defining Voltage Equation
T=2*math.pi;
Res=(integrate.quad(lambda t: Vm*Vm*sin(t)*sin(t),math.pi/4,math.pi))
Res=sqrt(Res[0]/T)
print"Rms value of voltage",round(Res,3),"Volts"
from scipy import integrate
Vm=1; #Assuming Vm=1
#y=Vm*Vm*sin(t)*sin(t),Defining Voltage Equation
#y1=0.866*0.866*Vm*Vm*sin(t)*sin(t)
T=math.pi;
Res1=(integrate.quad(lambda t:Vm*Vm*sin(t)*sin(t),0,math.pi/3))
Res2=(integrate.quad(lambda t:0.866*0.866*Vm*Vm*sin(t)*sin(t),math.pi/3,math.pi/2))
Res3=(integrate.quad(lambda t:Vm*Vm*sin(t)*sin(t),math.pi/2,math.pi))
VRms=sqrt((Res1[0]+Res2[0]+Res3[0])/T)
print"Rms voltage value is=",round(VRms,3),"Volts"
from scipy import integrate
Vm=1; #Assuming Vm=1
#y=10*t*10*t, Defining Current Equation
T=4;
Res=(integrate.quad(lambda t:10*t*10*t,0,2))
Irms=sqrt(Res[0]/T)
print"Rms current value is Irms=",round(Irms,2),"A"
from scipy import integrate
Vm=1; #Assuming Vm=1
#y=sin(t)*sin(t),Defining Voltage Equation
T=math.pi;
Res=integrate.quad(lambda t:sin(t)*sin(t),math.pi/6,math.pi)
Res=sqrt(Res[0]/T)
print"Rms voltage value",round(Res,3),"volts"
from scipy import integrate
Vm=1; #Assuming Vm=1
#y=sin(t+(math.pi/3))*sin(t+(math.pi/3)),Defining Voltage Equation
T=2*(math.pi/3);
Res=integrate.quad(lambda t:sin(t+(math.pi/3))*sin(t+(math.pi/3)),0,T)
Res=sqrt(Res[0]/T)
print"Rms voltage value",round(Res,4),"volts"
from scipy import integrate
#y=(10+10*sin(t))*(10+10*sin(t)),Defining Current Equation
T=2*math.pi;
Res=integrate.quad(lambda t:(10+10*sin(t))*(10+10*sin(t)),0,2*math.pi)
Res=sqrt(Res[0]/T)
print"Rms current value",round(Res,2),"A"
Im=62.35;
w=323;
#y=Im*sin(w*t), Defining Voltage Equation
fr=w/(2*math.pi);
Irms=Im/sqrt(2);
Iavg=0.637*Im;
formfac=Irms/Iavg;
print"Maximum value of current",round(Im,2),"A"
print"Frequency",round(fr,2),"Hertz"
print"Rms value of current",round(Irms,1),"A"
print"Average value of current",round(Iavg,1),"A"
print"Form factor",round(formfac,2)
import cmath
V1=42.43+1j*0; #Defining voltage equations in rectangular form
V2=14.14+1j*24.49;
Va=V1+V2;
[Ro,Theta]=cmath.polar(Va);
Vm=Ro*sqrt(2);
print"Maximum value of voltage considering addition of voltages",round(Vm,2),"Volts"
#function, y=Ro*sin(t+Theta),Defining voltage equation
Vb=V1-V2;
[Ro1,Theta1]=cmath.polar(Vb);
Vm1=Ro1*sqrt(2);
#function y1=f(t),y1=Ro*sin(t+Theta1),Defining voltage equation
print"Maximum value of voltage considering difference of voltages",round(Vm1,2),"Volts"
import cmath
V1=17.68 #Defining voltage equations in rectangular form
V2=6.12+1j*3.54
V3=1j*21.21
V4=10-1j*10;
V=V1+V2+V3+V4;
[Ro,Theta]=cmath.polar(V);
Vm=Ro*sqrt(2)
t1=math.degrees(Theta)
#function y=f(t), y=Ro*sqrt(2)*sin(t+Theta), endfunction
print"Maximum Voltage value",round(Vm,2),"Volts"
print"the value of Theta is=",round(t1,2),"degrees"
import cmath
V1=36.75+1j*21.22 #Defining voltage equations in rectangular form
V2=-45.93-1j*26.52
V3=-50+1j*50;
V=-30.59+1j*94.15;
V4=V-(V1+V2+V3);
[Ro,Theta]=cmath.polar(V4);
t=math.degrees(Theta)
#function y=f(t), y=Ro*sqrt(2)*sin(t+Theta), endfunction
V=Ro*sqrt(2)
print"Maximum Voltage value is=",round(V,2),"Volts"
print"the vlaue of Theta is=",round(t,2),"degrees"
import cmath
I1=2.12+1j*3.67 #Defining current equations in rectangular form
I2=-3.07+1j*1.77
I3=-1.84+1j*1.06;
I4=-(I1+I2+I3);
[Ro,Theta]=cmath.polar(I4);
#function y=f(t), y=Ro*sqrt(2)*sin(t+Theta), endfunction
I=Ro*sqrt(2)
t=math.degrees(Theta)
print"Maximum current value is I=",round(I,2),"A"
print"the value of Theta is t=",round(t,2),"degrees"
V1=230 #Defining voltage equations in rectangular form
V2=-115+1j*200;
V3=-115-1j*200;
V=V1+V2+V3;
[Ro,Theta]=cmath.polar(V);
#function y=f(t), y=Ro*sqrt(2)*sin(t+Theta), endfunction
ER=Ro*sqrt(2)
print"Maximum Voltage value is ER=",round(ER,2),"Volts"
V1=70.71 #Defining voltage equations in rectangular form
V2=1j*176.78
V3=91.86+1j*53.04
V4=100-1j*100;
V=V1+V2+V3+V4;
[Ro,Theta]=cmath.polar(V);
#function y=f(t), y=Ro*sqrt(2)*sin(t+Theta), endfunction
V=Ro*sqrt(2)
print"Maximum Voltage value with V2 polarity as it is",round(V,2),"Volts"
V=V1-V2+V3+V4;
[Ro1,Theta1]=cmath.polar(V);
#function y1=f(t), y1=Ro1*sqrt(2)*sin(t+Theta), endfunction
V=Ro1*sqrt(2)
print"Maximum Voltage value with polarity of V2 reversed",round(V,2),"Volts"
C=318*10**-6; #Assignig values to parameters
V=230.0;
f=50.0;
Xc=1.0/(2*math.pi*f*C);
I=V/Xc;
Vm=sqrt(2)*V;
Im=sqrt(2)*I;
#function y=f(t), y=Vm*sin(2*%pi*f*t),endfunction
#function y1=f(t), y1=Im*sin(2*%pi*f*t+%pi/2),endfunction
print"Peak voltage value",round(Vm,2),"Volts"
print"Peak currnet value",round(Im,2),"A"
L=10*10**-3; #ASssigning values to parameters
Im=5;
w=2000;
#function y=f(t), y=Im*sin(w*t+%pi/2),endfunction
I=Im/sqrt(2);
Xl=2*math.pi*L;
Vm=L*Im*w;
Vl=Vm/sqrt(2);
print"Voltage Vl",round(Vl,2),"Volts"
V=150; #Assigning values to parameters
f=50;
L=0.2;
Xl=2*math.pi*f*L;
Vm=V*sqrt(2);
I=V/Xl;
Im=sqrt(2)*I;
#function y=f(t), y=Vm*sin(2*%pi*f*t),endfunction
#function y1=f(t), y1=Im*sin(2*%pi*f*t-(%pi/2)) endfunction
print"Maximum voltage value",round(Vm,2),"Volts"
print"Maximum current value",round(Im,2),"A"
import math
R=7.0; #Assigning values to parametrs
L=31.8*10**-3;
V=230.0;
f=50.0;
Xl=2*math.pi*f*L;
Xl=round(Xl);
Zcoil=sqrt(R*R+Xl*Xl);
I=V/Zcoil;
Phi=math.atan(Xl/R);
Phi1=math.degrees(Phi)
PF=cos(Phi)
I=round(I,2);
P=V*I*0.574;
print"Circuit Current=",round(I,2),"A"
print"Phase angle=",round(Phi1),"degrees"
print"Power factor=",round(PF,2)
print"Power consumed=",round(P,2),"Watts"
import cmath
V=200.0; #Assigning values to parameters
R=20.0;
f=50.0;
L=0.1;
Xl=2*math.pi*f*L;
C=50*10**-6;
Xc=1.0/(2*math.pi*f*C);
X=Xc-Xl;
Z=R-1j*X;
[Ro,theta]=cmath.polar(Z)
I=V/Ro;
PF=cos(theta);
PF=round(PF,3);
I=round(I,2);
PA=V*I*PF;
PR=V*I*sin(theta);
P=V*I;
print"Circuit Current=",round(I,2),"A"
print"Circuit Impedance=",round(Ro,2),"ohms"
print"Power Factor=",round(PF,3)
print"Active Power=",round(PA,2),"Watts"
print"Reactive Power=",round(PR,1),"VAR"
print"Apparen Power=",round(P),"VA"
import cmath
V=200+1j*0; #Assigning values to parameters
R1=10;
R2=20;
R=R1+R2;
L1=0.05;
L2=0.1;
f=50;
Xl1=2*math.pi*f*L1;
Xl2=2*math.pi*f*L2;
Xl=Xl1+Xl2;
C=50*10**-6;
Xc=1/(2*math.pi*f*C);
X=Xc-Xl;
Z=R-1j*X;
[Ro,theta]=cmath.polar(Z);
I=V/Z;
Z1=R1+1j*Xl1;
Z2=R2-1j*(Xc-Xl2)
[Ro1,Theta1]=cmath.polar(Z1);
[Ro2,Theta2]=cmath.polar(Z2);
[ro,th]=cmath.polar(I);
V1=ro*Ro1;
V2=ro*Ro2;
print"Circuit Current",round(ro,2),"A"
print"Voltage V1",round(V1,1),"Volts"
print"Voltage V2",round(V2,1),"Volts"
import cmath
V=100+0*1j; #Assignig values to parametrs
Z1=17.32+10*1j;
V1=34.64-20*1j;
V2=V-V1;
[Ro,Theta]=cmath.polar(V2);
[ro,theta]=cmath.polar(Z1);
[r,t]=cmath.polar(V1);
I=Ro/r;
[ro1,t1]=cmath.polar(I);
I=round(I);
Z2=V2/I;
[r1,t1]=cmath.polar(Z2);
print"Impedance Z2","=",Z2,"=",cmath.polar(Z2),"=",round(r1,3),"ohms"
# The answer in the book is wrong ,The value of I is wrong in the book.
import cmath
V=150+180*1j; #Assigning values to parameters
I=5-4*1j;
Z=V/I;
print"Impedance =",Z,"=",round(Z.imag,1),"ohms"
[Ro,Theta]=cmath.polar(Z);
P=V*I*cos(Theta);
[r,t]=cmath.polar(P);
print"Power consumed =",round(r,4),"Watts"
import cmath
V=127.28+1j*0; #Assigning values to parameters
I=1.251-1j*1.251
Z=V/I
[r1,t1]=cmath.polar(Z);
[Ro,Theta]=cmath.polar(I)
P=V*I*cos(Theta)
[r,t]=cmath.polar(P)
print"Resistive and reactive part of impedance =",Z,"=",cmath.polar(Z),"=",round(r1,3),"ohms"
print"Average Power taken=",round(r,2),"Watts"
Z1=12.5+1j*21; #Assigning values to parameters
V=50+1j*0;
I1=V.real/Z1.real;
I2=0.722-0.723*1j;
Z=V/I2;
Z2=Z-Z1;
[r,t]=cmath.polar(Z2);
print"Impedance Z2 =",Z2,"=",cmath.polar(Z2),"=",round(r,3),"ohms"
#function v=f(t), v=200*sin(377*t), endfunction #Defining functions
#function i=f1(t), i=8*sin(377*t-%pi/6), endfunction
V=200.0/sqrt(2);#Assigning values to parameters
V=round(V,2);
I=8.0/sqrt(2);
I=round(I,2);
P=V*I*cos(math.pi/6)
print"Active Power=",round(P,3),"Watts"
Q=V*I*sin(math.pi/6);
print"Reactive Power=",round(Q,2),"VAR"
S=V*I;
print"Apparent Power=",round(S,2),"Watts"
import cmath
#function i=f(t), i=5*sin(314*t+2*%pi/3), endfunction; #Defining functions
#function v=f1(t), v=20*sin(314*t+5*%pi/6), endfunction;
I=-1.77+3.065*1j;
V=-12.24+7.07*1j;
Z=V/I;
[r,t]=cmath.polar(Z);
P=V*I*cos(t);
[ro,theta]=cmath.polar(P);
print"Impedance =",Z,"=",round(Z.real,3),"ohms"
print"Average Power =",round(ro,2),"Watts"
import cmath
import numpy as np
from numpy.linalg import inv
f=50.0;
I=5.0;
V=250.0;
I1=5.8
Z=V/I;
A=[1, (1/(2*math.pi*50))**2],[1, (1/(2*math.pi*60))**2]
B=[50**2],[43.1**2];
res=np.dot(inv(A),B);
r=res[0][0];
P=I1**2*(sqrt(r));
print"Power absorbed =",round(P,1),"Watts"
#function vl=f(t), vl=300*sin(1000*t), endfunction; #Defining functions
R=20.0; #Assigning values to parameters
w=1000;
Z=R/cos(math.pi/4);
Xc=sqrt(Z*Z-R*R);
Xl=2*Xc;
L=Xl/w;
C=1.0/(w*Xc);
print"Inductance Value=",round(L,2),"Henery"
print"Capacitance Value=",round(C,6),"farad"
import cmath
Vr=10; #Assigning values to parameters
Vl=15;
Vc=10;
V=sqrt(Vr^2+(Vl-Vc)^2);
V=10+1j*0+0+1j*15+0-1j*10;
[r,t]=cmath.polar(V);
print"Voltage=",round(r,2),"Volts"
import cmath
L=0.01; #Assigning value sto parameters
fr=50;
#function v=f(t), y=400*sin(3000*t-10),endfunction; #Defining functions
#function i=f1(t),i=10*sqrt(2)*cos(3000*t-55), endfunction;
V=278.54-1j*49.11;
I=8.191+5.7*1j;
Z=V/I;
[r,t]=cmath.polar(Z);
Xl=3000*L;
Xc=50;
C=1.0/(2*math.pi*fr*Xc);
print"impedence Z=",Z,"=",cmath.polar(Z),"=",round(r,2),"ohms"
print"Capacitance C=",round(C,5),"farad"
Vr=25; #Assigning values to parameters
Vcoil=40;
Vc=55;
Vrcoil=50;
I=0.345;
C=20*10**-6;
Xc=Vc/I;
f=1/(2*math.pi*C*Xc);
R=Vr/I;
Zcoil=Vcoil/I;
Zrcoil=Vrcoil/I;
r=(Zrcoil**2-(R**2+Zcoil**2))/(2*R);
Xl=sqrt(Zcoil**2-r**2);
Z=sqrt((R+r)**2+(Xc-Xl)**2);
I=round(I,3);
Z=round(Z);
V=I*Z;
print"Voltage=",round(V,3),"Volts"
#The answer in the book is wrong,which is 35.046
R=10.0; #Assigning values to parameters
L=0.014;
C=100*10**-6;
wr=1.0/sqrt(L*C);
Q=(1.0/R)*(sqrt(L/C));
BW=R/L;
w1=wr-BW/2;
w2=wr+BW/2;
Vm=1;
V=1/sqrt(2);
Vc=(V/R)*sqrt(L/C);
print"Resonant frequency=",round(wr,2),"rad/sec"
print"Quality factor=",round(Q,3)
print"Bandwidth=",round(BW,2),"rad/sec"
print"Lower frequency=",round(w1),"rad/sec"
print"Upper frequency=",round(w2,2),"rad/sec"
print"Maximum value of voltage across capacitor=",round(Vc,3),"Volts"
V=10/sqrt(2); #Assigning values to parameters
Vc=500;
BW=400/(2*math.pi);
R=100;
Q=Vc/V;
BW=round(BW,2);
Q=round(Q,2);
fr1=(Q*BW);
f1=fr1-(BW/2);
f2=fr1+BW/2;
L=R/(2*math.pi*BW);
fr=1.0/(2*math.pi*sqrt(L*C));
C=1.0/(fr1*fr1*4*math.pi*math.pi*L);
print"Resonant frequency=",round(fr1,2),"Hertz"
print"Lower frequency=",round(f1,2),"Hertz"
print"Upper frequency=",round(f2,2),"Hertz"
print"Inductor value=",round(L,2),"Hertz"
print"Capacitor value=",round(C,9),"Farads"
# the answer of the capacitance in ths book is given in nF
f=1*10**6; #Assigning values to parameters
C1=500*10**-12;
C2=600810**-12;
Xl=1.0/(2*math.pi*f*C1);
L=Xl/(2*math.pi*f);
R=30.623;
Q=(1/R)*sqrt(L/C1);
print"Resistance=",round(R,2),"ohms"
print"Inductance=",round(L,9),"Henery"
print"Quality Factor=",round(Q,2)
r=2.0; #Assigning values to parameters
L=0.01
V=230.0;
f=50.0;
C=1.0/(f*f*4*math.pi*math.pi*L);
Ir=V/r;
Vc=(V/r)*sqrt(L/C);
print"Current across capacitor C=","{:.3e}".format(C),"Farad"
print"Current I=",round(Ir,2),"A"
print"Voltage across the capacitor Vc=",round(Vc,1),"Volts"
L=0.1; #Assigning values to parameters
R=10.0;
V=230.0;
f=50.0;
C=200*10**-6;
Xl=2*math.pi*f*L;
Xc=1.0/(2*math.pi*f*C);
Z=sqrt(R*R+(Xl-Xc)*(Xl-Xc));
I=V/Z;
Zcoil=sqrt(R*R+Xl*Xl);
Vcoil=I*Zcoil;
Vc=I*Xc;
print"Circuit Current I=",round(I,2),"Amperes"
print"Coil impedance Zcoil=",round(Zcoil,2),"Ohms"
print"Volts","Coil voltage Vcoil=",round(Vcoil,1),"Volts"
print"Capacitor Voltage Vc=",round(Vc,2),"Volts"
fr=1.0/(2*math.pi*sqrt(L*C));
Ir=V/R;
Xl=2*math.pi*fr*L;
Xc=Xl;
Zcoil=sqrt(R*R+Xl*Xl);
Vcoil=Ir*Zcoil;
Vc=Ir*Xc;
print"Circuit Current at resonance Ir=",round(Ir,2),"Amperes"
print"Coil impedance at resonance Zcoil=",round(Zcoil,2),"Ohms"
print"Coil voltage at resonance Vcoil=",round(Vcoil,3),"Volts"
print"Capacitor Voltage at resonance Vc=",round(Vc,2),"Volts"
Vr=200.0; #Assiging values to parameters
P=15.3;
fr=10000.0;
BW=1000.0;
R=Vr**2/P;
Q=fr/BW;
L=Q*R/(2*math.pi*fr);
C=1.0/(4*math.pi*math.pi*fr*fr*L);
print"resistance=",round(R,2),"ohms"
print"inductor=",round(L,3),"Henery"
print"Capacitor=",round(C,9),"Farad"
#The answer of the capacitance in the book is given in the form of pF
R=20.0; #Assigning values to parameters
L=31.8*10**-3;
V=230.0;
f=50.0;
I1=V/R;
Xl=2*math.pi*f*L;
I2=V/Xl;
I2=round(I2);
I=sqrt(I1*I1+I2*I2);
pf=I1/I;
pf=round(pf,3);
P=V*I*pf;
print"Line current=",round(I,2),"A"
print"Power factor=",round(pf,3)
print"Power consumed=",round(P,1),"Watts"
import cmath
V=230+1j*0; #Assigning values to parameters
L=10*10**-3;
f=50.0;
R=10.0;
Xl=2*math.pi*f*L;
Xc=1.0/(2*math.pi*f*C);
Z1=10+1j*3.14;
Z2=10-1j*6.37;
Z=(Z1*Z2)/(Z1+Z2);
I=V/Z;
I1=V/Z1;
[r1,t1]=cmath.polar(I1);
I2=V/Z2;
[r2,t2]=cmath.polar(I2);
[r,t]=cmath.polar(Z1);
[ro,th]=cmath.polar(Z2);
[rot,tt]=cmath.polar(Z);
pf1=cos(t);
pf2=cos(th);
pft=cos(tt);
P1=I1*I1*R;
[r4,t4]=cmath.polar(P1);
P2=I2*I2*R;
[r5,t5]=cmath.polar(P2);
print"Total Impedance=",round(Z.real,2),"Ohms"
print"Branch current I1=",I1,"=",cmath.polar(I1),"=",round(r1,2),"Amperes"
print"Branch current I2=",I2,"=",cmath.polar(I2),"=",round(r2,3),"Amperes"
print" Power factor of branch1=",round(pf1,3)
print" Power factor of branch2=",round(pf2,3)
print" Total Power factor=",round(pft,3)
print" Power consumed by branch 1=",P1,"=",cmath.polar(P1),"=",round(r4,2),"Watts"
print" Power consumed by branch 2=",P2,"=",cmath.polar(P2),"=",round(r5,2),"Watts"
#In the book the answer is given in the polar form.
import cmath
Vm=100.0; #Assigning values to parameters
w=3.0;
#function v=f(t), v=Vm*sin(w*t), endfunction #Defining voltage equation
V=Vm/sqrt(2)+0*1j;
L=1.0/3;
Xl=w*L;
C=1.0/6;
Xc=1.0/(w*C);
Z1=1+1j*1;
Z2=1-1j*2;
I1=V/Z1;
[r,t]=cmath.polar(I1);
I2=V/Z2;
[r1,t1]=cmath.polar(I2);
I=I1+I2;
[r2,t2]=cmath.polar(I);
print"Branch current I1=",I1,"=",cmath.polar(I1),"=",round(r,3),"A"
print"Branch current I2=",I2,"=",cmath.polar(I2),"=",round(r1,3),"A"
print"Total current=",I,"=",cmath.polar(I),"=",round(r2,3),"A"
#In the book the final answer is given in the polar form.
import cmath
Z1=10+1j*15; #Assigning values to parameters
Z2=6-1j*8;
I=15.0;
Z=(Z1*Z2)/(Z1+Z2);
V=I*Z;
I1=V/Z1;
I2=V/Z2;
P1=I1**2*real(Z1);
[r,t]=cmath.polar(P1);
P2=I2**2*real(Z2);
[r1,t1]=cmath.polar(P2);
print"Power taken by branch 1=",P1,"=",cmath.polar(P1),"=",round(r,3),"Watts"
print"Power taken by branch 2=",P2,"=",cmath.polar(P2),"=",round(r1,3),"Watts"
#In the book the final answer is given in the polar form.
V=200; #Assigning values to parameters
f=50;
Ra=10;
La=0.12;
Rb=20;
Cb=40*10**-6;
Xla=2*math.pi*f*La;
Xcb=1/(2*math.pi*f*Cb);
Za=Ra+1j*Xla;
Zb=Rb-1j*Xcb;
Zeq=(Za*Zb)/(Za+Zb);
[r,t]=cmath.polar(Zeq);
Ia=V/Za;
[r1,t1]=cmath.polar(Ia);
Ib=V/Zb;
[r2,t2]=cmath.polar(Ib);
pf=cos(t);
print"Branch current 1=",Ia,"=",cmath.polar(Ia),"=",round(r1,3),"A"
print"Branch current 2=",Ib,"=",cmath.polar(Ib),"=",round(r2,3),"A"
print"power factor=",round(pf,2)
#In the book the final answer is given in the polar form.
Z1=14.14-1j*14.14; #Assigning values to parameters
Z2=26+1j*15;
I=10;
Zeq=Z1+Z2;
V=I*Zeq;
Zeq=(Z1*Z2)/(Z1+Z2);
I=V/Zeq;
[r,t]=cmath.polar(I);
print"Supply current=",I,"=",cmath.polar(I),"=",round(r,3),"A"
#In the book the final answer is given in the polar form.
I=25*1j; #Assigning values to parameters
Z1=3-1j*4;
Z2=10;
I1=I*Z2/(Z1+Z2);
[r,t]=cmath.polar(I1);
I2=I-I1;
[r1,t1]=cmath.polar(I2);
print"Current I1=",I1,"=",cmath.polar(I1),"=",round(r,3),"A"
print"Current I2=",I2,"=",cmath.polar(I2),"=",round(r1,3),"A"
#In the book the final answer is given in the polar form.
import cmath
V=120+1j*160; #Assigning values to parameters
Z1=12+1j*16;
Z2=10-1j*20;
I1=V/Z1;
I2=V/Z2;
[r,t]=cmath.polar(Z1);
kW1=(V*I1*cos(t))/1000;
[r1,t1]=cmath.polar(kW1);
kVAR1=(V*I1*sin(t))/1000;
[r2,t2]=cmath.polar(kVAR1);
kVA1=(V*I1)/1000;
[r3,t3]=cmath.polar(kVA1);
[ro,th]=cmath.polar(Z2);
kW2=(V*I2*cos(th))/1000;
[r4,t4]=cmath.polar(kW2);
kVAR2=(V*I2*sin(th))/1000;
[r5,t5]=cmath.polar(kVAR2);
kVA2=(V*I2)/1000;
[r6,t6]=cmath.polar(kVA2);
Zeq=(Z1*Z2)/(Z1+Z2);
[R,T]=cmath.polar(Zeq);
pf=cos(T);
print"kW1=","=",kW1,cmath.polar(kW1),"=",round(r1,2)
print"kVAR1=",kVAR1,"=",cmath.polar(kVAR1),"=",round(r2,2)
print"kVA1=",kVA1,"=",cmath.polar(kVA1),"=",round(r3,2)
print"kW2=",kW2,"=",cmath.polar(kW2),"=",round(r4,2)
print"kVAR2=",kVAR2,"=",cmath.polar(kVAR2),"=",round(r5,2)
print"kVA2=",kVA2,"=",cmath.polar(kVA2),"=",round(r6,2)
print"Power factor=",round(pf,2)
#In the book the final answer is given in the polar form.
R=30.0; #Assigning values to parameters
I=5.0;
V=110.0;
f=50.0;
I1=V/R;
I2=sqrt(I**2-I1**2);
Xc=V/I2;
C=1.0/(2*math.pi*f*Xc);
print"Unknown capacitance when total current drawn is 5 A=",round(C,8),"Farad"
Inew=4.0;
I2new=sqrt(Inew**2-I1**2);
I2new1=round(I2new,2);
Xc=110/1.59;
f=1.0/(2*math.pi*C*Xc);
print"Frequency when total current drawn is 4 A=",round(f,2),"HZ"
L1=0.0191 #Assigning values to parameters
f=50;
Xl1=2*math.pi*f*L1;
C=398*10**-6;
Xc=1/(2*math.pi*f*C);
L3=0.0318
Xl3=2*math.pi*f*L3;
Z1=2+1j*Xl1;
Z2=7-1j*Xc;
Z3=8+1j*Xl3;
Zeq=((Z1*Z2)/(Z1+Z2))+Z3;
[r,t]=cmath.polar(Zeq)
print"Equivalent Impedance=",Zeq,"=",cmath.polar(Zeq),"=",round(r,3),"ohms"
#In the book the final answer is given in the polar form.
Za=10+1j*8; #Assigning values to parameters
Zb=9-1j*6;
Zc=3+1j*2;
V2=100;
I=V2/Zc;
Ia=(I*Zb)/(Za+Zb);
[r,t]=cmath.polar(Ia);
Ib=I-Ia;
[r1,t1]=cmath.polar(Ib);
print"Current Ia=",Ia,"=",cmath.polar(Ia),"=",round(r,4),"Amperes"
print"Current Ib=",Ib,"=",cmath.polar(Ib),"=",round(r1,3),"Amperes"
import cmath
Im1=20.0; #Assigning values to parameters
Im2=40.0;
Im=25.0;
#function i1=f(wt), i1=Im1*sin(wt), endfunction
#function i2=f(wt), i2=Im2*sin(wt+%pi/6), endfunction
#function i=f(wt), i=Im*sin(wt+%pi/6), endfunction
Z=6+1j*8;
I1=Im1/sqrt(2);
I2=24.49+1j*14.14;
I=15.31+1j*8.84;
I3=I-(I1+I2);
[r,t]=cmath.polar(I3);
V=I*Z;
[r1,t1]=cmath.polar(V);
P=V*I*cos(t);
[r2,t2]=cmath.polar(P);
Z1=V/I1;
[r3,t3]=cmath.polar(Z1);
print"Current I3=",I3,"=",cmath.polar(I3),"=",round(r,3),"Amperes"
print"Supply Voltage V=",V,"=",cmath.polar(V),"=",round(r1,3),"Volts"
print"Active Power P=",P,"=",cmath.polar(P),"=",round(r2,3),"Watts"
print"Impedance Z1=",Z1,"=",cmath.polar(Z1),"=",round(r3,3),"Ohms"
Z=8.66+1j*5; #Assigning values to parameters
Y=1.0/Z;
G=real(Y);
B=imag(Y);
print"G =",round(G,4),"Mho"
print"B =",round(-B,2),"Mho"
import cmath
V=230.0; #Assigning value to parameters
f=50.0;
Z1=8.66-5*1j;
Z2=10+17.32*1j;
Z3=40;
Y1=1.0/Z1;
[r1,t]=cmath.polar(Y1)
Y2=1.0/Z2;
[r2,t]=cmath.polar(Y2)
Y3=1.0/Z3;
[r3,t]=cmath.polar(Y3);
Y=Y1+Y2+Y3;
[r4,t]=cmath.polar(Y);
Z=1/Y;
[r,t]=cmath.polar(Z);
I=V/Z.real
[r5,t5]=cmath.polar(I);
pf=cos(t);
P=V*I*pf;
[r6,t6]=cmath.polar(P);
print"Y1=",Y1,"=",cmath.polar(Y1),"=",round(r1,2),"Mho"
print"Y2=",Y2,"=",cmath.polar(Y2),"=",round(r2,2),"Mho"
print"Y3=",Y3,"=",cmath.polar(Y3),"=",round(r3,3),"Mho"
print"Equivalent Admittance Y=",Y,"=",cmath.polar(Y),"=",round(r4,4),"Ohms"
print"Equivalent Impedance Z=",Z,"=",cmath.polar(Z),"=",round(r,3),"Ohms"
print"Total current I=",I,"=",cmath.polar(I),"=",round(r5,2),"Amperes"
print"Power consumed P=",P,"=",cmath.polar(P),"=",round(r6,2),"Watts"
print"Power factor pf=",round(pf,4)
#In the book the final answer is given in the polar form.
V=200; #Assigning values to parameters
Z1=5*1j;
Z2=5+1j*8.66;
Z3=15;
Z4=-10*1j;
Y1=1.0/Z1;
Y2=1.0/Z2;
Y3=1.0/Z3;
Y4=1.0/Z4;
Yeq=Y1+Y2+Y3+Y4;
Zeq=1.0/Yeq;
I=V/Zeq;
[r,t]=cmath.polar(I);
print"Total current","=", I,"=",cmath.polar(I),"=",round(r,2),"A"
#In the book the final answer is given in the polar form.
Xl=4.0; #Assigning values to parameters
Xc=8.0;
Z1=1.0;
Z2=4*1j;
Z3=-1j*8;
Zeq=Z1+(Z2*Z3)/(Z2+Z3);
Y=1.0/Zeq;
[r,t]=cmath.polar(Y);
print"Admittance=",Y,"=",cmath.polar(Y),"=",round(r,3),"Mho"
Xl=10.0;
Xc=5.0;
Z1=1.0;
Z2=10.0*1j;
Z3=-1j*5;
Zeq=Z1+(Z2*Z3)/(Z2+Z3);
Y=1.0/Zeq;
[r,t]=cmath.polar(Y);
print"Admittance=",Y,"=",cmath.polar(Y),"=",round(r,4),"Mho"
import cmath
Z1=14+1j*5; #Assigning values to parameters
Z2=18+1j*10;
V=200;
Y1=1.0/Z1;
[r0,t0]=cmath.polar(Y1);
Y2=1.0/Z2;
[r3,t3]=cmath.polar(Y2);
Yeq=Y1+Y2;
[r4,t4]=cmath.polar(Yeq);
Zeq=1.0/Yeq;
I1=V/Z1;
[r5,t5]=cmath.polar(I1);
I2=V/Z2;
[r6,t6]=cmath.polar(I2);
I=V/Zeq;
[r7,t7]=cmath.polar(I);
P1=I1**2*real(Z1);
[r8,t8]=cmath.polar(P1);
P2=I2**2*real(Z2);
[r9,t9]=cmath.polar(P2);
[r,t]=cmath.polar(Zeq);
[r1,t1]=cmath.polar(Z1);
[r2,t2]=cmath.polar(Z2);
pf1=cos(t1);
pf2=cos(t2);
pf=cos(t);
print"Y1=",Y1,"=",cmath.polar(Y1),"=",round(r0,3),"Mho"
print"Y2=",Y2,"=",cmath.polar(Y2),"=",round(r3,3),"Mho"
print"Yeq=",Yeq,"=",cmath.polar(Yeq),"=",round(r4,3),"Mho"
print"Branch current I1=",I1,"=",cmath.polar(I1),"=",round(r5,3),"Amperes"
print"Branch current I2=",I2,"=",cmath.polar(I2),"=",round(r6,3),"Amperes"
print"Total current I=",I,"=",cmath.polar(I),"=",round(r7,2),"Amperes"
print"Power consumed by branch1=",P1,"=",cmath.polar(P1),"=",round(r8,3),"Watts"
print"Power consumed by branch2=",P2,"=",cmath.polar(P2),"=",round(r9,3),"Watts"
print"Power factor of branch1=",round(pf1,3)
print"Power factor of branch2=",round(pf2,3)
print"Total Power factor=",round(pf,3)
import cmath
V=230; #Assigning values to parameters
f=50;
L=0.08;
Xl=2*math.pi*f*L;
C=200*10**-6;
Xc=1/(2*math.pi*f*C);
Z1=20+1j*25.13;
Z2=10-1j*15.92;
Y1=1.0/Z1;
Y2=1.0/Z2;
Y=Y1+Y2;
I=V*Y;
[r,t]=cmath.polar(I);
pf=cos(t);
Z=1.0/Y;
[r1,t1]=cmath.polar(Z)
R=real(Z);
Xc=-1*imag(Z);
C=1.0/(2*math.pi*f*Xc);
[r2,t2]=cmath.polar(C);
print"Supply Current=",I,"=",cmath.polar(I),"=",round(r,2),"A"
print"Power factor=",round(pf,3)
print"Total impedance=",Z,"=",cmath.polar(Z),"=",round(r1,2),"Ohms"
print"Resistance of eequivalent series circuit=",R,"=",cmath.polar(R),"=",round(r1,2),"Ohms"
print"Capacitance of eequivalent series circuit=",C,"=",cmath.polar(C),"=",round(r2,5),"Farads"
V=200; #Assigning values to parameters
Z1=3+4*1j;
Z2=4-1j*3;
Z3=4.57+1j*5.51;
Y1=1.0/Z1;
Y2=1.0/Z2;
Yab=Y1+Y2;
Zab=1.0/Yab;
Z=Zab+Z3;
[r,t]=cmath.polar(Z);
I=V/r
pf=cos(t);
print"Total Impedance=",Z,"=",cmath.polar(Z),"=",round(r,2),"Ohms"
print"Supply current=",round(I,2),"A"
print"Power factor=",round(pf,4)
C=2.5*10**-6; #Assigning values to parameters
R=15.0;
L=260*10**-3;
temp=(1.0/(L*C))-(R**2/L**2);
fr=(1.0/20*math.pi)*sqrt(temp);
Q=(2*math.pi*fr*L)/R;
Zr=L/(C*R);
print"Resonant frequeny=",round(fr,2),"Hertz"
print"Quality factor=",round(Q,2)
print"Dynamic Impedance=",round(Zr,2),"Ohms"
#the answer of the fr in the book is wrong
import math
C=200*10**-6; #Assigning values to parameters
V=230.0;
R=20.0;
L=0.2;
temp=((1.0/(L*C))-(R**2/L**2));
fr=sqrt(temp)/(2*math.pi);
Zr=L/(C*R);
Ir=V/Zr;
Zl=sqrt(R**2+(2*math.pi*fr*L)**2);
Il=V/Zl;
Xc=1.0/(2*math.pi*fr*C);
Ic=V/Xc;
phi=math.atan(2*math.pi*fr*L/R);
phi=math.degrees(phi);
print"Resonant frequency",round(fr,2),"Hertz"
print"Dynamic impedance of the circuit=",round(Zr,2),"Ohms"
print"circuit current Ir=",round(Ir,2),"A"
print"current Il=",round(Il,2),"A"
print"current Ic=",round(Ic,2),"A"
print"phase angle of the coil phi=",round(phi,2),"degrees"
pfcoil=0.3; #Assigning values to parameters
phi=math.acos(pfcoil);
V=100.0;
f=50.0;
Il=1.0;
Ic=Il*sin(phi);
Xc=V/Ic;
C=1.0/(2*math.pi*f*Xc);
Ir=Il*cos(phi);
Zr=V/Ir;
print"Capacitance=",round(C,8),"Farads"
print"Dynamic impedance=",round(Zr,2),"Ohms"
V=200.0; #Assigning values to parameters
f=50.0;
L=20.0;
R=15.0;
Zl=sqrt(R**2+L**2);
pfcoil=R/Zl;
phi=math.acos(pfcoil);
Il=V/Zl;
Ic=Il*sin(phi);
Xc=V/Ic;
C=1/(2*math.pi*f*Xc);
Ir=Il*math.cos(phi);
print"Power factor=",round(pfcoil,2)
print"Current=",round(Il.real,2),"A"
print"Value f shunting capacitance=","{:.4e}".format(C),"Farads"
print"Circuit current at resonance=",round(Ir.real,2),"A"