1-phase rectifier

For the rectifier circuit given below, determine
  1. the average voltage across the current source
  2. the average power delivered to the current source
  3. duration for which each diode conducts (in one cycle)
  4. duration for which all four diodes conduct (in one cycle)
In [1]:
from IPython.display import Image
Image(filename =r'rectifier_1ph_8_fig_1.png', width=400)
Out[1]:
No description has been provided for this image
In [2]:
# run this cell to view the circuit file.
%pycat rectifier_1ph_8_orig.in

We now replace the strings such as \$L with the values of our choice by running the python script given below. It takes an existing circuit file rectifier_1ph_8_orig.in and produces a new circuit file rectifier_1ph_8.in, after replacing \$L (etc) with values of our choice.

In [3]:
import gseim_calc as calc
import numpy as np
import sys

s_L = "10e-3"

l = [
  ('$L', s_L),
]
calc.replace_strings_1("rectifier_1ph_8_orig.in", "rectifier_1ph_8.in", l)
print('rectifier_1ph_8.in is ready for execution')
rectifier_1ph_8.in is ready for execution
Execute the following cell to run GSEIM on rectifier_1ph_8.in.
In [4]:
import os
import dos_unix
# uncomment for windows:
#dos_unix.d2u("rectifier_1ph_8.in")
os.system('run_gseim rectifier_1ph_8.in')
get_lib_elements: filename gseim_aux/xbe.aux
get_lib_elements: filename gseim_aux/ebe.aux
Circuit: filename = rectifier_1ph_8.in
main: i_solve = 0
main: calling solve_trns
mat_ssw_1_e: n_statevar: 1
Transient simulation starts...
i=0
i=1000
solve_ssw_e: ssw_iter_newton=0, rhs_ssw_norm=5.0006e+00
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_8.in) is created in the same directory as that used for launching Jupyter notebook. The last step (i.e., running GSEIM on rectifier_1ph_8.in) creates a data file called rectifier_1ph_8.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_8.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_ID1  = slv.get_index(i_slv,i_out,"ID1")
col_ID2  = slv.get_index(i_slv,i_out,"ID2")
col_ID3  = slv.get_index(i_slv,i_out,"ID3")
col_ID4  = slv.get_index(i_slv,i_out,"ID4")
col_VS   = slv.get_index(i_slv,i_out,"VS")
col_IL   = slv.get_index(i_slv,i_out,"IL")
col_P_IS = slv.get_index(i_slv,i_out,"P_IS")
col_V_IS = slv.get_index(i_slv,i_out,"V_IS")

l_V_IS = calc.avg_rms_2(t, u[:,col_V_IS], 0.0, 2.0*T, 1.0e-5*T)
l_P_IS = calc.avg_rms_2(t, u[:,col_P_IS], 0.0, 2.0*T, 1.0e-5*T)

t_V_IS =  np.array(l_V_IS[0])
V_ISm  = -np.array(l_V_IS[1])

print('average voltage across IS:', "%11.4E"%(V_ISm[0]))
print('average power absorbed by IS:', "%11.4E"%(-l_P_IS[1][0]))

# compute durations of diode conduction:

ndiv = 5000

delt_ID1, ID1p = calc.interp_linear_1(t, u[:,col_ID1], ndiv)
delt_ID2, ID2p = calc.interp_linear_1(t, u[:,col_ID2], ndiv)
delt_ID3, ID3p = calc.interp_linear_1(t, u[:,col_ID3], ndiv)
delt_ID4, ID4p = calc.interp_linear_1(t, u[:,col_ID4], ndiv)

n_ID1 = 0
n_ID2 = 0
n_ID3 = 0
n_ID4 = 0

n_ID_all = 0

for k in range(ndiv):
    if (ID1p[k] > 0): n_ID1 += 1
    if (ID2p[k] > 0): n_ID2 += 1
    if (ID3p[k] > 0): n_ID3 += 1
    if (ID4p[k] > 0): n_ID4 += 1
    if (ID1p[k] > 0):
        if (ID2p[k] > 0):
            if (ID3p[k] > 0):
                if (ID4p[k] > 0):
                    n_ID_all += 1

print('angle of conduction for D1:', float(n_ID1)*delt_ID1*360.0/(2.0*T), 'deg.')
print('angle of conduction for D2:', float(n_ID1)*delt_ID2*360.0/(2.0*T), 'deg.')
print('angle of conduction for D3:', float(n_ID1)*delt_ID3*360.0/(2.0*T), 'deg.')
print('angle of conduction for D4:', float(n_ID1)*delt_ID4*360.0/(2.0*T), 'deg.')

print('angle of conduction for all diodes:', float(n_ID_all)*delt_ID4*360.0/(2.0*T), 'deg.')

color1 = 'blue'
color2 = 'green'
color3 = 'red'
color4 = 'dodgerblue'
color5 = 'olive'

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=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_L$'   , fontsize=12)
ax[2].set_ylabel(r'$V_{IS}$', fontsize=12)
ax[3].set_ylabel(r'$I_{diode}$' , fontsize=12)

for i in range(3):
    ax[i].tick_params(labelbottom=False)

ax[0].plot(t*1e3,  u[:,col_VS]  , color=color1, linewidth=1.0, label="$V_s$")
ax[1].plot(t*1e3,  u[:,col_IL]  , color=color2, linewidth=1.0, label="$I_L$")
ax[2].plot(t*1e3, -u[:,col_V_IS], color=color3, linewidth=1.0, label="$V_{IS}$")
ax[3].plot(t*1e3,  u[:,col_ID1] , color=color1, linewidth=1.0, label="$I_{D1}$")
ax[3].plot(t*1e3,  u[:,col_ID2] , color=color5, linewidth=1.0, label="$I_{D2}$")

ax[2].plot(t_V_IS*1e3, V_ISm, color=color3, linewidth=1.0, label="$V_{Is}^{avg}$", linestyle='--', dashes=(5,3))

ax[3].set_xlabel('time (msec)', fontsize=11)

ax[3].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()
filename: rectifier_1ph_8.dat
average voltage across IS:  1.8804E+02
average power absorbed by IS:  9.4021E+02
angle of conduction for D1: 206.208 deg.
angle of conduction for D2: 206.208 deg.
angle of conduction for D3: 206.208 deg.
angle of conduction for D4: 206.208 deg.
angle of conduction for all diodes: 52.416 deg.
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.