Pmlformulation choice command

这个提交包含在:
agianno
2018-03-15 16:17:58 +00:00
父节点 db929d52cd
当前提交 796346ebde
共有 8 个文件被更改,包括 1760 次插入45 次删除

查看文件

@@ -127,6 +127,7 @@ class FDTDGrid(Grid):
self.pmlthickness = OrderedDict((key, 10) for key in PML.boundaryIDs) self.pmlthickness = OrderedDict((key, 10) for key in PML.boundaryIDs)
self.cfs = [] self.cfs = []
self.pmls = [] self.pmls = []
self.pmlformulation = 'HORIPML'
self.materials = [] self.materials = []
self.mixingmodels = [] self.mixingmodels = []

查看文件

@@ -192,7 +192,7 @@ def check_cmd_names(processedlines, checkessential=True):
essentialcmds = ['#domain', '#dx_dy_dz', '#time_window'] essentialcmds = ['#domain', '#dx_dy_dz', '#time_window']
# Commands that there should only be one instance of in a model # Commands that there should only be one instance of in a model
singlecmds = dict.fromkeys(['#domain', '#dx_dy_dz', '#time_window', '#title', '#messages', '#num_threads', '#time_step_stability_factor', '#pml_cells', '#excitation_file', '#src_steps', '#rx_steps', '#taguchi', '#end_taguchi'], None) singlecmds = dict.fromkeys(['#domain', '#dx_dy_dz', '#time_window', '#title', '#messages', '#num_threads', '#time_step_stability_factor', '#pml_cells', '#excitation_file', '#src_steps', '#rx_steps', '#taguchi', '#end_taguchi', '#pml_formulation'], None)
# Commands that there can be multiple instances of in a model - these will be lists within the dictionary # Commands that there can be multiple instances of in a model - these will be lists within the dictionary
multiplecmds = {key: [] for key in ['#geometry_view', '#geometry_objects_write', '#material', '#soil_peplinski', '#add_dispersion_debye', '#add_dispersion_lorentz', '#add_dispersion_drude', '#waveform', '#voltage_source', '#hertzian_dipole', '#magnetic_dipole', '#transmission_line', '#rx', '#rx_array', '#snapshot', '#pml_cfs', '#include_file']} multiplecmds = {key: [] for key in ['#geometry_view', '#geometry_objects_write', '#material', '#soil_peplinski', '#add_dispersion_debye', '#add_dispersion_lorentz', '#add_dispersion_drude', '#waveform', '#voltage_source', '#hertzian_dipole', '#magnetic_dipole', '#transmission_line', '#rx', '#rx_array', '#snapshot', '#pml_cfs', '#include_file']}

查看文件

@@ -795,8 +795,8 @@ def process_multicmds(multicmds, G):
if tmp[1] not in CFSParameter.scalingdirections or tmp[5] not in CFSParameter.scalingdirections or tmp[9] not in CFSParameter.scalingdirections: if tmp[1] not in CFSParameter.scalingdirections or tmp[5] not in CFSParameter.scalingdirections or tmp[9] not in CFSParameter.scalingdirections:
raise CmdInputError("'" + cmdname + ': ' + ' '.join(tmp) + "'" + ' must have scaling type {}'.format(','.join(CFSParameter.scalingdirections))) raise CmdInputError("'" + cmdname + ': ' + ' '.join(tmp) + "'" + ' must have scaling type {}'.format(','.join(CFSParameter.scalingdirections)))
if float(tmp[2]) < 0 or float(tmp[3]) < 0 or float(tmp[6]) < 0 or float(tmp[7]) < 0 or float(tmp[10]) < 0: if float(tmp[2]) < 0 or float(tmp[3]) < 0 or float(tmp[6]) < 0 or float(tmp[7]) < 0 or float(tmp[10]) < 0:
raise CmdInputError("'" + cmdname + ': ' + ' '.join(tmp) + "'" + ' minimum and maximum scaling values must be greater than zero') raise CmdInputError("'" + cmdname + ': ' + ' '.join(tmp) + "'" + ' minimum and maximum scaling values must be positive')
if float(tmp[6]) < 1: if float(tmp[6]) < 1 and G.pmlformulation == 'HORIPML':
raise CmdInputError("'" + cmdname + ': ' + ' '.join(tmp) + "'" + ' minimum scaling value for kappa must be greater than or equal to one') raise CmdInputError("'" + cmdname + ': ' + ' '.join(tmp) + "'" + ' minimum scaling value for kappa must be greater than or equal to one')
cfsalpha = CFSParameter() cfsalpha = CFSParameter()

查看文件

@@ -232,6 +232,20 @@ def process_singlecmds(singlecmds, G):
if 2 * G.pmlthickness['x0'] >= G.nx or 2 * G.pmlthickness['y0'] >= G.ny or 2 * G.pmlthickness['z0'] >= G.nz or 2 * G.pmlthickness['xmax'] >= G.nx or 2 * G.pmlthickness['ymax'] >= G.ny or 2 * G.pmlthickness['zmax'] >= G.nz: if 2 * G.pmlthickness['x0'] >= G.nx or 2 * G.pmlthickness['y0'] >= G.ny or 2 * G.pmlthickness['z0'] >= G.nz or 2 * G.pmlthickness['xmax'] >= G.nx or 2 * G.pmlthickness['ymax'] >= G.ny or 2 * G.pmlthickness['zmax'] >= G.nz:
raise CmdInputError(cmd + ' has too many cells for the domain size') raise CmdInputError(cmd + ' has too many cells for the domain size')
cmd = '#pml_formulation'
if singlecmds[cmd] is not None:
pmlformulations = ['MRIPML', 'HORIPML']
tmp = singlecmds[cmd].split()
if len(tmp) != 1:
raise CmdInputError(cmd + ' requires exactly one parameter')
else:
G.pmlformulation = singlecmds[cmd].upper()
if singlecmds[cmd].upper() in pmlformulations:
if G.messages:
print('PML formulation: {}'.format(G.pmlformulation))
else:
raise CmdInputError(cmd + ' PML formulation is not found')
# src_steps # src_steps
cmd = '#src_steps' cmd = '#src_steps'
if singlecmds[cmd] is not None: if singlecmds[cmd] is not None:

查看文件

@@ -24,13 +24,14 @@ from tqdm import tqdm
from gprMax.constants import e0 from gprMax.constants import e0
from gprMax.constants import z0 from gprMax.constants import z0
from gprMax.constants import floattype from gprMax.constants import floattype
from gprMax.exceptions import GeneralError
class CFSParameter(object): class CFSParameter(object):
"""Individual CFS parameter (e.g. alpha, kappa, or sigma).""" """Individual CFS parameter (e.g. alpha, kappa, or sigma)."""
# Allowable scaling profiles and directions # Allowable scaling profiles and directions
scalingprofiles = {'constant': 0, 'linear': 1, 'quadratic': 2, 'cubic': 3, 'quartic': 4, 'quintic': 5, 'sextic': 6} scalingprofiles = {'constant': 0, 'linear': 1, 'quadratic': 2, 'cubic': 3, 'quartic': 4, 'quintic': 5, 'sextic': 6, 'dodeka': 12}
scalingdirections = ['forward', 'reverse'] scalingdirections = ['forward', 'reverse']
def __init__(self, ID=None, scaling='polynomial', scalingprofile=None, scalingdirection='forward', min=0, max=0): def __init__(self, ID=None, scaling='polynomial', scalingprofile=None, scalingdirection='forward', min=0, max=0):
@@ -232,19 +233,41 @@ class PML(object):
Ekappa, Hkappa = cfs.calculate_values(self.thickness, cfs.kappa) Ekappa, Hkappa = cfs.calculate_values(self.thickness, cfs.kappa)
Esigma, Hsigma = cfs.calculate_values(self.thickness, cfs.sigma) Esigma, Hsigma = cfs.calculate_values(self.thickness, cfs.sigma)
# Electric PML update coefficients # Define different parameters depending on PML formulation
tmp = (2 * e0 * Ekappa) + G.dt * (Ealpha * Ekappa + Esigma) if G.pmlformulation == 'HORIPML':
self.ERA[x, :] = (2 * e0 + G.dt * Ealpha) / tmp # HORIPML Electric PML update coefficients
self.ERB[x, :] = (2 * e0 * Ekappa) / tmp tmp = (2 * e0 * Ekappa) + G.dt * (Ealpha * Ekappa + Esigma)
self.ERE[x, :] = ((2 * e0 * Ekappa) - G.dt * (Ealpha * Ekappa + Esigma)) / tmp self.ERA[x, :] = (2 * e0 + G.dt * Ealpha) / tmp
self.ERF[x, :] = (2 * Esigma * G.dt) / (Ekappa * tmp) self.ERB[x, :] = (2 * e0 * Ekappa) / tmp
self.ERE[x, :] = ((2 * e0 * Ekappa) - G.dt * (Ealpha * Ekappa + Esigma)) / tmp
self.ERF[x, :] = (2 * Esigma * G.dt) / (Ekappa * tmp)
# HORIPML Magnetic PML update coefficients
tmp = (2 * e0 * Hkappa) + G.dt * (Halpha * Hkappa + Hsigma)
self.HRA[x, :] = (2 * e0 + G.dt * Halpha) / tmp
self.HRB[x, :] = (2 * e0 * Hkappa) / tmp
self.HRE[x, :] = ((2 * e0 * Hkappa) - G.dt * (Halpha * Hkappa + Hsigma)) / tmp
self.HRF[x, :] = (2 * Hsigma * G.dt) / (Hkappa * tmp)
elif G.pmlformulation == 'MRIPML':
# MRIPML Electric PML update coefficients
tmp = 2 * e0 + G.dt * Ealpha
self.ERA[x, :] = Ekappa + (G.dt * Esigma) / tmp
self.ERB[x, :] = (2 * e0) / tmp
self.ERE[x, :] = ((2 * e0) - G.dt * Ealpha) / tmp
self.ERF[x, :] = (2 * Esigma * G.dt) / tmp
# MRIPML Magnetic PML update coefficients
tmp = 2 * e0 + G.dt * Halpha
self.HRA[x, :] = Hkappa + (G.dt * Hsigma) / tmp
self.HRB[x, :] = (2 * e0) / tmp
self.HRE[x, :] = ((2 * e0) - G.dt * Halpha) / tmp
self.HRF[x, :] = (2 * Hsigma * G.dt) / tmp
else:
GeneralError('Do not know about ' + G.pmlformulation + ' No PML update coefficients calculated')
# Magnetic PML update coefficients
tmp = (2 * e0 * Hkappa) + G.dt * (Halpha * Hkappa + Hsigma)
self.HRA[x, :] = (2 * e0 + G.dt * Halpha) / tmp
self.HRB[x, :] = (2 * e0 * Hkappa) / tmp
self.HRE[x, :] = ((2 * e0 * Hkappa) - G.dt * (Halpha * Hkappa + Hsigma)) / tmp
self.HRF[x, :] = (2 * Hsigma * G.dt) / (Hkappa * tmp)
def update_electric(self, G): def update_electric(self, G):
"""This functions updates electric field components with the PML correction. """This functions updates electric field components with the PML correction.
@@ -253,7 +276,7 @@ class PML(object):
G (class): Grid class instance - holds essential parameters describing the model. G (class): Grid class instance - holds essential parameters describing the model.
""" """
func = getattr(import_module('gprMax.pml_updates_ext'), 'update_pml_' + str(len(self.CFS)) + 'order_electric_' + self.direction) func = getattr(import_module('gprMax.pml_updates_ext'), 'update_pml_' + str(len(self.CFS)) + 'order_electric_' + G.pmlformulation + '_' + self.direction)
func(self.xs, self.xf, self.ys, self.yf, self.zs, self.zf, G.nthreads, G.updatecoeffsE, G.ID, G.Ex, G.Ey, G.Ez, G.Hx, G.Hy, G.Hz, self.EPhi1, self.EPhi2, self.ERA, self.ERB, self.ERE, self.ERF, self.d) func(self.xs, self.xf, self.ys, self.yf, self.zs, self.zf, G.nthreads, G.updatecoeffsE, G.ID, G.Ex, G.Ey, G.Ez, G.Hx, G.Hy, G.Hz, self.EPhi1, self.EPhi2, self.ERA, self.ERB, self.ERE, self.ERF, self.d)
def update_magnetic(self, G): def update_magnetic(self, G):
@@ -263,7 +286,7 @@ class PML(object):
G (class): Grid class instance - holds essential parameters describing the model. G (class): Grid class instance - holds essential parameters describing the model.
""" """
func = getattr(import_module('gprMax.pml_updates_ext'), 'update_pml_' + str(len(self.CFS)) + 'order_magnetic_' + self.direction) func = getattr(import_module('gprMax.pml_updates_ext'), 'update_pml_' + str(len(self.CFS)) + 'order_magnetic_' + G.pmlformulation + '_' + self.direction)
func(self.xs, self.xf, self.ys, self.yf, self.zs, self.zf, G.nthreads, G.updatecoeffsH, G.ID, G.Ex, G.Ey, G.Ez, G.Hx, G.Hy, G.Hz, self.HPhi1, self.HPhi2, self.HRA, self.HRB, self.HRE, self.HRF, self.d) func(self.xs, self.xf, self.ys, self.yf, self.zs, self.zf, G.nthreads, G.updatecoeffsH, G.ID, G.Ex, G.Ey, G.Ez, G.Hx, G.Hy, G.Hz, self.HPhi1, self.HPhi2, self.HRA, self.HRB, self.HRE, self.HRF, self.d)
def gpu_set_blocks_per_grid(self, G): def gpu_set_blocks_per_grid(self, G):

