Bi-directional voltage source converter

A single-phase bi-directional voltage source converter is connected to an AC voltage source through an inductor $L = 5\,$mH as given below. All the switches are ideal and are operated using the sinusoidal pulse width modulation technique. The dc link voltage is $500\,$V. The AC source voltage is $230\,\cos\,(100\,\pi \,t)$V (rms). The PWM carrier signal is a triangle wave between $-1$ and $1$ with a frequency of $10\,$kHz, and the modulating signal is $v_{ref}(t) = 0.8\,\cos\,(100\,\pi \,t + \phi)$. If $\phi$ is varied from $-180^{\circ}$ to $180^{\circ}$, show that the locus of the tip of the fundamental component of the inductor current is a circle. Find the origin and radius of the circle.

In [1]:
from IPython.display import Image
Image(filename =r'Animation_VSC_bi_4_fig_1.png', width=300)
Out[1]:
In [2]:
# run this cell to view the circuit file.
%pycat Animation_VSC_bi_4_orig.in
In [3]:
import numpy as np
import gseim_calc as calc
import os
import dos_unix
import math
import cmath

Nphi1 = 37
Nphi2 = int((Nphi1-1)/2)
phi_arr = np.linspace(-180.0, 180.0, Nphi1)

real_IL = []
imag_IL = []
real_VL = []
imag_VL = []
real_v_inv = []
imag_v_inv = []
real_v_ac = []
imag_v_ac = []

s_L = '5e-3'
s_Vdc = '500'
s_M = '0.8'
s_f_hz = '50'
A_sin = 230.0*np.sqrt(2.0)
s_A_sin = ("%11.4E"%A_sin).strip()

slv = calc.slv("Animation_VSC_bi_4_orig.in")
i_slv = 0
i_out = 0
filename = slv.l_filename_all[i_slv][i_out]
col_IL = slv.get_index(i_slv,i_out,"IL")
col_VL = slv.get_index(i_slv,i_out,"VL")
col_v_inv = slv.get_index(i_slv,i_out,"v_inv")
col_v_ac = slv.get_index(i_slv,i_out,"v_ac")

sqrt2 = np.sqrt(2.0)

for phi in phi_arr:
    s_phi = "%11.4E"%(phi + 90.0)
    l = [
      ('$L', s_L),
      ('$Vdc', s_Vdc),
      ('$M', s_M),
      ('$f_hz', s_f_hz),
      ('$A_sin', s_A_sin),
      ('$phi', s_phi),
    ]
    print('phi:', "%5.1f"%phi)
    calc.replace_strings_1("Animation_VSC_bi_4_orig.in", "Animation_VSC_bi_4.in", l)

    # uncomment for windows:
    #dos_unix.d2u("Animation_VSC_bi_4.in")
    os.system('run_gseim Animation_VSC_bi_4.in')

    u = np.loadtxt(filename)
    t = u[:, 0]
    t0 = t[0]
    t = t - t0
    T = t[-1]
    k_fourier = 1

    coeff, thd, coeff_a, coeff_b = calc.fourier_coeff_2A(t, u[:,col_IL], 0.0, T, 1.0e-8*T, 1)
    real_x, imag_x = calc.get_mag_angle_2(k_fourier, coeff_a, coeff_b)
    real_IL.append(real_x/sqrt2)
    imag_IL.append(imag_x/sqrt2)

    coeff, thd, coeff_a, coeff_b = calc.fourier_coeff_2A(t, u[:,col_VL], 0.0, T, 1.0e-8*T, 1)
    real_x, imag_x = calc.get_mag_angle_2(k_fourier, coeff_a, coeff_b)
    real_VL.append(real_x/sqrt2)
    imag_VL.append(imag_x/sqrt2)

    coeff, thd, coeff_a, coeff_b = calc.fourier_coeff_2A(t, u[:,col_v_inv], 0.0, T, 1.0e-8*T, 1)
    real_x, imag_x = calc.get_mag_angle_2(k_fourier, coeff_a, coeff_b)
    real_v_inv.append(real_x/sqrt2)
    imag_v_inv.append(imag_x/sqrt2)

    coeff, thd, coeff_a, coeff_b = calc.fourier_coeff_2A(t, u[:,col_v_ac], 0.0, T, 1.0e-8*T, 1)
    real_x, imag_x = calc.get_mag_angle_2(k_fourier, coeff_a, coeff_b)
    real_v_ac.append(real_x/sqrt2)
    imag_v_ac.append(imag_x/sqrt2)

#print('phi_arr[Nphi2]:', phi_arr[Nphi2])

x1 = real_IL[0]
x2 = real_IL[Nphi2]

y1 = imag_IL[0]
y2 = imag_IL[Nphi2]

x_o = 0.5*(x1 + x2)
y_o = 0.5*(y1 + y2)

delx = x2 - x1
dely = y2 - y1

r = 0.5*np.sqrt(delx*delx + dely*dely)

print('x1:', "%11.4E"%x1, 'x2:', "%11.4E"%x2)
print('y1:', "%11.4E"%y1, 'y2:', "%11.4E"%y2)
print('delx:', "%11.4E"%delx)
print('dely:', "%11.4E"%dely)
print('from graph:')
print('origin: (', "%11.4E"%x_o, ",", "%11.4E"%y_o, ")")
print('radius:', "%11.4E"%r)

L = float(s_L)
Vdc = float(s_Vdc)
M = float(s_M)
f_hz = float(s_f_hz)
A_sin = float(s_A_sin)

omg = 2.0*np.pi*f_hz
XL = omg*L
y_o_theory = A_sin/(sqrt2*XL)
r_theory = M*Vdc/(sqrt2*XL)

print('from theory:')
print('origin: (0,', "%11.4E"%y_o_theory, ")")
print('radius:', "%11.4E"%r_theory)
phi: -180.0
phi: -170.0
phi: -160.0
phi: -150.0
phi: -140.0
phi: -130.0
phi: -120.0
phi: -110.0
phi: -100.0
phi: -90.0
phi: -80.0
phi: -70.0
phi: -60.0
phi: -50.0
phi: -40.0
phi: -30.0
phi: -20.0
phi: -10.0
phi:   0.0
phi:  10.0
phi:  20.0
phi:  30.0
phi:  40.0
phi:  50.0
phi:  60.0
phi:  70.0
phi:  80.0
phi:  90.0
phi: 100.0
phi: 110.0
phi: 120.0
phi: 130.0
phi: 140.0
phi: 150.0
phi: 160.0
phi: 170.0
phi: 180.0
x1: -5.9643E-01 x2:  3.7000E-02
y1:  3.2650E+02 y2: -3.3641E+01
delx:  6.3343E-01
dely: -3.6014E+02
from graph:
origin: ( -2.7971E-01 ,  1.4643E+02 )
radius:  1.8007E+02
from theory:
origin: (0,  1.4642E+02 )
radius:  1.8006E+02
In [4]:
import matplotlib.pyplot as plt 
import sys
from matplotlib.ticker import (MultipleLocator, AutoMinorLocator)
from matplotlib import animation
from IPython.display import HTML
import gseim_calc as calc

IL1 = []
for i in range(len(real_IL)):
    IL_phasor = complex(real_IL[i], imag_IL[i])
    IL1.append(IL_phasor)

fig, ax = plt.subplots()
fig.set_size_inches(8, 4)

xmin = min(real_IL) - 10.0
xmax = max(real_IL) + 10.0
ymin = min(imag_IL) - 10.0
ymax = max(imag_IL) + 10.0

ax.set_aspect('equal', adjustable='box')
ax.set(xlim=[xmin, xmax], ylim=[ymin, ymax])

plt.grid(color='#CCCCCC', linestyle='solid', linewidth=0.5)

plt.xlabel('$Re(i_L)$',fontsize=12)
plt.ylabel('$Im(i_L)$',fontsize=12)

fig.suptitle('Note: current is in A (rms)', fontsize=12)

line = ax.plot([], [], color='blue', linestyle = '--', linewidth=0.8, dashes=(3,3))[0]
line2 = []
for i in range(3):
    line2a = ax.plot([], [], color='blue', linestyle = '-', linewidth=1.0)[0]
    line2.append(line2a)

ax.axhline(y=0.0, color='#777777', linestyle = '-', linewidth=0.5)
ax.axvline(x=0.0, color='#777777', linestyle = '-', linewidth=0.5)

l3 = []
l_labels = []

props = dict(boxstyle='round', facecolor='grey', alpha=0.15)  # bbox features
text1 = ax.text(1.03, 0.98, '', transform=ax.transAxes, fontsize=11, verticalalignment='top', bbox=props)
theta_deg = 20.0

def update(frame):
    line.set_xdata(real_IL[:frame+1])
    line.set_ydata(imag_IL[:frame+1])
    l3.clear()
    l_labels.clear()
    calc.phasor_append_1(l3, l_labels, IL1[frame], "$i_L$")
    length_arrow = 0.03*(xmax-xmin)

    l4  = calc.phasor_2(l3 , theta_deg, length_arrow, 0.4)

    for k, t in enumerate(l4[0]):
        line2[k].set_xdata(t[0])
        line2[k].set_ydata(t[1])

    text1.set_text(
      r'$\phi$' + ' = %5.0f' % phi_arr[frame] + r'$^{\circ}$' + '\n' +
      'Re($i_L$) = %6.1f' % real_IL[frame] + '\n' +
      'Im($i_L$) = %6.1f' % imag_IL[frame]
    )
    return

anim = animation.FuncAnimation(
    fig=fig,
    func=update,
    frames=Nphi1,
    interval=500,
    repeat=False)

plt.tight_layout()
plt.close()

HTML(anim.to_jshtml())
Out[4]:
In [5]:
import matplotlib.pyplot as plt 
import sys
from matplotlib.ticker import (MultipleLocator, AutoMinorLocator)
from matplotlib import animation
from IPython.display import HTML
import gseim_calc as calc

IL1 = []
VL1 = []
v_inv1 = []
v_ac1 = []

for i in range(len(real_IL)):
    IL1.append   (complex(real_IL   [i], imag_IL   [i]))
    VL1.append   (complex(real_VL   [i], imag_VL   [i]))
    v_inv1.append(complex(real_v_inv[i], imag_v_inv[i]))
    v_ac1.append (complex(real_v_ac [i], imag_v_ac [i]))

fig, ax = plt.subplots()
fig.set_size_inches(8, 4)

xmin = min(real_IL + real_VL + real_v_inv + real_v_ac) - 10.0
xmax = max(real_IL + real_VL + real_v_inv + real_v_ac) + 10.0
ymin = min(imag_IL + imag_VL + imag_v_inv + imag_v_ac) - 10.0
ymax = max(imag_IL + imag_VL + imag_v_inv + imag_v_ac) + 10.0

ax.set_aspect('equal', adjustable='box')
ax.set(xlim=[xmin, xmax], ylim=[ymin, ymax])

plt.grid(color='#CCCCCC', linestyle='solid', linewidth=0.5)

plt.xlabel('$Re$',fontsize=12)
plt.ylabel('$Im$',fontsize=12)

fig.suptitle('Note: units are A (rms), V (rms)', fontsize=12)

c_IL    = 'blue'
c_VL    = 'red'
c_v_inv = 'green'
c_v_ac  = 'grey'

line_IL    = ax.plot([], [], color=c_IL,    linestyle='--', linewidth=0.8, dashes=(3,3))[0]
line_VL    = ax.plot([], [], color=c_VL,    linestyle='--', linewidth=0.8, dashes=(3,3))[0]
line_v_inv = ax.plot([], [], color=c_v_inv, linestyle='--', linewidth=0.8, dashes=(3,3))[0]

line2_IL    = []
line2_VL    = []
line2_v_inv = []
line2_v_ac  = []

line2_sum   = []

for i in range(3):
    if i == 0:
        line1_IL    = ax.plot([], [], color=c_IL,    linewidth=1.0, label='$i_L$')[0]
        line1_VL    = ax.plot([], [], color=c_VL,    linewidth=1.0, label='$v_L$')[0]
        line1_v_inv = ax.plot([], [], color=c_v_inv, linewidth=1.0, label='$v_{inv}$')[0]
        line1_v_ac  = ax.plot([], [], color=c_v_ac,  linewidth=1.0, label='$v_{ac}$')[0]
    else:
        line1_IL    = ax.plot([], [], color=c_IL,    linewidth=1.0)[0]
        line1_VL    = ax.plot([], [], color=c_VL,    linewidth=1.0)[0]
        line1_v_inv = ax.plot([], [], color=c_v_inv, linewidth=1.0)[0]
        line1_v_ac  = ax.plot([], [], color=c_v_ac,  linewidth=1.0)[0]

    if i == 0:
        line1_sum = ax.plot([], [], color=c_VL, linestyle='--', linewidth=1.0, dashes=(4,2))[0]
    else:
        line1_sum = ax.plot([], [], color=c_VL, linestyle='-', linewidth=1.0)[0]

    line2_IL   .append(line1_IL)
    line2_VL   .append(line1_VL)
    line2_v_inv.append(line1_v_inv)
    line2_v_ac .append(line1_v_ac)
    line2_sum  .append(line1_sum)

ax.axhline(y=0.0, color='#777777', linestyle = '-', linewidth=0.5)
ax.axvline(x=0.0, color='#777777', linestyle = '-', linewidth=0.5)

ax.legend(loc='lower left', fontsize=11, bbox_to_anchor=(1.05, 0.0))

l3_IL    = []
l3_VL    = []
l3_v_inv = []
l3_v_ac  = []
l3_sum   = []

l_dummy_sum = []

l_labels_IL    = []
l_labels_VL    = []
l_labels_v_inv = []
l_labels_v_ac  = []
l_labels_sum   = []

props = dict(boxstyle='round', facecolor='grey', alpha=0.15)  # bbox features
text1 = ax.text(1.03, 0.98, '', transform=ax.transAxes, fontsize=11, verticalalignment='top', bbox=props)
theta_deg = 20.0
length_arrow = 0.03*(xmax-xmin)

def update(frame):
    line_IL.set_xdata(real_IL[:frame+1])
    line_IL.set_ydata(imag_IL[:frame+1])

    line_VL.set_xdata(real_VL[:frame+1])
    line_VL.set_ydata(imag_VL[:frame+1])

    line_v_inv.set_xdata(real_v_inv[:frame+1])
    line_v_inv.set_ydata(imag_v_inv[:frame+1])

    l3_IL.clear()
    l_labels_IL.clear()
    calc.phasor_append_1(l3_IL, l_labels_IL, IL1[frame], "$i_L$")
    l4_IL  = calc.phasor_2(l3_IL , theta_deg, length_arrow, 0.4)

    for k, t in enumerate(l4_IL[0]):
        line2_IL[k].set_xdata(t[0])
        line2_IL[k].set_ydata(t[1])

    l3_VL.clear()
    l_labels_VL.clear()
    calc.phasor_append_1(l3_VL, l_labels_VL, VL1[frame], "$i_L$")
    l4_VL  = calc.phasor_2(l3_VL , theta_deg, length_arrow, 0.4)

    for k, t in enumerate(l4_VL[0]):
        line2_VL[k].set_xdata(t[0])
        line2_VL[k].set_ydata(t[1])

    l3_v_inv.clear()
    l_labels_v_inv.clear()
    calc.phasor_append_1(l3_v_inv, l_labels_v_inv, v_inv1[frame], "$i_L$")
    l4_v_inv  = calc.phasor_2(l3_v_inv , theta_deg, length_arrow, 0.4)

    for k, t in enumerate(l4_v_inv[0]):
        line2_v_inv[k].set_xdata(t[0])
        line2_v_inv[k].set_ydata(t[1])

    l3_v_ac.clear()
    l_labels_v_ac.clear()
    calc.phasor_append_1(l3_v_ac, l_labels_v_ac, v_ac1[frame], "$i_L$")
    l4_v_ac  = calc.phasor_2(l3_v_ac , theta_deg, length_arrow, 0.4)

    for k, t in enumerate(l4_v_ac[0]):
        line2_v_ac[k].set_xdata(t[0])
        line2_v_ac[k].set_ydata(t[1])

    l3_sum.clear()
    l_dummy_sum.clear()
    l_labels_sum.clear()
    calc.phasor_append_2(l3_sum, l_dummy_sum, v_ac1[frame-1], (VL1[frame] + v_ac1[frame-1]), c_VL)
    l4_sum = calc.phasor_2(l3_sum, theta_deg, length_arrow, 0.4)

    for k, t in enumerate(l4_sum[0]):
        line2_sum[k].set_xdata(t[0])
        line2_sum[k].set_ydata(t[1])

    text1.set_text(
      r'$\phi$' + ' = %5.0f' % phi_arr[frame] + r'$^{\circ}$' + '\n' +
      'Re($i_L$) = %6.1f' % real_IL[frame] + '\n' +
      'Im($i_L$) = %6.1f' % imag_IL[frame]
    )
    return

anim = animation.FuncAnimation(
    fig=fig,
    func=update,
    frames=Nphi1,
    interval=500,
    repeat=False)

plt.tight_layout()
plt.close()

HTML(anim.to_jshtml())
Out[5]:

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

In [ ]: