Inductor in periodic steady state

The periodic voltage (of period 6 ms) across an inductor in steady state is shown in the figure. The positive half and negative half voltages are both sinusoidal, with different peak values. If the positive peak voltage is 40 V, then find the value of $K$ shown in the figure.
In [1]:
from IPython.display import Image
Image(filename =r'misc_3_fig_1.png', width=350)
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

A = 40.0
K = 30.0 # to be changed by user

T1 = 4.0e-3
T2 = 2.0*T1
omg1 = 2.0*np.pi/T1
omg2 = 2.0*np.pi/T2

t_total = 0.5*(T1 + T2)
n_div = 1000
t = np.linspace(0.0, t_total, (n_div+1))

l_v = []
for i, t1 in enumerate(t):
    if t1 < 0.5*T1:
        v = A*np.sin(omg1*t1)
    else:
        v = K*np.sin(omg2*t1 + 0.5*np.pi)
    l_v.append(v)

v_arr = np.array(l_v)
l_x = calc.avg_rms_2(t, v_arr, 0.0, t_total, 1.0e-5*t_total)
t2 = np.array(l_x[0])

if abs(l_x[1][0]) > (1.0e-4*A):
    print('average value:', "%11.4E"%l_x[1][0])
    print('K =', K, 'is not correct')
else:
    print('K =', K, 'is correct')

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, v_arr, color=color1, linewidth=1.0, label="$v$")
ax.plot(t2*1e3, l_x[1], color=color1, linewidth=1.0, label="$v^{avg}$", linestyle='--', dashes=(5,3))
ax.set_xlim(0.0, t_total*1e3)

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

ax.legend(loc = 'upper 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: -4.2441E+00
K = 30.0 is not correct
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 [ ]: