Made changes to the reformatted code as per the suggestions given.

这个提交包含在:
Sai Suraj
2023-04-18 02:06:25 +05:30
父节点 4015c51bd7
当前提交 72c85b29d6
共有 7 个文件被更改,包括 58 次插入87 次删除

查看文件

@@ -178,8 +178,8 @@ def write_processed_file(processedlines):
for item in processedlines:
f.write(f'{item}')
logger.info(f'Written input commands, after processing any Python code and '
f'include commands, to file: {processedfile}\n')
logger.info(f'Written input commands, after processing any Python ' +
f'code and include commands, to file: {processedfile}\n')
def check_cmd_names(processedlines, checkessential=True):

查看文件

@@ -55,7 +55,7 @@ def process_singlecmds(singlecmds):
if singlecmds[cmd] is not None:
tmp = tuple(int(x) for x in singlecmds[cmd].split())
if len(tmp) != 1:
logger.exception(f'{cmd} requires exactly one parameter to specify '
logger.exception(f'{cmd} requires exactly one parameter to specify ' +
f'the number of CPU OpenMP threads to use')
raise ValueError
@@ -94,7 +94,7 @@ def process_singlecmds(singlecmds):
if singlecmds[cmd] is not None:
tmp = singlecmds[cmd].split()
if len(tmp) != 1:
logger.exception(f'{cmd} requires exactly one parameter to specify the '
logger.exception(f'{cmd} requires exactly one parameter to specify the ' +
f'time window. Either in seconds or number of iterations.')
raise ValueError
tmp = tmp[0].lower()

查看文件

@@ -884,27 +884,19 @@ class OpenCLUpdates:
knl_electric_name = getattr(knl_pml_updates_electric, knl_name)
knl_magnetic_name = getattr(knl_pml_updates_magnetic, knl_name)
pml.update_electric_dev = self.elwise(
self.ctx,
knl_electric_name['args_opencl'].substitute(
{'REAL': config.sim_config.dtypes['C_float_or_double']}
),
knl_electric_name['func'].substitute(subs),
f'pml_updates_electric_{knl_name}',
preamble=self.knl_common,
options=config.sim_config.devices['compiler_opts'],
)
pml.update_electric_dev = self.elwise(self.ctx,
knl_electric_name['args_opencl'].substitute({'REAL': config.sim_config.dtypes['C_float_or_double']}),
knl_electric_name['func'].substitute(subs),
'pml_updates_electric_' + knl_name,
preamble=self.knl_common,
options=config.sim_config.devices['compiler_opts'])
pml.update_magnetic_dev = self.elwise(
self.ctx,
knl_magnetic_name['args_opencl'].substitute(
{'REAL': config.sim_config.dtypes['C_float_or_double']}
),
knl_magnetic_name['func'].substitute(subs),
f'pml_updates_magnetic_{knl_name}',
preamble=self.knl_common,
options=config.sim_config.devices['compiler_opts'],
)
pml.update_magnetic_dev = self.elwise(self.ctx,
knl_magnetic_name['args_opencl'].substitute({'REAL': config.sim_config.dtypes['C_float_or_double']}),
knl_magnetic_name['func'].substitute(subs),
'pml_updates_magnetic_' + knl_name,
preamble=self.knl_common,
options=config.sim_config.devices['compiler_opts'])
def _set_rx_knl(self):
"""Receivers - initialises arrays on compute device, prepares kernel and

查看文件

@@ -29,20 +29,16 @@ 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')
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

查看文件

@@ -29,20 +29,16 @@ 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')
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)

查看文件

@@ -81,12 +81,10 @@ realmax = np.where(np.abs(real[:, 1]) == 1)[0][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',
)
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]')

查看文件

@@ -130,12 +130,9 @@ for i, model in enumerate(testmodels):
# 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}) 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
@@ -176,22 +173,18 @@ for i, model in enumerate(testmodels):
# Replace any NaNs or Infs from zero division
datadiffs[:, i][np.invert(np.isfinite(datadiffs[:, i]))] = 0
# Store maxi difference
# Store max difference
maxdiff = np.amax(np.amax(datadiffs))
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=f'{model}.in',
figsize=(20, 10),
facecolor='w',
edgecolor='w',
)
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)
@@ -214,17 +207,13 @@ 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=f'Diffs: {model}.in',
figsize=(20, 10),
facecolor='w',
edgecolor='w',
)
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')