1-phase rectifier
In the circuit given below, $V_m$ is $100\,$V and the load resistor is $10\,\Omega$. Determine- the power factor of each source
- the average power dissipated in the load resistor
In [1]:
from IPython.display import Image
Image(filename =r'rectifier_1ph_13_fig_1.png', width=450)
Out[1]:
In [2]:
# run this cell to view the circuit file.
%pycat rectifier_1ph_13_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_13_orig.in and produces a new circuit file rectifier_1ph_13.in, after replacing \$R (etc) with values of our choice.
In [3]:
import gseim_calc as calc
import numpy as np
import sys
s_R = "10"
l = [
('$R', s_R),
]
calc.replace_strings_1("rectifier_1ph_13_orig.in", "rectifier_1ph_13.in", l)
print('rectifier_1ph_13.in is ready for execution')
rectifier_1ph_13.in is ready for execution
Execute the following cell to run GSEIM on rectifier_1ph_13.in.
In [4]:
import os
import dos_unix
# uncomment for windows:
#dos_unix.d2u("rectifier_1ph_13.in")
os.system('run_gseim rectifier_1ph_13.in')
get_lib_elements: filename gseim_aux/xbe.aux get_lib_elements: filename gseim_aux/ebe.aux Circuit: filename = rectifier_1ph_13.in Circuit: n_xbeu_vr = 0 Circuit: n_ebeu_nd = 4 main: i_solve = 0 main: calling solve_trns Transient simulation starts... i=0 i=1000 GSEIM: Program completed.
Out[4]:
0
The circuit file (rectifier_1ph_13.in) is created in the same directory as that used for launching Jupyter notebook. The last step (i.e., running GSEIM on rectifier_1ph_13.in) creates a data file called rectifier_1ph_13.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_13_orig.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_V_S1 = slv.get_index(i_slv,i_out,"V_S1")
col_V_S2 = slv.get_index(i_slv,i_out,"V_S2")
col_I_S1 = slv.get_index(i_slv,i_out,"I_S1")
col_I_S2 = slv.get_index(i_slv,i_out,"I_S2")
col_P_S1 = slv.get_index(i_slv,i_out,"P_S1")
col_P_S2 = slv.get_index(i_slv,i_out,"P_S2")
col_I_R = slv.get_index(i_slv,i_out,"I_R")
col_P_R = slv.get_index(i_slv,i_out,"P_R")
l_I_S1 = calc.avg_rms_2(t, u[:,col_I_S1], 0.0, 2.0*T, 1.0e-5*T)
l_I_S2 = calc.avg_rms_2(t, u[:,col_I_S2], 0.0, 2.0*T, 1.0e-5*T)
l_V_S1 = calc.avg_rms_2(t, u[:,col_V_S1], 0.0, 2.0*T, 1.0e-5*T)
l_V_S2 = calc.avg_rms_2(t, u[:,col_V_S2], 0.0, 2.0*T, 1.0e-5*T)
l_P_S1 = calc.avg_rms_2(t, u[:,col_P_S1], 0.0, 2.0*T, 1.0e-5*T)
l_P_S2 = calc.avg_rms_2(t, u[:,col_P_S2], 0.0, 2.0*T, 1.0e-5*T)
l_P_R = calc.avg_rms_2(t, u[:,col_P_R ], 0.0, 2.0*T, 1.0e-5*T)
Pavg1 = l_P_S1[1][0]
Irms1 = l_I_S1[2][0]
Vrms1 = l_V_S1[2][0]
pf_S1 = Pavg1/(Vrms1*Irms1)
Pavg2 = l_P_S2[1][0]
Irms2 = l_I_S2[2][0]
Vrms2 = l_V_S2[2][0]
pf_S2 = Pavg2/(Vrms2*Irms2)
Pavg_R = l_P_R[1][0]
print('Vrms1:', "%11.4e"%Vrms1)
print('Irms1:', "%11.4e"%Irms1)
print('Pavg1:', "%11.4e"%Pavg1)
print('Vrms2:', "%11.4e"%Vrms2)
print('Irms2:', "%11.4e"%Irms2)
print('Pavg2:', "%11.4e"%Pavg2)
print('VS1 power factor:', "%6.3f"%pf_S1)
print('VS2 power factor:', "%6.3f"%pf_S2)
print('Pavg for R:', "%11.4e"%Pavg_R)
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_{src}$', fontsize=12)
ax[1].set_ylabel(r'$I_{S1}$' , fontsize=12)
ax[2].set_ylabel(r'$I_{S2}$' , fontsize=12)
ax[3].set_ylabel(r'$I_R$' , fontsize=12)
for i in range(3):
ax[i].tick_params(labelbottom=False)
ax[0].plot(t*1e3, u[:,col_V_S1], color=color1, linewidth=1.0, label="$v_{sa}$")
ax[0].plot(t*1e3, u[:,col_V_S2], color=color2, linewidth=1.0, label="$v_{sb}$")
ax[1].plot(t*1e3, u[:,col_I_S1], color=color3, linewidth=1.0, label="$I_{S1}$")
ax[2].plot(t*1e3, u[:,col_I_S2], color=color4, linewidth=1.0, label="$I_{S2}$")
ax[3].plot(t*1e3, u[:,col_I_R ], color=color5, linewidth=1.0, label="$I_{R}$")
ax[3].set_xlabel('time (msec)', fontsize=11)
ax[0].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_13.dat Vrms1: 7.0693e+01 Irms1: 4.9971e+00 Pavg1: 2.4974e+02 Vrms2: 7.0693e+01 Irms2: 4.9996e+00 Pavg2: 2.4998e+02 VS1 power factor: 0.707 VS2 power factor: 0.707 Pavg for R: 4.9965e+02
This notebook was contributed by Prof. Nakul Narayanan K, Govt. Engineering College, Thrissur. He may be contacted at nakul@gectcr.ac.in.
In [ ]: