diff --git a/docs/source/examples_antennas.rst b/docs/source/examples_antennas.rst index f3c6ee9b..68360ae4 100644 --- a/docs/source/examples_antennas.rst +++ b/docs/source/examples_antennas.rst @@ -22,6 +22,21 @@ This example demonstrates a model of a half-wavelength wire dipole antenna in fr The antenna is fed using the ``#tranmission_line`` command. The one-dimensional transmission line model virtually attaches to the dipole at the gap between the arms. The antenna has an input impedance :math:`Z_0` of 73 Ohms specified in the ``#tranmission_line`` command. The transmission line uses a Gaussian waveform with a centre frequency of 1GHz. +Results +------- + +.. _antenna_wire_dipole_fs_tl_params: + +.. figure:: images/antenna_wire_dipole_fs_tl_params.png + + Time and frequency domain plots of the incident and reflected (scattered) voltages in the transmission line. + +.. _antenna_wire_dipole_fs_ant_params: + + .. figure:: images/antenna_wire_dipole_fs_ant_params.png + + s11 parameter and input impedance (resistance and reactance) of the antenna. + Bowtie antenna model ==================== diff --git a/docs/source/images/antenna_wire_dipole_fs_ant_params.png b/docs/source/images/antenna_wire_dipole_fs_ant_params.png new file mode 100644 index 00000000..7cfbb882 Binary files /dev/null and b/docs/source/images/antenna_wire_dipole_fs_ant_params.png differ diff --git a/docs/source/images/antenna_wire_dipole_fs_tl_params.png b/docs/source/images/antenna_wire_dipole_fs_tl_params.png new file mode 100644 index 00000000..48cb4bea Binary files /dev/null and b/docs/source/images/antenna_wire_dipole_fs_tl_params.png differ diff --git a/tools/plot_Bscan.py b/tools/plot_Bscan.py index 417d9521..e54e1fee 100644 --- a/tools/plot_Bscan.py +++ b/tools/plot_Bscan.py @@ -58,6 +58,7 @@ if 'E' in args.field: cb.set_label('Field strength [V/m]') elif 'H' in args.field: cb.set_label('Field strength [A/m]') + plt.show() #fig.savefig(os.path.splitext(os.path.abspath(file))[0] + '.pdf', dpi=None, format='pdf', bbox_inches='tight', pad_inches=0.1) f.close() diff --git a/tools/plot_s11.py b/tools/plot_antenna_params.py similarity index 54% rename from tools/plot_s11.py rename to tools/plot_antenna_params.py index cba9d77e..44cd0338 100644 --- a/tools/plot_s11.py +++ b/tools/plot_antenna_params.py @@ -16,7 +16,7 @@ # You should have received a copy of the GNU General Public License # along with gprMax. If not, see . -import argparse +import os, argparse import h5py import numpy as np np.seterr(divide='ignore', invalid='ignore') @@ -25,10 +25,10 @@ import matplotlib.gridspec as gridspec from gprMax.exceptions import CmdInputError -"""Plots the s11 scattering parameter (input port voltage reflection coefficient) from an output file containing a transmission line source.""" +"""Plots antenna parameters (s11 parameter and input impedance) from an output file containing a transmission line source.""" # Parse command line arguments -parser = argparse.ArgumentParser(description='Plots the s11 scattering parameter (input port voltage reflection coefficient) from an output file containing a transmission line source.', usage='cd gprMax; python -m tools.plot_s11 outputfile') +parser = argparse.ArgumentParser(description='Plots antenna parameters (s11 parameter and input impedance) from an output file containing a transmission line source.', usage='cd gprMax; python -m tools.plot_antenna_params outputfile') parser.add_argument('outputfile', help='name of output file including path') parser.add_argument('-tln', default=1, type=int, help='transmission line number') args = parser.parse_args() @@ -44,6 +44,7 @@ time = time / 1e-9 path = '/tls/tl' + str(args.tln) + '/' Vinc = f[path + 'Vinc'][:] Vscat = f[path + 'Vscat'][:] +Iscat = f[path + 'Iscat'][:] Vtotal = f[path +'Vtotal'][:] # Calculate magnitude of frequency spectra @@ -51,6 +52,8 @@ Vincp = np.abs(np.fft.fft(Vinc))**2 freqs = np.fft.fftfreq(Vincp.size, d=dt) Vscatp = np.abs(np.fft.fft(Vscat))**2 s11 = Vscatp / Vincp +zin = np.zeros(iterations, dtype=np.complex) +zin = np.abs(np.fft.fft(Vscat)) / np.abs(np.fft.fft(Iscat)) # Convert to decibels Vincp = 10 * np.log10(Vincp) @@ -62,55 +65,92 @@ pltrange = np.where((np.amax(Vincp) - Vincp) > 60)[0][0] + 1 pltrange = np.s_[0:pltrange] # Plot incident voltage -plt.subplots(num='Transmission line voltages & s11 parameter', figsize=(20, 10), facecolor='w', edgecolor='w') -gs = gridspec.GridSpec(3, 2) -ax1 = plt.subplot(gs[0, 0]) +fig1, ax = plt.subplots(num='Transmission line parameters', figsize=(20, 10), facecolor='w', edgecolor='w') +gs1 = gridspec.GridSpec(2, 2, hspace=0.3) +ax1 = plt.subplot(gs1[0, 0]) ax1.plot(time, Vinc, 'r', lw=2, label='Vinc') +ax1.set_title('Incident voltage') ax1.set_xlabel('Time [ns]') -ax1.set_ylabel('Incident voltage [V]') +ax1.set_ylabel('Voltage [V]') ax1.set_xlim([0, np.amax(time)]) ax1.grid() # Plot frequency spectra of incident voltage -ax2 = plt.subplot(gs[0, 1]) +ax2 = plt.subplot(gs1[0, 1]) markerline, stemlines, baseline = ax2.stem(freqs[pltrange]/1e9, Vincp[pltrange], '-.') plt.setp(baseline, 'linewidth', 0) plt.setp(stemlines, 'color', 'r') plt.setp(markerline, 'markerfacecolor', 'r', 'markeredgecolor', 'r') ax2.plot(freqs[pltrange]/1e9, Vincp[pltrange], 'r', lw=2) +ax2.set_title('Incident voltage') ax2.set_xlabel('Frequency [GHz]') -ax2.set_ylabel('Incident voltage spectra [dB]') +ax2.set_ylabel('Power [dB]') ax2.grid() # Plot scattered (field) voltage -ax3 = plt.subplot(gs[1, 0]) +ax3 = plt.subplot(gs1[1, 0]) ax3.plot(time, Vscat, 'r', lw=2, label='Vscat') +ax3.set_title('Reflected voltage') ax3.set_xlabel('Time [ns]') -ax3.set_ylabel('Scattered (field) voltage [V]') +ax3.set_ylabel('Voltage [V]') ax3.set_xlim([0, np.amax(time)]) ax3.grid() # Plot frequency spectra of scattered voltage -ax4 = plt.subplot(gs[1, 1]) +ax4 = plt.subplot(gs1[1, 1]) markerline, stemlines, baseline = ax4.stem(freqs[pltrange]/1e9, Vscatp[pltrange], '-.') plt.setp(baseline, 'linewidth', 0) plt.setp(stemlines, 'color', 'r') plt.setp(markerline, 'markerfacecolor', 'r', 'markeredgecolor', 'r') ax4.plot(freqs[pltrange]/1e9, Vscatp[pltrange], 'r', lw=2) +ax4.set_title('Reflected voltage') ax4.set_xlabel('Frequency [GHz]') -ax4.set_ylabel('Scattered (field) voltage spectra [dB]') +ax4.set_ylabel('Power [dB]') ax4.grid() # Plot frequency spectra of s11 -ax5 = plt.subplot(gs[2, 1]) +fig2, ax = plt.subplots(num='Antenna parameters', figsize=(20, 10), facecolor='w', edgecolor='w') +gs2 = gridspec.GridSpec(3, 1, hspace=0.5) +ax5 = plt.subplot(gs2[0, 0]) markerline, stemlines, baseline = ax5.stem(freqs[pltrange]/1e9, s11[pltrange], '-.') plt.setp(baseline, 'linewidth', 0) plt.setp(stemlines, 'color', 'r') plt.setp(markerline, 'markerfacecolor', 'r', 'markeredgecolor', 'r') ax5.plot(freqs[pltrange]/1e9, s11[pltrange], 'r', lw=2) +ax5.set_title('s11 parameter') ax5.set_xlabel('Frequency [GHz]') -ax5.set_ylabel('s11 [dB]') +ax5.set_ylabel('Power [dB]') ax5.grid() +# Plot input resistance (real part of impedance) +ax6 = plt.subplot(gs2[1, 0]) +markerline, stemlines, baseline = ax6.stem(freqs[pltrange]/1e9, zin[pltrange].real, '-.') +plt.setp(baseline, 'linewidth', 0) +plt.setp(stemlines, 'color', 'r') +plt.setp(markerline, 'markerfacecolor', 'r', 'markeredgecolor', 'r') +ax6.plot(freqs[pltrange]/1e9, zin[pltrange].real, 'r', lw=2) +ax6.set_title('Input impedance') +ax6.set_xlabel('Frequency [GHz]') +ax6.set_ylabel('Resistance [Ohms]') +ax6.set_ylim(bottom=0) +ax6.grid() + +# Plot input reactance (imaginery part of impedance) +ax7 = plt.subplot(gs2[2, 0]) +markerline, stemlines, baseline = ax7.stem(freqs[pltrange]/1e9, zin[pltrange].imag, '-.') +plt.setp(baseline, 'linewidth', 0) +plt.setp(stemlines, 'color', 'r') +plt.setp(markerline, 'markerfacecolor', 'r', 'markeredgecolor', 'r') +ax7.plot(freqs[pltrange]/1e9, zin[pltrange].imag, 'r', lw=2) +ax7.set_title('Input impedance') +ax7.set_xlabel('Frequency [GHz]') +ax7.set_ylabel('Reactance [Ohms]') +ax7.set_ylim(bottom=0) +ax7.grid() + plt.show() +fig1.savefig(os.path.splitext(os.path.abspath(file))[0] + '_tl_params.png', dpi=150, format='png', bbox_inches='tight', pad_inches=0.1) +fig2.savefig(os.path.splitext(os.path.abspath(file))[0] + '_ant_params.png', dpi=150, format='png', bbox_inches='tight', pad_inches=0.1) +#fig1.savefig(os.path.splitext(os.path.abspath(file))[0] + '_tl_params.pdf', dpi=None, format='pdf', bbox_inches='tight', pad_inches=0.1) +#fig2.savefig(os.path.splitext(os.path.abspath(file))[0] + '_ant_params.pdf', dpi=None, format='pdf', bbox_inches='tight', pad_inches=0.1) f.close() \ No newline at end of file