# Chapter 2: Antenna Basics

### Example 2-3.1, Page number: 14

In :
import math

#Variable declaration
e_half_power = 1/math.sqrt(2)    #E(theta) at half power (relative quantity)

#Calculation
theta = math.acos(math.sqrt(e_half_power)) # theta (radians)
hpbw = 2*theta*180/math.pi     # Half power beamwidth (degrees)

#Result
print "The half power beamwidth is ", round(hpbw), "degrees"

The half power beamwidth is  66.0 degrees


### Example 2-3.2, Page number: 14

In :
import math

#Variable declaration
e_half_power = 1/math.sqrt(2)   #E(theta) at half power(unitless)
e_null = 0      #E(theta) = 0 at null points (unitless)
theta_1 = 0     #theta' (degrees)
theta = 1       #theta (degrees)

#Calculation
for x in range(3):      #Iterate till theta = i
theta = 0.5*math.acos(e_half_power/math.cos(theta_1*math.pi/180))
theta_1 = theta*180/math.pi       #set i = theta for next iteration (degrees)

hpbw = 2*(theta*180/math.pi)    #Half-power beamwidth (Degrees)
fnbw = 2*(theta*180/math.pi)    #Beamwidth between first null (degrees)

#Result
print "The half power beamwidth is", round(hpbw), "degrees"
print "The beamwidth between first nulls is ", round(fnbw), "degrees"

The half power beamwidth is 41.0 degrees
The beamwidth between first nulls is  90.0 degrees


### Example 2-4.1, Page number: 17

In :
import scipy.integrate
import math

#Variable declaration
def integrand(x):
return math.sin(x)      #Function sin(theta)

def integrand2(x):
return 1                #Contant function

#Calculation
omega = omega*(180/math.pi) * scipy.integrate.quad(integrand2 ,30 ,70)
#Integration between the ranges gives solid angle, omega (square degrees)

#Result
print "The solid angle, omega is", round(omega), "square degrees"

The solid angle, omega is 398.0 square degrees


### Example 2-4.2, Page number: 17

In :
import math
import scipy.integrate

#Variable declaration
def func1(x,y):
return (math.cos(x)**4)*math.sin(x)*1 #Function for integration

#Calculation
lambda x: 0, lambda x: math.pi/2)

#Result
print "The beam area of the given pattern is", round(beam_area, 2), "sr"

The beam area of the given pattern is 1.26 sr


### Example 2-7.1, Page number: 21

In :
import scipy.integrate
from math import pi,sin,cos,log10

#Variable declaration
n = 10     #Number of isotropic point sources
hpbw = 40    #Half power beamwidth (degrees)
def integrand(x,phi):
E_norm  = (sin(pi/20))*(sin((pi/2)*(5*cos(phi)-6))/sin((pi/20)*(5*cos(phi)-6)))
return (E_norm**2)

#Calculation
lambda x: 0, lambda x: pi/2)
gain = (4*pi)/gain    #Gain (unitless)
gain_db = 10*log10(gain)#Gain (dB)
gain_hpbw = 40000/(hpbw**2)    #Gain from approx. equation (unitless)
gain_hpbw_db = 10*log10(gain_hpbw)    #Gain from approx. equation (dB)
gain_diff = gain_hpbw_db - gain_db    #Difference in gain (dB)

#Result
print "The gain G is", round(gain_db,2),"dB"
print "The gain from approx. equation is", round(gain_hpbw_db),"dB"
print "The difference is", round(gain_diff,2),"dB"

#The solution is incorrect due to the incorrect integration of the normalized power pattern
#As a result, the difference in gain is slightly higher

The gain G is 10.01 dB
The gain from approx. equation is 14.0 dB
The difference is 3.97 dB


### Example 2-7.2, Page number: 21

In :
import math
import scipy.integrate

#Variable declaration
theta_hp = 90
phi_hp = 90

def integrand(theta, phi):
return ((math.sin(theta)**3)*(math.sin(phi)**2))

#Calculation
lambda x: 0, lambda x: math.pi)
#Exact Directivity(No unit)
direct_apprx = 41253.0/(theta_hp*phi_hp)    #Approximate directivity (No unit)
db_diff = 10*math.log10(direct_exact/direct_apprx) #Difference (decibels)

#Result
print "The exact directivity is", round(direct_exact, 1)
print "The approximate directivity is", round(direct_apprx,1)
print "The decibel difference is ", round(db_diff, 1), "dB"

The exact directivity is 6.0
The approximate directivity is 5.1
The decibel difference is  0.7 dB


### Example 2-10.1, Page number: 28

In :
import math

#Variable declaration
Z = 120*math.pi                 #Intrinsic impedence of free space (ohm)

#Calculation
max_aper = Z/(320*math.pi**2)   #Max. effective aperture (lambda^2)
direct = 4*math.pi*max_aper     #directivity (unitless)

#Result
print "The maximum effective aperture is", round(max_aper, 3), "lambda^2"
print "The direcitivity is", direct

The maximum effective aperture is 0.119 lambda^2
The direcitivity is 1.5


### Example 2-10.2, Page number: 29

In :
import math

#Variable declaration
R_r = 73                            #Radiation resistance (ohm)

#Calculation
eff_aper = 30/(R_r*math.pi)         #Effective aperture (lambda^2)
directivity = 4*math.pi*eff_aper    #Directivity (unitless)

#Result
print "The effective aperture is", round(eff_aper, 2), "lambda^2"
print "The directivity is", round(directivity,2)

The effective aperture is 0.13 lambda^2
The directivity is 1.64


### Example 2-11.1, Page number: 31

In :
#Variable declaration
P_t = 15        #Transmitter power (W)
A_et = 2.5      #Effective aperture of transmitter (meter^2)
A_er = 0.5      #Effective aperture of receiver (meter^2)
r = 15e3        #Distance between the antennas (Line of sight) (m)
freq  = 5e9     #Frequency (Hz)
c = 3e8         #speed of light (m/s)

#Calculation
wave_len = c/freq                               #Wavelength (m)
P_r = (P_t*A_et*A_er)/((r**2)*(wave_len**2))    #received power (W)

#Result
print "The power delivered to the receiver is", round(P_r,6), "watts"

The power delivered to the receiver is 2.3e-05 watts


### Example 2-16.1, Page number: 40

In :
#Variable declaration
E1 = 3      #Magnitude of electric field in x direction (V/m)
E2 = 6      #Magnitude of electric field in y direction (V/m)
Z = 377     #Intrinsic impedence of free space (ohm)

#Calculation
avg_power = 0.5*(E1**2 + E2**2)/Z       #average power per unit area (W/m^2)

#Result
print "The average power per unit area is", avg_power, "watts/meter^2"

The average power per unit area is 0.0596816976127 watts/meter^2


### Example 2-17.1, Page number: 43

In :
import math

#Variable declaration
AR_w = 4          #Axial Ratio for left elliptically polarized wave (unitless)
tau_w = 15        #Tilt angle for left elliptically polarized wave (degrees)
AR_a = -2         #Axial Ratio for right elliptically polarized wave (unitless)
tau_a = 45        #Tilt angle for right elliptically polarized wave (degrees)
tau_w2 = 20.7     #2*Tilt angle for left elliptically polarized wave (degrees)
tau_a2 = 39.3     #2*Tilt angle for right elliptically polarized wave (degrees)

#Calculation
eps_a2 = 2*math.atan2(1,AR_a)*180/math.pi  #polarisation latitude (degrees)
eps_w2 = 2*math.atan2(1,AR_w)*180/math.pi   #antenna latitude (degrees)
gamma_w2 =math.acos(math.cos(eps_w2*math.pi/180)*math.cos(tau_w2*math.pi/180));

The polarization matching factor is 0.44