In [7]:

```
#Question:
"""Finding the resonant frequency,quality factor,voltage across each element in a series RLC circuit."""
from math import sqrt,pi,pow
#Variable Declaration:
R=12.0 #Resistance of resistor(in Ohms)
L=0.15 #Self-inductance of inductor(in Henry)
C=100e-06 #Capacitance of capacitor(in Farads)
V=100.0 #Voltage(rms) of ac source(in Volts)
#Calculations:
resonant_freq=1/(2.0*pi*sqrt(L*C))
I_max=V/R
freq_c=(sqrt((1.0/(L*C))-(0.5*pow((R/L),2))))/(2.0*pi)
freq_l=1.0/(sqrt((L*C)-(0.5*pow((R*C),2)))*2*pi)
cap_rea=1.0/(2.0*pi*freq_l*C)
ind_rea=2.0*pi*round(freq_l,2)*L
Q=cap_rea/R
Vr=V
Vl=Q*V
Vc=Vl
#Result:
print "(a)The Resonant frequency(at which the circuit current becomes maximum) is %.2f Hz." %(resonant_freq)
print "(b)The maximum current supplied by the source is %.2f A." %(I_max)
print "(c)The frequency at which voltage across the capacitor is maximum is %.2f Hz." %(freq_c)
print "(d)The frequency at which voltage across the inducttor is maximum is %.2f Hz." %(freq_l)
print "(e)The inductive reactance is %.2f Ohms." %(ind_rea)
print "(f)The capacitive reactance is %.2f Ohms." %(cap_rea)
print "(g)The quality factor of the circiut is %.2f." %(Q)
print "(h)The voltage drop across resistor is %.2f V." %(Vr)
print " The voltage drop across inductor is %.2f V." %(Vl)
print " The voltage drop across capacitor is %.2f V." %(Vc)
```

In [4]:

```
#Question:
"""Finding the capacitance value to give resonance in a series RLC circuit. """
from math import pi,sqrt,pow
#Variable Declaration:
res_freq=50.0 #Resonant frequency(in Hertz)
L=0.5 #Self-inductance of inductor(in Henry)
R=4.0 #Resistance of resistor(in Ohms)
V=100.0 #Voltage of the supply(in Volts)
#Calculations:
C=1/(pow((2*pi*res_freq),2)*L)
I_max=V/R
V_L=I_max*(2*pi*res_freq*L)
V_C=V_L
Q=(2.0*pi*res_freq*L)/R
#Result:
print "(a)The capacitance to give resonance is %e F." %(C)
print "(b)The voltage across the inductor is %.2f V." %(V_L)
print " The voltage across the capacitor is %.2f V." %(V_C)
print "(c)The quality factor of the circuit is %.2f." %(Q)
```

In [5]:

```
#Question:
"""Finding the inductance,the circuit current and the voltage across the capacitor under resonance."""
from math import pi,pow
#Variable Declaration:
res_freq=175e03 #Resonant frequency(in Hertz)
V=0.85 #Voltage applied(in Volts)
Q=50.0 #Quality factor of the coil
C=320e-012 #Capacitance of the capacitor(in Farads)
#Calculations:
L=1/(pow((2*pi*res_freq),2)*C)
ind_rea=2*pi*res_freq*L
R=ind_rea/Q
Io=V/R
Vc=Q*V
#Result:
print "The value of inductance is %e H." %(L)
print "The circuit current is %e A." %(Io)
print "The voltage across the capacitor under resonance is %.2f V." %(Vc)
```

In [6]:

```
#Question:
"""Finding the current at the resonant frequency and the energy stored by inductor."""
from math import pow,pi
#Variable Declaration:
res_freq=5e03 #Resonant frequency(in Hertz)
L=1e-03 #Self-inductance of the inductor(in Henry)
V=120.0 #Voltage of the supply(in Volts)
R=2.0 #Resistance of the coil(in Ohms)
#Calculations:
C=1/(pow((2*pi*res_freq),2)*L)
I_max=V/R
""" U=0.5*L*I*I=L*Irms*Irms"""
U=L*I_max*I_max
#Result:
print "The required value of capacitance is %e F." %(C)
print "(a)The current at the resonance frequency is %.2f A." %(I_max)
print "(b)The maximum instantaneous energy is %.2f J." %(U)
```

In [7]:

```
#Question:
"""Finding the resonance frequency and the quality factor for the overall circuit."""
from math import sqrt,pi
#Variable Declaration:
R1=0.51 #Resistor of the resistor-1(in Ohms)
R2=1.3 #Resistor of the resistor-2(in Ohms)
R3=0.24 #Resistor of the resistor-3(in Ohms)
L1=32e-03 #Self-inductance of the inductor-1(in Henry)
L2=15e-03 #Self-inductance of the inductor-2(in Henry)
C1=25e-06 #Capacitance of the capacitor-1(in Farads)
C2=62e-06 #Capacitance of the capacitor-2(in Farads)
#Calculations:
Req=R1+R2+R3
Leq=L1+L2
Ceq=(C1*C2)/(C1+C2)
res_freq=1/(2*pi*sqrt(Leq*Ceq))
Q=(sqrt(Leq/Ceq))/Req
Q1=(2*pi*res_freq*L1)/R1
Q2=(2*pi*res_freq*L2)/R2
#Result:
print "(a)The resonance frequency is %.2f Hz." %(res_freq)
print "(b)The quality factor of the overall circuit is %.2f." %(Q)
print "(c)The quality factor of coil-1 is %.2f." %(Q1)
print "(d)The quality factor of coil-2 is %.2f." %(Q2)
```

In [8]:

```
#Question:
"""Finding the half-power frequencies of a series ac circuit."""
from math import pow,sqrt
#Variable Declaration:
bandwidth=75e03 #Bandwidth of the resonant circuit(in Hertz)
#Calculations:
pro=pow((150e03),2)
sum=sqrt(pow(bandwidth,2)+(4*pro))
f2=(sum+bandwidth)/2.0
f1=(sum-bandwidth)/2.0
#Result:
print "Lower Half-power frequency is %e Hz." %(f1)
print "Upper Half-power frequency is %e Hz." %(f2)
```

In [11]:

```
#Question:
"""Finding the line current,quality factor and the dynamic impedance of a series-parallel ac circuit."""
from math import pi,sqrt,pow
#Variable Declaration:
L=200e-06 #Self-inductance of the inductor coil(in Henry)
res_freq=1e06 #Resonant frequency(in Hertz)
R=20.0 #Resistance of the coil(in Ohms)
Rs=8e03 #Series resistance(in Ohms)
V=230.0 #Voltage(rms) of the supply(in Volts)
#Calculations:
C=1/(pow((2*pi*res_freq),2)*L)
XL=2*pi*res_freq*L
Q=XL/R
Zo=L/(C*R)
Z=Zo+Rs
I=V/Z
#Result:
print "(a)The value of capacitance to cause resonance is %e F." %(C)
print "(b)The Q factor of the circuit is %.5f." %(Q)
print "(c)The dynamic impedance of the parallel resonant circuit is %.2f Ohms." %(Zo)
print "(d)The total line current is %e A." %(I)
```

In [12]:

```
#Question:
"""Finding the resonant frequency,Q-factor and bandwidth of a practical parallel resonant circuit."""
from math import pow,sqrt,pi
#Variable Declaration:
R=150.0 #Resistance of the coil(in Ohms)
L=0.24 #Self-inductance of the coil(in Henry)
C=3e-06 #Capacitance of the capacitor(in Farads)
#Calculations:
res_freq=(sqrt(1-((R*R*C)/L)))/(2*pi*sqrt(L*C))
Q=(2*pi*res_freq*L)/R
BW=res_freq/Q
#Result:
print "The resonant frequency is %.2f Hz." %(res_freq)
print "The quality factor is %.2f." %(Q)
print "The bandwidth is %.2f Hz." %(BW)
```

In [16]:

```
#Question:
"""Finding the source frequency and the current supplied by the source."""
from math import sqrt,pi,pow,degrees
from cmath import phase
#Variable Declaration:
V=125.0 #Voltage of the source(in Volts)
C=20.5e-06 #Capacitance of the capacitor(in Farads)
R=1.06 #Resistance of the coil(in Ohms)
L=25.4e-03 #Inductance of the coil(in Henry)
#Calculations:
fo=1.0/(2*pi*sqrt(L*C))
Io=V/R
V_L=Io*(2*pi*fo*L)
V_C=V_L
X_L=(2*pi*fo*L)
Z_coil=R+(1j*X_L)
V_coil=Io*Z_coil
I=300.0/X_L
R_new=V/I
Rx=R_new-R
#Result:
print "(a) (i)The source frequency is %.2f Hz, and\n (ii)The current supplied by the source is %.2f A.\n" %(fo,Io)
print "(b) (i)The voltage across the capacitor is %.2f V and" %(V_C)
print " (ii)The voltage across the coil is %.2f V at an angle of %.2f degrees.\n" %(abs(V_coil),degrees(phase(V_coil)))
print "(c)The resistance that must be connected in series with the circuit to limit the capacitor voltage to 300V is %.3f Ohms." %(Rx)
```

In [2]:

```
#Question:
"""Finding the maximum instantaneous energy stored in the inductor."""
from math import pow,pi,sqrt
#Variable Declaration:
R=3.0 #Resistance of the coil(in Ohms)
L=12e-03 #Self-inductance of the coil(in Henry)
fo=9e03 #Resonant frequency(in Hertz)
V=240.0 #Supply voltage(in Volts)
#Calculations:
C=1.0/(pow((2*pi*fo),2)*L)
Io=V/R
ener=0.5*L*Io*Io
#Result:
print "The value of capacitance to be connected in series with the coil is %e F." %(C)
print "The maximum instantaneous energy stored in the inductor is %.2f J." %(ener)
```

In [3]:

```
#Question:
"""Finding the parameters of a series RLC circuit."""
from math import pi,sqrt,pow
#Variable Declaration:
fo=10e03 #Resonant frequency(in Hertz)
BW=1e03 #Bandwidth(in HErtz)
P=15.3 #Power drawn(in Watts)
V=200.0 #Voltage of generator(in Volts)
#Calculations:
V_R=V
R=(V_R*V_R)/P
""" Q=fo/BW=(2*pi*fo*L)/R; Q=Quality factor of the circuit. """
L=R/(2*pi*BW)
C=1.0/(pow((2*pi*fo),2)*L)
#Result:
print "The parameters of the circuit are:\n R=%.2f Ohms,\n L=%.3f H,\n C=%e F." %(R,L,C)
```

In [6]:

```
#Question:
"""Finding the half-power frequencies and the circuit current."""
from math import sqrt,pi,pow
#Variable Declaration:
fo=200.0 #Resonant frequency(in Hertz)
V=400.0 #Voltage of the source(in Volts)
R=20e-03 #Resistance of the coil(in Ohms)
L=6e-03 #Inductance of the coil(in Henry)
#Calculations:
C=1.0/(pow((2*pi*fo),2)*L)
Io=V/R
X_C=1.0/(2*pi*fo*C)
V_C=Io*X_C
Im=sqrt(2)*Io
U_max=0.5*L*Im*Im
Q=(2*pi*fo*L)/R
BW=fo/Q
f1=fo-(BW/2.0)
f2=fo+(BW/2.0)
#Result:
print "(a)The capacitance of the capacitor is %e F." %(C)
print "(b)The circuit current is %.2f kA." %(Io/1000)
print "(c)The voltage across the capacitor is %.2f kV." %(V_C/1000)
print "(d)The maximum energy stored in the coil is %.2f MJ." %(U_max/1000000)
print "(e)The lower half-power frequency is %.3f Hz and the upper half-power frequency is %.3f Hz." %(f1,f2)
```

In [17]:

```
#Question:
"""Finding the bandwidth,resonant frequency,inductance and capacitance."""
from math import pi,pow,sqrt
#Variable Declaration:
R=1e03 #Resistance of the resistor(in Ohms)
f1=20e03 #Lower half-power frequency(in Hertz)
f2=100e03 #Upper half-power frequency(in Hertz)
#Calculations:
BW=f2-f1
res_freq=sqrt(f1*f2)
Q=res_freq/BW
L=(Q*R)/(2*pi*res_freq)
C=1.0/(pow((2*pi*res_freq),2)*L)
#Result:
print "(a)The bandwidth is %.2f kHz." %(BW/1000.0)
print "(b)The resonant frequency is %.2f kHz." %(res_freq/1000.0)
print "(c)The inductance is %e H." %(L)
print "(d)The capacitance is %e F." %(C)
```

In [14]:

```
#Question:
"""Finding the power at half-power frequencies."""
#Variable Declaration:
R=5.0 #Resistance of resistor(in Ohms)
V=20.0 #Voltage of the source(in Volts)
#Calculations:
Zo=R
Io=V/Zo
Po=(Io*Io)*R
P_half=Po/2.0
#Result:
print "The power at half-power frequencies is %.2f W." %(P_half)
```

In [15]:

```
#Question:
"""Finding the half-power frequencies and the quality factor."""
from math import pi,pow,sqrt
#Variable Declaration:
res_freq=100.0 #Resonant frequency(in Hertz)
V=240.0 #Voltage of the source(in Volts)
R=55e-03 #Resistance of the coil(in Ohms)
L=7e-03 #Self-inductance of the coil(in Henry)
#Calculations:
C=1.0/(pow((2*pi*res_freq),2)*L)
Q=(2*pi*res_freq*L)/R
BW=res_freq/Q
f1=res_freq-(BW/2.0)
f2=res_freq+(BW/2.0)
#Result:
print "(a)The value of the capacitance is %e F." %(C)
print "(b)The quality factor of the circuit is %.2f." %(Q)
print "(c)The lower half-power frequency is %.2f Hz and The upper half-power frequency is %.2f Hz." %(f1,f2)
```

In [16]:

```
#Question:
"""Finding the resonance frequency and the effective resistance at resonance."""
from math import sqrt,pi
#Variable Declaration:
R=20.0 #Resistance of the coil(in Ohms)
L=0.2 #Inductance of the coil(in Henry)
C=100e-06 #Capacitance of the capacitor(in Farads)
#Calculations:
res_freq=sqrt(1-((R*R*C)/L))/(2*pi*sqrt(L*C))
Zo=L/(C*R)
#Result:
print "The frequency at which the circuit behaves as a non-inductive reactance is %.2f Hz." %(res_freq)
print "The effective resistance at resonance is %.2f Ohms." %(Zo)
```

In [18]:

```
#Question:
"""Finding the quality factor at the upper tuning frequency."""
from math import sqrt,pow,pi
#Variable Declaration:
L=20e-06 #Self-inductance of the coil(in Henry)
fo_1=570e03 #Lower tuning frequency(in Hertz)
fo_2=1560e03 #Upper tuning frequency(in Hertz)
Q1=50.0 #Quality factor at the lower tuning frequency
#Calculations:
C1=1.0/(pow((2*pi*fo_1),2)*L)
C2=1.0/(pow((2*pi*fo_2),2)*L)
R=(2*pi*fo_1*L)/Q1
BW=fo_1/Q1
Q2=(2*pi*fo_2*L)/R
#Result:
print "(a)The range of tuning capacitor is from %.3f nF to %.3f nF." %((C2*1e09),(C1*1e09))
print "(b)The resistance of the coil is %.3f Ohms and the bandwidth of the circuit is %.3f kHz." %(R,(BW/1000))
print "(c)The quality factor of the circuit at the upper tuning frequency is %.3f." %(Q2)
```