Docstrings updates

这个提交包含在:
Craig Warren
2022-11-15 16:13:59 +00:00
父节点 49520f8f6f
当前提交 ae6026de26
共有 2 个文件被更改,包括 39 次插入35 次删除

查看文件

@@ -47,15 +47,15 @@ class SubGridHSG(SubGridBaseGrid):
# Hz = c0Hz - c1Ey + c2Ex
# Hy = c0Hy - c3Ex + c1Ez
# Hx = c0Hx - c2Ez + c3Ey
# bottom and top
# Bottom and Top
cython_update_is(self.nwx, self.nwy, self.nwz, self.updatecoeffsH, self.ID, self.n_boundary_cells, -1, self.nwx, self.nwy + 1, self.nwz, 1, self.Hy, precursors.ex_bottom, precursors.ex_top, self.IDlookup['Hy'], 1, -1, 3, config.get_model_config().ompthreads)
cython_update_is(self.nwx, self.nwy, self.nwz, self.updatecoeffsH, self.ID, self.n_boundary_cells, -1, self.nwx + 1, self.nwy, self.nwz, 1, self.Hx, precursors.ey_bottom, precursors.ey_top, self.IDlookup['Hx'], -1, 1, 3, config.get_model_config().ompthreads)
# left and right
# Left and Right
cython_update_is(self.nwx, self.nwy, self.nwz, self.updatecoeffsH, self.ID, self.n_boundary_cells, -1, self.nwy, self.nwz + 1, self.nwx, 2, self.Hz, precursors.ey_left, precursors.ey_right, self.IDlookup['Hz'], 1, -1, 1, config.get_model_config().ompthreads)
cython_update_is(self.nwx, self.nwy, self.nwz, self.updatecoeffsH, self.ID, self.n_boundary_cells, -1, self.nwy + 1, self.nwz, self.nwx, 2, self.Hy, precursors.ez_left, precursors.ez_right, self.IDlookup['Hy'], -1, 1, 1, config.get_model_config().ompthreads)
# front and back
# Front and Back
cython_update_is(self.nwx, self.nwy, self.nwz, self.updatecoeffsH, self.ID, self.n_boundary_cells, -1, self.nwx, self.nwz + 1, self.nwy, 3, self.Hz, precursors.ex_front, precursors.ex_back, self.IDlookup['Hz'], -1, 1, 2, config.get_model_config().ompthreads)
cython_update_is(self.nwx, self.nwy, self.nwz, self.updatecoeffsH, self.ID, self.n_boundary_cells, -1, self.nwx + 1, self.nwz, self.nwy, 3, self.Hx, precursors.ez_front, precursors.ez_back, self.IDlookup['Hx'], 1, -1, 2, config.get_model_config().ompthreads)
@@ -71,15 +71,15 @@ class SubGridHSG(SubGridBaseGrid):
# Ey = c0(Ey) + c3(dHx) - c1(dHz)
# Ez = c0(Ez) + c1(dHy) - c2(dHx)
# bottom and top
# Bottom and Top
cython_update_is(self.nwx, self.nwy, self.nwz, self.updatecoeffsE, self.ID, self.n_boundary_cells, 0, self.nwx, self.nwy + 1, self.nwz, 1, self.Ex, precursors.hy_bottom, precursors.hy_top, self.IDlookup['Ex'], 1, -1, 3, config.get_model_config().ompthreads)
cython_update_is(self.nwx, self.nwy, self.nwz, self.updatecoeffsE, self.ID, self.n_boundary_cells, 0, self.nwx + 1, self.nwy, self.nwz, 1, self.Ey, precursors.hx_bottom, precursors.hx_top, self.IDlookup['Ey'], -1, 1, 3, config.get_model_config().ompthreads)
# left and right
# Left and Right
cython_update_is(self.nwx, self.nwy, self.nwz, self.updatecoeffsE, self.ID, self.n_boundary_cells, 0, self.nwy, self.nwz + 1, self.nwx, 2, self.Ey, precursors.hz_left, precursors.hz_right, self.IDlookup['Ey'], 1, -1, 1, config.get_model_config().ompthreads)
cython_update_is(self.nwx, self.nwy, self.nwz, self.updatecoeffsE, self.ID, self.n_boundary_cells, 0, self.nwy + 1, self.nwz, self.nwx, 2, self.Ez, precursors.hy_left, precursors.hy_right, self.IDlookup['Ez'], -1, 1, 1, config.get_model_config().ompthreads)
# front and back
# Front and Back
cython_update_is(self.nwx, self.nwy, self.nwz, self.updatecoeffsE, self.ID, self.n_boundary_cells, 0, self.nwx, self.nwz + 1, self.nwy, 3, self.Ex, precursors.hz_front, precursors.hz_back, self.IDlookup['Ex'], -1, 1, 2, config.get_model_config().ompthreads)
cython_update_is(self.nwx, self.nwy, self.nwz, self.updatecoeffsE, self.ID, self.n_boundary_cells, 0, self.nwx + 1, self.nwz, self.nwy, 3, self.Ez, precursors.hx_front, precursors.hx_back, self.IDlookup['Ez'], 1, -1, 2, config.get_model_config().ompthreads)
@@ -134,7 +134,7 @@ class SubGridHSG(SubGridBaseGrid):
cython_update_magnetic_os(main_grid.updatecoeffsH, main_grid.ID, 2, j_l, j_u, k_l, k_u + 1, i_l - 1, i_u, self.nwx, main_grid.IDlookup['Hz'], main_grid.Hz, self.Ey, 1, -1, 1, 1, self.ratio, self.is_os_sep, self.n_boundary_cells, config.get_model_config().ompthreads)
cython_update_magnetic_os(main_grid.updatecoeffsH, main_grid.ID, 2, j_l, j_u + 1, k_l, k_u, i_l - 1, i_u, self.nwx, main_grid.IDlookup['Hy'], main_grid.Hy, self.Ez, 1, 1, -1, 0, self.ratio, self.is_os_sep, self.n_boundary_cells, config.get_model_config().ompthreads)
# bottom and top
# Bottom and Top
cython_update_magnetic_os(main_grid.updatecoeffsH, main_grid.ID, 1, i_l, i_u, j_l, j_u + 1, k_l - 1, k_u, self.nwz, main_grid.IDlookup['Hy'], main_grid.Hy, self.Ex, 3, -1, 1, 1, self.ratio, self.is_os_sep, self.n_boundary_cells, config.get_model_config().ompthreads)
cython_update_magnetic_os(main_grid.updatecoeffsH, main_grid.ID, 1, i_l, i_u + 1, j_l, j_u, k_l - 1, k_u, self.nwz, main_grid.IDlookup['Hx'], main_grid.Hx, self.Ey, 3, 1, -1, 0, self.ratio, self.is_os_sep, self.n_boundary_cells, config.get_model_config().ompthreads)
@@ -151,7 +151,8 @@ class SubGridHSG(SubGridBaseGrid):
pml_thickness: number of PML cells on each of the 6 sides of the
subgrid. Defaults to 6.
"""
# Working region
xs, ys, zs = self.round_to_grid((self.i0 * self.dx * self.ratio,
self.j0 * self.dy * self.ratio,
self.k0 * self.dz * self.ratio))
@@ -160,12 +161,12 @@ class SubGridHSG(SubGridBaseGrid):
self.k1 * self.dz * self.ratio))
logger.info('')
logger.info(f'[{self.name}] Type: {self.gridtype}')
logger.debug(f'[{self.name}] Type: {self.gridtype}')
logger.info(f'[{self.name}] Ratio: 1:{self.ratio}')
logger.info(f'[{self.name}] Spatial discretisation: {self.dx:g} x ' +
f'{self.dy:g} x {self.dz:g}m')
logger.info(f'[{self.name}] Extent: {xs}m, {ys}m, {zs}m to {xf}m, {yf}m, {zf}m')
logger.info(f'[{self.name}] Working region: {self.nwx} x {self.nwy} x {self.nwz} cells')
logger.info(f'[{self.name}] Total region: {self.nx:d} x {self.ny:d} x {self.nz:d} = ' +
logger.info(f'[{self.name}] Extent (working region): {xs}m, {ys}m, {zs}m to {xf}m, {yf}m, {zf}m ' +
f'(({self.nwx} x {self.nwy} x {self.nwz} = {self.nwx * self.nwy * self.nwz} cells)')
logger.debug(f'[{self.name}] Total region: {self.nx:d} x {self.ny:d} x {self.nz:d} = ' +
f'{(self.nx * self.ny * self.nz):g} cells')
logger.info(f'[{self.name}] Time step (at CFL limit): {self.dt:g} secs')

查看文件

@@ -52,11 +52,11 @@ class CPUUpdates:
self.dispersive_update_b = None
def store_outputs(self):
"""Store field component values for every receiver and transmission line."""
"""Stores field component values for every receiver and transmission line."""
store_outputs_cpu(self.grid)
def store_snapshots(self, iteration):
"""Store any snapshots.
"""Stores any snapshots.
Args:
iteration: int for iteration number.
@@ -66,7 +66,7 @@ class CPUUpdates:
snap.store(self.grid)
def update_magnetic(self):
"""Update magnetic field components."""
"""Updates magnetic field components."""
update_magnetic_cpu(self.grid.nx,
self.grid.ny,
self.grid.nz,
@@ -81,12 +81,12 @@ class CPUUpdates:
self.grid.Hz)
def update_magnetic_pml(self):
"""Update magnetic field components with the PML correction."""
"""Updates magnetic field components with the PML correction."""
for pml in self.grid.pmls['slabs']:
pml.update_magnetic()
def update_magnetic_sources(self):
"""Update magnetic field components from sources."""
"""Updates magnetic field components from sources."""
for source in self.grid.transmissionlines + self.grid.magneticdipoles:
source.update_magnetic(self.grid.iteration,
self.grid.updatecoeffsH,
@@ -97,7 +97,7 @@ class CPUUpdates:
self.grid)
def update_electric_a(self):
"""Update electric field components."""
"""Updates electric field components."""
# All materials are non-dispersive so do standard update.
if config.get_model_config().materials['maxpoles'] == 0:
update_electric_cpu(self.grid.nx,
@@ -135,12 +135,12 @@ class CPUUpdates:
self.grid.Hz)
def update_electric_pml(self):
"""Update electric field components with the PML correction."""
"""Updates electric field components with the PML correction."""
for pml in self.grid.pmls['slabs']:
pml.update_electric()
def update_electric_sources(self):
"""Update electric field components from sources -
"""Updates electric field components from sources -
update any Hertzian dipole sources last.
"""
for source in self.grid.voltagesources + self.grid.transmissionlines + self.grid.hertziandipoles:
@@ -176,7 +176,7 @@ class CPUUpdates:
self.grid.Ez)
def adapt_dispersive_config(self):
"""Set properties for disperive materials.
"""Sets properties for disperive materials.
Returns:
props: dict of dispersive material properties.
@@ -191,7 +191,7 @@ class CPUUpdates:
return props
def set_dispersive_updates(self, props):
"""Set dispersive update functions.
"""Sets dispersive update functions.
Args:
props: dict of dispersive material properties.
@@ -199,7 +199,7 @@ class CPUUpdates:
update_f = 'update_electric_dispersive_{}pole_{}_{}_{}'
disp_a = update_f.format(props['poles'], 'A', props['precision'], props['dispersion_type'])
disp_b = update_f.format(props['poles'], 'B', props['precision'], props['dispersion_type'])
disp_a_f = getattr(import_module('gprMax.cython.fields_updates_dispersive'), disp_a)
disp_b_f = getattr(import_module('gprMax.cython.fields_updates_dispersive'), disp_b)
@@ -207,11 +207,11 @@ class CPUUpdates:
self.dispersive_update_b = disp_b_f
def time_start(self):
"""Start timer used to calculate solving time for model."""
"""Starts timer used to calculate solving time for model."""
self.timestart = timer()
def calculate_tsolve(self):
"""Calculate solving time for model."""
"""Calculates solving time for model."""
return timer() - self.timestart
def finalise(self):
@@ -335,8 +335,8 @@ class CUDAUpdates:
NZ_SNAPS=Snapshot.nz_max)
def _set_field_knls(self):
"""Electric and magnetic field updates - prepare kernels, and
get kernel functions.
"""Electric and magnetic field updates - prepares kernels, and
gets kernel functions.
"""
bld = self._build_knl(knl_fields_updates.update_electric,
@@ -382,9 +382,11 @@ class CUDAUpdates:
self.grid.htod_dispersive_arrays()
def _set_pml_knls(self):
"""PMLS - prepare kernels and get kernel functions."""
knl_pml_updates_electric = import_module('gprMax.cuda_opencl.knl_pml_updates_electric_' + self.grid.pmlformulation)
knl_pml_updates_magnetic = import_module('gprMax.cuda_opencl.knl_pml_updates_magnetic_' + self.grid.pmlformulation)
"""PMLS - prepares kernels and gets kernel functions."""
knl_pml_updates_electric = import_module('gprMax.cuda_opencl.knl_pml_updates_electric_' +
self.grid.pmls['formulation'])
knl_pml_updates_magnetic = import_module('gprMax.cuda_opencl.knl_pml_updates_magnetic_' +
self.grid.pmls['formulation'])
# Initialise arrays on GPU, set block per grid, and get kernel functions
for pml in self.grid.pmls['slabs']:
@@ -402,6 +404,7 @@ class CUDAUpdates:
bld = self._build_knl(knl_magnetic, self.subs_name_args, self.subs_func)
knlH = self.source_module(bld, options=config.sim_config.devices['nvcc_opts'])
pml.update_magnetic_dev = knlH.get_function(knl_name)
print(pml.update_magnetic_dev)
self._copy_mat_coeffs(knlE, knlH)
@@ -779,8 +782,8 @@ class OpenCLUpdates:
self._set_snapshot_knl()
def _set_field_knls(self):
"""Electric and magnetic field updates - prepare kernels, and
get kernel functions.
"""Electric and magnetic field updates - prepares kernels, and
gets kernel functions.
"""
if config.get_model_config().materials['maxpoles'] > 0:
NY_MATDISPCOEFFS = self.grid.updatecoeffsdispersive.shape[1]
@@ -873,9 +876,9 @@ class OpenCLUpdates:
self.grid.htod_dispersive_arrays(self.queue)
def _set_pml_knls(self):
"""PMLS - prepare kernels and get kernel functions."""
knl_pml_updates_electric = import_module('gprMax.cuda_opencl.knl_pml_updates_electric_' + self.grid.pmlformulation)
knl_pml_updates_magnetic = import_module('gprMax.cuda_opencl.knl_pml_updates_magnetic_' + self.grid.pmlformulation)
"""PMLS - prepares kernels and gets kernel functions."""
knl_pml_updates_electric = import_module('gprMax.cuda_opencl.knl_pml_updates_electric_' + self.grid.pmls['formulation'])
knl_pml_updates_magnetic = import_module('gprMax.cuda_opencl.knl_pml_updates_magnetic_' + self.grid.pmls['formulation'])
subs = {'CUDA_IDX': '',
'REAL': config.sim_config.dtypes['C_float_or_double'],