文件差异内容过多而无法显示 加载差异

查看文件

@@ -1,15 +1,20 @@
#title: A-scan from a metal cylinder buried in a dielectric half-space #title: A-scan from a metal cylinder buried in a dielectric half-space
#domain: 0.240 0.210 0.002 #domain: 0.240 0.210 0.002
#dx_dy_dz: 0.002 0.002 0.002 #dx_dy_dz: 0.002 0.002 0.002
#time_window: 3e-9 #time_window: 300e-9
#pml_cfs: constant forward 0 0 cubic forward 1 4 dodeka forward 0 13.7934
#pml_cfs: constant forward 0.1 0.1 constant forward 0 0 cubic forward 0 8.4883
#material: 8 0.01 1 0 wet
#material: 6 0 1 0 half_space #material: 6 0 1 0 half_space
#waveform: ricker 1 1.5e9 my_ricker #waveform: ricker 1 1.5e9 my_ricker
#hertzian_dipole: z 0.100 0.170 0 my_ricker #hertzian_dipole: z 0.100 0.170 0 my_ricker
#rx: 0.140 0.170 0 #rx: 0.140 0.170 0
#pml_formulation: MRIPML
#box: 0 0 0 0.240 0.170 0.002 half_space #box: 0 0 0 0.240 0.170 0.002 half_space
#cylinder: 0.120 0.080 0 0.120 0.080 0.002 0.010 pec #cylinder: 0.120 0.080 0 0.120 0.080 0.002 0.010 pec
#geometry_view: 0 0 0 0.240 0.210 0.002 0.002 0.002 0.002 cylinder_half_space n #geometry_view: 0 0 0 0.240 0.210 0.002 0.002 0.002 0.002 cylinder_half_space n
#messages: y

二进制文件未显示。