Time constants

In the circuit shown in the figure, $i_L=0\,$A at $t=0$ and $1.2\,$A at $t=0.6\,$msec.
  1. What is $i_L$ as $t \rightarrow \infty$?
  2. Find $R_2$.
  3. Plot $i_1(t)$, $i_2(t)$, $i_L(t)$, and $V_L(t)$.
In [1]:
from IPython.display import Image
Image(filename =r'time_constant_3_fig_1.png', width=260)
Out[1]:
No description has been provided for this image
In [2]:
# run this cell to view the circuit file.
%pycat time_constant_3_orig.in

We now replace the string \$R2 with the value of our choice by running the python script given below. It takes an existing circuit file time_constant_3_orig.in and produces a new circuit file time_constant_3.in, after replacing \$R2 with the value of our choice.

In [3]:
import gseim_calc as calc
s_R2 = '20' # to be changed by user
l = [
  ('$R2', s_R2),
]
calc.replace_strings_1("time_constant_3_orig.in", "time_constant_3.in", l)
print('time_constant_3.in is ready for execution')
time_constant_3.in is ready for execution
Execute the following cell to run GSEIM on time_constant_3.in.
In [4]:
import os
import dos_unix
# uncomment for windows:
#dos_unix.d2u("time_constant_3.in")
os.system('run_gseim time_constant_3.in')
Circuit: filename = time_constant_3.in
main: i_solve = 0
main: calling solve_startup
main: i_solve = 1
main: calling solve_trns
Transient simulation starts...
i=0
GSEIM: Program completed.
Out[4]:
0

The circuit file (time_constant_3.in) is created in the same directory as that used for launching Jupyter notebook. The last step (i.e., running GSEIM on time_constant_3.in) creates the data file time_constant_3.dat in the same directory. We can now use the python code below to compute and display the quantities of interest.

In [5]:
import numpy as np
import matplotlib.pyplot as plt 
import gseim_calc as calc
from setsize import set_size

slv = calc.slv("time_constant_3.in")

i_slv = 1
i_out = 0
filename = slv.l_filename_all[i_slv][i_out]
print('filename:', filename)
u = np.loadtxt(filename)

t = u[:, 0]
t_end = t[-1]
IL1 = 1.2

IR1 = slv.get_array_double(i_slv, i_out, 'IR1', u)
IR2 = slv.get_array_double(i_slv, i_out, 'IR2', u)
IL  = slv.get_array_double(i_slv, i_out, 'IL',  u)
VL  = slv.get_array_double(i_slv, i_out, 'VL',  u)

l_cross_1, l_cross_2 = calc.cross_over_points_1(t, IL, 0.0, t_end, IL1)
print('time points at which IL crosses', "%5.2f"%IL1, "A")
for t1 in l_cross_1:
    print("  ", "%5.2f"%(t1*1e3), "msec")

color1='blue'
color2='green'
color3='red'

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

set_size(5.5, 7.0, ax[0])

for i in range(4):
    ax[i].set_xlim(left=0.0, right=t_end*1e3)
    ax[i].grid(color='#CCCCCC', linestyle='solid', linewidth=0.5)

ax[0].set_ylim(bottom=0.0, top=2.0)

ax[0].set_ylabel(r'$i_L$ (A)', fontsize=12)
ax[1].set_ylabel(r'$i_1$ (A)', fontsize=12)
ax[2].set_ylabel(r'$i_2$ (A)', fontsize=12)
ax[3].set_ylabel(r'$V_L$ (V)', fontsize=12)

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

ax[0].plot(t*1e3, IL,  color=color1, linewidth=1.0, label="$i_L$")
ax[1].plot(t*1e3, IR1, color=color1, linewidth=1.0, label="$i_1$")
ax[2].plot(t*1e3, IR2, color=color1, linewidth=1.0, label="$i_2$")
ax[3].plot(t*1e3, VL,  color=color2, linewidth=1.0, label="$V_L$")

ax[0].axhline(y = IL1, color = color3, linestyle = '--', linewidth=0.8, dashes=(5,5))
if len(l_cross_1) != 0:
    ax[0].axvline(x = l_cross_1[0]*1e3, color = color3, linestyle = '--', linewidth=0.8, dashes=(5,5))

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

#plt.tight_layout()
plt.show()
filename: time_constant_3.dat
time points at which IL crosses  1.20 A
    0.82 msec
No description has been provided for this image

This notebook was contributed by Prof. M. B. Patil, IIT Bombay. He may be contacted at mbpatil@ee.iitb.ac.in.

In [ ]: