你已经派生过 gprMax
镜像自地址
https://gitee.com/sunhf/gprMax.git
已同步 2025-08-07 23:14:03 +08:00
Added a pre-commit config file and reformatted all the files accordingly by using it.
这个提交包含在:
@@ -23,14 +23,14 @@ from gprMax.waveforms import Waveform
|
||||
|
||||
|
||||
def hertzian_dipole_fs(iterations, dt, dxdydz, rx):
|
||||
"""Analytical solution of a z-directed Hertzian dipole in free space with a
|
||||
"""Analytical solution of a z-directed Hertzian dipole in free space with a
|
||||
Gaussian current waveform (http://dx.doi.org/10.1016/0021-9991(83)90103-1).
|
||||
|
||||
Args:
|
||||
iterations: int for number of time steps.
|
||||
dt: float for time step (seconds).
|
||||
dxdydz: tuple of floats for spatial resolution (metres).
|
||||
rx: tuple of floats for coordinates of receiver position relative to
|
||||
rx: tuple of floats for coordinates of receiver position relative to
|
||||
transmitter position (metres).
|
||||
|
||||
Returns:
|
||||
@@ -39,25 +39,25 @@ def hertzian_dipole_fs(iterations, dt, dxdydz, rx):
|
||||
|
||||
# Waveform
|
||||
w = Waveform()
|
||||
w.type = 'gaussianprime'
|
||||
w.type = "gaussianprime"
|
||||
w.amp = 1
|
||||
w.freq = 1e9
|
||||
|
||||
# Waveform integral
|
||||
wint = Waveform()
|
||||
wint.type = 'gaussian'
|
||||
wint.type = "gaussian"
|
||||
wint.amp = w.amp
|
||||
wint.freq = w.freq
|
||||
|
||||
# Waveform first derivative
|
||||
wdot = Waveform()
|
||||
wdot.type = 'gaussiandoubleprime'
|
||||
wdot.type = "gaussiandoubleprime"
|
||||
wdot.amp = w.amp
|
||||
wdot.freq = w.freq
|
||||
|
||||
# Time
|
||||
time = np.linspace(0, 1, iterations)
|
||||
time *= (iterations * dt)
|
||||
time *= iterations * dt
|
||||
|
||||
# Spatial resolution
|
||||
dx = dxdydz[0]
|
||||
@@ -77,43 +77,42 @@ def hertzian_dipole_fs(iterations, dt, dxdydz, rx):
|
||||
Ex_y = y
|
||||
Ex_z = z - 0.5 * dz
|
||||
Er_x = np.sqrt((Ex_x**2 + Ex_y**2 + Ex_z**2))
|
||||
tau_Ex = Er_x / config.sim_config.em_consts['c']
|
||||
tau_Ex = Er_x / config.sim_config.em_consts["c"]
|
||||
|
||||
# Coordinates of Rx for Ey FDTD component
|
||||
Ey_x = x
|
||||
Ey_y = y + 0.5 * dy
|
||||
Ey_z = z - 0.5 * dz
|
||||
Er_y = np.sqrt((Ey_x**2 + Ey_y**2 + Ey_z**2))
|
||||
tau_Ey = Er_y / config.sim_config.em_consts['c']
|
||||
tau_Ey = Er_y / config.sim_config.em_consts["c"]
|
||||
|
||||
# Coordinates of Rx for Ez FDTD component
|
||||
Ez_x = x
|
||||
Ez_y = y
|
||||
Ez_z = z
|
||||
Er_z = np.sqrt((Ez_x**2 + Ez_y**2 + Ez_z**2))
|
||||
tau_Ez = Er_z / config.sim_config.em_consts['c']
|
||||
tau_Ez = Er_z / config.sim_config.em_consts["c"]
|
||||
|
||||
# Coordinates of Rx for Hx FDTD component
|
||||
Hx_x = x
|
||||
Hx_y = y + 0.5 * dy
|
||||
Hx_z = z
|
||||
Hr_x = np.sqrt((Hx_x**2 + Hx_y**2 + Hx_z**2))
|
||||
tau_Hx = Hr_x / config.sim_config.em_consts['c']
|
||||
tau_Hx = Hr_x / config.sim_config.em_consts["c"]
|
||||
|
||||
# Coordinates of Rx for Hy FDTD component
|
||||
Hy_x = x + 0.5 * dx
|
||||
Hy_y = y
|
||||
Hy_z = z
|
||||
Hr_y = np.sqrt((Hy_x**2 + Hy_y**2 + Hy_z**2))
|
||||
tau_Hy = Hr_y / config.sim_config.em_consts['c']
|
||||
tau_Hy = Hr_y / config.sim_config.em_consts["c"]
|
||||
|
||||
# Initialise fields
|
||||
fields = np.zeros((iterations, 6))
|
||||
|
||||
# Calculate fields
|
||||
for timestep in range(iterations):
|
||||
|
||||
# Calculate values for waveform, I * dl (current multiplied by dipole
|
||||
# Calculate values for waveform, I * dl (current multiplied by dipole
|
||||
# length) to match gprMax behaviour
|
||||
fint_Ex = wint.calculate_value((timestep * dt) - tau_Ex, dt) * dl
|
||||
f_Ex = w.calculate_value((timestep * dt) - tau_Ex, dt) * dl
|
||||
@@ -134,31 +133,36 @@ def hertzian_dipole_fs(iterations, dt, dxdydz, rx):
|
||||
fdot_Hy = wdot.calculate_value((timestep * dt) - tau_Hy, dt) * dl
|
||||
|
||||
# Ex
|
||||
fields[timestep, 0] = (((Ex_x * Ex_z) / (4 * np.pi * config.sim_config.em_consts['e0'] * Er_x**5)) *
|
||||
(3 * (fint_Ex + (tau_Ex * f_Ex)) + (tau_Ex**2 * fdot_Ex)))
|
||||
fields[timestep, 0] = ((Ex_x * Ex_z) / (4 * np.pi * config.sim_config.em_consts["e0"] * Er_x**5)) * (
|
||||
3 * (fint_Ex + (tau_Ex * f_Ex)) + (tau_Ex**2 * fdot_Ex)
|
||||
)
|
||||
|
||||
# Ey
|
||||
try:
|
||||
tmp = Ey_y / Ey_x
|
||||
except ZeroDivisionError:
|
||||
tmp = 0
|
||||
fields[timestep, 1] = (tmp * ((Ey_x * Ey_z) / (4 * np.pi * config.sim_config.em_consts['e0'] * Er_y**5)) *
|
||||
(3 * (fint_Ey + (tau_Ey * f_Ey)) + (tau_Ey**2 * fdot_Ey)))
|
||||
fields[timestep, 1] = (
|
||||
tmp
|
||||
* ((Ey_x * Ey_z) / (4 * np.pi * config.sim_config.em_consts["e0"] * Er_y**5))
|
||||
* (3 * (fint_Ey + (tau_Ey * f_Ey)) + (tau_Ey**2 * fdot_Ey))
|
||||
)
|
||||
|
||||
# Ez
|
||||
fields[timestep, 2] = ((1 / (4 * np.pi * config.sim_config.em_consts['e0'] * Er_z**5)) *
|
||||
((2 * Ez_z**2 - (Ez_x**2 + Ez_y**2)) * (fint_Ez + (tau_Ez * f_Ez)) -
|
||||
(Ez_x**2 + Ez_y**2) * tau_Ez**2 * fdot_Ez))
|
||||
fields[timestep, 2] = (1 / (4 * np.pi * config.sim_config.em_consts["e0"] * Er_z**5)) * (
|
||||
(2 * Ez_z**2 - (Ez_x**2 + Ez_y**2)) * (fint_Ez + (tau_Ez * f_Ez))
|
||||
- (Ez_x**2 + Ez_y**2) * tau_Ez**2 * fdot_Ez
|
||||
)
|
||||
|
||||
# Hx
|
||||
fields[timestep, 3] = - (Hx_y / (4 * np.pi * Hr_x**3)) * (f_Hx + (tau_Hx * fdot_Hx))
|
||||
fields[timestep, 3] = -(Hx_y / (4 * np.pi * Hr_x**3)) * (f_Hx + (tau_Hx * fdot_Hx))
|
||||
|
||||
# Hy
|
||||
try:
|
||||
tmp = Hy_x / Hy_y
|
||||
except ZeroDivisionError:
|
||||
tmp = 0
|
||||
fields[timestep, 4] = - tmp * (- (Hy_y / (4 * np.pi * Hr_y**3)) * (f_Hy + (tau_Hy * fdot_Hy)))
|
||||
fields[timestep, 4] = -tmp * (-(Hy_y / (4 * np.pi * Hr_y**3)) * (f_Hy + (tau_Hy * fdot_Hy)))
|
||||
|
||||
# Hz
|
||||
fields[timestep, 5] = 0
|
||||
|
@@ -1,5 +1,5 @@
|
||||
"""A series of models with different domain sizes used for benchmarking.
|
||||
The domain is free space with a simple source (Hertzian Dipole) and
|
||||
The domain is free space with a simple source (Hertzian Dipole) and
|
||||
receiver at the centre.
|
||||
"""
|
||||
|
||||
@@ -19,7 +19,6 @@ scenes = []
|
||||
|
||||
for d in domains:
|
||||
for threads in ompthreads:
|
||||
|
||||
# Discretisation
|
||||
dl = 0.001
|
||||
|
||||
@@ -30,14 +29,12 @@ for d in domains:
|
||||
|
||||
scene = gprMax.Scene()
|
||||
|
||||
title = gprMax.Title(name=fn.with_suffix('').name)
|
||||
title = gprMax.Title(name=fn.with_suffix("").name)
|
||||
domain = gprMax.Domain(p1=(x, y, z))
|
||||
dxdydz = gprMax.Discretisation(p1=(dl, dl, dl))
|
||||
time_window = gprMax.TimeWindow(time=3e-9)
|
||||
wv = gprMax.Waveform(wave_type='gaussiandotnorm', amp=1, freq=900e6,
|
||||
id='MySource')
|
||||
src = gprMax.HertzianDipole(p1=(x/2, y/2, z/2), polarisation='x',
|
||||
waveform_id='MySource')
|
||||
wv = gprMax.Waveform(wave_type="gaussiandotnorm", amp=1, freq=900e6, id="MySource")
|
||||
src = gprMax.HertzianDipole(p1=(x / 2, y / 2, z / 2), polarisation="x", waveform_id="MySource")
|
||||
|
||||
omp = gprMax.OMPThreads(n=threads)
|
||||
|
||||
@@ -51,4 +48,4 @@ for d in domains:
|
||||
scenes.append(scene)
|
||||
|
||||
# Run model
|
||||
gprMax.run(scenes=scenes, n=len(scenes), geometry_only=False, outputfile=fn, gpu=None)
|
||||
gprMax.run(scenes=scenes, n=len(scenes), geometry_only=False, outputfile=fn, gpu=None)
|
||||
|
@@ -7,4 +7,3 @@
|
||||
from user_libs.GPRAntennaModels import antenna_like_GSSI_1500
|
||||
antenna_like_GSSI_1500(0.125, 0.094, 0.100)
|
||||
#end_python:
|
||||
|
||||
|
@@ -7,4 +7,3 @@
|
||||
from user_libs.GPRAntennaModels import antenna_like_MALA_1200
|
||||
antenna_like_MALA_1200(0.132, 0.095, 0.100)
|
||||
#end_python:
|
||||
|
||||
|
@@ -28,41 +28,45 @@ import numpy as np
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
# Create/setup plot figure
|
||||
#colors = ['#E60D30', '#5CB7C6', '#A21797', '#A3B347'] # Plot colours from http://tools.medialab.sciences-po.fr/iwanthue/index.php
|
||||
#colorIDs = ["#62a85b", "#9967c7", "#b3943f", "#6095cd", "#cb5c42", "#c95889"]
|
||||
# colors = ['#E60D30', '#5CB7C6', '#A21797', '#A3B347'] # Plot colours from http://tools.medialab.sciences-po.fr/iwanthue/index.php
|
||||
# colorIDs = ["#62a85b", "#9967c7", "#b3943f", "#6095cd", "#cb5c42", "#c95889"]
|
||||
colorIDs = ["#79c72e", "#5774ff", "#ff7c2c", "#4b4e80", "#d7004e", "#007545", "#ff83ec"]
|
||||
#colorIDs = ["#ba0044", "#b2d334", "#470055", "#185300", "#ff96b1", "#3e2700", "#0162a9", "#fdb786"]
|
||||
# colorIDs = ["#ba0044", "#b2d334", "#470055", "#185300", "#ff96b1", "#3e2700", "#0162a9", "#fdb786"]
|
||||
colors = itertools.cycle(colorIDs)
|
||||
# for i in range(2):
|
||||
# next(colors)
|
||||
lines = itertools.cycle(('--', ':', '-.', '-'))
|
||||
markers = ['o', 'd', '^', 's', '*']
|
||||
lines = itertools.cycle(("--", ":", "-.", "-"))
|
||||
markers = ["o", "d", "^", "s", "*"]
|
||||
|
||||
parts = Path(__file__).parts
|
||||
path = 'rxs/rx1/'
|
||||
basename = 'pml_3D_pec_plate'
|
||||
PMLIDs = ['CFS-PML', 'HORIPML-1', 'HORIPML-2', 'MRIPML-1', 'MRIPML-2']
|
||||
path = "rxs/rx1/"
|
||||
basename = "pml_3D_pec_plate"
|
||||
PMLIDs = ["CFS-PML", "HORIPML-1", "HORIPML-2", "MRIPML-1", "MRIPML-2"]
|
||||
maxerrors = []
|
||||
testmodels = ['pml_3D_pec_plate_' + s for s in PMLIDs]
|
||||
testmodels = ["pml_3D_pec_plate_" + s for s in PMLIDs]
|
||||
|
||||
fig, ax = plt.subplots(subplot_kw=dict(xlabel='Iterations', ylabel='Error [dB]'), figsize=(20, 10), facecolor='w', edgecolor='w')
|
||||
fig, ax = plt.subplots(
|
||||
subplot_kw=dict(xlabel="Iterations", ylabel="Error [dB]"), figsize=(20, 10), facecolor="w", edgecolor="w"
|
||||
)
|
||||
|
||||
for x, model in enumerate(testmodels):
|
||||
# Open output file and read iterations
|
||||
fileref = h5py.File(Path(*parts[:-1], basename, basename + '_ref.h5'), 'r')
|
||||
filetest = h5py.File(Path(*parts[:-1], basename, basename + str(x + 1) + '.h5'), 'r')
|
||||
fileref = h5py.File(Path(*parts[:-1], basename, basename + "_ref.h5"), "r")
|
||||
filetest = h5py.File(Path(*parts[:-1], basename, basename + str(x + 1) + ".h5"), "r")
|
||||
|
||||
# Get available field output component names
|
||||
outputsref = list(fileref[path].keys())
|
||||
outputstest = list(filetest[path].keys())
|
||||
if outputsref != outputstest:
|
||||
logger.exception('Field output components do not match reference solution')
|
||||
logger.exception("Field output components do not match reference solution")
|
||||
raise ValueError
|
||||
|
||||
# Check that type of float used to store fields matches
|
||||
if filetest[path + outputstest[0]].dtype != fileref[path + outputsref[0]].dtype:
|
||||
logger.warning(f'Type of floating point number in test model ({filetest[path + outputstest[0]].dtype}) '
|
||||
f'does not match type in reference solution ({fileref[path + outputsref[0]].dtype})\n')
|
||||
logger.warning(
|
||||
f"Type of floating point number in test model ({filetest[path + outputstest[0]].dtype}) "
|
||||
f"does not match type in reference solution ({fileref[path + outputsref[0]].dtype})\n"
|
||||
)
|
||||
floattyperef = fileref[path + outputsref[0]].dtype
|
||||
floattypetest = filetest[path + outputstest[0]].dtype
|
||||
# logger.info(f'Data type: {floattypetest}')
|
||||
@@ -72,19 +76,19 @@ for x, model in enumerate(testmodels):
|
||||
# timeref = np.linspace(0, (fileref.attrs['Iterations'] - 1) * fileref.attrs['dt'], num=fileref.attrs['Iterations']) / 1e-9
|
||||
# timetest = np.zeros((filetest.attrs['Iterations']), dtype=floattypetest)
|
||||
# timetest = np.linspace(0, (filetest.attrs['Iterations'] - 1) * filetest.attrs['dt'], num=filetest.attrs['Iterations']) / 1e-9
|
||||
timeref = np.zeros((fileref.attrs['Iterations']), dtype=floattyperef)
|
||||
timeref = np.linspace(0, (fileref.attrs['Iterations'] - 1), num=fileref.attrs['Iterations'])
|
||||
timetest = np.zeros((filetest.attrs['Iterations']), dtype=floattypetest)
|
||||
timetest = np.linspace(0, (filetest.attrs['Iterations'] - 1), num=filetest.attrs['Iterations'])
|
||||
timeref = np.zeros((fileref.attrs["Iterations"]), dtype=floattyperef)
|
||||
timeref = np.linspace(0, (fileref.attrs["Iterations"] - 1), num=fileref.attrs["Iterations"])
|
||||
timetest = np.zeros((filetest.attrs["Iterations"]), dtype=floattypetest)
|
||||
timetest = np.linspace(0, (filetest.attrs["Iterations"] - 1), num=filetest.attrs["Iterations"])
|
||||
|
||||
# Arrays for storing field data
|
||||
dataref = np.zeros((fileref.attrs['Iterations'], len(outputsref)), dtype=floattyperef)
|
||||
datatest = np.zeros((filetest.attrs['Iterations'], len(outputstest)), dtype=floattypetest)
|
||||
dataref = np.zeros((fileref.attrs["Iterations"], len(outputsref)), dtype=floattyperef)
|
||||
datatest = np.zeros((filetest.attrs["Iterations"], len(outputstest)), dtype=floattypetest)
|
||||
for ID, name in enumerate(outputsref):
|
||||
dataref[:, ID] = fileref[path + str(name)][:]
|
||||
datatest[:, ID] = filetest[path + str(name)][:]
|
||||
if np.any(np.isnan(datatest[:, ID])):
|
||||
logger.exception('Test data contains NaNs')
|
||||
logger.exception("Test data contains NaNs")
|
||||
raise ValueError
|
||||
|
||||
fileref.close()
|
||||
@@ -94,18 +98,20 @@ for x, model in enumerate(testmodels):
|
||||
datadiffs = np.zeros(datatest.shape, dtype=np.float64)
|
||||
for i in range(len(outputstest)):
|
||||
maxi = np.amax(np.abs(dataref[:, i]))
|
||||
datadiffs[:, i] = np.divide(np.abs(datatest[:, i] - dataref[:, i]), maxi, out=np.zeros_like(dataref[:, i]), where=maxi != 0) # Replace any division by zero with zero
|
||||
datadiffs[:, i] = np.divide(
|
||||
np.abs(datatest[:, i] - dataref[:, i]), maxi, out=np.zeros_like(dataref[:, i]), where=maxi != 0
|
||||
) # Replace any division by zero with zero
|
||||
|
||||
# Calculate power (ignore warning from taking a log of any zero values)
|
||||
with np.errstate(divide='ignore'):
|
||||
with np.errstate(divide="ignore"):
|
||||
datadiffs[:, i] = 20 * np.log10(datadiffs[:, i])
|
||||
# Replace any NaNs or Infs from zero division
|
||||
datadiffs[:, i][np.invert(np.isfinite(datadiffs[:, i]))] = 0
|
||||
|
||||
# Print maximum error value
|
||||
start = 210
|
||||
maxerrors.append(f': {np.amax(datadiffs[start::, 1]):.1f} [dB]')
|
||||
logger.info(f'{model}: Max. error {maxerrors[x]}')
|
||||
maxerrors.append(f": {np.amax(datadiffs[start::, 1]):.1f} [dB]")
|
||||
logger.info(f"{model}: Max. error {maxerrors[x]}")
|
||||
|
||||
# Plot diffs (select column to choose field component, 0-Ex, 1-Ey etc..)
|
||||
ax.plot(timeref[start::], datadiffs[start::, 1], color=next(colors), lw=2, ls=next(lines), label=model)
|
||||
@@ -114,16 +120,16 @@ for x, model in enumerate(testmodels):
|
||||
ax.set_yticks(np.arange(-160, 0, step=20))
|
||||
ax.set_ylim([-160, -20])
|
||||
ax.set_axisbelow(True)
|
||||
ax.grid(color=(0.75,0.75,0.75), linestyle='dashed')
|
||||
ax.grid(color=(0.75, 0.75, 0.75), linestyle="dashed")
|
||||
|
||||
mylegend = list(map(add, PMLIDs, maxerrors))
|
||||
legend = ax.legend(mylegend, loc=1, fontsize=14)
|
||||
frame = legend.get_frame()
|
||||
frame.set_edgecolor('white')
|
||||
frame.set_edgecolor("white")
|
||||
frame.set_alpha(0)
|
||||
|
||||
plt.show()
|
||||
|
||||
# Save a PDF/PNG of the figure
|
||||
#fig.savefig(basepath + '.pdf', dpi=None, format='pdf', bbox_inches='tight', pad_inches=0.1)
|
||||
#fig.savefig(savename + '.png', dpi=150, format='png', bbox_inches='tight', pad_inches=0.1)
|
||||
# fig.savefig(basepath + '.pdf', dpi=None, format='pdf', bbox_inches='tight', pad_inches=0.1)
|
||||
# fig.savefig(savename + '.png', dpi=150, format='png', bbox_inches='tight', pad_inches=0.1)
|
||||
|
@@ -20,112 +20,162 @@ dxdydz = gprMax.Discretisation(p1=(dl, dl, dl))
|
||||
time_window = gprMax.TimeWindow(iterations=2100)
|
||||
tssf = gprMax.TimeStepStabilityFactor(f=0.99)
|
||||
|
||||
waveform = gprMax.Waveform(wave_type='gaussiandotnorm', amp=1, freq=9.42e9, id='mypulse')
|
||||
hertzian_dipole = gprMax.HertzianDipole(polarisation='z',
|
||||
p1=(0.013, 0.013, 0.014),
|
||||
waveform_id='mypulse')
|
||||
waveform = gprMax.Waveform(wave_type="gaussiandotnorm", amp=1, freq=9.42e9, id="mypulse")
|
||||
hertzian_dipole = gprMax.HertzianDipole(polarisation="z", p1=(0.013, 0.013, 0.014), waveform_id="mypulse")
|
||||
rx = gprMax.Rx(p1=(0.038, 0.114, 0.013))
|
||||
|
||||
plate = gprMax.Plate(p1=(0.013, 0.013, 0.013),
|
||||
p2=(0.038, 0.113, 0.013), material_id='pec')
|
||||
plate = gprMax.Plate(p1=(0.013, 0.013, 0.013), p2=(0.038, 0.113, 0.013), material_id="pec")
|
||||
|
||||
gv1 = gprMax.GeometryView(p1=(0, 0, 0),
|
||||
p2=(x, y, z),
|
||||
dl=(dl, dl, dl),
|
||||
filename=Path(*parts[:-1], f'{parts[-1]}_n'),
|
||||
output_type='n',)
|
||||
gv2 = gprMax.GeometryView(p1=(0, 0, 0),
|
||||
p2=(x, y, z),
|
||||
dl=(dl, dl, dl),
|
||||
filename=Path(*parts[:-1], f'{parts[-1]}_f'),
|
||||
output_type='f',)
|
||||
gv1 = gprMax.GeometryView(
|
||||
p1=(0, 0, 0),
|
||||
p2=(x, y, z),
|
||||
dl=(dl, dl, dl),
|
||||
filename=Path(*parts[:-1], f"{parts[-1]}_n"),
|
||||
output_type="n",
|
||||
)
|
||||
gv2 = gprMax.GeometryView(
|
||||
p1=(0, 0, 0),
|
||||
p2=(x, y, z),
|
||||
dl=(dl, dl, dl),
|
||||
filename=Path(*parts[:-1], f"{parts[-1]}_f"),
|
||||
output_type="f",
|
||||
)
|
||||
|
||||
pmls = {'CFS-PML': {'pml': gprMax.PMLProps(formulation='HORIPML', thickness=10),
|
||||
# Parameters from http://dx.doi.org/10.1109/TAP.2018.2823864
|
||||
'pml_cfs': [gprMax.PMLCFS(alphascalingprofile='constant',
|
||||
alphascalingdirection='forward',
|
||||
alphamin=0.05, alphamax=0.05,
|
||||
kappascalingprofile='quartic',
|
||||
kappascalingdirection='forward',
|
||||
kappamin=1, kappamax=8,
|
||||
sigmascalingprofile='quartic',
|
||||
sigmascalingdirection='forward',
|
||||
sigmamin=0,
|
||||
sigmamax=1.1 * ((4 + 1) / (150 * np.pi * dl)))]},
|
||||
'HORIPML-1': {'pml': gprMax.PMLProps(formulation='HORIPML', thickness=10),
|
||||
# Parameters from http://dx.doi.org/10.1109/TAP.2011.2180344
|
||||
'pml_cfs': [gprMax.PMLCFS(alphascalingprofile='constant',
|
||||
alphascalingdirection='forward',
|
||||
alphamin=0, alphamax=0,
|
||||
kappascalingprofile='quartic',
|
||||
kappascalingdirection='forward',
|
||||
kappamin=1, kappamax=12,
|
||||
sigmascalingprofile='quartic',
|
||||
sigmascalingdirection='forward',
|
||||
sigmamin=0,
|
||||
sigmamax=0.7 * ((4 + 1) / (150 * np.pi * dl)))]},
|
||||
'HORIPML-2': {'pml': gprMax.PMLProps(formulation='HORIPML', thickness=10),
|
||||
# Parameters from http://dx.doi.org/10.1109/TAP.2018.2823864
|
||||
'pml_cfs': [gprMax.PMLCFS(alphascalingprofile='constant',
|
||||
alphascalingdirection='forward',
|
||||
alphamin=0, alphamax=0,
|
||||
kappascalingprofile='constant',
|
||||
kappascalingdirection='forward',
|
||||
kappamin=1, kappamax=1,
|
||||
sigmascalingprofile='sextic',
|
||||
sigmascalingdirection='forward',
|
||||
sigmamin=0,
|
||||
sigmamax=0.275 / (150 * np.pi * dl)),
|
||||
gprMax.PMLCFS(alphascalingprofile='sextic',
|
||||
alphascalingdirection='forward',
|
||||
alphamin=0.07, alphamax=0.07 + (0.275 / (150 * np.pi * dl)),
|
||||
kappascalingprofile='cubic',
|
||||
kappascalingdirection='forward',
|
||||
kappamin=1, kappamax=8,
|
||||
sigmascalingprofile='quadratic',
|
||||
sigmascalingdirection='forward',
|
||||
sigmamin=0,
|
||||
sigmamax=2.75 / (150 * np.pi * dl))]},
|
||||
'MRIPML-1': {'pml': gprMax.PMLProps(formulation='MRIPML', thickness=10),
|
||||
# Parameters from Antonis' MATLAB script (M3Dparams.m)
|
||||
'pml_cfs': [gprMax.PMLCFS(alphascalingprofile='constant',
|
||||
alphascalingdirection='forward',
|
||||
alphamin=0.05, alphamax=0.05,
|
||||
kappascalingprofile='quartic',
|
||||
kappascalingdirection='forward',
|
||||
kappamin=1, kappamax=8,
|
||||
sigmascalingprofile='quartic',
|
||||
sigmascalingdirection='forward',
|
||||
sigmamin=0,
|
||||
sigmamax=1.1 * ((4 + 1) / (150 * np.pi * dl)))]},
|
||||
'MRIPML-2': {'pml': gprMax.PMLProps(formulation='MRIPML', thickness=10),
|
||||
# Parameters from http://dx.doi.org/10.1109/TAP.2018.2823864
|
||||
'pml_cfs': [gprMax.PMLCFS(alphascalingprofile='quadratic',
|
||||
alphascalingdirection='reverse',
|
||||
alphamin=0, alphamax=0.15,
|
||||
kappascalingprofile='quartic',
|
||||
kappascalingdirection='forward',
|
||||
kappamin=1, kappamax=12,
|
||||
sigmascalingprofile='quartic',
|
||||
sigmascalingdirection='forward',
|
||||
sigmamin=0,
|
||||
sigmamax=0.65 * ((4 + 1) / (150 * np.pi * dl))),
|
||||
gprMax.PMLCFS(alphascalingprofile='linear',
|
||||
alphascalingdirection='reverse',
|
||||
alphamin=0.07, alphamax=0.8,
|
||||
kappascalingprofile='constant',
|
||||
kappascalingdirection='forward',
|
||||
kappamin=0, kappamax=0,
|
||||
sigmascalingprofile='quadratic',
|
||||
sigmascalingdirection='forward',
|
||||
sigmamin=0,
|
||||
sigmamax=0.65 * ((2 + 1) / (150 * np.pi * dl)))]}
|
||||
}
|
||||
pmls = {
|
||||
"CFS-PML": {
|
||||
"pml": gprMax.PMLProps(formulation="HORIPML", thickness=10),
|
||||
# Parameters from http://dx.doi.org/10.1109/TAP.2018.2823864
|
||||
"pml_cfs": [
|
||||
gprMax.PMLCFS(
|
||||
alphascalingprofile="constant",
|
||||
alphascalingdirection="forward",
|
||||
alphamin=0.05,
|
||||
alphamax=0.05,
|
||||
kappascalingprofile="quartic",
|
||||
kappascalingdirection="forward",
|
||||
kappamin=1,
|
||||
kappamax=8,
|
||||
sigmascalingprofile="quartic",
|
||||
sigmascalingdirection="forward",
|
||||
sigmamin=0,
|
||||
sigmamax=1.1 * ((4 + 1) / (150 * np.pi * dl)),
|
||||
)
|
||||
],
|
||||
},
|
||||
"HORIPML-1": {
|
||||
"pml": gprMax.PMLProps(formulation="HORIPML", thickness=10),
|
||||
# Parameters from http://dx.doi.org/10.1109/TAP.2011.2180344
|
||||
"pml_cfs": [
|
||||
gprMax.PMLCFS(
|
||||
alphascalingprofile="constant",
|
||||
alphascalingdirection="forward",
|
||||
alphamin=0,
|
||||
alphamax=0,
|
||||
kappascalingprofile="quartic",
|
||||
kappascalingdirection="forward",
|
||||
kappamin=1,
|
||||
kappamax=12,
|
||||
sigmascalingprofile="quartic",
|
||||
sigmascalingdirection="forward",
|
||||
sigmamin=0,
|
||||
sigmamax=0.7 * ((4 + 1) / (150 * np.pi * dl)),
|
||||
)
|
||||
],
|
||||
},
|
||||
"HORIPML-2": {
|
||||
"pml": gprMax.PMLProps(formulation="HORIPML", thickness=10),
|
||||
# Parameters from http://dx.doi.org/10.1109/TAP.2018.2823864
|
||||
"pml_cfs": [
|
||||
gprMax.PMLCFS(
|
||||
alphascalingprofile="constant",
|
||||
alphascalingdirection="forward",
|
||||
alphamin=0,
|
||||
alphamax=0,
|
||||
kappascalingprofile="constant",
|
||||
kappascalingdirection="forward",
|
||||
kappamin=1,
|
||||
kappamax=1,
|
||||
sigmascalingprofile="sextic",
|
||||
sigmascalingdirection="forward",
|
||||
sigmamin=0,
|
||||
sigmamax=0.275 / (150 * np.pi * dl),
|
||||
),
|
||||
gprMax.PMLCFS(
|
||||
alphascalingprofile="sextic",
|
||||
alphascalingdirection="forward",
|
||||
alphamin=0.07,
|
||||
alphamax=0.07 + (0.275 / (150 * np.pi * dl)),
|
||||
kappascalingprofile="cubic",
|
||||
kappascalingdirection="forward",
|
||||
kappamin=1,
|
||||
kappamax=8,
|
||||
sigmascalingprofile="quadratic",
|
||||
sigmascalingdirection="forward",
|
||||
sigmamin=0,
|
||||
sigmamax=2.75 / (150 * np.pi * dl),
|
||||
),
|
||||
],
|
||||
},
|
||||
"MRIPML-1": {
|
||||
"pml": gprMax.PMLProps(formulation="MRIPML", thickness=10),
|
||||
# Parameters from Antonis' MATLAB script (M3Dparams.m)
|
||||
"pml_cfs": [
|
||||
gprMax.PMLCFS(
|
||||
alphascalingprofile="constant",
|
||||
alphascalingdirection="forward",
|
||||
alphamin=0.05,
|
||||
alphamax=0.05,
|
||||
kappascalingprofile="quartic",
|
||||
kappascalingdirection="forward",
|
||||
kappamin=1,
|
||||
kappamax=8,
|
||||
sigmascalingprofile="quartic",
|
||||
sigmascalingdirection="forward",
|
||||
sigmamin=0,
|
||||
sigmamax=1.1 * ((4 + 1) / (150 * np.pi * dl)),
|
||||
)
|
||||
],
|
||||
},
|
||||
"MRIPML-2": {
|
||||
"pml": gprMax.PMLProps(formulation="MRIPML", thickness=10),
|
||||
# Parameters from http://dx.doi.org/10.1109/TAP.2018.2823864
|
||||
"pml_cfs": [
|
||||
gprMax.PMLCFS(
|
||||
alphascalingprofile="quadratic",
|
||||
alphascalingdirection="reverse",
|
||||
alphamin=0,
|
||||
alphamax=0.15,
|
||||
kappascalingprofile="quartic",
|
||||
kappascalingdirection="forward",
|
||||
kappamin=1,
|
||||
kappamax=12,
|
||||
sigmascalingprofile="quartic",
|
||||
sigmascalingdirection="forward",
|
||||
sigmamin=0,
|
||||
sigmamax=0.65 * ((4 + 1) / (150 * np.pi * dl)),
|
||||
),
|
||||
gprMax.PMLCFS(
|
||||
alphascalingprofile="linear",
|
||||
alphascalingdirection="reverse",
|
||||
alphamin=0.07,
|
||||
alphamax=0.8,
|
||||
kappascalingprofile="constant",
|
||||
kappascalingdirection="forward",
|
||||
kappamin=0,
|
||||
kappamax=0,
|
||||
sigmascalingprofile="quadratic",
|
||||
sigmascalingdirection="forward",
|
||||
sigmamin=0,
|
||||
sigmamax=0.65 * ((2 + 1) / (150 * np.pi * dl)),
|
||||
),
|
||||
],
|
||||
},
|
||||
}
|
||||
|
||||
scenes = []
|
||||
for k, v in pmls.items():
|
||||
scene = gprMax.Scene()
|
||||
title = gprMax.Title(name=fn.with_suffix('').name + '_' + k)
|
||||
title = gprMax.Title(name=fn.with_suffix("").name + "_" + k)
|
||||
scene.add(title)
|
||||
scene.add(domain)
|
||||
scene.add(dxdydz)
|
||||
@@ -137,8 +187,8 @@ for k, v in pmls.items():
|
||||
# scene.add(gv1)
|
||||
# scene.add(gv2)
|
||||
|
||||
scene.add(v['pml'])
|
||||
for pml_cfs in v['pml_cfs']:
|
||||
scene.add(v["pml"])
|
||||
for pml_cfs in v["pml_cfs"]:
|
||||
scene.add(pml_cfs)
|
||||
|
||||
scenes.append(scene)
|
||||
|
@@ -20,42 +20,47 @@ dxdydz = gprMax.Discretisation(p1=(dl, dl, dl))
|
||||
time_window = gprMax.TimeWindow(iterations=2100)
|
||||
tssf = gprMax.TimeStepStabilityFactor(f=0.99)
|
||||
|
||||
waveform = gprMax.Waveform(wave_type='gaussiandotnorm', amp=1, freq=9.42e9, id='mypulse')
|
||||
hertzian_dipole = gprMax.HertzianDipole(polarisation='z',
|
||||
p1=(0.088, 0.088, 0.089),
|
||||
waveform_id='mypulse')
|
||||
waveform = gprMax.Waveform(wave_type="gaussiandotnorm", amp=1, freq=9.42e9, id="mypulse")
|
||||
hertzian_dipole = gprMax.HertzianDipole(polarisation="z", p1=(0.088, 0.088, 0.089), waveform_id="mypulse")
|
||||
rx = gprMax.Rx(p1=(0.113, 0.189, 0.088))
|
||||
|
||||
plate = gprMax.Plate(p1=(0.088, 0.088, 0.088),
|
||||
p2=(0.113, 0.188, 0.088), material_id='pec')
|
||||
plate = gprMax.Plate(p1=(0.088, 0.088, 0.088), p2=(0.113, 0.188, 0.088), material_id="pec")
|
||||
|
||||
gv1 = gprMax.GeometryView(p1=(0, 0, 0),
|
||||
p2=(x, y, z),
|
||||
dl=(dl, dl, dl),
|
||||
filename=Path(*parts[:-1], f'{parts[-1]}_n'),
|
||||
output_type='n',)
|
||||
gv2 = gprMax.GeometryView(p1=(0, 0, 0),
|
||||
p2=(x, y, z),
|
||||
dl=(dl, dl, dl),
|
||||
filename=Path(*parts[:-1], f'{parts[-1]}_f'),
|
||||
output_type='f',)
|
||||
gv1 = gprMax.GeometryView(
|
||||
p1=(0, 0, 0),
|
||||
p2=(x, y, z),
|
||||
dl=(dl, dl, dl),
|
||||
filename=Path(*parts[:-1], f"{parts[-1]}_n"),
|
||||
output_type="n",
|
||||
)
|
||||
gv2 = gprMax.GeometryView(
|
||||
p1=(0, 0, 0),
|
||||
p2=(x, y, z),
|
||||
dl=(dl, dl, dl),
|
||||
filename=Path(*parts[:-1], f"{parts[-1]}_f"),
|
||||
output_type="f",
|
||||
)
|
||||
|
||||
pml = gprMax.PMLProps(formulation='HORIPML', thickness=10)
|
||||
pml = gprMax.PMLProps(formulation="HORIPML", thickness=10)
|
||||
|
||||
# Parameters from http://dx.doi.org/10.1109/TAP.2018.2823864
|
||||
pml_cfs = gprMax.PMLCFS(alphascalingprofile='constant',
|
||||
alphascalingdirection='forward',
|
||||
alphamin=0.05, alphamax=0.05,
|
||||
kappascalingprofile='quartic',
|
||||
kappascalingdirection='forward',
|
||||
kappamin=1, kappamax=8,
|
||||
sigmascalingprofile='quartic',
|
||||
sigmascalingdirection='forward',
|
||||
sigmamin=0,
|
||||
sigmamax=1.1 * ((4 + 1) / (150 * np.pi * dl)))
|
||||
pml_cfs = gprMax.PMLCFS(
|
||||
alphascalingprofile="constant",
|
||||
alphascalingdirection="forward",
|
||||
alphamin=0.05,
|
||||
alphamax=0.05,
|
||||
kappascalingprofile="quartic",
|
||||
kappascalingdirection="forward",
|
||||
kappamin=1,
|
||||
kappamax=8,
|
||||
sigmascalingprofile="quartic",
|
||||
sigmascalingdirection="forward",
|
||||
sigmamin=0,
|
||||
sigmamax=1.1 * ((4 + 1) / (150 * np.pi * dl)),
|
||||
)
|
||||
|
||||
scene = gprMax.Scene()
|
||||
title = gprMax.Title(name=fn.with_suffix('').name + '_ref')
|
||||
title = gprMax.Title(name=fn.with_suffix("").name + "_ref")
|
||||
scene.add(title)
|
||||
scene.add(domain)
|
||||
scene.add(dxdydz)
|
||||
|
@@ -17,83 +17,88 @@ domain = gprMax.Domain(p1=(x, y, z))
|
||||
dxdydz = gprMax.Discretisation(p1=(dl, dl, dl))
|
||||
time_window = gprMax.TimeWindow(time=3e-9)
|
||||
|
||||
waveform = gprMax.Waveform(wave_type='gaussian', amp=1, freq=1e9, id='mypulse')
|
||||
hertzian_dipole = gprMax.HertzianDipole(polarisation='z',
|
||||
p1=(0.050, 0.050, 0.050),
|
||||
waveform_id='mypulse')
|
||||
waveform = gprMax.Waveform(wave_type="gaussian", amp=1, freq=1e9, id="mypulse")
|
||||
hertzian_dipole = gprMax.HertzianDipole(polarisation="z", p1=(0.050, 0.050, 0.050), waveform_id="mypulse")
|
||||
rx = gprMax.Rx(p1=(0.070, 0.070, 0.070))
|
||||
|
||||
# PML cases
|
||||
thick = 10 # thickness
|
||||
cases = {'off': {'x0': 0, 'y0': 0, 'z0': 0, 'xmax': 0, 'ymax': 0, 'zmax':0},
|
||||
'x0': {'x0': thick, 'y0': 0, 'z0': 0, 'xmax': 0, 'ymax': 0, 'zmax':0},
|
||||
'y0': {'x0': 0, 'y0': thick, 'z0': 0, 'xmax': 0, 'ymax': 0, 'zmax':0},
|
||||
'z0': {'x0': 0, 'y0': 0, 'z0': thick, 'xmax': 0, 'ymax': 0, 'zmax':0},
|
||||
'xmax': {'x0': 0, 'y0': 0, 'z0': 0, 'xmax': thick, 'ymax': 0, 'zmax':0},
|
||||
'ymax': {'x0': 0, 'y0': 0, 'z0': 0, 'xmax': 0, 'ymax': thick, 'zmax':0},
|
||||
'zmax': {'x0': 0, 'y0': 0, 'z0': 0, 'xmax': 0, 'ymax': 0, 'zmax': thick}}
|
||||
thick = 10 # thickness
|
||||
cases = {
|
||||
"off": {"x0": 0, "y0": 0, "z0": 0, "xmax": 0, "ymax": 0, "zmax": 0},
|
||||
"x0": {"x0": thick, "y0": 0, "z0": 0, "xmax": 0, "ymax": 0, "zmax": 0},
|
||||
"y0": {"x0": 0, "y0": thick, "z0": 0, "xmax": 0, "ymax": 0, "zmax": 0},
|
||||
"z0": {"x0": 0, "y0": 0, "z0": thick, "xmax": 0, "ymax": 0, "zmax": 0},
|
||||
"xmax": {"x0": 0, "y0": 0, "z0": 0, "xmax": thick, "ymax": 0, "zmax": 0},
|
||||
"ymax": {"x0": 0, "y0": 0, "z0": 0, "xmax": 0, "ymax": thick, "zmax": 0},
|
||||
"zmax": {"x0": 0, "y0": 0, "z0": 0, "xmax": 0, "ymax": 0, "zmax": thick},
|
||||
}
|
||||
|
||||
# PML formulation
|
||||
pml_type = gprMax.PMLProps(formulation='HORIPML')
|
||||
pml_type = gprMax.PMLProps(formulation="HORIPML")
|
||||
|
||||
## Built-in 1st order PML
|
||||
pml_cfs = gprMax.PMLCFS(alphascalingprofile='constant',
|
||||
alphascalingdirection='forward',
|
||||
alphamin=0, alphamax=0,
|
||||
kappascalingprofile='constant',
|
||||
kappascalingdirection='forward',
|
||||
kappamin=1, kappamax=1,
|
||||
sigmascalingprofile='quartic',
|
||||
sigmascalingdirection='forward',
|
||||
sigmamin=0, sigmamax=None)
|
||||
pml_cfs = gprMax.PMLCFS(
|
||||
alphascalingprofile="constant",
|
||||
alphascalingdirection="forward",
|
||||
alphamin=0,
|
||||
alphamax=0,
|
||||
kappascalingprofile="constant",
|
||||
kappascalingdirection="forward",
|
||||
kappamin=1,
|
||||
kappamax=1,
|
||||
sigmascalingprofile="quartic",
|
||||
sigmascalingdirection="forward",
|
||||
sigmamin=0,
|
||||
sigmamax=None,
|
||||
)
|
||||
|
||||
## PMLs from http://dx.doi.org/10.1109/TAP.2011.2180344
|
||||
## Standard PML
|
||||
# pml_cfs = gprMax.PMLCFS(alphascalingprofile='constant',
|
||||
# alphascalingdirection='forward',
|
||||
# pml_cfs = gprMax.PMLCFS(alphascalingprofile='constant',
|
||||
# alphascalingdirection='forward',
|
||||
# alphamin=0, alphamax=0,
|
||||
# kappascalingprofile='quartic',
|
||||
# kappascalingdirection='forward',
|
||||
# kappamin=1, kappamax=11,
|
||||
# sigmascalingprofile='quartic',
|
||||
# sigmascalingdirection='forward',
|
||||
# kappascalingprofile='quartic',
|
||||
# kappascalingdirection='forward',
|
||||
# kappamin=1, kappamax=11,
|
||||
# sigmascalingprofile='quartic',
|
||||
# sigmascalingdirection='forward',
|
||||
# sigmamin=0, sigmamax=7.427)
|
||||
|
||||
## CFS PML
|
||||
# pml_cfs = gprMax.PMLCFS(alphascalingprofile='constant',
|
||||
# alphascalingdirection='forward',
|
||||
# pml_cfs = gprMax.PMLCFS(alphascalingprofile='constant',
|
||||
# alphascalingdirection='forward',
|
||||
# alphamin=0.05, alphamax=0.05,
|
||||
# kappascalingprofile='quartic',
|
||||
# kappascalingdirection='forward',
|
||||
# kappamin=1, kappamax=7,
|
||||
# sigmascalingprofile='quartic',
|
||||
# sigmascalingdirection='forward',
|
||||
# kappascalingprofile='quartic',
|
||||
# kappascalingdirection='forward',
|
||||
# kappamin=1, kappamax=7,
|
||||
# sigmascalingprofile='quartic',
|
||||
# sigmascalingdirection='forward',
|
||||
# sigmamin=0, sigmamax=11.671)
|
||||
|
||||
## 2nd order RIPML
|
||||
# pml_cfs1 = gprMax.PMLCFS(alphascalingprofile='constant',
|
||||
# alphascalingdirection='forward',
|
||||
# pml_cfs1 = gprMax.PMLCFS(alphascalingprofile='constant',
|
||||
# alphascalingdirection='forward',
|
||||
# alphamin=0, alphamax=0,
|
||||
# kappascalingprofile='constant',
|
||||
# kappascalingdirection='forward',
|
||||
# kappamin=1, kappamax=1,
|
||||
# sigmascalingprofile='sextic',
|
||||
# sigmascalingdirection='forward',
|
||||
# kappascalingprofile='constant',
|
||||
# kappascalingdirection='forward',
|
||||
# kappamin=1, kappamax=1,
|
||||
# sigmascalingprofile='sextic',
|
||||
# sigmascalingdirection='forward',
|
||||
# sigmamin=0, sigmamax=0.5836)
|
||||
# pml_cfs2 = gprMax.PMLCFS(alphascalingprofile='constant',
|
||||
# alphascalingdirection='forward',
|
||||
# pml_cfs2 = gprMax.PMLCFS(alphascalingprofile='constant',
|
||||
# alphascalingdirection='forward',
|
||||
# alphamin=0.05, alphamax=0.05,
|
||||
# kappascalingprofile='cubic',
|
||||
# kappascalingdirection='forward',
|
||||
# kappamin=1, kappamax=8,
|
||||
# sigmascalingprofile='quadratic',
|
||||
# sigmascalingdirection='forward',
|
||||
# kappascalingprofile='cubic',
|
||||
# kappascalingdirection='forward',
|
||||
# kappamin=1, kappamax=8,
|
||||
# sigmascalingprofile='quadratic',
|
||||
# sigmascalingdirection='forward',
|
||||
# sigmamin=0, sigmamax=5.8357)
|
||||
|
||||
scenes = []
|
||||
for k, v in cases.items():
|
||||
scene = gprMax.Scene()
|
||||
title = gprMax.Title(name=fn.with_suffix('').name + '_' + k)
|
||||
title = gprMax.Title(name=fn.with_suffix("").name + "_" + k)
|
||||
scene.add(title)
|
||||
scene.add(domain)
|
||||
scene.add(dxdydz)
|
||||
@@ -102,11 +107,11 @@ for k, v in cases.items():
|
||||
scene.add(hertzian_dipole)
|
||||
scene.add(rx)
|
||||
|
||||
pml = gprMax.PMLProps(formulation='HORIPML', **v)
|
||||
pml = gprMax.PMLProps(formulation="HORIPML", **v)
|
||||
scene.add(pml)
|
||||
scene.add(pml_cfs)
|
||||
|
||||
scenes.append(scene)
|
||||
|
||||
# Run model
|
||||
gprMax.run(scenes=scenes, n=len(cases), geometry_only=False, outputfile=fn)
|
||||
gprMax.run(scenes=scenes, n=len(cases), geometry_only=False, outputfile=fn)
|
||||
|
@@ -15,7 +15,7 @@ z = 0.100
|
||||
|
||||
scene = gprMax.Scene()
|
||||
|
||||
title = gprMax.Title(name=fn.with_suffix('').name)
|
||||
title = gprMax.Title(name=fn.with_suffix("").name)
|
||||
domain = gprMax.Domain(p1=(x, y, z))
|
||||
dxdydz = gprMax.Discretisation(p1=(dl, dl, dl))
|
||||
time_window = gprMax.TimeWindow(time=30e-9)
|
||||
@@ -25,49 +25,47 @@ scene.add(domain)
|
||||
scene.add(dxdydz)
|
||||
scene.add(time_window)
|
||||
|
||||
bowtie_dims = (0.050, 0.100) # Length, height
|
||||
tx_pos = (x/2, y/2, z/2)
|
||||
bowtie_dims = (0.050, 0.100) # Length, height
|
||||
tx_pos = (x / 2, y / 2, z / 2)
|
||||
|
||||
# Source excitation and type
|
||||
wave = gprMax.Waveform(wave_type='gaussian', amp=1, freq=1.5e9, id='mypulse')
|
||||
tl = gprMax.TransmissionLine(p1=(tx_pos[0], tx_pos[1], tx_pos[2]),
|
||||
polarisation='x', resistance=50, waveform_id='mypulse')
|
||||
wave = gprMax.Waveform(wave_type="gaussian", amp=1, freq=1.5e9, id="mypulse")
|
||||
tl = gprMax.TransmissionLine(
|
||||
p1=(tx_pos[0], tx_pos[1], tx_pos[2]), polarisation="x", resistance=50, waveform_id="mypulse"
|
||||
)
|
||||
scene.add(wave)
|
||||
scene.add(tl)
|
||||
|
||||
# Bowtie - upper x half
|
||||
t1 = gprMax.Triangle(p1=(tx_pos[0], tx_pos[1], tx_pos[2]),
|
||||
p2=(tx_pos[0] + bowtie_dims[0] + 2 * dl,
|
||||
tx_pos[1] - bowtie_dims[1]/2,
|
||||
tx_pos[2]),
|
||||
p3=(tx_pos[0] + bowtie_dims[0] + 2 * dl,
|
||||
tx_pos[1] + bowtie_dims[1]/2,
|
||||
tx_pos[2]),
|
||||
thickness=0, material_id='pec')
|
||||
t1 = gprMax.Triangle(
|
||||
p1=(tx_pos[0], tx_pos[1], tx_pos[2]),
|
||||
p2=(tx_pos[0] + bowtie_dims[0] + 2 * dl, tx_pos[1] - bowtie_dims[1] / 2, tx_pos[2]),
|
||||
p3=(tx_pos[0] + bowtie_dims[0] + 2 * dl, tx_pos[1] + bowtie_dims[1] / 2, tx_pos[2]),
|
||||
thickness=0,
|
||||
material_id="pec",
|
||||
)
|
||||
|
||||
# Bowtie - lower x half
|
||||
t2 = gprMax.Triangle(p1=(tx_pos[0] + dl, tx_pos[1], tx_pos[2]),
|
||||
p2=(tx_pos[0] - bowtie_dims[0],
|
||||
tx_pos[1] - bowtie_dims[1]/2,
|
||||
tx_pos[2]),
|
||||
p3=(tx_pos[0] - bowtie_dims[0],
|
||||
tx_pos[1] + bowtie_dims[1]/2,
|
||||
tx_pos[2]),
|
||||
thickness=0, material_id='pec')
|
||||
t2 = gprMax.Triangle(
|
||||
p1=(tx_pos[0] + dl, tx_pos[1], tx_pos[2]),
|
||||
p2=(tx_pos[0] - bowtie_dims[0], tx_pos[1] - bowtie_dims[1] / 2, tx_pos[2]),
|
||||
p3=(tx_pos[0] - bowtie_dims[0], tx_pos[1] + bowtie_dims[1] / 2, tx_pos[2]),
|
||||
thickness=0,
|
||||
material_id="pec",
|
||||
)
|
||||
|
||||
scene.add(t1)
|
||||
scene.add(t2)
|
||||
|
||||
# Detailed geometry view around bowtie and feed position
|
||||
gv1 = gprMax.GeometryView(p1=(tx_pos[0] - bowtie_dims[0] - 2*dl,
|
||||
tx_pos[1] - bowtie_dims[1]/2 - 2*dl,
|
||||
tx_pos[2] - 2*dl),
|
||||
p2=(tx_pos[0] + bowtie_dims[0] + 2*dl,
|
||||
tx_pos[1] + bowtie_dims[1]/2 + 2*dl,
|
||||
tx_pos[2] + 2*dl),
|
||||
dl=(dl, dl, dl), filename='antenna_bowtie_fs_pcb',
|
||||
output_type='f')
|
||||
gv1 = gprMax.GeometryView(
|
||||
p1=(tx_pos[0] - bowtie_dims[0] - 2 * dl, tx_pos[1] - bowtie_dims[1] / 2 - 2 * dl, tx_pos[2] - 2 * dl),
|
||||
p2=(tx_pos[0] + bowtie_dims[0] + 2 * dl, tx_pos[1] + bowtie_dims[1] / 2 + 2 * dl, tx_pos[2] + 2 * dl),
|
||||
dl=(dl, dl, dl),
|
||||
filename="antenna_bowtie_fs_pcb",
|
||||
output_type="f",
|
||||
)
|
||||
scene.add(gv1)
|
||||
|
||||
# Run model
|
||||
gprMax.run(scenes=[scene], geometry_only=False, outputfile=fn, gpu=None)
|
||||
gprMax.run(scenes=[scene], geometry_only=False, outputfile=fn, gpu=None)
|
||||
|
@@ -26,80 +26,85 @@ import numpy as np
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
"""Plots a comparison of fields between given simulation output and experimental
|
||||
"""Plots a comparison of fields between given simulation output and experimental
|
||||
data files.
|
||||
"""
|
||||
|
||||
# Parse command line arguments
|
||||
parser = argparse.ArgumentParser(description='Plots a comparison of fields between ' +
|
||||
'given simulation output and experimental data files.',
|
||||
usage='cd gprMax; python -m testing.test_experimental modelfile realfile output')
|
||||
parser.add_argument('modelfile', help='name of model output file including path')
|
||||
parser.add_argument('realfile', help='name of file containing experimental data including path')
|
||||
parser.add_argument('output', help='output to be plotted, i.e. Ex Ey Ez', nargs='+')
|
||||
parser = argparse.ArgumentParser(
|
||||
description="Plots a comparison of fields between " + "given simulation output and experimental data files.",
|
||||
usage="cd gprMax; python -m testing.test_experimental modelfile realfile output",
|
||||
)
|
||||
parser.add_argument("modelfile", help="name of model output file including path")
|
||||
parser.add_argument("realfile", help="name of file containing experimental data including path")
|
||||
parser.add_argument("output", help="output to be plotted, i.e. Ex Ey Ez", nargs="+")
|
||||
args = parser.parse_args()
|
||||
|
||||
modelfile = Path(args.modelfile)
|
||||
realfile = Path(args.realfile)
|
||||
|
||||
# Model results
|
||||
f = h5py.File(Path(modelfile), 'r')
|
||||
path = '/rxs/rx1/'
|
||||
f = h5py.File(Path(modelfile), "r")
|
||||
path = "/rxs/rx1/"
|
||||
availablecomponents = list(f[path].keys())
|
||||
|
||||
# Check for polarity of output and if requested output is in file
|
||||
if args.output[0][0] == 'm':
|
||||
if args.output[0][0] == "m":
|
||||
polarity = -1
|
||||
args.outputs[0] = args.output[0][1:]
|
||||
else:
|
||||
polarity = 1
|
||||
|
||||
if args.output[0] not in availablecomponents:
|
||||
logger.exception(f"{args.output[0]} output requested to plot, but the " +
|
||||
f"available output for receiver 1 is {', '.join(availablecomponents)}")
|
||||
logger.exception(
|
||||
f"{args.output[0]} output requested to plot, but the "
|
||||
+ f"available output for receiver 1 is {', '.join(availablecomponents)}"
|
||||
)
|
||||
raise ValueError
|
||||
|
||||
floattype = f[path + args.output[0]].dtype
|
||||
iterations = f.attrs['Iterations']
|
||||
dt = f.attrs['dt']
|
||||
iterations = f.attrs["Iterations"]
|
||||
dt = f.attrs["dt"]
|
||||
model = np.zeros(iterations, dtype=floattype)
|
||||
model = f[path + args.output[0]][:] * polarity
|
||||
model /= np.amax(np.abs(model))
|
||||
timemodel = np.linspace(0, 1, iterations)
|
||||
timemodel *= (iterations * dt)
|
||||
timemodel *= iterations * dt
|
||||
f.close()
|
||||
|
||||
# Find location of maximum value from model
|
||||
modelmax = np.where(np.abs(model) == 1)[0][0]
|
||||
|
||||
# Real results
|
||||
with open(realfile, 'r') as f:
|
||||
with open(realfile, "r") as f:
|
||||
real = np.loadtxt(f)
|
||||
real[:, 1] = real[:, 1] / np.amax(np.abs(real[:, 1]))
|
||||
realmax = np.where(np.abs(real[:, 1]) == 1)[0][0]
|
||||
|
||||
difftime = - (timemodel[modelmax] - real[realmax, 0])
|
||||
difftime = -(timemodel[modelmax] - real[realmax, 0])
|
||||
|
||||
# Plot modelled and real data
|
||||
fig, ax = plt.subplots(num=f'{modelfile.stem}_vs_{realfile.stem}',
|
||||
figsize=(20, 10),
|
||||
facecolor='w',
|
||||
edgecolor='w',)
|
||||
ax.plot(timemodel + difftime, model, 'r', lw=2, label='Model')
|
||||
ax.plot(real[:, 0], real[:, 1], 'r', ls='--', lw=2, label='Experiment')
|
||||
ax.set_xlabel('Time [s]')
|
||||
ax.set_ylabel('Amplitude')
|
||||
fig, ax = plt.subplots(
|
||||
num=f"{modelfile.stem}_vs_{realfile.stem}",
|
||||
figsize=(20, 10),
|
||||
facecolor="w",
|
||||
edgecolor="w",
|
||||
)
|
||||
ax.plot(timemodel + difftime, model, "r", lw=2, label="Model")
|
||||
ax.plot(real[:, 0], real[:, 1], "r", ls="--", lw=2, label="Experiment")
|
||||
ax.set_xlabel("Time [s]")
|
||||
ax.set_ylabel("Amplitude")
|
||||
ax.set_xlim([0, timemodel[-1]])
|
||||
# ax.set_ylim([-1, 1])
|
||||
ax.legend()
|
||||
ax.grid()
|
||||
|
||||
# Save a PDF/PNG of the figure
|
||||
savename = f'{modelfile.stem}_vs_{realfile.stem}'
|
||||
savename = f"{modelfile.stem}_vs_{realfile.stem}"
|
||||
savename = modelfile.parent / savename
|
||||
# fig.savefig(savename.with_suffix('.pdf'), dpi=None, format='pdf',
|
||||
# fig.savefig(savename.with_suffix('.pdf'), dpi=None, format='pdf',
|
||||
# bbox_inches='tight', pad_inches=0.1)
|
||||
# fig.savefig(savename.with_suffix('.png'), dpi=150, format='png',
|
||||
# fig.savefig(savename.with_suffix('.png'), dpi=150, format='png',
|
||||
# bbox_inches='tight', pad_inches=0.1)
|
||||
|
||||
plt.show()
|
||||
|
@@ -29,8 +29,8 @@ from testing.analytical_solutions import hertzian_dipole_fs
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
if sys.platform == 'linux':
|
||||
plt.switch_backend('agg')
|
||||
if sys.platform == "linux":
|
||||
plt.switch_backend("agg")
|
||||
|
||||
|
||||
"""Compare field outputs
|
||||
@@ -41,7 +41,7 @@ if sys.platform == 'linux':
|
||||
"""
|
||||
|
||||
# Specify directoty with set of models to test
|
||||
modelset = 'models_basic'
|
||||
modelset = "models_basic"
|
||||
# modelset += 'models_advanced'
|
||||
# modelset += 'models_pmls'
|
||||
|
||||
@@ -49,9 +49,17 @@ basepath = Path(__file__).parents[0] / modelset
|
||||
|
||||
|
||||
# List of available basic test models
|
||||
testmodels = ['hertzian_dipole_fs_analytical', '2D_ExHyHz', '2D_EyHxHz', '2D_EzHxHy',
|
||||
'cylinder_Ascan_2D', 'hertzian_dipole_fs', 'hertzian_dipole_hs',
|
||||
'hertzian_dipole_dispersive', 'magnetic_dipole_fs']
|
||||
testmodels = [
|
||||
"hertzian_dipole_fs_analytical",
|
||||
"2D_ExHyHz",
|
||||
"2D_EyHxHz",
|
||||
"2D_EzHxHy",
|
||||
"cylinder_Ascan_2D",
|
||||
"hertzian_dipole_fs",
|
||||
"hertzian_dipole_hs",
|
||||
"hertzian_dipole_dispersive",
|
||||
"magnetic_dipole_fs",
|
||||
]
|
||||
|
||||
# List of available advanced test models
|
||||
# testmodels = ['antenna_GSSI_1500_fs', 'antenna_MALA_1200_fs']
|
||||
@@ -63,97 +71,99 @@ testmodels = ['hertzian_dipole_fs_analytical', '2D_ExHyHz', '2D_EyHxHz', '2D_EzH
|
||||
# testmodels = testmodels[:-1]
|
||||
# testmodels = [testmodels[6]]
|
||||
testresults = dict.fromkeys(testmodels)
|
||||
path = '/rxs/rx1/'
|
||||
path = "/rxs/rx1/"
|
||||
|
||||
# Minimum value of difference to plot (dB)
|
||||
plotmin = -160
|
||||
|
||||
for i, model in enumerate(testmodels):
|
||||
|
||||
testresults[model] = {}
|
||||
|
||||
# Run model
|
||||
file = basepath / model / model
|
||||
gprMax.run(inputfile=file.with_suffix('.in'), gpu=None)
|
||||
gprMax.run(inputfile=file.with_suffix(".in"), gpu=None)
|
||||
|
||||
# Special case for analytical comparison
|
||||
if model == 'hertzian_dipole_fs_analytical':
|
||||
if model == "hertzian_dipole_fs_analytical":
|
||||
# Get output for model file
|
||||
filetest = h5py.File(file.with_suffix('.h5'), 'r')
|
||||
testresults[model]['Test version'] = filetest.attrs['gprMax']
|
||||
filetest = h5py.File(file.with_suffix(".h5"), "r")
|
||||
testresults[model]["Test version"] = filetest.attrs["gprMax"]
|
||||
|
||||
# Get available field output component names
|
||||
outputstest = list(filetest[path].keys())
|
||||
|
||||
# Arrays for storing time
|
||||
float_or_double = filetest[path + outputstest[0]].dtype
|
||||
timetest = np.linspace(0, (filetest.attrs['Iterations'] - 1) * filetest.attrs['dt'],
|
||||
num=filetest.attrs['Iterations']) / 1e-9
|
||||
timetest = (
|
||||
np.linspace(0, (filetest.attrs["Iterations"] - 1) * filetest.attrs["dt"], num=filetest.attrs["Iterations"])
|
||||
/ 1e-9
|
||||
)
|
||||
timeref = timetest
|
||||
|
||||
# Arrays for storing field data
|
||||
datatest = np.zeros((filetest.attrs['Iterations'], len(outputstest)),
|
||||
dtype=float_or_double)
|
||||
datatest = np.zeros((filetest.attrs["Iterations"], len(outputstest)), dtype=float_or_double)
|
||||
for ID, name in enumerate(outputstest):
|
||||
datatest[:, ID] = filetest[path + str(name)][:]
|
||||
if np.any(np.isnan(datatest[:, ID])):
|
||||
logger.exception('Test data contains NaNs')
|
||||
logger.exception("Test data contains NaNs")
|
||||
raise ValueError
|
||||
|
||||
# Tx/Rx position to feed to analytical solution
|
||||
rxpos = filetest[path].attrs['Position']
|
||||
txpos = filetest['/srcs/src1/'].attrs['Position']
|
||||
rxposrelative = ((rxpos[0] - txpos[0]),
|
||||
(rxpos[1] - txpos[1]),
|
||||
(rxpos[2] - txpos[2]))
|
||||
rxpos = filetest[path].attrs["Position"]
|
||||
txpos = filetest["/srcs/src1/"].attrs["Position"]
|
||||
rxposrelative = ((rxpos[0] - txpos[0]), (rxpos[1] - txpos[1]), (rxpos[2] - txpos[2]))
|
||||
|
||||
# Analytical solution of a dipole in free space
|
||||
dataref = hertzian_dipole_fs(filetest.attrs['Iterations'],
|
||||
filetest.attrs['dt'],
|
||||
filetest.attrs['dx_dy_dz'], rxposrelative)
|
||||
dataref = hertzian_dipole_fs(
|
||||
filetest.attrs["Iterations"], filetest.attrs["dt"], filetest.attrs["dx_dy_dz"], rxposrelative
|
||||
)
|
||||
|
||||
else:
|
||||
# Get output for model and reference files
|
||||
fileref = f'{file.stem}_ref'
|
||||
fileref = f"{file.stem}_ref"
|
||||
fileref = file.parent / Path(fileref)
|
||||
fileref = h5py.File(fileref.with_suffix('.h5'), 'r')
|
||||
filetest = h5py.File(file.with_suffix('.h5'), 'r')
|
||||
testresults[model]['Ref version'] = fileref.attrs['gprMax']
|
||||
testresults[model]['Test version'] = filetest.attrs['gprMax']
|
||||
fileref = h5py.File(fileref.with_suffix(".h5"), "r")
|
||||
filetest = h5py.File(file.with_suffix(".h5"), "r")
|
||||
testresults[model]["Ref version"] = fileref.attrs["gprMax"]
|
||||
testresults[model]["Test version"] = filetest.attrs["gprMax"]
|
||||
|
||||
# Get available field output component names
|
||||
outputsref = list(fileref[path].keys())
|
||||
outputstest = list(filetest[path].keys())
|
||||
if outputsref != outputstest:
|
||||
logger.exception('Field output components do not match reference solution')
|
||||
logger.exception("Field output components do not match reference solution")
|
||||
raise ValueError
|
||||
|
||||
# Check that type of float used to store fields matches
|
||||
if filetest[path + outputstest[0]].dtype != fileref[path + outputsref[0]].dtype:
|
||||
logger.warning(f'Type of floating point number in test model ' +
|
||||
f'({filetest[path + outputstest[0]].dtype}) does not ' +
|
||||
f'match type in reference solution ({fileref[path + outputsref[0]].dtype})\n')
|
||||
logger.warning(
|
||||
f"Type of floating point number in test model "
|
||||
+ f"({filetest[path + outputstest[0]].dtype}) does not "
|
||||
+ f"match type in reference solution ({fileref[path + outputsref[0]].dtype})\n"
|
||||
)
|
||||
float_or_doubleref = fileref[path + outputsref[0]].dtype
|
||||
float_or_doubletest = filetest[path + outputstest[0]].dtype
|
||||
|
||||
# Arrays for storing time
|
||||
timeref = np.zeros((fileref.attrs['Iterations']), dtype=float_or_doubleref)
|
||||
timeref = np.linspace(0, (fileref.attrs['Iterations'] - 1) * fileref.attrs['dt'],
|
||||
num=fileref.attrs['Iterations']) / 1e-9
|
||||
timetest = np.zeros((filetest.attrs['Iterations']), dtype=float_or_doubletest)
|
||||
timetest = np.linspace(0, (filetest.attrs['Iterations'] - 1) * filetest.attrs['dt'],
|
||||
num=filetest.attrs['Iterations']) / 1e-9
|
||||
timeref = np.zeros((fileref.attrs["Iterations"]), dtype=float_or_doubleref)
|
||||
timeref = (
|
||||
np.linspace(0, (fileref.attrs["Iterations"] - 1) * fileref.attrs["dt"], num=fileref.attrs["Iterations"])
|
||||
/ 1e-9
|
||||
)
|
||||
timetest = np.zeros((filetest.attrs["Iterations"]), dtype=float_or_doubletest)
|
||||
timetest = (
|
||||
np.linspace(0, (filetest.attrs["Iterations"] - 1) * filetest.attrs["dt"], num=filetest.attrs["Iterations"])
|
||||
/ 1e-9
|
||||
)
|
||||
|
||||
# Arrays for storing field data
|
||||
dataref = np.zeros((fileref.attrs['Iterations'], len(outputsref)),
|
||||
dtype=float_or_doubleref)
|
||||
datatest = np.zeros((filetest.attrs['Iterations'], len(outputstest)),
|
||||
dtype=float_or_doubletest)
|
||||
dataref = np.zeros((fileref.attrs["Iterations"], len(outputsref)), dtype=float_or_doubleref)
|
||||
datatest = np.zeros((filetest.attrs["Iterations"], len(outputstest)), dtype=float_or_doubletest)
|
||||
for ID, name in enumerate(outputsref):
|
||||
dataref[:, ID] = fileref[path + str(name)][:]
|
||||
datatest[:, ID] = filetest[path + str(name)][:]
|
||||
if np.any(np.isnan(datatest[:, ID])):
|
||||
logger.exception('Test data contains NaNs')
|
||||
logger.exception("Test data contains NaNs")
|
||||
raise ValueError
|
||||
|
||||
fileref.close()
|
||||
@@ -163,43 +173,52 @@ for i, model in enumerate(testmodels):
|
||||
datadiffs = np.zeros(datatest.shape, dtype=np.float64)
|
||||
for i in range(len(outputstest)):
|
||||
maxi = np.amax(np.abs(dataref[:, i]))
|
||||
datadiffs[:, i] = np.divide(np.abs(dataref[:, i] - datatest[:, i]), maxi,
|
||||
out=np.zeros_like(dataref[:, i]),
|
||||
where=maxi != 0) # Replace any division by zero with zero
|
||||
datadiffs[:, i] = np.divide(
|
||||
np.abs(dataref[:, i] - datatest[:, i]), maxi, out=np.zeros_like(dataref[:, i]), where=maxi != 0
|
||||
) # Replace any division by zero with zero
|
||||
|
||||
# Calculate power (ignore warning from taking a log of any zero values)
|
||||
with np.errstate(divide='ignore'):
|
||||
with np.errstate(divide="ignore"):
|
||||
datadiffs[:, i] = 20 * np.log10(datadiffs[:, i])
|
||||
# Replace any NaNs or Infs from zero division
|
||||
datadiffs[:, i][np.invert(np.isfinite(datadiffs[:, i]))] = 0
|
||||
|
||||
# Store max difference
|
||||
maxdiff = np.amax(np.amax(datadiffs))
|
||||
testresults[model]['Max diff'] = maxdiff
|
||||
testresults[model]["Max diff"] = maxdiff
|
||||
|
||||
# Plot datasets
|
||||
fig1, ((ex1, hx1), (ey1, hy1), (ez1, hz1)) = plt.subplots(nrows=3, ncols=2,
|
||||
sharex=False, sharey='col',
|
||||
subplot_kw=dict(xlabel='Time [ns]'),
|
||||
num=model + '.in',
|
||||
figsize=(20, 10),
|
||||
facecolor='w',
|
||||
edgecolor='w')
|
||||
ex1.plot(timetest, datatest[:, 0], 'r', lw=2, label=model)
|
||||
ex1.plot(timeref, dataref[:, 0], 'g', lw=2, ls='--', label=f'{model}(Ref)')
|
||||
ey1.plot(timetest, datatest[:, 1], 'r', lw=2, label=model)
|
||||
ey1.plot(timeref, dataref[:, 1], 'g', lw=2, ls='--', label=f'{model}(Ref)')
|
||||
ez1.plot(timetest, datatest[:, 2], 'r', lw=2, label=model)
|
||||
ez1.plot(timeref, dataref[:, 2], 'g', lw=2, ls='--', label=f'{model}(Ref)')
|
||||
hx1.plot(timetest, datatest[:, 3], 'r', lw=2, label=model)
|
||||
hx1.plot(timeref, dataref[:, 3], 'g', lw=2, ls='--', label=f'{model}(Ref)')
|
||||
hy1.plot(timetest, datatest[:, 4], 'r', lw=2, label=model)
|
||||
hy1.plot(timeref, dataref[:, 4], 'g', lw=2, ls='--', label=f'{model}(Ref)')
|
||||
hz1.plot(timetest, datatest[:, 5], 'r', lw=2, label=model)
|
||||
hz1.plot(timeref, dataref[:, 5], 'g', lw=2, ls='--', label=f'{model}(Ref)')
|
||||
ylabels = ['$E_x$, field strength [V/m]', '$H_x$, field strength [A/m]',
|
||||
'$E_y$, field strength [V/m]', '$H_y$, field strength [A/m]',
|
||||
'$E_z$, field strength [V/m]', '$H_z$, field strength [A/m]']
|
||||
fig1, ((ex1, hx1), (ey1, hy1), (ez1, hz1)) = plt.subplots(
|
||||
nrows=3,
|
||||
ncols=2,
|
||||
sharex=False,
|
||||
sharey="col",
|
||||
subplot_kw=dict(xlabel="Time [ns]"),
|
||||
num=model + ".in",
|
||||
figsize=(20, 10),
|
||||
facecolor="w",
|
||||
edgecolor="w",
|
||||
)
|
||||
ex1.plot(timetest, datatest[:, 0], "r", lw=2, label=model)
|
||||
ex1.plot(timeref, dataref[:, 0], "g", lw=2, ls="--", label=f"{model}(Ref)")
|
||||
ey1.plot(timetest, datatest[:, 1], "r", lw=2, label=model)
|
||||
ey1.plot(timeref, dataref[:, 1], "g", lw=2, ls="--", label=f"{model}(Ref)")
|
||||
ez1.plot(timetest, datatest[:, 2], "r", lw=2, label=model)
|
||||
ez1.plot(timeref, dataref[:, 2], "g", lw=2, ls="--", label=f"{model}(Ref)")
|
||||
hx1.plot(timetest, datatest[:, 3], "r", lw=2, label=model)
|
||||
hx1.plot(timeref, dataref[:, 3], "g", lw=2, ls="--", label=f"{model}(Ref)")
|
||||
hy1.plot(timetest, datatest[:, 4], "r", lw=2, label=model)
|
||||
hy1.plot(timeref, dataref[:, 4], "g", lw=2, ls="--", label=f"{model}(Ref)")
|
||||
hz1.plot(timetest, datatest[:, 5], "r", lw=2, label=model)
|
||||
hz1.plot(timeref, dataref[:, 5], "g", lw=2, ls="--", label=f"{model}(Ref)")
|
||||
ylabels = [
|
||||
"$E_x$, field strength [V/m]",
|
||||
"$H_x$, field strength [A/m]",
|
||||
"$E_y$, field strength [V/m]",
|
||||
"$H_y$, field strength [A/m]",
|
||||
"$E_z$, field strength [V/m]",
|
||||
"$H_z$, field strength [A/m]",
|
||||
]
|
||||
for i, ax in enumerate(fig1.axes):
|
||||
ax.set_ylabel(ylabels[i])
|
||||
ax.set_xlim(0, np.amax(timetest))
|
||||
@@ -207,22 +226,31 @@ for i, model in enumerate(testmodels):
|
||||
ax.legend()
|
||||
|
||||
# Plot diffs
|
||||
fig2, ((ex2, hx2), (ey2, hy2), (ez2, hz2)) = plt.subplots(nrows=3, ncols=2,
|
||||
sharex=False, sharey='col',
|
||||
subplot_kw=dict(xlabel='Time [ns]'),
|
||||
num='Diffs: ' + model + '.in',
|
||||
figsize=(20, 10),
|
||||
facecolor='w',
|
||||
edgecolor='w')
|
||||
ex2.plot(timeref, datadiffs[:, 0], 'r', lw=2, label='Ex')
|
||||
ey2.plot(timeref, datadiffs[:, 1], 'r', lw=2, label='Ey')
|
||||
ez2.plot(timeref, datadiffs[:, 2], 'r', lw=2, label='Ez')
|
||||
hx2.plot(timeref, datadiffs[:, 3], 'r', lw=2, label='Hx')
|
||||
hy2.plot(timeref, datadiffs[:, 4], 'r', lw=2, label='Hy')
|
||||
hz2.plot(timeref, datadiffs[:, 5], 'r', lw=2, label='Hz')
|
||||
ylabels = ['$E_x$, difference [dB]', '$H_x$, difference [dB]',
|
||||
'$E_y$, difference [dB]', '$H_y$, difference [dB]',
|
||||
'$E_z$, difference [dB]', '$H_z$, difference [dB]']
|
||||
fig2, ((ex2, hx2), (ey2, hy2), (ez2, hz2)) = plt.subplots(
|
||||
nrows=3,
|
||||
ncols=2,
|
||||
sharex=False,
|
||||
sharey="col",
|
||||
subplot_kw=dict(xlabel="Time [ns]"),
|
||||
num="Diffs: " + model + ".in",
|
||||
figsize=(20, 10),
|
||||
facecolor="w",
|
||||
edgecolor="w",
|
||||
)
|
||||
ex2.plot(timeref, datadiffs[:, 0], "r", lw=2, label="Ex")
|
||||
ey2.plot(timeref, datadiffs[:, 1], "r", lw=2, label="Ey")
|
||||
ez2.plot(timeref, datadiffs[:, 2], "r", lw=2, label="Ez")
|
||||
hx2.plot(timeref, datadiffs[:, 3], "r", lw=2, label="Hx")
|
||||
hy2.plot(timeref, datadiffs[:, 4], "r", lw=2, label="Hy")
|
||||
hz2.plot(timeref, datadiffs[:, 5], "r", lw=2, label="Hz")
|
||||
ylabels = [
|
||||
"$E_x$, difference [dB]",
|
||||
"$H_x$, difference [dB]",
|
||||
"$E_y$, difference [dB]",
|
||||
"$H_y$, difference [dB]",
|
||||
"$E_z$, difference [dB]",
|
||||
"$H_z$, difference [dB]",
|
||||
]
|
||||
for i, ax in enumerate(fig2.axes):
|
||||
ax.set_ylabel(ylabels[i])
|
||||
ax.set_xlim(0, np.amax(timetest))
|
||||
@@ -230,23 +258,25 @@ for i, model in enumerate(testmodels):
|
||||
ax.grid()
|
||||
|
||||
# Save a PDF/PNG of the figure
|
||||
filediffs = f'{file.stem}_diffs'
|
||||
filediffs = f"{file.stem}_diffs"
|
||||
filediffs = file.parent / Path(filediffs)
|
||||
# fig1.savefig(file.with_suffix('.pdf'), dpi=None, format='pdf',
|
||||
# fig1.savefig(file.with_suffix('.pdf'), dpi=None, format='pdf',
|
||||
# bbox_inches='tight', pad_inches=0.1)
|
||||
# fig2.savefig(savediffs.with_suffix('.pdf'), dpi=None, format='pdf',
|
||||
# fig2.savefig(savediffs.with_suffix('.pdf'), dpi=None, format='pdf',
|
||||
# bbox_inches='tight', pad_inches=0.1)
|
||||
fig1.savefig(file.with_suffix('.png'), dpi=150, format='png',
|
||||
bbox_inches='tight', pad_inches=0.1)
|
||||
fig2.savefig(filediffs.with_suffix('.png'), dpi=150, format='png',
|
||||
bbox_inches='tight', pad_inches=0.1)
|
||||
fig1.savefig(file.with_suffix(".png"), dpi=150, format="png", bbox_inches="tight", pad_inches=0.1)
|
||||
fig2.savefig(filediffs.with_suffix(".png"), dpi=150, format="png", bbox_inches="tight", pad_inches=0.1)
|
||||
|
||||
# Summary of results
|
||||
for name, data in sorted(testresults.items()):
|
||||
if 'analytical' in name:
|
||||
logger.info(f"Test '{name}.in' using v.{data['Test version']} compared " +
|
||||
f"to analytical solution. Max difference {data['Max diff']:.2f}dB.")
|
||||
if "analytical" in name:
|
||||
logger.info(
|
||||
f"Test '{name}.in' using v.{data['Test version']} compared "
|
||||
+ f"to analytical solution. Max difference {data['Max diff']:.2f}dB."
|
||||
)
|
||||
else:
|
||||
logger.info(f"Test '{name}.in' using v.{data['Test version']} compared to " +
|
||||
f"reference solution using v.{data['Ref version']}. Max difference " +
|
||||
f"{data['Max diff']:.2f}dB.")
|
||||
logger.info(
|
||||
f"Test '{name}.in' using v.{data['Test version']} compared to "
|
||||
+ f"reference solution using v.{data['Ref version']}. Max difference "
|
||||
+ f"{data['Max diff']:.2f}dB."
|
||||
)
|
||||
|
在新工单中引用
屏蔽一个用户