def target(x): global freq, target_impedance base_height = np.exp(x[0]) # Make it positive length = np.exp(x[1]) # Make it positive if (length > 10.0): return 100 try: z = monopole.impedance(freq, base_height, length) return reflection_coefficient(z, z0=target_impedance) except RuntimeError as re: return 100
def target(x): global freq base_height = np.exp(x[0]) # Make it positive length = np.exp(x[1]) # Make it positive z = monopole.impedance(freq, base_height, length) return reflection_coefficient(z, z0=50.0)
# # Plot of reflection coefficient vs antenna length for a fixed base height. # import monopole import numpy as np import pylab as plt from antenna_util import reflection_coefficient lengths = np.linspace(0.2, 5.0, 270) reflections = [] z0 = 50 for l in lengths: freq = 134.5 z = monopole.impedance(freq, base=0.5, length=l) reflections.append(reflection_coefficient(z, z0)) plt.plot(lengths, reflections) plt.xlabel("Antenna length (m)") plt.ylabel("Reflection coefficient") plt.title("Reflection coefficient vs length (base_height=0.5m)") plt.grid(True) plt.show() plt.savefig("reflection_coefficient.png")
# Plot stuff import matplotlib.pyplot as plt from antenna_util import reflection_coefficient l_best = 0.01 r_best = -9999.9 z0 = 50.0 droop = to_radians(40.0) for l in np.linspace(0.03, 0.19, 70): z, gains_db, thetas, phis = inverted_v(freq=1545.42, base=0.1, length=l, angle=droop, phi_start=60, phi_stop=90) gmean = np.mean(np.mean(from_db(gains_db))) gmax = np.max(np.max(from_db(gains_db))) gmin = np.min(np.min(from_db(gains_db))) r = (gmean) * (1.0 - reflection_coefficient(z, z0)) / (1.5 + gmax - gmin) if (r > r_best): r_best = r l_best = l print r_best print l_best z, gains_db, thetas, phis = inverted_v(freq=1545.42, base=0.1, length=l_best, angle=droop, phi_start=10, phi_stop=90) print z print reflection_coefficient(z,50) ax = plt.subplot(111, polar=True) for j in range(0,10):
l_best = 0.01 r_best = -9999.9 z0 = 50.0 droop = to_radians(40.0) for l in np.linspace(0.03, 0.19, 70): z, gains_db, thetas, phis = inverted_v(freq=1545.42, base=0.1, length=l, angle=droop, phi_start=60, phi_stop=90) gmean = np.mean(np.mean(from_db(gains_db))) gmax = np.max(np.max(from_db(gains_db))) gmin = np.min(np.min(from_db(gains_db))) r = (gmean) * (1.0 - reflection_coefficient(z, z0)) / (1.5 + gmax - gmin) if (r > r_best): r_best = r l_best = l print r_best print l_best z, gains_db, thetas, phis = inverted_v(freq=1545.42, base=0.1, length=l_best, angle=droop, phi_start=10, phi_stop=90)
#if (r > r_best): #r_best = r #l_best = l #print r_best #print l_best z, gains_db, thetas, phis = quad_helix(freq=1545.42, base=0.1, length=l_best, angle=droop, phi_start=5, phi_stop=90) print z print reflection_coefficient(z, 50) ax = plt.subplot(111, polar=True) for j in range(0, 10): ax.plot(thetas, gains_db[:, j] + 20, linewidth=3, label=("%s" % (phis[j] * 180.0 / 3.1415))) ax.grid(True) ax.set_title("Gain at an elevation of 45 degrees", va='bottom') plt.savefig('RadiationPattern.png') plt.legend() plt.show() #import matplotlib.pyplot as plt