import math
#Variable declaration
z = 333.0 #Driving point impedence (ohm)
r = 300.0 #twin-line impedence (ohm)
z1 = 73.0 #Self impedence of lambda/2 dipole (ohm)
z2 = 13.0 #Mutual impedence with lambda/2 spacing (ohm)
#Calculation
pv = (z-r)/(z+r) #Reflection coefficient (unitless)
vswr = (1+pv)/(1-pv) #Voltage Standing Wave Ratio (unitless)
gain_l2 =math.sqrt((2*z1)/(z1-z2)) #Field gain over lambda/2 dipole (unitless)
gain_l2_db = 20*math.log10(gain_l2) #Field gain (in dB)
gain_iso = (gain_l2**2)*1.64 #Gain over isotropic source (unitless)
gain_iso_db = 10*math.log10(gain_iso) #Gain over isotropic source (in dB)
#Result
print "The VSWR is", vswr
print "The field gain over lambda/2 dipole is", round(gain_l2,2), "or", round(gain_l2_db,1), "dB"
print """The gain over isotropic source is %.1f or %.1f dB
""" % (round(gain_iso),gain_iso_db)
import math
#Variable declaration
z = 73.0 #Self impedence of lambda/2 dipole (ohm)
zm = 64.4 #Mutual impedence with lambda/8 spacing (ohm)
#Calculation
D = math.sqrt((2*z)/(z-zm))*math.sin(math.pi/8) #Field gain over lambda/2 dipole (unitless)
D_db = 20*math.log10(D) #Field gain over lambda/2 dipole (in dB)
gain_iso = (D**2)*1.64 #gain over isotropic source (unitless)
gain_iso_db = 10*math.log10(gain_iso) #gain over isotropic source (in dB)
#Result
print "The field gain over lambda/2 dipole is", round(D,2), "or", round(D_db,2), "dB"
print "The gain over isotropic source is", round(gain_iso,2), "or", round(gain_iso_db,1), "dB"
from math import sqrt, log10
#Variable declaration
s1 = 0.4 #Spacing 1(lambda)
s2 = 0.5 #Spacing 2(lambda)
s3 = 0.6 #Spacing 3(lambda)
R_21_1 = 6.3 #Mutual resistance for s1 (ohm)
R_21_2 = -12.691 #Murual resistance for s2 (ohm)
R_21_3 = -23.381 #Mutual resistance for s3 (ohm)
Z = 73.13 #Self impedence of lambda/2 dipole (ohm)
#Calculation
gain_1 = sqrt(2*(Z/(Z+R_21_1))) #Gain in fieldfor s1 (unitless)
gain_iso1 = 1.64*(gain_1**2) #Power gain over isotropic (unitless)
gain_iso_db1 = 10*log10(gain_iso1) #Power gain (in dBi)
gain_2 = sqrt(2*(Z/(Z+R_21_2))) #Gain in fieldfor s2 (unitless)
gain_iso2 = 1.64*(gain_2**2) #Power gain over isotropic (unitless)
gain_iso_db2 = 10*log10(gain_iso2) #Power gain (in dBi)
gain_3 = sqrt(2*(Z/(Z+R_21_3))) #Gain in fieldfor s3 (unitless)
gain_iso3 = 1.64*(gain_3**2) #Power gain over isotropic (unitless)
gain_iso_db3 = 10*log10(gain_iso3) #Power gain (in dBi)
#Result
print "The gain in field over half wave antenna for s1 is", round(gain_1,2)
print """The power gain over isotropic for s1 is %.2f or %.1f dBi
""" % (gain_iso1,gain_iso_db1)
print "The gain in field over half wave antenna for s2 is", round(gain_2,2)
print """The power gain over isotropic for s2 is %.2f or %.2f dBi
""" % (gain_iso2,gain_iso_db2)
print "The gain in field over half wave antenna for s3 is", round(gain_3,2)
print """The power gain over isotropic for s3 is %.2f or %.2f dBi
""" % (gain_iso3,gain_iso_db3)