1-phase rectifier
A single 500$\mu$s duration pulse is used to turn-on switch $SW$ as shown below. Determine the peak voltage appearing across the switch.In [1]:
from IPython.display import Image
Image(filename =r'rectifier_1ph_5_fig_1.png', width=600)
Out[1]:
In [2]:
# run this cell to view the circuit file.
%pycat rectifier_1ph_5_orig.in
We now replace the strings such as \$R with the values of our choice by running the python script given below. It takes an existing circuit file rectifier_1ph_2_orig.in and produces a new circuit file rectifier_1ph_2.in, after replacing \$R (etc) with values of our choice.
In [3]:
import gseim_calc as calc
import numpy as np
s_R = "10"
s_L = "10e-3"
l = [
('$R', s_R),
('$L', s_L),
]
calc.replace_strings_1("rectifier_1ph_5_orig.in", "rectifier_1ph_5.in", l)
print('rectifier_1ph_5.in is ready for execution')
rectifier_1ph_5.in is ready for execution
Execute the following cell to run GSEIM on rectifier_1ph_5.in.
In [4]:
import os
import dos_unix
# uncomment for windows:
#dos_unix.d2u("rectifier_1ph_5.in")
os.system('run_gseim rectifier_1ph_5.in')
get_lib_elements: filename gseim_aux/xbe.aux get_lib_elements: filename gseim_aux/ebe.aux Circuit: filename = rectifier_1ph_5.in Circuit: n_xbeu_vr = 1 Circuit: n_ebeu_nd = 4 main: i_solve = 0 main: calling solve_startup main: i_solve = 1 main: calling solve_trns Transient simulation starts... i=0 i=1000 i=2000 i=3000 i=4000 i=5000 i=6000 i=7000 i=8000 i=9000 solve_trns_exc completed. GSEIM: Program completed.
Out[4]:
0
The circuit file (rectifier_1ph_5.in) is created in the same directory as that used for launching Jupyter notebook. The last step (i.e., running GSEIM on rectifier_1ph_5.in) creates a data file called rectifier_1ph_5.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
slv = calc.slv("rectifier_1ph_5.in")
i_slv = 1
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_IL = slv.get_index(i_slv,i_out,"IL")
col_I_SW = slv.get_index(i_slv,i_out,"I_SW")
col_V_SW = slv.get_index(i_slv,i_out,"V_SW")
# get value of t_end from the circuit file:
fin = open("rectifier_1ph_5.in", "r")
for line in fin:
if 't_end' in line:
s = line.replace("\n","")
t_end = float(s.split('=')[1])
color1='blue'
color2='green'
color3='red'
color4='dodgerblue'
fig, ax = plt.subplots(4, sharex=False)
plt.subplots_adjust(wspace=0, hspace=0.0)
set_size(5.5, 8, ax[0])
for i in range(4):
ax[i].set_xlim(left=0.0, right=t_end*1e6)
ax[i].grid(color='#CCCCCC', linestyle='solid', linewidth=0.5)
ax[0].set_ylabel(r'$I_{SW}$', fontsize=12)
ax[1].set_ylabel(r'$I_L$' , fontsize=12)
ax[2].set_ylabel(r'$I_D$' , fontsize=12)
ax[3].set_ylabel(r'$V_{SW}$', fontsize=12)
for i in range(3):
ax[i].tick_params(labelbottom=False)
ax[0].plot(t*1e6, u[:,col_I_SW], color=color1, linewidth=1.0, label="$I_{SW}$")
ax[1].plot(t*1e6, u[:,col_IL] , color=color2, linewidth=1.0, label="$I_L$")
ax[2].plot(t*1e6, u[:,col_ID] , color=color3, linewidth=1.0, label="$I_D$")
ax[3].plot(t*1e6, u[:,col_V_SW], color=color4, linewidth=1.0, label="$V_{SW}$")
ax[3].set_xlabel(r'time ($\mu$sec)', fontsize=11)
#plt.tight_layout()
plt.show()
filename: rectifier_1ph_5.dat
This notebook was contributed by Prof. Nakul Narayanan K, Govt. Engineering College, Thrissur. He may be contacted at nakul@gectcr.ac.in.