Capacitor in periodic steady state

A capacitor C of $22\,\mu$F is being charged from a periodic sinusoidal current source (with period $T_s = 100\,\mu$s) and discharged by a constant current source as shown in the figure below. Assume that the capacitor has reached a cyclic steady state.
  1. Find $I_m$.
  2. Find the peak-to-peak voltage across the capacitor.
In [1]:
from IPython.display import Image
Image(filename =r'misc_5_fig_1.png', width=550)
Out[1]:
No description has been provided for this image
In [2]:
import numpy as np
import matplotlib.pyplot as plt 
import gseim_calc as calc
from setsize import set_size

Im_sin = 12.0 # to be changed by user
T = 100.0e-6
I0 = 5.0
C = 22e-6
omg = 2.0*np.pi/T

n_div = 2000
t = np.linspace(0.0, 2*T, (n_div+1))

Tby2 = T/2

l_sin = []
l_con = []
for i, u in enumerate(t):
    t1 = u % T
    if t1 < Tby2:
        I_sin = Im_sin*np.sin(omg*t1)
    else:
        I_sin = 0.0

    l_con.append(I0)
    l_sin.append(I_sin)

x_con = np.array(l_con)
x_sin = np.array(l_sin)

x_net = x_sin-x_con

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*I0):
    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')

# set vc = 0 at t = 0 (this is arbitrary)

l_vc = []
vc = 0
l_vc.append(vc)

delt = 2.0*T/float(n_div)
c1 = delt/C

for k in range(1,len(t)):
    vc += c1*x_net[k]
    l_vc.append(vc)

vc1 = np.array(l_vc)

l1 = calc.min_max_1(t, vc1, 0.0, 2.0*T)
vc_ptop = l1[1] - l1[0]
print('vc_ptop:', "%11.4E"%vc_ptop)

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_{net}$',fontsize=13)
ax[2].set_ylabel('$v_C$',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_net, color=color2, linewidth=1.0, label="$i_{net}$")
ax[2].plot(t*1e6, vc1  , color=color3, linewidth=1.0, label="$v_C$")

ax[1].plot(t_net*1e6, l_x_net[1], color=color2, linewidth=1.0, label="$i_{net}^{avg}$", linestyle='-.')

ax[1].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.1803E+00
Im_sin = 12.0 is not correct
vc_ptop:  1.7505E+01
No description has been provided for this image

This notebook was contributed by Prof. Nakul Narayanan K, Govt. Engineering College, Thrissur. He may be contacted at nakul@gectcr.ac.in.

In [ ]:
 
In [ ]: