Capacitor charging/discharging
The periodic current given below is passed through a capacitor which is initially uncharged. The energy stored in the capacitor at the end of five cycles is $0.78\,$mJ. If $D=0.5$, $T=10\,\mu$s, $I_1=15\,$A, $I_2=-10\,$A, find $C$.In [1]:
from IPython.display import Image
Image(filename =r'misc_7_fig_1.png', width=220)
Out[1]:
In [2]:
import numpy as np
import matplotlib.pyplot as plt
import gseim_calc as calc
from setsize import set_size
C = 50e-6 # to be changed by user
I1 = 15.0
I2 = -10.0
T = 10.0e-6
D = 0.5
n_div = 5000
t = np.linspace(0.0, 5.0*T, (n_div+1))
DT = D*T
l_ic = []
for i, u in enumerate(t):
t1 = u % T
if t1 < DT:
Ix = I1
else:
Ix = I2
l_ic.append(Ix)
ic1 = np.array(l_ic)
l_vc = []
vc = 0
l_vc.append(vc)
delt = 5.0*T/float(n_div)
c1 = delt/C
for k in range(1,len(t)):
vc += c1*ic1[k]
l_vc.append(vc)
vc1 = np.array(l_vc)
E = 0.5*C*vc1*vc1
print('Final energy:', "%11.4E"%E[-1])
fig, ax = plt.subplots(3, sharex=False)
plt.subplots_adjust(wspace=0, hspace=0.0)
grid_color='#CCCCCC'
set_size(6, 6, ax[0])
color1 ='blue'
color2 ='olive'
color3 ='crimson'
for k in range(3):
ax[k].set_xlim(left=0.0, right=5.0*T*1e6)
ax[k].grid(color='#CCCCCC', linestyle='solid', linewidth=0.5)
ax[0].set_ylabel('$i_C$',fontsize=13)
ax[1].set_ylabel('$v_C$',fontsize=13)
ax[2].set_ylabel('$E$',fontsize=13)
ax[0].tick_params(labelbottom=False)
ax[1].tick_params(labelbottom=False)
ax[2].set_xlabel(r'$t$ ($\mu$sec)',fontsize=13)
ax[0].plot(t*1e6, ic1, color=color1, linewidth=1.0, label="$i_C$")
ax[1].plot(t*1e6, vc1, color=color2, linewidth=1.0, label="$v_C$")
ax[2].plot(t*1e6, E , color=color3, linewidth=1.0, label="$E$")
#plt.tight_layout()
plt.show()
Final energy: 1.5688E-04
This notebook was contributed by Prof. Nakul Narayanan K, Govt. Engineering College, Thrissur. He may be contacted at nakul@gectcr.ac.in.
In [ ]: