import math
from scipy.linalg import polar
#Problem 10.4")
#For V1
Ro1 = 25
Theta1 = 143.13
#For V1
Ro2 = 11.2
Theta2 = 26.57
#We need to find V1/V2
#Let V = V1/V2
Vmag = (Ro1/Ro2)
Vph = Theta1-Theta2
x = Vmag*math.cos((Vph*math.pi)/180);
y = Vmag*math.sin((Vph*math.pi)/180);
z = complex(x,y)
#Let V1+V2 = V12
x1 = Ro1*math.cos((Theta1*math.pi)/180);
y1 = Ro1*math.sin((Theta1*math.pi)/180);
z1 = complex(x1,y1)
x2 = Ro2*math.cos((Theta2*math.pi)/180);
y2 = Ro2*math.sin((Theta2*math.pi)/180);
z2 = complex(x2,y2)
V12 = z1+z2
print V12
R,Theta = polar([[V12]])
print R,Theta
# Results
print "V1/V2 = %0.2f+i*%3.2f V1+V2 = %3.2f%3.2f deg)"%(x, y,R[0,0].real,Theta[0,0].real*180/math.pi)
import math
#Problem 10.5")
# Given
#Voltage is 100(45 deg)")
#Current is 5(15 deg)")
#For V
Ro1 = 100
Theta1 = 45
#For I
Ro2 = 5
Theta2 = 15
#We need to find V/I = Z
Zmag = (Ro1/Ro2)
Zph = Theta1-Theta2
x = Zmag*math.cos((Zph*math.pi)/180);
y = Zmag*math.sin((Zph*math.pi)/180);
z = complex(x,y)
#Let Y = 1/Z
Ymag = (Ro2/Ro1)
Yph = Theta2-Theta1
x1 = Ymag*math.cos((Yph*math.pi)/180);
y1 = Ymag*math.sin((Yph*math.pi)/180);
z1 = complex(x1,y1)
# Results
print "R = %3.2fohm XL = %3.2fH G = %0.3fS BL = %0.3fS"%(x,y,x1,abs(y1));
import math
from scipy.linalg import polar
#Problem 10.7")
print "Voltage v1 = 5*math.cosw1*t"
print "Voltage v2 = 10*math.cosw2*t+60"
#The circuit is modeled as
#resistance is 10ohm and inducmath.tance is 5mH")
R = 10;
L = 5*10**-3;
#a)")
w1 = 2000;
w2 = 2000;
#Let Z be the impedance of the coil
Z1 = R+1j*L*w1
Z2 = R+1j*L*w2
#Let V be phasor voltage between the terminals
Vmag = 10;
Vph = 60;
x = Vmag*math.cos((Vph*math.pi)/180);
y = Vmag*math.sin((Vph*math.pi)/180);
z = complex(x,y)
v = 5-z;
#Let I be the current
I = v/Z1
R,Theta = polar([[I]])
R = R[0,0].real
Theta = Theta[0,0].real
print "i = %0.2f*math.cos%dt%d deg)"%(R,w1,Theta*180/math.pi);
#b)")
R = 10;L = 5*10**-3;
w1 = 2000;w2 = 4000;
#Let Z be the impedance of the coil
Z1 = R+1j*L*w1
Z2 = R+1j*L*w2
V1 = 5;
#By applying superposition i = i1-i2
I1 = V1/Z1
R,Theta = polar([[I1]])
R = R[0,0].real
Theta = Theta[0,0].real
print "i1 = %0.2f*math.cos%dt%d deg)"%(R,w1,Theta*180/math.pi);
V2mag = 10;V2ph = 60;
I2 = z/Z2
R1,Theta1 = polar([[I2]])
R1 = R1[0,0].real
Theta1 = Theta1[0,0].real
print "i2 = %0.2f*math.cos%dt%3.2f deg)"%(R1,w2,Theta1*180/math.pi);
#i = i1-i2
print "i = %0.2f*math.cos%dt%d deg)-%0.2f*math.cos%dt%3.2f deg)"%(R,w1,Theta*180/math.pi,R1,w2,Theta1*180/math.pi)