Capacitor in periodic steady state
A capacitor $C$ is being charged by a current source and discharged by a current sink as shown in the figure below. $i_{in}(t)$ is a rectified sinusoid. If the capacitor is in cyclic steady state, find $I_m$.In [1]:
from IPython.display import Image
Image(filename =r'misc_4_fig_1.png', width=600)
Out[1]:
In [2]:
import numpy as np
import matplotlib.pyplot as plt
import gseim_calc as calc
from setsize import set_size
Im_sin = 4.0 # to be changed by user
T = 10.0e-6
D = 0.75
Im_sqr = 5.0
T_sin = 2.0*T
omg = 2.0*np.pi/T_sin
n_div = 2000
t = np.linspace(0.0, 2*T, (n_div+1))
DT = D*T
l_sin = []
l_sqr = []
for i, u in enumerate(t):
t1 = u % T
if t1 < DT:
I_sqr = Im_sqr
else:
I_sqr = 0.0
I_sin = Im_sin*np.sin(omg*t1)
l_sqr.append(I_sqr)
l_sin.append(I_sin)
x_sqr = np.array(l_sqr)
x_sin = np.array(l_sin)
x_net = x_sin-x_sqr
l_x_net = calc.avg_rms_2(t, x_net, 0.0, 2.0*T, 1.0e-5*T)
t_net = np.array(l_x_net[0])
if abs(l_x_net[1][0]) > (1.0e-3*Im_sqr):
print('average value:', "%11.4E"%l_x_net[1][0])
print('Im_sin =', Im_sin, 'is not correct')
else:
print('Im_sin =', Im_sin, 'is correct')
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=2.0*T*1e6)
ax[k].grid(color='#CCCCCC', linestyle='solid', linewidth=0.5)
ax[0].set_ylabel('$i_{in}$',fontsize=13)
ax[1].set_ylabel('$i_{out}$',fontsize=13)
ax[2].set_ylabel('$i_{net}$',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, x_sin, color=color1, linewidth=1.0, label="$i_{in}$")
ax[1].plot(t*1e6, x_sqr, color=color2, linewidth=1.0, label="$i_{out}$")
ax[2].plot(t*1e6, x_net, color=color3, linewidth=1.0, label="$i_{net}$")
ax[2].plot(t_net*1e6, l_x_net[1], color=color3, linewidth=1.0, label="$i_{net}^{avg}$", linestyle='-.')
ax[2].legend(loc = 'lower right',frameon = True, fontsize = 10, title = None,
markerfirst = True, markerscale = 1.0, labelspacing = 0.5, columnspacing = 2.0,
prop = {'size' : 12},)
#plt.tight_layout()
plt.show()
average value: -1.2060E+00 Im_sin = 4.0 is not correct
This notebook was contributed by Prof. Nakul Narayanan K, Govt. Engineering College, Thrissur. He may be contacted at nakul@gectcr.ac.in.
In [ ]: