1-phase rectifier
In the circuit given below (assuming ideal diode), determine the maximum value of the capacitance $C$ which ensures 360-degree conduction of the diode.In [1]:
from IPython.display import Image
Image(filename =r'rectifier_1ph_3_fig_1.png', width=400)
Out[1]:
In [2]:
# run this cell to view the circuit file.
%pycat rectifier_1ph_3_orig.in
We now replace the strings such as \$C with the values of our choice by running the python script given below. It takes an existing circuit file rectifier_1ph_3_orig.in and produces a new circuit file rectifier_1ph_3.in, after replacing \$C (etc) with values of our choice.
In [3]:
import gseim_calc as calc
import numpy as np
s_C = "1500e-6" # to be changed by user
s_I0 = "31.416"
l = [
('$C', s_C),
('$I0', s_I0),
]
calc.replace_strings_1("rectifier_1ph_3_orig.in", "rectifier_1ph_3.in", l)
print('rectifier_1ph_3.in is ready for execution')
rectifier_1ph_3.in is ready for execution
Execute the following cell to run GSEIM on rectifier_1ph_3.in.
In [4]:
import os
import dos_unix
# uncomment for windows:
#dos_unix.d2u("rectifier_1ph_3.in")
os.system('run_gseim rectifier_1ph_3.in')
get_lib_elements: filename gseim_aux/xbe.aux get_lib_elements: filename gseim_aux/ebe.aux Circuit: filename = rectifier_1ph_3.in Circuit: n_xbeu_vr = 0 Circuit: n_ebeu_nd = 3 main: i_solve = 0 ssw_allocate_1 (2): n_statevar=2 main: calling solve_trns mat_ssw_1_e: n_statevar: 2 mat_ssw_1_e0: cct.n_ebeu: 4 Transient simulation starts... i=0 i=1000 solve_ssw_e: ssw_iter_newton=0, rhs_ssw_norm=1.4995e-01 Transient simulation starts... i=0 i=1000 solve_ssw_e: ssw_iter_newton=1, rhs_ssw_norm=0.0000e+00 solve_ssw_e: calling solve_ssw_1_e for one more trns step Transient simulation starts... i=0 i=1000 solve_ssw_1_e over (after trns step for output) solve_ssw_e ends, slv.ssw_iter_newton=1 GSEIM: Program completed.
Out[4]:
0
The circuit file (rectifier_1ph_3.in) is created in the same directory as that used for launching Jupyter notebook. The last step (i.e., running GSEIM on rectifier_1ph_3.in) creates a data file called rectifier_1ph_3.dat in the same directory. We can now use the python code below to compute/plot the various quantities of interest.
In [5]:
import numpy as np
import matplotlib.pyplot as plt
import gseim_calc as calc
from setsize import set_size
f_hz = 50.0
T = 1.0/f_hz
slv = calc.slv("rectifier_1ph_3.in")
i_slv = 0
i_out = 0
filename = slv.l_filename_all[i_slv][i_out]
print('filename:', filename)
u = np.loadtxt(filename)
t = u[:, 0]
col_ID = slv.get_index(i_slv,i_out,"ID")
col_v_s = slv.get_index(i_slv,i_out,"v_s")
col_v_c = slv.get_index(i_slv,i_out,"v_c")
color1='blue'
color2='green'
color3='red'
fig, ax = plt.subplots(3, sharex=False)
plt.subplots_adjust(wspace=0, hspace=0.0)
set_size(5.5, 6, ax[0])
for i in range(3):
ax[i].set_xlim(left=0.0, right=2.0*T*1e3)
ax[i].grid(color='#CCCCCC', linestyle='solid', linewidth=0.5)
ax[0].set_ylabel(r'$v_s$', fontsize=12)
ax[1].set_ylabel(r'$I_{D}$', fontsize=12)
ax[2].set_ylabel(r'$v_c$', fontsize=12)
ax[0].tick_params(labelbottom=False)
ax[1].tick_params(labelbottom=False)
ax[0].plot(t*1e3, u[:,col_v_s], color=color1, linewidth=1.0, label="$v_s$")
ax[1].plot(t*1e3, u[:,col_ID ], color=color2, linewidth=1.0, label="$I_{D}$")
ax[2].plot(t*1e3, u[:,col_v_c], color=color3, linewidth=1.0, label="$v_c$")
ax[2].set_xlabel('time (msec)', fontsize=11)
#plt.tight_layout()
plt.show()
filename: rectifier_1ph_3.dat
This notebook was contributed by Prof. Nakul Narayanan K, Govt. Engineering College, Thrissur. He may be contacted at nakul@gectcr.ac.in.