Modifications to simplify setting PML and time step limit for 2D models. This is now done automatically by gprMax and does not requires any user input commands to do so.

这个提交包含在:
craig-warren
2016-03-05 12:47:01 +00:00
父节点 06e6e8db25
当前提交 7eb5f3983b
共有 6 个文件被更改,包括 15 次插入37 次删除

查看文件

@@ -68,12 +68,6 @@ The domain size should be enough to enclose the volume of interest, plus allow 1
#domain: 0.240 0.190 0.002
Since this is a 2D model the PML should be switched off for the two faces of the domain in the infinite direction (in this case the z direction). This is achieved using the command:
.. code-block:: none
#pml_cells: 10 10 0 10 10 0
Choose a time window
--------------------
@@ -87,11 +81,7 @@ This is the minimum time required, but the pulse wavelet has a width of 1.2 ns,
#time_window: 3e-9
gprMax will calculate the time step required for the model using the CFL condition in 3D. However, since this is a 2D model the time step can be relaxed to the CFL condition in 2D. This is achieved using the command:
.. code-block:: none
#time_step_limit_type: 2D
gprMax will calculate the time step required for the model using the CFL condition in 2D.
Create the objects
------------------

查看文件

@@ -40,7 +40,7 @@ class FDTDGrid:
self.timewindow = 0
self.nthreads = 0
self.cfs = []
self.pmlthickness = (10, 10, 10, 10, 10, 10)
self.pmlthickness = 10
self.pmls = []
self.materials = []
self.mixingmodels = []

查看文件

@@ -116,7 +116,7 @@ def check_cmd_names(processedlines):
essentialcmds = ['#domain', '#dx_dy_dz', '#time_window']
# 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', '#time_step_limit_type', '#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'], 'None')
# 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', '#material', '#soil_peplinski', '#add_dispersion_debye', '#add_dispersion_lorentz', '#add_dispersion_drude', '#waveform', '#voltage_source', '#hertzian_dipole', '#magnetic_dipole', '#transmission_line', '#rx', '#rx_box', '#snapshot', '#pml_cfs']}

查看文件

@@ -115,27 +115,19 @@ def process_singlecmds(singlecmds, multicmds, G):
print('Memory (RAM) usage: ~{} required, {} available'.format(human_size(mem), human_size(psutil.virtual_memory().total)))
# Time step CFL limit - use either 2D or 3D (default)
cmd = '#time_step_limit_type'
if singlecmds[cmd] != 'None':
tmp = singlecmds[cmd].split()
if len(tmp) != 1:
raise CmdInputError(cmd + ' requires exactly one parameter')
if singlecmds[cmd].lower() == '2d':
# Time step CFL limit (use either 2D or 3D) and default PML thickness
if G.nx == 1:
G.dt = 1 / (c * np.sqrt((1 / G.dy) * (1 / G.dy) + (1 / G.dz) * (1 / G.dz)))
G.pmlthickness = (0, G.pmlthickness, G.pmlthickness, 0, G.pmlthickness, G.pmlthickness)
elif G.ny == 1:
G.dt = 1 / (c * np.sqrt((1 / G.dx) * (1 / G.dx) + (1 / G.dz) * (1 / G.dz)))
G.pmlthickness = (G.pmlthickness, 0, G.pmlthickness, G.pmlthickness, 0, G.pmlthickness)
elif G.nz == 1:
G.dt = 1 / (c * np.sqrt((1 / G.dx) * (1 / G.dx) + (1 / G.dy) * (1 / G.dy)))
else:
raise CmdInputError(cmd + ' 2D CFL limit can only be used when one dimension of the domain is one cell')
elif singlecmds[cmd].lower() == '3d':
G.dt = 1 / (c * np.sqrt((1 / G.dx) * (1 / G.dx) + (1 / G.dy) * (1 / G.dy) + (1 / G.dz) * (1 / G.dz)))
else:
raise CmdInputError(cmd + ' requires input values of either 2D or 3D')
G.pmlthickness = (G.pmlthickness, G.pmlthickness, 0, G.pmlthickness, G.pmlthickness, 0)
else:
G.dt = 1 / (c * np.sqrt((1 / G.dx) * (1 / G.dx) + (1 / G.dy) * (1 / G.dy) + (1 / G.dz) * (1 / G.dz)))
G.pmlthickness = (G.pmlthickness, G.pmlthickness, G.pmlthickness, G.pmlthickness, G.pmlthickness, G.pmlthickness)
# Round down time step to nearest float with precision one less than hardware maximum. Avoids inadvertently exceeding the CFL due to binary representation of floating point number.
G.dt = round_value(G.dt, decimalplaces=d.getcontext().prec - 1)

查看文件

@@ -2,13 +2,11 @@
#domain: 0.240 0.190 0.002
#dx_dy_dz: 0.002 0.002 0.002
#time_window: 3e-9
#time_step_limit_type: 2D
#pml_cells: 10 10 0 10 10 0
#material: 6 0 1 0 half_space
#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 0 2e-9
#rx: 0.140 0.170 0
#box: 0 0 0 0.240 0.170 0.002 half_space

查看文件

@@ -2,8 +2,6 @@
#domain: 0.240 0.190 0.002
#dx_dy_dz: 0.002 0.002 0.002
#time_window: 3e-9
#time_step_limit_type: 2D
#pml_cells: 10 10 0 10 10 0
#material: 6 0 1 0 half_space