#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Plot difference in SWR bandwidth with attenuation Created on Sun Sep 19 10:30:04 2021 @author: jimlux """ import numpy as np import matplotlib.pyplot as plt def findvswrbw(freqs,vswr,points=[1.5,2]): output = [] for p in points: vswrpts = np.where(vswr<=p) vswrbw = freqs[vswrpts[0][-1]] - freqs[vswrpts[0][0]] output.append(vswrbw) return (output) """ assume antenna resonance is a classic Lorenzian RLC resonance Z = 50 + 1/jwC + jwL, where imaginary part disappears at resonance Set for resonance at 10 MHz (omega = 62.8 rad/sec) Rres is set to 50 representing something like a inverted V """ omega0 = 10 * 2 * np.pi R = 52 C = 4 #pF L = 63.2 #uH LC = 1E6/((10*2*np.pi)**2) C = LC/L titlestr = "R:%5.2f C:%5.2f pF L:%5.2f uH"%(R,C,L) freqs = np.linspace(9.9,10.1,301) Xc = 1/(freqs * 2*np.pi * C*1e-6) #pF, MHz Xl = freqs * 2 * np.pi * L #uH, MHz plt.figure() plt.plot(freqs,Xc) plt.plot(freqs,Xl) plt.legend(["Xc","Xl"]) plt.xlabel("MHz") plt.xlim([min(freqs), max(freqs)]) plt.title(titlestr) plt.grid() Zant = R + 1j * (Xl-Xc) Z0 = 50 gamma = (Zant-Z0)/(Zant+Z0) mags11 = 20*np.log10(np.abs(gamma)) mags11pad = mags11-2 gammapad = 10**(mags11pad/20) vswr = (1+np.abs(gamma))/(1-np.abs(gamma)) vswrpad = (1+gammapad)/(1-gammapad) bws = findvswrbw(freqs,vswr) bwspad = findvswrbw(freqs,vswrpad) plt.figure() plt.plot(freqs,mags11) plt.plot(freqs,mags11pad) plt.legend(["no loss","1dB loss"]) plt.ylabel("|S11|") plt.xlabel("MHz") plt.xlim([min(freqs), max(freqs)]) plt.title(titlestr) plt.grid() plt.figure() plt.plot(freqs,vswr) plt.plot(freqs,vswrpad) plt.legend(["no loss","1dB loss"]) plt.ylim([1,5]) plt.ylabel('VSWR') plt.xlabel("MHz") plt.xlim([min(freqs), max(freqs)]) plt.title(titlestr) textboxstr = "1.5:1 %5.2f %5.2f kHz"%(bws[0]*1000,bwspad[0]*1000) textboxstr += "\n 2:1 %5.2f %5.2f kHz"%(bws[1]*1000,bwspad[1]*1000) plt.text(10,4,textboxstr,ha='center',bbox=dict(ec=(0,0,0),fc=(1,1,1))) plt.grid()