PML comparison updated to use API

这个提交包含在:
Craig Warren
2022-11-03 14:25:11 +00:00
父节点 513611c8c7
当前提交 64250b01f4
共有 6 个文件被更改,包括 6 次插入187 次删除

查看文件

@@ -18,7 +18,6 @@
import itertools import itertools
import logging import logging
import os
from operator import add from operator import add
from pathlib import Path from pathlib import Path
@@ -39,9 +38,9 @@ colors = itertools.cycle(colorIDs)
lines = itertools.cycle(('--', ':', '-.', '-')) lines = itertools.cycle(('--', ':', '-.', '-'))
markers = ['o', 'd', '^', 's', '*'] markers = ['o', 'd', '^', 's', '*']
basepath = Path(__file__).parent parts = Path(__file__).parts
path = 'rxs/rx1/' path = 'rxs/rx1/'
refmodel = 'pml_3D_pec_plate_ref' basename = 'pml_3D_pec_plate'
PMLIDs = ['CFS-PML', 'HORIPML-1', 'HORIPML-2', 'MRIPML-1', 'MRIPML-2'] PMLIDs = ['CFS-PML', 'HORIPML-1', 'HORIPML-2', 'MRIPML-1', 'MRIPML-2']
maxerrors = [] maxerrors = []
testmodels = ['pml_3D_pec_plate_' + s for s in PMLIDs] testmodels = ['pml_3D_pec_plate_' + s for s in PMLIDs]
@@ -50,8 +49,8 @@ fig, ax = plt.subplots(subplot_kw=dict(xlabel='Iterations', ylabel='Error [dB]')
for x, model in enumerate(testmodels): for x, model in enumerate(testmodels):
# Open output file and read iterations # Open output file and read iterations
fileref = h5py.File(basepath.joinpath(refmodel, '.h5'), 'r') fileref = h5py.File(Path(*parts[:-1], basename, basename + '_ref.h5'), 'r')
filetest = h5py.File(basepath.joinpath(model, '.h5'), 'r') filetest = h5py.File(Path(*parts[:-1], basename, basename + str(x + 1) + '.h5'), 'r')
# Get available field output component names # Get available field output component names
outputsref = list(fileref[path].keys()) outputsref = list(fileref[path].keys())
@@ -66,7 +65,7 @@ for x, model in enumerate(testmodels):
f'does not match type in reference solution ({fileref[path + outputsref[0]].dtype})\n') f'does not match type in reference solution ({fileref[path + outputsref[0]].dtype})\n')
floattyperef = fileref[path + outputsref[0]].dtype floattyperef = fileref[path + outputsref[0]].dtype
floattypetest = filetest[path + outputstest[0]].dtype floattypetest = filetest[path + outputstest[0]].dtype
# print('Data type: {}'.format(floattypetest)) # logger.info(f'Data type: {floattypetest}')
# Arrays for storing time # Arrays for storing time
# timeref = np.zeros((fileref.attrs['Iterations']), dtype=floattyperef) # timeref = np.zeros((fileref.attrs['Iterations']), dtype=floattyperef)
@@ -106,7 +105,7 @@ for x, model in enumerate(testmodels):
# Print maximum error value # Print maximum error value
start = 210 start = 210
maxerrors.append(f': {np.amax(datadiffs[start::, 1]):.1f} [dB]') maxerrors.append(f': {np.amax(datadiffs[start::, 1]):.1f} [dB]')
print(f'{model}: Max. error {maxerrors[x]}') logger.info(f'{model}: Max. error {maxerrors[x]}')
# Plot diffs (select column to choose field component, 0-Ex, 1-Ey etc..) # 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) ax.plot(timeref[start::], datadiffs[start::, 1], color=next(colors), lw=2, ls=next(lines), label=model)

查看文件

@@ -1,34 +0,0 @@
#title: Response from an elongated thin PEC plate
#domain: 0.051 0.126 0.026
#dx_dy_dz: 0.001 0.001 0.001
#time_window: 2100
#time_step_stability_factor: 0.99
################################################
## PML parameters
## CFS (alpha, kappa, sigma)
## sigma_max = (0.8 * (m + 1)) / (z0 * d * np.sqrt(er * mr))
## z0 = 376.73, d = 0.001
################################################
#pml_cells: 10
#############
## CFS PML ##
#############
#python:
import numpy as np
# Parameters from http://dx.doi.org/10.1109/TAP.2018.2823864
smax = 1.1 * ((4 + 1) / (150 * np.pi * 0.001))
print('#pml_cfs: constant forward 0.05 0.05 quartic forward 1 8 quartic forward 0 {}'.format(smax))
#end_python:
#waveform: gaussiandotnorm 1 9.42e9 mypulse
#hertzian_dipole: z 0.013 0.013 0.014 mypulse
#rx: 0.038 0.114 0.013
#plate: 0.013 0.013 0.013 0.038 0.113 0.013 pec
geometry_view: 0 0 0 0.051 0.126 0.026 0.001 0.001 0.001 pml_3D_pec_plate_f f
geometry_view: 0 0 0 0.051 0.126 0.026 0.001 0.001 0.001 pml_3D_pec_plate_n n

查看文件

@@ -1,34 +0,0 @@
#title: Response from an elongated thin PEC plate
#domain: 0.051 0.126 0.026
#dx_dy_dz: 0.001 0.001 0.001
#time_window: 2100
#time_step_stability_factor: 0.99
################################################
## PML parameters
## CFS (alpha, kappa, sigma)
## sigma_max = (0.8 * (m + 1)) / (z0 * d * np.sqrt(er * mr))
## z0 = 376.73, d = 0.001
################################################
#pml_cells: 10
################################################
## 1st order (default) HORIPML - Standard PML ##
################################################
#python:
import numpy as np
# Parameters from http://dx.doi.org/10.1109/TAP.2011.2180344
smax = 0.7 * ((4 + 1) / (150 * np.pi * 0.001))
print('#pml_cfs: constant forward 0 0 quartic forward 1 12 quartic forward 0 {}'.format(smax))
#end_python:
#waveform: gaussiandotnorm 1 9.42e9 mypulse
#hertzian_dipole: z 0.013 0.013 0.014 mypulse
#rx: 0.038 0.114 0.013
#plate: 0.013 0.013 0.013 0.038 0.113 0.013 pec
geometry_view: 0 0 0 0.051 0.126 0.026 0.001 0.001 0.001 pml_3D_pec_plate_f f
geometry_view: 0 0 0 0.051 0.126 0.026 0.001 0.001 0.001 pml_3D_pec_plate_n n

查看文件

@@ -1,37 +0,0 @@
#title: Response from an elongated thin PEC plate
#domain: 0.051 0.126 0.026
#dx_dy_dz: 0.001 0.001 0.001
#time_window: 2100
#time_step_stability_factor: 0.99
################################################
## PML parameters
## CFS (alpha, kappa, sigma)
## sigma_max = (0.8 * (m + 1)) / (z0 * d * np.sqrt(er * mr))
## z0 = 376.73, d = 0.001
################################################
#pml_cells: 10
#######################
## 2nd order HORIPML ##
#######################
#python:
import numpy as np
# Parameters from http://dx.doi.org/10.1109/TAP.2018.2823864
smax1 = 0.275 / (150 * np.pi * 0.001)
smax2 = 2.75 / (150 * np.pi * 0.001)
a0 = 0.07
print('#pml_cfs: constant forward 0 0 constant forward 1 1 sextic forward 0 {}'.format(smax1))
print('#pml_cfs: sextic forward {} {} cubic forward 1 8 quadratic forward 0 {}'.format(a0, a0 + smax1, smax2))
#end_python:
#waveform: gaussiandotnorm 1 9.42e9 mypulse
#hertzian_dipole: z 0.013 0.013 0.014 mypulse
#rx: 0.038 0.114 0.013
#plate: 0.013 0.013 0.013 0.038 0.113 0.013 pec
geometry_view: 0 0 0 0.051 0.126 0.026 0.001 0.001 0.001 pml_3D_pec_plate_f f
geometry_view: 0 0 0 0.051 0.126 0.026 0.001 0.001 0.001 pml_3D_pec_plate_n n

查看文件

@@ -1,36 +0,0 @@
#title: Response from an elongated thin PEC plate
#domain: 0.051 0.126 0.026
#dx_dy_dz: 0.001 0.001 0.001
#time_window: 2100
#time_step_stability_factor: 0.99
################################################
## PML parameters
## CFS (alpha, kappa, sigma)
## sigma_max = (0.8 * (m + 1)) / (z0 * d * np.sqrt(er * mr))
## z0 = 376.73, d = 0.001
################################################
#pml_cells: 10
######################
## 1st order MRIPML ##
######################
#pml_formulation: MRIPML
#python:
import numpy as np
# Parameters from Antonis' MATLAB script (M3Dparams.m)
smax = 1.1 * ((4 + 1) / (150 * np.pi * 0.001))
print('#pml_cfs: constant forward 0.05 0.05 quartic forward 1 8 quartic forward 0 {}'.format(smax))
#end_python:
#waveform: gaussiandotnorm 1 9.42e9 mypulse
#hertzian_dipole: z 0.013 0.013 0.014 mypulse
#rx: 0.038 0.114 0.013
#plate: 0.013 0.013 0.013 0.038 0.113 0.013 pec
geometry_view: 0 0 0 0.051 0.126 0.026 0.001 0.001 0.001 pml_3D_pec_plate_f f
geometry_view: 0 0 0 0.051 0.126 0.026 0.001 0.001 0.001 pml_3D_pec_plate_n n

查看文件

@@ -1,39 +0,0 @@
#title: Response from an elongated thin PEC plate
#domain: 0.051 0.126 0.026
#dx_dy_dz: 0.001 0.001 0.001
#time_window: 2100
#time_step_stability_factor: 0.99
################################################
## PML parameters
## CFS (alpha, kappa, sigma)
## sigma_max = (0.8 * (m + 1)) / (z0 * d * np.sqrt(er * mr))
## z0 = 376.73, d = 0.001
################################################
#pml_cells: 10
######################
## 2nd order MRIPML ##
######################
#pml_formulation: MRIPML
#python:
import numpy as np
# Parameters from http://dx.doi.org/10.1109/TAP.2018.2823864
smax1 = 0.65 * ((4 + 1) / (150 * np.pi * 0.001))
smax2 = 0.65 * ((2 + 1) / (150 * np.pi * 0.001))
print('#pml_cfs: quadratic reverse 0 0.15 quartic forward 1 12 quartic forward 0 {}'.format(smax1))
print('#pml_cfs: linear reverse 0 0.8 constant forward 0 0 quadratic forward 0 {}'.format(smax2))
#end_python:
#waveform: gaussiandotnorm 1 9.42e9 mypulse
#hertzian_dipole: z 0.013 0.013 0.014 mypulse
#rx: 0.038 0.114 0.013
#plate: 0.013 0.013 0.013 0.038 0.113 0.013 pec
geometry_view: 0 0 0 0.051 0.126 0.026 0.001 0.001 0.001 pml_3D_pec_plate_f f
geometry_view: 0 0 0 0.051 0.126 0.026 0.001 0.001 0.001 pml_3D_pec_plate_n n