#Question:
"""Finding the angle at which the instantaneous value of voltage is 10 V."""
from math import asin,degrees
#Variable Declaration:
Vm=20.0 #Peak value of sinusoidal voltage(in Volts)
#Calculations:
v=10.0 #Instantaneous Voltage(in Volts)
angle=degrees(asin(v/Vm))
#Result:
print "(a)The angle at which the instantaneous value of voltage is 10V is %.2f degrees." %(angle)
print "(b)The maximum value of voltage is Vm=20 V.This occurs twice in one cycle at angles 90 degrees and 270 degrees."
#Question:
"""Finding the time represented by a 60 degrees phase angle."""
from math import pi,sin,radians
#Variable Declaration:
ang_freq=2000.0 #Angular Frequency(in radians per second)
#Calculations:
f=ang_freq/(2*pi)
T=1/f
t=160e-06
v=0.04*sin((2000*t)+radians(60))
t_60=(60.0/360)*T
#Result:
print "(a)The frequency is %.2f Hz." %(f)
print "(b)The angular frequency is %.2f rad/sec." %(ang_freq)
print "(c)The instantaneous voltage when t=60 micro seconds, is %e V." %(v)
print "(d)The time represented by 60 degrees phase angle is %e seconds." %(t_60)
#Question:
"""Finding the equation for the instantaneous value of a sinusoidal voltage."""
from math import pi,sin,radians,degrees,asin
#Variable Declaration:
V_peak_to_peak=20.0 #Peak-to-peak Voltage(in Volts)
#Calculations:
V_m=V_peak_to_peak/2
T=10.0e-03
f=1/T
ang_freq=2*pi*f
phi=180-degrees(asin(3.6/V_m))
t=12e-03
v_12=V_m*sin((ang_freq*t)-radians(phi))
#Result:
print "(a)The equation of the given sinusoidal voltage is v(t)=%.2f sin(%.2ft+%.2f) V." %(V_m,ang_freq,phi)
print "(b)The value of voltage at 12ms would be %.3f V." %(v_12)
#Question:
"""Finding the equation for the instantaneous value of an alternating current."""
from math import pi,sin,asin
#Variable Declaration:
f=60.0 #Frequency of alternating current(in Hertz)
i_m=12.0 #Peak value of the alternating current(in Amperes)
#Calculations:
ang_freq=2*pi*f
t1=1.0/360
i_t1=i_m*sin(ang_freq*t1)
i2=9.6
t2=(asin(9.6/12))/ang_freq
#Result:
print "(a)The equation for the instantaneous value of alternating current is i= %d sin(%.2ft) A." %(i_m,ang_freq)
print "(b)The value of current at t=1/360 second is %.2f A." %(i_t1)
print "(c)The time taken to reach 9.6A for the first time is %e seconds." %(t2)
#Question:
"""Finding the phase difference between two sinusoidal currents."""
from math import pi
#Calculations:
ang_freq=100.0*pi
f=ang_freq/(2.0*pi)
T=1/f
t=(30.0/360.0)*T
#Result:
print "The phase difference in terms of time is %e seconds." %(t)
#Question:
"""Finding the power consumed by a resistor."""
from cmath import phase
#Variable Declaration:
R=10 #Resistance of resistance(in Ohms)
I=4+ 1j*3 #Alternating current phasor(in Amperes)
#Calculations:
I_mod=abs(I)
I_phase= phase(I)
I_rms=I_mod
P=pow(I_rms,2)*R
#Result:
print "The power consumed by the 10 ohm resistor is %.2f W." %(P)
#Question:
"""Finding the resultant current obtained by adding two alternating currents."""
from cmath import rect,phase
from math import radians,degrees,sqrt
#Calculations:
I1=rect(10,0)
I2=rect(20,radians(60))
I=I1+I2
Im=abs(I)
I_phase=degrees(phase(I))
#Result:
print "The resultant current is %.2f A at a phase angle of %.2f degrees." %(Im,I_phase)
#Question:
"""Finding the rms value of the sum of two currents."""
from cmath import rect
from math import radians,sqrt
#Calculations:
I1=rect((10*sqrt(2)),0)
I2=rect((20*sqrt(2)),radians(60))
I=I1+I2
Im=abs(I)
Irms=Im/(sqrt(2))
#Result:
print "The rms value of the sum of the currents is %.2f A." %(Irms)
#Question:
"""Finding the rms value of the resultant current."""
from cmath import rect,phase
from math import radians,sqrt,degrees
#Calculations:
I1=rect(5,0)
I2=rect(5,radians(30))
I3=rect(5,radians(-120))
I=I1+I2+I3
Im=abs(I)
Irms=Im/(sqrt(2))
I_phase=degrees(phase(I))
#Result:
print "The rms value of the resultant current that leaves the junction is %.2f A at a phase angle of %.2f degrees." %(Irms,I_phase)
#Question:
"""Finding the average and rms value of the resultant cuurent in a wire."""
from math import sqrt
#Variable Declaration:
I1rms=10.0 #Rms value of direct current(in Amperes)
#Calculations:
avg=10.0
I2rms=10.0/sqrt(2)
I_rms=sqrt(pow(I1rms,2)+pow(I2rms,2))
#Result:
print "The average value of the resultant current is %d A as the current goes as much positive as negative around the value of %d A." %(avg,avg)
print "The rms value of the resultant current is %.3f A." %(I_rms)
#Question:
"""Finding the average value of a voltage waveform."""
#Calculations:
area_0_to_1=10*(1e-03)
area_1_to_3=-5*(2e-03)
area_3_to_4=20*(1e-03)
area_4_to_5=0*(1e-03)
area_5_to_8=5*(3e-03)
total_area=(area_0_to_1+area_1_to_3+area_3_to_4+area_4_to_5+area_5_to_8)
total_period=8e-03
avg_value=total_area/total_period
#Result:
print "The average value of the alternating voltage waveform is %.3f V." %(avg_value)
#Question:
"""Finding the effective value of a voltage waveform."""
from math import sqrt
#Calculations:
area_0_to_10=400*(10e-03)
area_10_to_20=100*(10e-03)
total_area=(area_0_to_10+area_10_to_20)
total_period=20e-03
avg_value_of_square=total_area/total_period
rms=sqrt(avg_value_of_square)
#Result:
print "The effective(rms) value of the alternating voltage waveform is %.3f V." %(rms)
#Question:
"""Finding the rms value,the average value and the form factor for a current waveform."""
from math import sqrt
#Variable Declaration:
period=3.0 #Time period of the current waveform(in seconds)
#Calculations:
Irms=sqrt( ((pow(10,2)*2)+(pow(0,2)*1))/3 )
Iavg=((10.0*2)+(0*1))/3.0
form_factor=Irms/Iavg
#Result:
print "The rms value of current waveform is %.2f A." %(Irms)
print "The average value of current waveform is %.2f A." %(Iavg)
print "The form factor of the current waveform is %.2f." %(form_factor)
#Question:
"""Finding the form factor and the peak factor for a saw-tooth waveform."""
from math import sqrt
#Variable Declaration:
T=5e-03 #Time period of saw-tooth waveform(in seconds)
V_m=10.0 #Peak value of the saw-tooth voltage(in Volts)
""" Vav=(Area under the curve in one cycle)/(Duration of one cycle) """
#Calculations:
Vav=((1.0/2)*V_m*T)/T
Vrms=V_m/(sqrt(3))
form_factor=Vrms/Vav
peak_factor=V_m/Vrms
#Result:
print "The average value of the saw-tooth voltage waveform is %.3f V." %(Vav)
print "The rms value of the saw-tooth voltage waveform is %.3f V." %(Vrms)
print "The form factor for the saw-tooth voltage waveform is %.3f." %(form_factor)
print "The peak factor for the saw-tooth voltage waveform is %.3f." %(peak_factor)
#Question:
"""Finding the average power,the apparent power,the instantaneous power and the power factor in percentage in an ac circuit."""
from math import cos,sqrt,pi
#Variable Declaration:
phase_angle=pi/5 #Phase difference between the alternating current and alternating voltage(in radians)
Vm=55 #Peak value of the alternating voltage(in Volts)
Im=6.1 #Peak value of the alternating current(in Amperes)
#Calculations:
Vrms=Vm/sqrt(2)
Irms=Im/sqrt(2)
pf=cos(phase_angle)
P_avg=Vrms*Irms*cos(phase_angle)
P_app=Vrms*Irms
P_inst=P_avg-(Vrms*Irms*cos((2*0.3)-(pi/5)))
#Result:
print "The average power is %.2f W." %(P_avg)
print "The apparent power is %.2f VA." %(P_app)
print "The instantaneous power at wt=0.3 is %.2f W." %(P_inst)
print "The power factor is %.3f lagging." %(pf)
#Question:
"""Finding the average and rms values of waveforms."""
from math import sqrt
#Variable Declaration:
Vm1=10.0 #Peak voltage of first waveform(in Volts)
Vm2=10.0 #Peak voltage of second waveform(in Volts)
#Calculations:
Vav1=Vm1/2.0
Vrms1=Vm1/sqrt(3.0)
Vav2=Vm2/4.0
Vrms2=Vm2/sqrt(6.0)
#Result:
print "(a)The average value of the voltage is %.2f V and the rms value of the voltage is %.2f V." %(Vav1,Vrms1)
print "(b)The average value of the voltage is %.2f V and the rms value of the voltage is %.2f V." %(Vav2,Vrms2)
#Question:
"Finding the value of current at a given instant."""
from math import pi,sin,asin
#Variable Declaration:
Im=12.0 #Maximum value of the alternating current(in Amperes)
f=60.0 #Frequency of the alternating current(in Hertz)
#Calculations:
w=2*pi*f
t=1/360.0
i=Im*sin(w*t)
i1=9.6
t=asin(i1/Im)/w
#Result:
print "(a)The equation for the instantaneous current is i(t)=%.2f sin(%.2f*t) A." %(Im,w)
print "(b)The value of the current after (1/360) second is %.2f A." %round(i,2)
print "(c)The time taken to reach 9.6 A for the first time is %e seconds." %(t)
#Question:
"""Finding the expression of an alternating current in cosine form."""
from math import asin,pi
#Variable Declaration:
Imax=10.0 #Maximum value of current(in Amperes)
Io=5.0 #Value of current at t=0(in Amperes)
#Calculations:
phi=asin(Io/Imax)
phi_new=(pi/2.0)-phi
#Result:
print "The expression for current is i=%.2f cos(wt-%.2f) A." %(Imax,phi_new)
#Question:
"""Finding the time(from negative value) at which the instantaneous current is 10/sqrt(2.0) A."""
from math import pi,sqrt,radians,asin
#Variable Declaration:
Irms=20.0 #Rms value of alternating current(in Amperes)
f=50.0 #Frequency of the alternating current(in Hertz)
#Calculations:
ang_freq=2*pi*f
Im=Irms*sqrt(2.0)
i=10.0*sqrt(2.0)
ph_lag=pi/2.0
t=(asin(i/Im)+ph_lag)/ang_freq
#Result:
print "The time(measured from negative value) at which instantaneous current will be 10/sqrt(2.0) is %.2f ms." %round((t*1000),2)
#Question:
"""Finding the average and rms value of an alternating current."""
from math import pow,sqrt
#Variable Declaration:
Idc=10.0 #Dc current(in Amperes)
Im=5.0 #Peak value of sinusoidal component(in Volts)
#Calculations:
Iav=Idc
Irms=sqrt((10*10)+pow((5.0/sqrt(2.0)),2))
#Result:
print "The average value of current is %.2f A." %(Iav)
print "The rms value of current is %.2f A." %(Irms)
#Question:
"""Finding the sum of three alternating voltages."""
from math import radians,degrees
from cmath import rect,phase
#Calculations:
v1=rect(147.3,radians(188.1))
v2=rect(294.6,radians(45))
v3=rect(88.4,radians(135))
v_res=v1+v2+v3
#Result:
print "The resultant voltage is v=%.2f sin(wt+(%.2f degrees)) V." %(abs(v_res),degrees(phase(v_res)))
#Question:
"""Finding the reactance offered by an inductor and a capacitor."""
from math import pi
#Variable Declaration:
L=0.2 #Inductance of the inductor(in Henry)
C=10e-06 #Capacitance of the capacitor(in Farads)
f=100 #Initial frequency of the ac input voltage(in Hertz)
f1=140 #New frequency of the ac input voltage(in Hertz)
#Calculations:
X_L=2*pi*f*L
X_C=1.0/(2*pi*f*C)
X_L1=2*pi*f1*L
X_C1=1.0/(2*pi*f1*C)
#Result:
print "(a)For a frequency of 100Hz, X_L=%.2f Ohms and X_C=%.2f Ohms." %(X_L,X_C)
print "(a)For a frequency of 140Hz, X_L=%.2f Ohms and X_C=%.2f Ohms." %(X_L1,X_C1)
#Question:
"""Finding the currents in each case."""
from math import radians,degrees
from cmath import rect,phase
#Calculations:
I1=rect(10,0)
I2=rect(10,0)
Ia=I1+I2
I1=rect(10,radians(90))
Ib=I1+I2
I1=rect(10,radians(-90))
I2=rect(10,radians(-90))
Ic=I1+I2
V=250.0+1j*0
X_L=1j*25.0
Id=V/X_L
X_C=-1j*25.0
I=5.0+1j*0
Ve=I*X_C
#Result:
print "(a)The unknown current is %.2f A at a phase angle of %.2f degrees." %(abs(Ia),degrees(phase(Ia)))
print "(a)The unknown current is %.2f A at a phase angle of %.2f degrees." %(abs(Ib),degrees(phase(Ib)))
print "(a)The unknown current is %.2f A at a phase angle of %.2f degrees." %(abs(Ic),degrees(phase(Ic)))
print "(a)The unknown current is %.2f A at a phase angle of %.2f degrees." %(abs(Id),degrees(phase(Id)))
print "(a)The unknown voltage is %.2f A at a phase angle of %.2f degrees." %(abs(Ve),degrees(phase(Ve)))