EE2703 End Sem IITM, May 22
EE2703 End Sem IITM, May 22
This code involves a lot of vectors and arrays. All such operations should be vector-
ized.
Label all plots. Add legends. Make the plots professional looking.
There are five sections to the code. Each should have its own pseudocode (you can cut
and paste the question itself here to some extent)
Each array or vector asked for in this assignment should be printed out in the pdf. For
this, use N = 4. The printing of vectors and arrays is messy so use print((MATRIX).round(2)),
where MATRIX is the matrix (or vector) you are printing.
Only in the case of the matrix P, use “print((P*1e8).round(2))” so that the numbers
are meaningful after rounding to two digits.
Once you have the code debugged, set N=100 and do the actual calculation (do not
print out all the matrices here!)
Python code should be named your-roll-number.py Please note that I will accept only
raw python code and it should run in Python 3.x (prefer Python 3.8) So don’t send
me Jupyter notebooks.
The Pdf should be submitted to the ’final’ assignment, and the .py code should be
submitted to the ’final-code’ assignment.
This is a problem to find the antenna currents in a half-wave dipole antenna
A long wire carries a current I(z) in a dipole antenna with half length of 50cm - so
the antenna is a metre long, and has a wavelength of 2 metres. We want to determine the
currents in the two wires of the antenna. The standard analysis assumes that the antenna
current is given by ( )
Im sin (k(l − z)) 0 ≤ z ≤ l
I=
Im sin (k(l + z)) −l ≤ z < 0
This is then used to compute the radiated field. The problem is to determine if this is a good
assumption. The parameters of this problem are as follows:
l=0.5 metres (quarter wavelength) c=2.9979e8 m/sec, speed of light mu0=4e-7*pi per-
meability of free space N=4 Number of sections in each half section of the antenna. Set
to N=4 initially and to N=100 later. Im=1.0 current injected into the antenna. a=0.01 me-
tres, radius of wire. Dependent Parameters lamda=l*4.0 metres, wavelength f=c/lamda Hz,
frequency k=2*pi/lamda wave number dz=l/N spacing of current samples
1. Divide the wire into pieces of length dz. Ideally we should number the pieces with
indices going from −N to +N. Unfortunately, Python does not allow negative array
indices, so we will have an array with indices going from 0 to 2N (2N + 1 elements,
with element N being the feed of the antenna).
Define points along the antenna as an array, z,
z = i × dz, −N ≤ i ≤ N
These are the points at which we compute the currents. The currents at end of the
wire are zero, while the currents at z = 0 are prescribed by the circuit driving the
antenna. There is the entering current Im and the return current −Im . Both currents
are at z = 0, and both point in the same direction along the antenna. So a single value
is sufficient. The currents are therefore I[i] for 0 ≤ i ≤ N. So there are 2N + 1 currents,
with 2N − 2 currents unknown (The end currents are known to be zero and current
at the centre is given as Im .) The 2N − 2 locations of unknown currents are computed
and kept in array u. Also construct the current vector I at points corresponding to
vector z, and the current vector J at points corresponding to vector u.
2. We need an equation for each unknown current. These equations are obtained by
calculating the Magnetic field in two different ways. From Ampere’s Law, we have
for Hφ (z, r = a)
2πaHφ (zi ) = Ii
write this as a matrix equation
Hφ [z1 ] 1 ... 0 0 ... 0 J1
...
... ... ... ... ... ...
...
Hφ [zN−1 ] 1 0 ... 1 0 ... 0 JN−1
=
2πa
Hφ [zN+1 ]
0 ... 0 1 ... 0 JN+1
...
... ... ... ... ... ...
...
Hφ [z2N−1 ] 0 ... 0 0 ... 1 J2N−1
= M∗J
Note that the matrix M assumes Hφ is computed at r = a. Also note that the vector J
is the vector of unknown currents. This is why the matrix is 2N − 2 by 2N − 2.
Write a function to compute and return the matrix M.
4π R
where ~R =~r −~r0 = rr̂ + zẑ − z0 ẑ and k = ω/c = 0.1. ~r is the point where we want the
field, and~r0 = z0 zˆ0 is the point on the wire. This can be reduced to a sum:
again a matrix equation like the previous one. P is a matrix with 2N − 2 columns and
2N − 2 rows. Note that the vector potential is driven by all the currents, which is why
we use the I vector. PB is the contribution to the vector potential due to current IN ,
and is given by
µ0 exp (− jkRiN ) 0
PB = dz j
4π RiN
Compute and create vectors Rz and Ru which are the distances from observer at ~r +
zi ẑ, and source at z0j ẑ. The difference between Rz and Ru is that the former computes
distances including distances to known currents, while Ru is a vector of distances to
unknown currents.
Also compute the matrix P and PB . Note that PB is a column vector.
~ and ~A only has the ẑ component. So the equation
We only want the φ component of H
become
0 !
1 ∂Az µ0 dz j ∂ exp − jkRi j
Hφ (r, z) = − = −∑ Ij
µ ∂r j 4π µ ∂r Ri j
~
q contribute to Hφ , and so the current vector is I. Now, R =
Note that all the currents
rr̂ + (z − z0 )ẑ. So, R = r2 + (z − z0 )2 . The derivative becomes
∂ 1 r
Ri j = 2r =
∂r 2Ri j Ri j
So,
dz0j
!
− jk 1 rI j
Hφ (r, zi ) = − ∑ − 2 exp − jkRi j
j 4π Ri j Ri j Ri j
!
r − jk 1 r − jk 1
= − ∑ Pi j − 2 I j + PB − Im
j µ0 Ri j Ri j µ0 RiN R2iN
= ∑ Q0i j I j
j
Hφ (r, zi ) = ∑ Q0i j I j
j
= ∑ Qi j J j + QBiIm
j
The Q0i j in the equation is over all the currents. However this needs to be split into the
unknown currents, J j and the boundary currents. Only one of the boundary currents
is non-zero, namely the feed current at i = N. The matrix corresponding to J j we call
Qi j , and the boundary current we call QB = Q0iN
Create the matrices Qi j and QB .
i.e.,
(M − Q) J = QB Im
~ and hence ~I. The current vector can be compared
This is easily solved for to obtain J,
to the standard expression given at the top of the assignment.
Invert (M − Q) and obtain J. Use inv(M-Q) in python. Add the Boundary currents
(zero at i=0, i=2N, and Im at i=N). Then plot this current vs. z and also plot the
equation assumed for current at the top of this question paper.
Explain any discrepancies.