Waveforms

A periodic waveform with period $T$ is given below. If $V=100\,$V, determine the RMS value of the waveform. ($T=20\,$msec)
In [1]:
from IPython.display import Image
Image(filename =r'waveforms_5_fig_1.png', width=450)
Out[1]:
No description has been provided for this image
In [2]:
import numpy as np
import matplotlib.pyplot as plt 
import gseim_calc as calc
from setsize import set_size

T = 20.0e-3
V = 100.0

T1 = T/5
T2 = 2.0*T1
T3 = 3.0*T1
T4 = 4.0*T1

n_div = 5000
t = np.linspace(0.0, 2*T, (n_div+1))

slope = V/T1

l1 = []
for i, t1a in enumerate(t):
    t1 = t1a % T
    if t1 < T1:
        t0 = 0.0
        v0 = V
        v1 = v0 - slope*(t1-t0)
    elif t1 < T2:
        t0 = T1
        v0 = 0.0
        v1 = v0 + slope*(t1-t0)
    elif t1 < T3:
        t0 = T2
        v0 = V
        v1 = v0 - slope*(t1-t0)
    elif t1 < T4:
        t0 = T3
        v0 = 0.0
        v1 = v0 + slope*(t1-t0)
    else:
        t0 = T4
        v0 = V
        v1 = v0 - slope*(t1-t0)
    l1.append(v1)

x = np.array(l1)

l_x = calc.avg_rms_2(t, x, 0.0, 2.0*T, 1.0e-5*T)
x1 = np.array(l_x[0])

print('average value:', "%11.4E"%l_x[1][0])
print('rms value:',     "%11.4E"%l_x[2][0])

color1='blue'

fig, ax = plt.subplots()
plt.subplots_adjust(wspace=0, hspace=0.0)

set_size(5, 2.5, ax) 

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

ax.plot(t*1e3, x, color=color1, linewidth=1.0, label="$x$")
ax.plot(x1*1e3, l_x[1], color=color1, linewidth=1.0, label="$x^{avg}$", linestyle='--', dashes=(5,3))
ax.plot(x1*1e3, l_x[2], color=color1, linewidth=1.0, label="$x^{rms}$", linestyle='-.')
ax.set_xlim(0.0, 40.0)

plt.xlabel('time (msec)', fontsize=11)

ax.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()
average value:  5.0020E+01
rms value:  5.7752E+01
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.

In [ ]: