##AC Circuits:example 4.1:(pg4.4)
import math
i=15.;
t=3.375*10**-3;
f=40.;
pi=3.14;
Im=(i/math.sin(2.*pi*f*t));
print("i=15 Amp");
print("t=3.375 ms");
print("f=40 Hz");
print("i=Im*sin(2*pi*f*t)");
print'%s %.2f %s'%("Im= ",Im, "Amp");
##AC Circuits:example 4.2:(pg4.4)
import math
f=50.;
Im=100.;
i1=86.6;
t=(1/600.);
pi=3.14;
print("f=50 c/s");
print("Im=100 A");
## part(a)
print("i=Im*sin(2*pi*f*t)");
i=Im*math.sin(2*pi*f*t);
print'%s %.2f %s'%("i= ",i," A");
## part (b)
print("i=Im*sin(2*pi*f*t1)");
t1=(math.asin(i1/Im)/(2.*pi*f));
print'%s %.2e %s'%("t1= ",t1," second");
##AC Circuits:example 4.3:(pg4.5)
f=50.;
import math
I=20.;
t1=0.0025;
t2=0.0125;
I1=14.14;
pi=3.14;
print("f=50 c/s");
print("I=20 A");
print("Im=I*sqrt(2)");
Im=(math.sqrt(2)*I);
print'%s %.2f %s'%("\nIm= ",Im," A");
print("\nEquation of current, \ni=Im*sin(2*pi*f*t)");
print("=28.28sin(2*pi*f*t)=28.28sin(100*pi*t)");
print("(a)At t=0.0025 seconds");
i=(Im*math.sin(2.*pi*f*t1));
print'%s %.2f %s'%("i= ",i," A"); ##when t=0.0025seconds
print("(b)At t=0.0125 seconds");
i=(Im*math.sin(2*pi*f*t2));
print'%s %.2f %s'%("i= ",i," A"); ##when t=0.0125seconds
print("(c) i=28.28sin(100*pi*t) ");
t=(math.asin(I1/Im)/(2*math.pi*f));
print'%s %.2e %s'%("t= ",t," second");## when I=14.14A
##AC Circuits : example 4.4 :pg(4.5)
import math
pi=3.14;
Vm=200.;
print("v=200sin314t");
print("v=Vmsin(2*pi*f*t)");
print("(2*pi*f)=314");
f=(314./(2.*pi));
print'%s %.2f %s'%("f= ",f," Hz");
Vavg=((2.*Vm)/pi);
Vrms=(Vm/math.sqrt(2.));
print('\nFor a sinusoidal waveform, \nVavg=(2*Vm/pi) \nVrms=(Vm/sqrt(2))');
kf=(Vrms/Vavg);
kc=(Vm/Vrms);
print'%s %.2f %s'%('\nform fator=',kf,'');
print'%s %.2f %s'%('\ncrest factor=',kc,'');
##AC Circuits : example 4.5 :(pg 4.6)
kf=1.2;
import math
kp=1.5;
Vavg=10.;
print("kf=1.2");
print("kp=1.5");
print("Vavg=10");
print("form factor kf=(Vrms/Vavg)");
Vrms=(kf*Vavg);
print'%s %.2f %s'%("\nVrms= ",Vrms," V");
print("peak factor kp=(Vm/Vrms)");
Vm=(kp*Vrms);
print'%s %.2f %s'%("\nVm= ",Vm," V");
##AC Circuits: example 4.14 :(pg 4.11)
v1=0.;
import math
v2=40.;
v3=60.;
v4=80.;
v5=100.;
t=8.;
Vavg=((v1+v2+v3+v4+v5+v4+v3+v2)/t);
Vrms=math.sqrt((v1**2+v2**2+v3**2+v4**2+v5**2+v4**2+v3**2+v2**2)/t);
print("Vavg=((0.+40.+60.+80.+100.+80.+60.+40.)/8.)");
print'%s %.2f %s'%("\nVavg= ",Vavg," V");
print("Vrms=sqrt((0+(40)^2+(60)^2+(80)^2+(100)^2+(80)^2+(60)^2+(40)^2)/8)");
print'%s %.2f %s'%("\nVrms= ",Vrms," V");
##AC Circuits : example 4.15 :pg(4.11 & 4.12)
v1=0.;
import math
v2=10.;
v3=20.;
t=3.;
Vavg=((v1+v2+v3)/t);
Vrms=(math.sqrt((v1**2+v2**2+v3**2)/t));
print("Vavg=((0+10+20)/3)");
print'%s %.2f %s'%("Vavg= ",Vavg, "V");
print("Vrms=(((0)^2+(10)^2+(20)^2)/3)");
print'%s %.2f %s'%("Vrms= ",Vrms," V");
##AC Circuits : example 4.33 :pg(4.27)
Vm=177.;
import math
Im=14.14;
phi=30.;
V=(Vm/math.sqrt(2));
I=(Im/math.sqrt(2));
pf=math.cos(30/57.3);
P=(V*I*pf);
print("v(t)=177sin(314t+10)");## value of 10 is in degrees
print("i(t)=14.14sin(314t-20)");##value of 20 is in degrees
print("\nCurrent i(t) lags behind voltage v(t) by 30degrees");
print("phi=30degrees");
print'%s %.2f %s'%("Power factor pf=cos(30)= ",pf," (lagging)");
print'%s %.2f %s'%("\nPower consumed P=V*I*cos(phi)= ",P," W");
##AC Circuits : example 4.42 :pg(4.32 & 4.33)
import math
PR=1000.;
VR=200.;
Pcoil=250.;
Vcoil=300.;
R=((VR**2)/PR);
I=(VR/R);
r=((Pcoil/(I**2)));
Zcoil=(Vcoil/I);
XL=math.sqrt((Zcoil**2)-(r**2));
RT=(R+r);
ZT=math.sqrt((RT**2)+(XL**2));
V=(ZT*I);
print("\nPR=1000 W \nVR=200 V \nPcoil=250 W \nVcoil=300 V \nPR=(VR^2/R)");
print'%s %.2f %s'%("\nR= ",R," Ohms");
print'%s %.2f %s'%("\nVR=R*I \nI= ",I," A");
print("Pcoil=(I^2)*r");
print'%s %.2f %s'%("\nResistance of coil r= ",r," Ohm");
print'%s %.2f %s'%("\nImpedance of coil Zcoil=(Vcoil/I)= ",Zcoil," Ohms");
print'%s %.2f %s'%("\nReactance of coil XL=sqrt((Zcoil^2)-(r^2)) = ",XL," Ohms");
print'%s %.2f %s'%("\nCombined resistance RT=R+r= ",RT,"Ohms");
print'%s %.2f %s'%("\nCombined impedance ZT=sqrt(((R+r)^2)+(XL^2)) = ",ZT," Ohms");
print'%s %.2f %s'%("\nSupply voltage V=ZT*I= ",V," V");
##AC Circuits : example 4.47 :pg(4.47)
import math
f1=60.;
V=200.;
P=600.;
I=5.;
f=50.;
Z=V/I;
r=(P/(I**2));
XL=math.sqrt((Z**2)-(r**2));
L=(XL/(2.*math.pi*f));
XL1=(2.*math.pi*f1*L);
Z1=math.sqrt((r**2)+(XL1**2));
I=(V/Z1);
print("\nI=5 A \nV=200 V \nP=600 W \nFor f=50 Hz,");
print'%s %.2f %s'%("\nZ=V/I = ",Z," Ohms");
print'%s %.2f %s'%("\nP=((I^2)*r) \nr= ",r," Ohms");
print'%s %.2f %s'%("\nXL=sqrt((Z^2)-(r^2)) \nXL= ",XL," Ohms");
print'%s %.2f %s'%("\nXL=(2*pi*f*L)\nL= ",L," H");
print'%s %.2f %s'%("\nFor f=60 Hz \nXL= ",XL1," Ohm");
print'%s %.2f %s'%("\nr=24 Ohms \nZ=sqrt((r^2)+(XL^2))= ",Z1," Ohms");
print'%s %.2f %s'%("\nI=V/Z= ",I," A");
##AC Circuits : example 4.48 :(pg 4.37)
f=50.;
import math
pi=3.14;
Vdc=12.;
Idc=2.5;
Vac=230.;
Iac=2.;
Pac=50.;
R=(Vdc/Idc);
Z=(Vac/Iac);
Pi=(Pac-((Iac**2)*R));
RT=(Pac/(Iac**2));
XL=math.sqrt((Z**2)-(RT**2));
L=(XL/(2.*pi*f));
pf=(RT/Z);
i=(Pi/(Iac**2));
print("\nFor dc V=12 V, I=2.5 A \nFor ac V=230 V, I=2 A, P=50 W");
print("\nIn an iron-cored coil,there are two types of losses \n(i)Losses in core known as core or iron loss \n(ii)Losses in winding known as copper loss");
print("\nP=(I^2)*R+Pi \nP/(I^2)=R+((Pi)/(I^2)) \nRT=R+(Pi/(I^2)) \nwhere R is the resistance of the coil and (Pi/I^2) is the resistance which is equivalent to the effect of iron loss");
print("\nFor dc supply, f=0 \nXL=0");
print'%s %.2f %s'%("\nR= ",R," Ohm");
print'%s %.2f %s'%("\nFor ac supply \nZ= ",Z," Ohms");
print'%s %.2f %s'%("\nIron loss Pi=P-I^2*R= ",Pi," W");
print'%s %.2f %s'%("\nRT=(P/I^2)= ",RT," Ohm");
print'%s %.2f %s'%("\nXL=sqrt((Z^2)-(RT^2))= ",XL," Ohm");
print'%s %.2f %s'%("\nXL=2*pi*L \nInductance L= ",L," H");
print'%s %.2f %s'%("\nPower factor =RT/Z= ",pf," (lagging)");
print'%s %.2f %s'%("\nThe series resistance equivalent to the effect of iron loss= Pi/(I^2)= ",i," Ohms");
##AC Circuits : example 4.49 :(pg 4.37 & 4.38)
import math
f=50.;
I1=4.;
pf1=0.5;
V1=200.;
I2=5.;
pf2=0.8;
V2=40.;
Z1=(V2/I2);
R=(Z1*pf2);
XL1=math.sqrt((Z1**2)-(R**2));
L1=(XL1/(2.*math.pi*f));
Z2=(V1/I1);
RT=(Z2*pf1);
XL2=math.sqrt((Z2**2)-(RT**2));
L2=(XL2/(2.*math.pi*f));
Pi=(V1*I1*pf1-(I1**2)*R);
print("\nWith iron core I=4 A pf=0.5, V=200 V \nWithout iron core I=5 A pf=0.8, V=40 V \nWhen the iron-core is removed,");
print'%s %.2f %s'%("\nZ=V/I= ",Z1," Ohms");
print'%s %.2f %s'%("\npf=R/Z \nR= ",R," Ohms");
print'%s %.2f %s'%("\nXL=sqrt((Z**2)-(RT**2))= ",XL1," Ohms");
print'%s %.2f %s'%("\nXL=(2*pi*f*L) \nInductance L= ",L1," H");
print'%s %.2f %s'%("\nWith iron core, \nZ= ",Z2," Ohms");
print'%s %.2f %s'%("\npf=RT/Z \nRT= ",RT," Ohm");
print'%s %.2f %s'%("\nXL=sqrt((Z**2)-(RT**2))= ",XL2," Ohm");
print'%s %.2f %s'%("\nXL=(2*pi*f*L) \nInductance L= ",L2," H");
print'%s %.2f %s'%("\nIron loss Pi=P=(I**2)*R \n=VIcos(phi)-I**2*R \n= ",Pi," W");
##AC Circuits : example 4.51 :(pg 4.40 & 4.41)
import math
P=2000.;
pf=0.5;
V=230.;
S=(P/pf);
phi=math.acos(pf)*57.3;
I=(P/(V*pf));
Q=(V*I*math.sin(phi/57.3));
print("P=2000 W");
print("pf=0.5 (leading)");
print("V=230 V");
print("P=V*I*cos(phi)");
print'%s %.2f %s'%("\nI= ",I," A");
print'%s %.2f %s'%("\nS=V*I=P/cos(phi)= ",S," VA");
print'%s %.2f %s'%("\nphi= ",phi," degrees");
print'%s %.2f %s'%("\nQ=V*I*sin(phi)= ",Q," VAR");
##AC Circuits : example 4.52 :(pg 4.41)
import math
V=240.;
VR=100.;
P=300.;
f=50.;
R=((VR**2)/P);
I=math.sqrt(P/R);
Z=V/I;
XC=math.sqrt((Z**2)-(R**2));
C=(1./(2.*math.pi*f*XC));
VC=math.sqrt((V**2)-(VR**2));
VCmax=(VC*math.sqrt(2.));
Qmax=(C*VCmax);
Emax=((1./2.)*C*(VCmax**2));
print("\nV=240 V \nVR=100 V \nP=300 W \nf=50 Hz");
print'%s %.2f %s'%("\nP=(VR^2)/R \nR=((VR^2)/P)= ",R," Ohm");
print'%s %.2f %s'%("\nP=(I^2)*R \nI=sqrt((P/R)) \nI= ",I," A");
print'%s %.2f %s'%("\nZ=V/I=",Z," Ohm");
print'%s %.2f %s'%("\nXC=sqrt((Z^2)-(R^2))= ",XC," Ohm");
print'%s %.2e %s'%("\nXC=1/2*pi*f*C \nC= ",C," F");
print'%s %.2f %s'%("\nVoltage across capacitor VC=sqrt((V^2)-(VR^2))= ",VC," V");
print'%s %.2f %s %.2f %s '%("\nMaximum value of max charge \nVC= ",VCmax," V" and " \nQmax=C*VCmax= ",Qmax," C");
print'%s %.2f %s'%("\nMax stored energy Emax=((1/2)*C*(VCmax^2)) \n= ",Emax," J");
##AC Circuits : example 4.53 :(pg 4.42)
import math
C=35.*10**-6;
f=50.;
XC=(1./(2.*math.pi*f*C));
R=math.sqrt(3.*(XC**2));
R2=(3*(XC**2));
print'%s %.2f %s'%("\nC=35*10^-6 F \nf=50 Hz \nVC=1/2.V \nXC=1/(2*pi*f*C)= ",XC," Ohm");
print("\nVC=1/2.V \nXC.I=1/2.Z.I \nXC=1/2.Z \nZ=2.XC \nZ=sqrt((R^2)+(XC^2)) \n(2XC)^2=(R^2)+(XC^2) \n3XC^2=R^2");
print'%s %.2f %s %.2f %s '%("\nR^2=3*XC^2= ",R2," Ohm" and " \nR= ",R," Ohm");
##AC Circuits : example 4.54 :(pg 4.42)
V=125.;
import math
I=2.2;
P=96.8;
f=50.;
Z=V/I;
R=(P/(I**2));
Xc=math.sqrt((Z**2)-(R**2));
C=(1./(2.*math.pi*f*Xc));
print("\nV=125 V \nP=96.8 W \nI=2.2 A \nf=50 Hz");
print'%s %.2f %s'%("\nZ=V/I= ",Z," A");
print'%s %.2f %s'%("\nP=(I^2)*R \nR= ",R," Ohm");
print'%s %.2f %s'%("\nXc=sqrt((Z^2)-(R^2))= ",Xc," Ohm");
print'%s %.2e %s'%("\nXc=1/(2*pi*f*C) \n C= ",C," F");
##AC Circuits :example 4.57 :(pg 4.46)
import math
j=-math.sqrt(1);
f=50.;
L=0.22;
R1=3.;
Z=3.8+j*6.4;
XL=2.*math.pi*f*L;
R2=3.8;
R=R2-R1;
X=6.4;
XC=XL-X;
C=(1./(2.*math.pi*f*XC));
print("\nZ=(3.8+j*6.4) Ohm");
print'%s %.2f %s'%("\nXL=2*pi*f*L= ",XL," Ohm");
print("\nZ=(3+j69.12+R-jXC) \n=(3+R)+j(69.12-XC)");
print'%s %.2f %s'%("\n3+R=3.8 \nR= ",R," Ohm");
print'%s %.2f %s'%("\nXC= ",XC,"Ohm");
print'%s %.2e %s'%("\nXC=1/2.pi.f.C \nC= ",C," F");
##AC Circuits : example 4.58 :(pg 4.46)
import math
R=20.;
phi=45.;
Z=R/math.cos(phi/57.3);
XC=math.sqrt((Z**2)-(R**2));
XL=(2.*XC);
w=1000.;
L=(XL/w);
C=(1./(w*XC));
print("\nvL=300sin(1000t) \nR=20 Ohm \nphi=45 \nVL(max)=2Vcc(max) \nsqrt(2)*VL=2*sqrt(2)*VC \nI*XL=2*I*XC \nXL=2*XC \ncos(phi)=R/Z");
print'%s %.2f %s'%("\nZ= ",Z," Ohm");
print'%s %.2f %s'%("\nZ=sqrt((R^2)+(XL-XC)^2) \nXC = ",XC," Ohm"); ##for series R-L-C ckt
print'%s %.2f %s'%("\nXL=2*XC = ",XL," Ohm");
print'%s %.2f %s'%("\nXL=w*L \nL= ",L," H");
print'%s %.2e %s'%("\nXC=1/w*C \nC= ",C," F");
##AC Circuits : example 4.59 :(pg 4.47)
import math
pf=0.5;
C=79.59*10**-6;
f=50.;
XC=(1./(2.*math.pi*f*C));
R=pf*XC;
Zcoil=XC;
XL=math.sqrt((Zcoil**2)-(R**2));
L=(XL/(2.*math.pi*f));
print("\npf=0.5 \nC=79.57uF \nf=50 Hz \nVcoil=VC ");
print'%s %.2f %s'%("\nXC=1/2*pi*f*C = ",XC," Ohm");
print'%s %.2f %s'%("\nVcoil=VC \nZcoil=XC= ",XC," Ohm");
print'%s %.2f %s'%("\npf of coil=cos(phi)=R/Zcoil \nResistance of coil R= ",R," Ohm");
print'%s %.2f %s'%("\nXL=sqrt((Zcoil^2)-(R^2))= ",XL," Ohm");
print'%s %.2f %s'%("\nXL=2*pi*f*L \nInductance of coil= ",L," H");
##AC Circuits : example 4.60 :(pg 4.48)
import math
f=50.;
V=250.;
R=5.;
L=9.55;
Vcoil=300.;
XL=2.*math.pi*f*L;
Zcoil=(math.sqrt((R**2)+(XL**2)));
I=Vcoil/Zcoil;
Z=V/I;
XC1=Zcoil-Z;
XC2=Zcoil+Z;
C1=(1./(2.*math.pi*f*XC1));
C2=(1./(2.*math.pi*f*XC2));
print("\nV=250 V \nR=5 Ohm \nL=9.55 H \nVcoil=300 V");
print'%s %.2f %s'%("\nXL=2*pi*f*L = ",XL," Ohm");
print'%s %.2f %s'%("\nZcoil=sqrt(R^2)+(XL^2) = ",Zcoil," Ohm");
print'%s %.2f %s'%("\nI=Vcoil/Zcoil = ",I," A");
print'%s %.2f %s'%("\nZ=V/I = ",Z," Ohm");##total impedance
print'%s %.2f %s'%("\nZ=sqrt((R^2)+(XL-XC)^2) \nXC= ",XC1," Ohm");##when XL>XC
print'%s %.2f %s'%("\nC=1/2*pi*f*XC = ",C1," F");
print'%s %.2f %s'%("\nZ=sqrt((R^2)+(XC-XL)^2) \nXC= ",XC2," Ohm");##when XC>XL
print'%s %.2e %s'%("\nC= ",C2," F");
##AC Circuits : example 4.79 :(pg 4.64)
import math
R=10.;
L=0.01;
C=100.*10**-6;
f0=(1./(2.*math.pi*math.sqrt(L*C)));
BW=(R/(2.*math.pi*L));
f1=f0-(BW/2.);
f2=f0+(BW/2.);
print("\nR=10 Ohm \nL=0.01H \nC=100uF");
print'%s %.2f %s'%("\nf0=1/2*pi*sqrt(L*C)= ",f0," Hz");##resonant frequency
print'%s %.2f %s'%("\nBW=R/2*pi*L = ",BW," Hz"); ##bandwidth
print'%s %.2f %s'%("\nf1=f0-BW/2 \n= ",f1," Hz"); ##lower frequency
print'%s %.2f %s'%("\nf2=f0+BW/2 = ",f2," Hz"); ##higher frequency
##AC Circuits : example 4.80 :(pg 4.65)
import math
R=10.;
L=0.2;
C=40.*10**-6;
V=100.;
f0=(1./(2.*math.pi*math.sqrt(L*C)));
I0=(V/R);
P0=((I0**2)*R);
pf=1.;
Vr=(R*I0);
Vl=((2.*math.pi*f0*L)*I0);
Vc=((1/(2.*math.pi*f0*C))*I0);
Q=((1./R)*math.sqrt(L/C));
f1=(f0-(R/(4.*math.pi*L)));
f2=(f0+(R/(4.*math.pi*L)));
print("\nR=10 Ohm \nL=0.2 H \nC=40uF \nV=100 V");
print'%s %.2f %s'%("\n(i) f0= 1/2*pi*sqrt(LC) = ",f0," Hz"); ##resonant frequency
print'%s %.2f %s'%("\n(ii) I0= V/R = ",I0," A"); ##current
print'%s %.2f %s'%("\n(iii) P0=(I0^2)*R = ",P0," W");##power
print("\n(iv) pf=1");##power factor
print'%s %.2f %s'%("\n(v) Rv = R.I = ",Vr," V");##voltage across resistor
print'%s %.2f %s'%("\n Lv = XL.I = ",Vl," V");##voltage across inductor
print'%s %.2f %s'%("\n Cv = XC.I = ",Vc," V"); ##voltage across capacitor
print'%s %.2f %s'%("\n(vi) Q =1/R*sqrt(L/C)=",Q,"");##Quality factor
print'%s %.2f %s'%("\n(vii)f1 = f0-R/4.pi.L = ",f1," Hz"); ##half power points
print'%s %.2f %s'%("\nf2=f0+R/4.pi.L = ",f2," Hz");
## x initialisation
import math
%matplotlib inline
import warnings
warnings.filterwarnings('ignore')
from math import log
import numpy
from math import tan
import matplotlib
from matplotlib import pyplot
x=numpy.array([-1,0.1,6.28]);
##simple plot
y=numpy.sin(x)
pyplot.plot(x,y)
##AC Circuits : example 4.81 :(pg 4.66)
import math
V=200.;
Vc=5000.;
I0=20.;
C=4.*10**-6;
R=V/I0;
Xco=Vc/I0;
f0=(1./(2.*math.pi*Xco*C));
L=(Xco/(2.*math.pi*f0));
print("\nV=200 V \nI0= 20 A \nVc=5000 V \nC=4uF");
print'%s %.2f %s'%("\nR=V/I0 = ",R," Ohm");##resistance
print'%s %.2f %s'%("\nXco=Vco/Io = ",Xco," Ohm");
print'%s %.2f %s'%("\nXco=1/2*pi*f0*C \nf0=1/2*pi*Xco*C = ",f0," Hz");
print'%s %.2f %s'%("\nat resonance Xco=Xlo \nXlo= ",Xco," Ohm");
print'%s %.2f %s'%("\nXlo=2*pi*f0*L \nL= ",L," H");
##AC Circuits : example 4.82 :(pg 4.66)
import math
V=230.;
f0=50.;
I0=2.;
Vco=500.;
R=V/I0;
Xco=Vco/I0;
C=(1/(2.*math.pi*f0*Xco));
L=(Xco/(2.*math.pi*f0));
print("\nV = 230 V \nf0 = 50 Hz \nI0 = 2A \nVco = 500 V");
print'%s %.2f %s'%("\nR=V/I0 = ",R," Ohm");
print'%s %.2f %s'%("\nXco=Vco/I0 = ",Xco," Ohm");
print'%s %.2f %s'%("\nXco=1/2.pi.f0.C \nC= ",C," F");##capacitance
print'%s %.2f %s'%("\nXco=Xlo \nXlo= ",Xco," Ohm");##at resonance
print'%s %.2f %s'%("\nXlo=2.pi.f0.L \nL= ",L," H");##inductance
##AC Circuits : example 4.82 :(pg 4.66)
import math
R=2.;
L=0.01;
V=200.;
f0=50.;
C=(1./(4.*(math.pi)**2*L*(f0**2)));
I0=V/R;
Vco=I0*(1./(2.*math.pi*f0*C));
print("\nR= 2 Ohm \nL= 0.01 H \nV=200 V \nf0=50 Hz \nf0=1/(2.pi.sqrt(LC)");
print'%s %.2f %s'%("\nC = ",C," F");##capacitance
print'%s %.2f %s'%("\nI0= V/R = ",I0," A");##current
print'%s %.2f %s'%("\nVco=I0.Xco \n= ",Vco," V"); ##voltage across capacitor
##AC Circuits : example 4.84 :(pg 4.67)
import math
BW=400.;
Vco=500.;
R=100.;
Vm=10.;
V=(Vm/math.sqrt(2.));
I0=V/R;
L=R/BW;
Q0=Vco/V;
C=(L/(Q0*R)**2);
f0=(1/(2.*math.pi*math.sqrt(L*C)));
f1=(f0-(R/(4.*math.pi*L)));##lower cut-off frequency
f2=(f0+(R/(4.*math.pi*L)));##upper cut-off frequency
print("\nv(t)=10sinwt \nVco=5000V \nBW=400rad/s \nR=100 Ohm");
print'%s %.2f %s'%("\nV= ",V," V");
print'%s %.2f %s'%("\nI0=V/R= ",I0," A");
print'%s %.2f %s'%("\nBW=R/L \nL= ",L," H");
print'%s %.2f %s'%("\nQ0=Vco/V =",Q0,"");
print'%s %.2e %s'%("\nQ0=1/R*sqrt(L/C) \nC= ",C," F");
print'%s %.2f %s'%("\nf0=1/2.pi.sqrt(LC)= ",f0," Hz");
print'%s %.2f %s'%("\nf1=f0-R/4.pi.L = ",f1," Hz");##lower cut-off frequency
print'%s %.2f %s'%("\nf2=f0+R/4.pi.L = ",f2," Hz"); ##upper cut-off frequency
##AC Circuits : example 4.85 :(pg 4.68)
import math
R=500.;
f1=100.;
f2=10.*10**3;
BW=f2-f1;
f0=((f1+f2)/2.);
L=(R/(2.*math.pi*BW));
XL0=(2.*math.pi*f0*L);
C=(1/(2.*math.pi*f0*XL0));
Q0=((1./R)*(math.sqrt(L/C)));
print'%s %.2f %s'%("\nR= 500 Ohm \nf1 = 100 Hz \nf2=10kHz \nBW= f2-f1 = ",BW," Hz");
print'%s %.2f %s'%("\nf1=f0-BW/2 ------(i) \nf2=f0+BW/2 ------(ii) \nf1+f2 =2f0 \nf0=(f1+f2)/2 = ",f0," Hz");
print'%s %.2f %s'%("\nBW=R/2.pi.f0.L \nL= ",L," H");
print'%s %.2f %s'%("\nXL0=2.pi.f0.L = ",XL0," Ohm");
print'%s %.2f %s'%("\nXL0=XC0 = ",XL0," Ohm");##at resonance
print'%s %.2e %s'%("\nXC0 =1/2.pi.f0.C \nC= ",C," F");
print'%s %.2f %s'%("\nQ0=(1/R*sqrt(L/C)) =",Q0,"");
##AC Circuits : example 4.87 :(pg 4.69 & 4.70)
import math
f0=10**6;
C1=500.*10**-12;
C2=600.*10**-12;
C=500.*10**-12;
x=((2.*math.pi*f0)**2);
L=(1./(x*C));
XL=(2.*math.pi*f0*L);
y=2.*math.pi*f0*C2;
XC=(1./y);
R=math.sqrt(((XL-XC)**2)/3.);
x=math.sqrt(L/C);
Q0=((1./R)*x);
print("\nf0= 1MHz \nC1=500pF \nC2=600pF \nC=500pF");##At resonance
print'%s %.2e %s'%("\nf0=1/2.pi.sqrt(LC)\nL= ",L," H");
print'%s %.2f %s'%("\nXL=2.pi.f0.L = ",XL," Ohm");
print'%s %.2f %s'%("\nXC=1/2.pi.f0.C \nXC= ",XC," Ohm");
print("\nI=1/2.I0 \nV/Z=1/2.V/R \nZ=2R");
print'%s %.2f %s'%("\nsqrt((R^2)-(XL-XC)^2)=2R \nR= ",R," Ohm");##Resistance of Inductor
print'%s %.2f %s'%("\nQ0=1/R.sqrt(L/C) \n=",Q0,"");
##AC Circuits : example 4.88 :(pg 4.72)
import math
R=20.;
C=100.*10**-6;
L=0.2;
DR=(L/(C*R));
x=(1./(L*C));
y=((R/L)**2);
f0=((1./(2.*math.pi))*math.sqrt(x-y));
DR=(L/(C*R));
print("\nR=20 Ohm \nL=0.2 H \nC=100uF");
print'%s %.2f %s'%("\nf0=1/2.pi.sqrt(1/LC-R^2/L^2) \n= ",f0," Hz");
print'%s %.2f %s'%("\n dynamic resistance =L/CR \n= ",DR," Ohm");
##AC Circuits : example 4.89 :(pg 4.72 & 4.73)
import math
R=20.;
L=200.*10**-6;
f=10**6;
V=230.;
Rs=8000.;
XL=2.*math.pi*f*L;
x=((2.*math.pi*f)**2);
y=((R/L)**2);
C=(1./((x+y)*L));
Q=((2.*math.pi*f*L)/R);
Z=(L/(C*R));
ZT=(Rs+Z);
IT=(V/ZT);
print'%s %.2f %s'%("\nR=20 Ohm \nL=200uH \nf=10^6 \nV=230 V \nRs=8000 Ohm \nXL=2.pi.f.L = ",XL,"Ohm");
print'%s %.2f %s'%("\nf0=1/2.pi.sqrt(1/LC-R^2/L^2) \nC= ",C," F");
print'%s %.2f %s'%("\nQ0=2.pi.f.L/R =",Q,"");##quality factor
print'%s %.2f %s'%("\nZ=L/CR \n ",Z," Ohm");##dynamic impedance
print'%s %.2f %s'%("\nZt= ",ZT," Ohm");##total equivalent Z at resonance
print'%s %.2e %s'%("\nIt= ",IT," A");##total ckt current