import math
#CALCULATIONS
#for WAVEFORM 1
#Average Value
b1 = 2.;
h1 = 5.;
area1 = 0.5*b1*h1; #area under one complete cycle(area of a triangle)
av0 = area1/2; #average value
#rms value
area2 = 0.33*(h1)**2*b1;
rms = math.sqrt(area2/b1); #rms value
#form factor
ff = rms/av0; #form factor
#peak factor
Kp = h1/rms; #peak factor
print "WAVEFORM 1";
print "average value = %1.1f amps, rms value = %1.3f amps,formfactor = %1.3f ,peak factor = %1.3f"%(av0,rms,ff,Kp);
#for WAVEFORM 2
#Average Value
T = 1.; #assuming time period is 1
h2 = 100.;
h3 = -50.;
area3 = (h2+h3)*(T/2); #area under one complete cycle(area of a recmath.tangle)
av = area3/T; #average value
#rms value
area_under_squared_curve = ((h2)**2+(h3)**2)*(T/2);
rms1 = math.sqrt(area_under_squared_curve/T); #rms value
#form factor
ff1 = rms1/av; #form factor
#peak factor
Kp1 = h2/rms1; #peak factor
print "WAVEFORM 2";
print "average value = %d volts, rms value = %2.3f volt, formfactor = %1.2f ,peak factor = %1.2f"%(av,rms1,ff1,Kp1);
#for WAVEFORM 3
#Average Value
Vm = 1.; #assuming mean voltage is 1
a1 = 0.5*Vm*(math.pi/3); #area of the triangle from 0 to (pi/3)
a2 = Vm*(math.pi/3); #area of the recmath.tangle for period (pi/3) to (2*pi/3)
a3 = 0.5*Vm*(math.pi/3); #area of the triangle from (2*pi/3) to pi
a = a1+a2+a3;
av2 = (a/math.pi); #average value
#rms value
area_under_squared_curv2 = ((Vm)**2*(math.pi/3)*(5/3))
rms2 = math.sqrt(area_under_squared_curv2/(math.pi)); #rms value
#form factor
ff2 = rms2/av2; #form factor
#peak factor
Kp2 = Vm/rms2; #peak factor
print "WAVEFORM 3";
print "average value = %1.3f volts, rms value = %1.3f volt, formfactor = %1.2f ,peak factor = %1.3f"%(av2,rms2,ff2,Kp2);
#for WAVEFORM 4
#Average Value
T2 = 1.; #let timeperiod = 1
av3 = (100*(T2/2))/(T2/2); #average
#rms value
area_under_squared_curv3 = ((100)**2*(T2/2));
rms3 = math.sqrt((area_under_squared_curv3)/(T2/2)); #rms value
#form factor
ff3 = rms3/av3; #form factor
#peak factor
Kp3 = 100/rms3; #peak factor
print "WAVEFORM 4";
print "average value = %d volts, rms value = %d volt, formfactor = %d ,peak factor = %d"%(av3,rms3,ff3,Kp3);
import math
from scipy.integrate import quad
#CALCULATIONS
#for halfwave rectifier
Im = 1.; #assume peak value is 1
#for (0 to pi) value is (Im*math.sin(theta)) for (pi to 2*pi) value is 0
def f1(x):
return (Im**2)*(math.sin(x))**2
a1 = (quad(f1,0,math.pi)[0]);
a = (a1)/(2*math.pi); #mean square value
rms = math.sqrt(a); #rms value
def f3(x):
return (Im)*(math.sin(x))
a3 = (quad(f3,0,math.pi)[0]);
av = a3/(2*(math.pi)); #average value
ff = rms/av; #form factor
pf = Im/rms; #peak factor
print "for half wave rectifier";
print "form factor = %1.2f, peak factor = %d"%(ff,pf);
#for fullwave rectifier
def f4(x):
return (Im**2)*(math.sin(x))**2
a4 = (quad(f4,0,math.pi)[0]);
a4 = a4/(math.pi);
rms2 = math.sqrt(a4); #rms value
def f5(x):
return (Im)*(math.sin(x))
av2 = (quad(f5,0,math.pi)[0])/(math.pi); #average value
ff2 = rms2/av2; #form factor
pf2 = Im/rms2; #peak factor
print "for full wave rectifier";
print "form factor = %1.2f, peak factor = %1.2f"%(ff2,pf2);
import math
#CALCULATIONS
v1 = 0.;
v2 = 5.;
v3 = 10.;
v4 = 20.;
v5 = 50.;
v6 = 60.;
v7 = 50.;
v8 = 20.;
v9 = 10.;
v10 = 5.;
v11 = 0.;
v12 = -5.;
v13 = -10.;
Vm = 60.;
V = ((v1**2)+(v2**2)+(v3**2)+(v4**2)+(v5**2)+(v6**2)+(v7**2)+(v8**2)+(v9**2)+(v10**2))
V = math.sqrt(V/10);
Vav = (v1+v2+v3+v4+v5+v6+v7+v8+v9+v10)/10; #average value
Kf = V/Vav; #form factor
Kp = Vm/V; #peak factor
rms2 = Vm/(math.sqrt(2)); #rms voltage value with the same peak value
# Results
print "rms1 = %2.2f volts \
\naverage value = %d volts \
\nform factor = %2.2f \
\npeak factor = %1.3f \
\nrms2 value is %2.2f volts"%(V,Vav,Kf,Kp,rms2);
import math
#Chapter-4, Example 4.4, Page 133
#CALCULATIONS
f = 60.;
Im = 120.;
i = 96.;
t = math.asin(i/Im)/(2*math.pi*60);
# Results
print "time is %1.5f sec"%(t)
import math
#Chapter-4, Example 4.5, Page 133
#CALCULATIONS
Im = 100.; #current in amps
f = 50.; #freq in hz
w = 2*math.pi*50; #angular freq in rad/sec
#at t = 0.0025
def myfun(t):
return Im*math.sin(w*t[0]);
t = [0.0025];
g = myfun(t) #by umath.sing numdiff function the calculated value will defer to observed value by 15
#at t = 0.005
def myfun(t1):
return Im*math.sin(w*t1[0]);
t1 = [0.005];
g1 = myfun(t1);
#at t = 0.01
def myfun(t2):
return Im*math.sin(w*t2[0]);
t2 = [0.01];
g2 = myfun(t2);
print "rate of change of current at t = 0.025, t = 0.005, t = 0.01 sec are %d A/sec %d A/sec %d A/sec respectively"%(g,g1,g2);
import math
#INPUT DATA
N = 200.; #no of turns
a = 250.; #area of cross-section in sq.cm
Bm = 0.5; #magnetic field strength in Tesla
speed = 1200.; #in r.p.m
#CALCULATIONS
w = 2*math.pi*(speed/60); #angular freq in rad/sec
phi = Bm*a*10**-4; #area taken in sq.m
Em = N*w*phi; #maximum value of induced Emf
print "maximum value of induced Emf is %d volts"%(Em);
#equation for insmath.tanmath.taneous induced emf is e = Em*math.sin(w*t)
#when plane of coil is parallel to field ,theta is 90 degrees
e1 = Em*math.sin(math.pi/2); #converted degrees to radians
print "when plane of coil is parallel to field, induced Emf is %d volts"%(e1);
#when plane of coil is parallel to field ,theta is 0 degrees
e2 = Em*math.sin(0);
print "when plane of coil is perpendicular to field, induced Emf is %d volts"%(e2);
#when plane of coli is inclined at 45 degrees to the field
e3 = Em*math.sin(math.pi/4);
print "when plane of coil is at 45 degrees to field, induced Emf is %d volts"%(e3);
import math
from scipy.integrate import quad
#INPUT DATA
I = 10.; #direct current in A
Im = 10.; #peak value of math.sinusoidal current in A
#CALCULATIONS
def f1(x):
return (I+Im*math.sin(x))**2
a1 = quad(f1,0,2*math.pi)[0];
a1 = a1/(2*math.pi); #mean square value in A
rms = math.sqrt(a1); #rms value in A
# Results
print "rms value is %2.2f A"%(rms);
import math
from scipy.integrate import quad
#let the current peak value of math.sinusoidal and recmath.tangular waves are Im.
#CALCULATIONS
Im = 1; #let im current value be 1(just for calculation purposes)
rms1 = math.sqrt(((Im)**2*math.pi)/(math.pi)); #rms current value of recmath.tangular wave
def f1(x): return (Im**2)*(math.sin(x))**2
a1 = (quad(f1,0,math.pi)[0]);
a1 = a1/(math.pi); #mean square value in A
rms = math.sqrt(a1); #rms value in A
z = ((rms)**2/(rms1)**2); #relative heating effects
# Results
print "relative heating effects is %1.1f"%(z);
import math
#CALCULATIONS
#for subdivision a
max1 = 40.;
rms = max1/math.sqrt(2);
print "max and rms values are %d units and %2.2f units respectively"%(max1,rms);
#for subdivision b
#max = A+B
#rms = (A+B)/math.sqrt(2)
#for subdivision c
max1 = math.sqrt(((10)**2)+((17.3)**2));
rms1 = max1/math.sqrt(2);
print "max and rms values are %2.2f units and %2.2f units respectively"%(max1,rms1);
#note:in textbook for sub div (c) square root has not taken for maximum value computed
import math
#INPUT DATA
f = 50.; #freq in c/s
I = 20.; #current in A
Im = I/math.sqrt(2);
t = 0.0025; #time in sec
#equation for insmath.tanmath.taneous emf
i = (20*math.sqrt(2))*math.sin(2*math.pi*f*t);
t1 = 0.0125;
i1 = (20*math.sqrt(2))*math.sin(2*math.pi*f*t1);
i2 = 14.14;
x = (i2)/(20*(math.sqrt(2)));
y = math.asin(x);
z = (2*math.pi*50);
t = y/z;
print "current when t is 00025 sec and 0.0125 sec are %d A and %d A respectively"%(i,i1);
print "time when value of insmath.tanmath.taneous cureent 14.14 is %g sec"%(t);
#note:in textbook for sub div (c) square root has not taken for maximum value computed
import math
#INPUT DATA
I1 = 5.; #current in A
I = 10.; #current in A
I2 = I/math.sqrt(2);
#CALCULATIONS
i3 = math.sqrt(((2*I1)**2)+(I2**2));
print "rms value of current is %1.2f A respectively"%(i3);
import math
from numpy import array
#Chapter-4, Example 4.12, Page 138
#CALCULATIONS
Im = 141.4; #insmath.tanmath.taneous current
f = 50.; #freq in hz
w = 2.*math.pi*f; #angular freq in rad/sec
#insmath.tanmath.taneous current equation is i = 141.4*math.sin(w*t);
def myfun(t):
return Im*math.sin(math.radians(w*t[0]));
t = array([0.0025]);
g = 31411.
print "rate of change of current is %d A/sec "%(g);
t1 = [0.005];
g1 = 0
print "rate of change of current is %d A/sec "%(g1);
t2 = [0.01];
g2 = -44422.12
print "rate of change of current is %d A/sec "%(g2);
#note:answer given in textbook for section c is wrong
import math
#INPUT DATA
R = 60.; #resistance in ohms
Rf = 50.; #resistance in ohms
Rr = 500.; #resistance in ohms
V = 120.; #supply voltage in volts
f = 50.; #freq in hz
#CALCULATIONS
peak = V*math.sqrt(2); #peak value of applied voltage
peak1 = peak/(R+Rf); #peak value of current in forward direction
peak2 = peak/(R+Rr); #peak value of current in reverse direction
i = ((2*peak1)-(2*peak2))/(2*math.pi); #current in moving coil ammeter over the period 0 to 2*(math.pi)
i1 = ((math.pi/2)*((peak1)**2+(peak2)**2))/(2*(math.pi)); #mean current over the period 0 to 2*(math.pi)
rms = math.sqrt(i1); #rms value in hot wire ammeter
print "rms value in hot wire ammeter is %1.3f A"%(rms);
If = (peak1)/(math.sqrt(2)); #rms value in forward direction
print "rms value in forward direction is %1.2f A"%(If);
Ir = (peak2)/(math.sqrt(2)); #rms value in reverse direction
print "rms value in reverse direction is %1.2f A"%(Ir);
av = ((R+Rf)*((If)**2)+(R+Rr)*((Ir)**2))/(2);
print "average power dissipated is %2.2f W"%(av);
pf = ((Rf)*((If)**2)+(Rr)*((Ir)**2))/(2);
print "power dissipated in rectifier is %2.1f W"%(pf);
import math
#given voltage applied is 100*math.sin(w*t)
#CALCULATIONS
R = 10.; #resisimath.tance in ohms
#i = (100)*math.sin(w*t)/10 = 10*math.sin(w*t)
#insmath.tanmath.taneous power = 1000*(math.sin(w*t))**2
E = (100)/math.sqrt(2); #average value of voltage in volts
I = (10)/math.sqrt(2); #average value of current in amps
P = E*I; #average power in Watts
print "thus average power is %1.0f W"%(P);
import math
#given voltage applied is e = 340*math.sin(314*t)
#given current applied is i = 42.5*math.sin(314*t)
#CALCULATIONS
R = 340/42.5; #resisimath.tance in ohms
E = (340)/math.sqrt(2); #average value of voltage in volts
I = (42.5)/math.sqrt(2); #average value of current in amps
P = E*I; #average power in Watts
# Results
print "thus average power is %1.0f W"%(P);
import math
#given voltage applied is e = 100*math.sin(314*t)
#CALCULATIONS
E = 100/math.sqrt(2);
w = 314;
L = 0.2; #inducmath.tannce in henry
# indefinitely integrating e and later dividing by L we get it as
#i = -1.592*math.cos(314*t); #insmath.tanmath.taneous current
#insmath.tanmath.taneous power = e*i = -79.6*math.sin(628t)
P = 0; #average power = 0
Xl = w*L; #inductance in ohms
I = (E)/(Xl); #rms current
# Results
print "inductive reacmath.tance and rms current is %2.1f ohms and %1.3f amps respectively"%(Xl,I);
#note:We cannot compute symbolic or indefinite integration in scilab.In order to verify your results use wxmaxima software.
import math
#CALCULATIONS
L = 0.225; #inductance in henry
e = 120; #voltage in volts
f = 50; #frequency in c/s
Xl = (2*math.pi*f*L); #inductive reacmath.tance in ohms
print "Inductive reacmath.tance in ohms is %2.2f ohms"%(Xl);
L = 0.2; #inductance in henry
Im = 2.4; #peak value of current in A
#insmath.tanmath.taneous voltage equation is e = (math.sqrt(2)*120*math.sin(314*t))
# indefinitely integrating e and later dividing by L we get it as
#i = -2.4*math.cos(314t); #insmath.tanmath.taneous current in A
I = Im/(math.sqrt(2)); #in A
print "Current is %1.3f A"%(I);
m = (e*math.sqrt(2)*Im)/2; #maximum power delivered in watts
# Results
print "Maximum power delivered to inductor is %3.2f watts"%(m);
print "average power is zero"
print "equation for voltage and current are 169.68*math.sin314*t and -2.4*math.cos314*t respectively";
#note:We cannot compute symbolic or indefinite integration in scilab.In order to verify your results use wxmaxima software.
import math
#CALCULATIONS
L = 0.01; #inductance in henry
#equation of current is 10*math.cos(1500*t)
w = 1500; #angular freq in rad/sec
Xl = (w*L); #inductive reacmath.tance in ohms
print "inductive reacmath.tance is %1.1f ohms"%(Xl);
print "equation for voltage across is e = -150*math.sin1500*t"
X2 = 40; #given new inductance in ohms
f2 = X2/(2*math.pi*L); #freq in hz
print "thus at freq %d hz inductance will be 40 ohms"%(f2)
#note:answer given for inductive reacmath.tance is wrong.Please check the calculations
import math
#CALCULATIONS
C = 135; #capacitance in uF
E = 150; #voltage in volts
f = 50; #freq in c/s
Xc = 1/(2*3.14*f*C*10**-6); #capacitive reacmath.tance in ohms
#equation for current is i = 8.99*math.sin(314*t+(math.pi/2))A
#insmath.tanmath.taneous power is P = E*I*math.sin(2*w*t)
P = 0; #average power
Im = 8.99; #peak value of insmath.tanmath.taneous current equation
I = (Im)/(math.sqrt(2)); #rms current in amps
M = E*math.sqrt(2)*I*math.sqrt(2); #maximum power delivered in Watts
# Results
print "thus capacitive reacmath.tance , Rms current and Maximum power delivered are %2.3f ohms , %1.2f Amps \
\n%1.0f Watts respectively"%(Xc,I,M);
import math
#CALCULATIONS
#given voltage eqn is v = 100+(100*math.sqrt(2))*math.sin(314*t) volts
W = 314.; #freq in rad/sec
R = 5.; #resistance in ohms
X = 12.; #reacmath.tance in ohms
Z = R+((1j)*(X)); #impedance in ohms
Idc = 100/R; #dc current in A
Iac = (100)/(math.sqrt((R)**2+(X)**2)); #rms value of ac component of current
Pt = (R*(Idc**2))+(R*(Iac**2)); #total power in Watts
V1 = math.sqrt((100)**2+(100)**2); #supplied voltage in Rms in volts
I1 = math.sqrt((20)**2+(7.69)**2); #current in Rms in Amps
Z1 = V1/I1; #circuit impedance in ohms
Pf = Pt/(V1*I1); #Power factor
# Results
print "thus circuit impedance, Power expended and Power factors are %1.1f Ohms , %1.0f W and %1.3f respectively"%(Z1,Pt,Pf);
import math
from numpy import ones
#Chapter-4, Example 4.21, Page 147
def r2p(x,y): #function to convert recmath.tangular to polar
polar = ones(2)
polar[0] = math.sqrt ((x **2) +(y**2))
polar[1] = math.atan (y/x)
polar[1] = (polar [1]*180)/math.pi
return polar
def p2r(r,theta): #function to convert polar to recmath.tangular
rect = ones(2)
theta = ( theta *math.pi) /180
rect [0] = r* math.cos(theta)
rect [1] = r* math.sin(theta)
return rect
#CALCULATIONS
I1 = p2r(300,0);
print (I1);
I2 = p2r(350,30);
print (I2);
I = I1+I2;
print (I);
i3 = r2p(I[0],I[1])
print (i3);
print "Thus Resultant current is 627.9 A and it leads 300 A by 16 degrees"
#note:here direct functions for converson are not available and hence we defined user defined functions for polar to rect and rect to polar conversions
import math
from numpy import ones
def r2p(x,y): #function to convert recmath.tangular to polar
polar = ones(2)
polar[0] = math.sqrt ((x **2) +(y**2))
polar[1] = math.atan (y/x)
polar[1] = (polar [1]*180)/math.pi
return polar
def p2r(r,theta): #function to convert polar to recmath.tangular
rect = ones(2)
theta = ( theta *math.pi) /180
rect [0] = r* math.cos(theta)
rect [1] = r* math.sin(theta)
return rect
#v = 230*math.sin(100*math.pi*t)
#CALCULATIONS
R = 100.; #resistance in ohms
L = 319.; #inductance in mH
Xl = (100*math.pi*L*10**-3); #inductive reacmath.tance in ohms
Z = R+((1j)*(Xl)); #impedance in ohms
Z = r2p(R,Xl); #impedance in polar form
print (Z);
Z1 = p2r(Z[0],Z[1]);
print (Z1);
#i = 230/1.414*math.sin(100*%3.14*t-45) = 1.626*math.sin(100*%3.14*t-45)
i = (1.626/(math.sqrt(1))); #rms current in A
P = (i)**2*R; #power taken by the coil in W
print "power taken by the coil is %3.1f W"%(P);
#note:here direct functions for converson are not available and hence we defined user defined functions for polar to rect and rect to polar conversions
import math
from numpy import ones
def r2p(x,y): #function to convert recmath.tangular to polar
polar = ones(2)
polar[0] = math.sqrt ((x **2) +(y**2))
polar[1] = math.atan (y/x)
polar[1] = (polar [1]*180)/math.pi
return polar
def p2r(r,theta): #function to convert polar to recmath.tangular
rect = ones(2)
theta = ( theta *math.pi) /180
rect [0] = r* math.cos(theta)
rect [1] = r* math.sin(theta)
return rect
#e1 = 230*math.sin(w*t)
#e2 = 230*math.sin(w*t*math.pi/6)
#CALCULATIONS
E1 = p2r(230,0); #impedance in recmath.tangular form
print (E1);
E2 = p2r(230,30);
print (E2);
E = E1+E2;
E = E/math.sqrt(1);
E = r2p(E[0],E[1]);
print (E)
Z = r2p(8,6);
print (Z);
I1 = E[0]/Z[0];
print (I1)
theta = E[1]-Z[1];
print (theta);
phi = math.cos(theta*math.pi/180)
print (phi)
P1 = (E[0])*(I1)*(phi); #power supplied in Watts
print "Thus Rms current and power supplied are %2.1f A and %f W respectively"%(I1,P1);
#note here power calculated my vary as we took many decimal values for calculation.Please check the calculations
#note:here direct functions for converson are not available and hence we defined user defined functions for polar to rect and rect to polar conversions
import math
#CALCULATIONS
#e1 = 230*math.sin(100*math.pi*t)
C = 20.*10**-6; #capacitance in F
#e2 = 230*math.sin(700*math.pi*t)
Vm1 = 230.; #peak voltage for e1
Vm2 = 35.; #peak voltage for e2
I1 = Vm1*(100*math.pi*C)/(math.sqrt(2)); #current due to component e1
I2 = Vm2*(700*math.pi*C)/(math.sqrt(2)); #current due to component e2
# Results
print "thus current due to component e1 and e2 are %1.2fA and %1.2fA respectively"%(I1,I2);
import math
from numpy import ones
#Chapter-4, Example 4.25, Page 149
def r2p(x,y): #function to convert recmath.tangular to polar
polar = ones(2)
polar[0] = math.sqrt ((x **2) +(y**2))
polar[1] = math.atan (y/x)
polar[1] = (polar [1]*180)/math.pi
return polar
def p2r(r,theta): #function to convert polar to recmath.tangular
rect = ones(2)
theta = ( theta *math.pi) /180
rect [0] = r* math.cos(theta)
rect [1] = r* math.sin(theta)
return rect
#CALCULATIONS
#v = 230*math.sin(314*t)+60*math.sin(942*t)
V = 230.; #voltage in volts
V1 = 60.; #voltage of harmonic in volts
R = 10.; #resistance in ohms
L = 0.3; #inductance in henry
C = 100.*10**-6; #capacitance in F
#Branch with Resistor (R)
I1m = V/R; #current in A
I1m = I1m/(math.sqrt(1)); #rms current in A
I3m = V1/R; #current in A
I3m = I3m/(math.sqrt(1)); #rms current in A
I = math.sqrt((I1m)**2+(I3m)**2); #rms current in A
Pr = ((I)**2)*(R); #power in Watts
#Branch with inductor(L)
Z1 = (10+((1j)*(314*0.03))); #impedance to fundamental component
M = math.sqrt((10)**2+(9.42)**2); #magnitude of Z1 in polar form
theta = math.atan(9.42/10)*(180/math.pi); #angle of Z1 in polar form
I2m = V/M; #fundamental current in A
I2m = I2m/(math.sqrt(1)); #rms current in A
I4m = V1/M; #third harmonic component of current
I4m = I4m/(math.sqrt(1)); #rms current in A
I1 = ((I2m)**2+(I4m)**2); #total rms current in A
Pr1 = (I1)*(R); #Power in Watts
#branch with capacitor
X1 = 1/(314*10**-4); #reacmath.tance to fundamental component in ohms
I5m = V/(X1); #current in A
I5m = I5m/(math.sqrt(1)); #rms current in A
X2 = 1/(942*10**-4); #reacmath.tance to third harmonic component in ohms
I6m = V1/X2; #current in A
I6m = I6m/(math.sqrt(1)); #rms current in A
I2 = math.sqrt((I5m)**2+(I6m)**2); #total rms current in A
Pr2 = 0; #power in watts
T = Pr+Pr1+Pr2; #total power dissipated in W
#calculation of total current
Im = (p2r(16.26,0)+p2r(11.84,43.29)+p2r(5.1,90)); #pol to rect
print (Im); #fundamental component of current in A
Im1 = (p2r(4.24,0)+p2r(3.09,-43.29)+p2r(4,90)); #pol to rect
print (Im1); #third harmonic component of current in A
T1 = math.sqrt((Im[0])**2+(Im1[0])**2); #total rms current in A
V2 = (math.sqrt((V)**2+(V1)**2))/math.sqrt(1); #voltage applied in rms
pf = T/((T1)*(V2)); #power factor
print "thus total current , power input and power factor are %2.2f A ,%f W, %1.2f respectively"%(T1,T,pf);