Phasors

In the circuit given below, determine $Z_L$ for maximum power transfer.

(Follow the convention that $\cos\,(\omega \,t)$ corresponds to the phasor $1\,\angle {0}$.)

In [1]:
from IPython.display import Image
Image(filename =r'phasor_10_fig_1.png', width=400)
Out[1]:
No description has been provided for this image
In [2]:
# run this cell to view the circuit file.
%pycat phasor_10_orig.in

We now replace the strings \$R and \$X with the values of our choice by running the python script given below. It takes an existing circuit file phasor_10_orig.in and produces a new circuit file phasor_10.in, after replacing \$R and \$X with the values of our choice.

In [3]:
import gseim_calc as calc
s_R = '3' # to be changed by user
s_X = '-1' # to be changed by user
l = [
  ('$R', s_R),
  ('$X', s_X),
]
calc.replace_strings_1("phasor_10_orig.in", "phasor_10.in", l)
print('phasor_10.in is ready for execution')
phasor_10.in is ready for execution
Execute the following cell to run GSEIM on phasor_10.in.
In [4]:
import os
import dos_unix
# uncomment for windows:
#dos_unix.d2u("phasor_10.in")
os.system('run_gseim phasor_10.in')
Circuit: filename = phasor_10.in
main: i_solve = 0
GSEIM: Program completed.
Out[4]:
0

The circuit file (phasor_10.in) is created in the same directory as that used for launching Jupyter notebook. The last step (i.e., running GSEIM on phasor_10.in) creates the data file phasor_10.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 gseim_calc as calc

rad_to_deg = 180.0/np.pi

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

i_slv = 0
i_out = 0
filename = slv.l_filename_all[i_slv][i_out]
print('filename:', filename)
u = np.loadtxt(filename)
SZ = slv.get_scalar_complex_1(i_slv, i_out, "S_Z", u)

s_format = "%7.2f"

print('phasors in rectangular form:')
calc.print_complex_rect('SZ', SZ, s_format)

print('phasors in polar form:')
calc.print_complex_polar('SZ', SZ, s_format)

Pmax = 312.5
delP0 = 0.001*Pmax
delP = abs(Pmax - SZ.real)
if delP < delP0:
    print('Your ZL value is correct.')
else:
    print('Your ZL value is not correct.')
    print('The expected Pmax is', s_format%Pmax, 'W, but your are getting', s_format%(SZ.real), 'W')
filename: phasor_10.dat
phasors in rectangular form:
SZ: ( 288.45,  -96.15)
phasors in polar form:
SZ: magnitude:  304.05, angle:  -18.43 deg
Your ZL value is not correct.
The expected Pmax is  312.50 W, but your are getting  288.45 W

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

In [ ]: