Corrected testing and setting of None.

这个提交包含在:
Craig Warren
2017-03-14 15:13:13 +00:00
父节点 dfe637ea6c
当前提交 75eee6038f
共有 4 个文件被更改,包括 32 次插入32 次删除

查看文件

@@ -158,7 +158,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'], 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']} 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']}
@@ -190,7 +190,7 @@ def check_cmd_names(processedlines, checkessential=True):
# Assign command parameters as values to dictionary keys # Assign command parameters as values to dictionary keys
if cmdname in singlecmds: if cmdname in singlecmds:
if singlecmds[cmdname] == 'None': if singlecmds[cmdname] is None:
singlecmds[cmdname] = cmd[1].strip(' \t\n') singlecmds[cmdname] = cmd[1].strip(' \t\n')
else: else:
raise CmdInputError('You can only have a single instance of ' + cmdname + ' in your model') raise CmdInputError('You can only have a single instance of ' + cmdname + ' in your model')

查看文件

@@ -51,7 +51,7 @@ def process_multicmds(multicmds, G):
# Waveform definitions # Waveform definitions
cmdname = '#waveform' cmdname = '#waveform'
if multicmds[cmdname] != 'None': if multicmds[cmdname] is not None:
for cmdinstance in multicmds[cmdname]: for cmdinstance in multicmds[cmdname]:
tmp = cmdinstance.split() tmp = cmdinstance.split()
if len(tmp) != 4: if len(tmp) != 4:
@@ -76,7 +76,7 @@ def process_multicmds(multicmds, G):
# Voltage source # Voltage source
cmdname = '#voltage_source' cmdname = '#voltage_source'
if multicmds[cmdname] != 'None': if multicmds[cmdname] is not None:
for cmdinstance in multicmds[cmdname]: for cmdinstance in multicmds[cmdname]:
tmp = cmdinstance.split() tmp = cmdinstance.split()
if len(tmp) < 6: if len(tmp) < 6:
@@ -141,7 +141,7 @@ def process_multicmds(multicmds, G):
# Hertzian dipole # Hertzian dipole
cmdname = '#hertzian_dipole' cmdname = '#hertzian_dipole'
if multicmds[cmdname] != 'None': if multicmds[cmdname] is not None:
for cmdinstance in multicmds[cmdname]: for cmdinstance in multicmds[cmdname]:
tmp = cmdinstance.split() tmp = cmdinstance.split()
if len(tmp) < 5: if len(tmp) < 5:
@@ -216,7 +216,7 @@ def process_multicmds(multicmds, G):
# Magnetic dipole # Magnetic dipole
cmdname = '#magnetic_dipole' cmdname = '#magnetic_dipole'
if multicmds[cmdname] != 'None': if multicmds[cmdname] is not None:
for cmdinstance in multicmds[cmdname]: for cmdinstance in multicmds[cmdname]:
tmp = cmdinstance.split() tmp = cmdinstance.split()
if len(tmp) < 5: if len(tmp) < 5:
@@ -279,7 +279,7 @@ def process_multicmds(multicmds, G):
# Transmission line # Transmission line
cmdname = '#transmission_line' cmdname = '#transmission_line'
if multicmds[cmdname] != 'None': if multicmds[cmdname] is not None:
for cmdinstance in multicmds[cmdname]: for cmdinstance in multicmds[cmdname]:
tmp = cmdinstance.split() tmp = cmdinstance.split()
if len(tmp) < 6: if len(tmp) < 6:
@@ -345,7 +345,7 @@ def process_multicmds(multicmds, G):
# Receiver # Receiver
cmdname = '#rx' cmdname = '#rx'
if multicmds[cmdname] != 'None': if multicmds[cmdname] is not None:
for cmdinstance in multicmds[cmdname]: for cmdinstance in multicmds[cmdname]:
tmp = cmdinstance.split() tmp = cmdinstance.split()
if len(tmp) != 3 and len(tmp) < 5: if len(tmp) != 3 and len(tmp) < 5:
@@ -390,7 +390,7 @@ def process_multicmds(multicmds, G):
# Receiver array # Receiver array
cmdname = '#rx_array' cmdname = '#rx_array'
if multicmds[cmdname] != 'None': if multicmds[cmdname] is not None:
for cmdinstance in multicmds[cmdname]: for cmdinstance in multicmds[cmdname]:
tmp = cmdinstance.split() tmp = cmdinstance.split()
if len(tmp) != 9: if len(tmp) != 9:
@@ -455,7 +455,7 @@ def process_multicmds(multicmds, G):
# Snapshot # Snapshot
cmdname = '#snapshot' cmdname = '#snapshot'
if multicmds[cmdname] != 'None': if multicmds[cmdname] is not None:
for cmdinstance in multicmds[cmdname]: for cmdinstance in multicmds[cmdname]:
tmp = cmdinstance.split() tmp = cmdinstance.split()
if len(tmp) != 11: if len(tmp) != 11:
@@ -505,7 +505,7 @@ def process_multicmds(multicmds, G):
# Materials # Materials
cmdname = '#material' cmdname = '#material'
if multicmds[cmdname] != 'None': if multicmds[cmdname] is not None:
for cmdinstance in multicmds[cmdname]: for cmdinstance in multicmds[cmdname]:
tmp = cmdinstance.split() tmp = cmdinstance.split()
if len(tmp) != 5: if len(tmp) != 5:
@@ -543,7 +543,7 @@ def process_multicmds(multicmds, G):
G.materials.append(m) G.materials.append(m)
cmdname = '#add_dispersion_debye' cmdname = '#add_dispersion_debye'
if multicmds[cmdname] != 'None': if multicmds[cmdname] is not None:
for cmdinstance in multicmds[cmdname]: for cmdinstance in multicmds[cmdname]:
tmp = cmdinstance.split() tmp = cmdinstance.split()
@@ -578,7 +578,7 @@ def process_multicmds(multicmds, G):
tqdm.write('Debye disperion added to {} with delta_eps_r={}, and tau={} secs created.'.format(material.ID, ', '.join('%4.2f' % deltaer for deltaer in material.deltaer), ', '.join('%4.3e' % tau for tau in material.tau))) tqdm.write('Debye disperion added to {} with delta_eps_r={}, and tau={} secs created.'.format(material.ID, ', '.join('%4.2f' % deltaer for deltaer in material.deltaer), ', '.join('%4.3e' % tau for tau in material.tau)))
cmdname = '#add_dispersion_lorentz' cmdname = '#add_dispersion_lorentz'
if multicmds[cmdname] != 'None': if multicmds[cmdname] is not None:
for cmdinstance in multicmds[cmdname]: for cmdinstance in multicmds[cmdname]:
tmp = cmdinstance.split() tmp = cmdinstance.split()
@@ -614,7 +614,7 @@ def process_multicmds(multicmds, G):
tqdm.write('Lorentz disperion added to {} with delta_eps_r={}, omega={} secs, and gamma={} created.'.format(material.ID, ', '.join('%4.2f' % deltaer for deltaer in material.deltaer), ', '.join('%4.3e' % tau for tau in material.tau), ', '.join('%4.3e' % alpha for alpha in material.alpha))) tqdm.write('Lorentz disperion added to {} with delta_eps_r={}, omega={} secs, and gamma={} created.'.format(material.ID, ', '.join('%4.2f' % deltaer for deltaer in material.deltaer), ', '.join('%4.3e' % tau for tau in material.tau), ', '.join('%4.3e' % alpha for alpha in material.alpha)))
cmdname = '#add_dispersion_drude' cmdname = '#add_dispersion_drude'
if multicmds[cmdname] != 'None': if multicmds[cmdname] is not None:
for cmdinstance in multicmds[cmdname]: for cmdinstance in multicmds[cmdname]:
tmp = cmdinstance.split() tmp = cmdinstance.split()
@@ -649,7 +649,7 @@ def process_multicmds(multicmds, G):
tqdm.write('Drude disperion added to {} with omega={} secs, and gamma={} secs created.'.format(material.ID, ', '.join('%4.3e' % tau for tau in material.tau), ', '.join('%4.3e' % alpha for alpha in material.alpha))) tqdm.write('Drude disperion added to {} with omega={} secs, and gamma={} secs created.'.format(material.ID, ', '.join('%4.3e' % tau for tau in material.tau), ', '.join('%4.3e' % alpha for alpha in material.alpha)))
cmdname = '#soil_peplinski' cmdname = '#soil_peplinski'
if multicmds[cmdname] != 'None': if multicmds[cmdname] is not None:
for cmdinstance in multicmds[cmdname]: for cmdinstance in multicmds[cmdname]:
tmp = cmdinstance.split() tmp = cmdinstance.split()
if len(tmp) != 7: if len(tmp) != 7:
@@ -680,7 +680,7 @@ def process_multicmds(multicmds, G):
# Geometry views (creates VTK-based geometry files) # Geometry views (creates VTK-based geometry files)
cmdname = '#geometry_view' cmdname = '#geometry_view'
if multicmds[cmdname] != 'None': if multicmds[cmdname] is not None:
for cmdinstance in multicmds[cmdname]: for cmdinstance in multicmds[cmdname]:
tmp = cmdinstance.split() tmp = cmdinstance.split()
if len(tmp) != 11: if len(tmp) != 11:
@@ -730,7 +730,7 @@ def process_multicmds(multicmds, G):
# Geometry object(s) output # Geometry object(s) output
cmdname = '#geometry_objects_write' cmdname = '#geometry_objects_write'
if multicmds[cmdname] != 'None': if multicmds[cmdname] is not None:
for cmdinstance in multicmds[cmdname]: for cmdinstance in multicmds[cmdname]:
tmp = cmdinstance.split() tmp = cmdinstance.split()
if len(tmp) != 7: if len(tmp) != 7:
@@ -760,7 +760,7 @@ def process_multicmds(multicmds, G):
# Complex frequency shifted (CFS) PML parameter # Complex frequency shifted (CFS) PML parameter
cmdname = '#pml_cfs' cmdname = '#pml_cfs'
if multicmds[cmdname] != 'None': if multicmds[cmdname] is not None:
if len(multicmds[cmdname]) > 2: if len(multicmds[cmdname]) > 2:
raise CmdInputError("'" + cmdname + ': ' + ' '.join(tmp) + "'" + ' can only be used up to two times, for up to a 2nd order PML') raise CmdInputError("'" + cmdname + ': ' + ' '.join(tmp) + "'" + ' can only be used up to two times, for up to a 2nd order PML')
for cmdinstance in multicmds[cmdname]: for cmdinstance in multicmds[cmdname]:

查看文件

@@ -41,7 +41,7 @@ def process_singlecmds(singlecmds, G):
# Check validity of command parameters in order needed # Check validity of command parameters in order needed
# messages # messages
cmd = '#messages' cmd = '#messages'
if singlecmds[cmd] != 'None': if singlecmds[cmd] is not None:
tmp = singlecmds[cmd].split() tmp = singlecmds[cmd].split()
if len(tmp) != 1: if len(tmp) != 1:
raise CmdInputError(cmd + ' requires exactly one parameter') raise CmdInputError(cmd + ' requires exactly one parameter')
@@ -54,7 +54,7 @@ def process_singlecmds(singlecmds, G):
# Title # Title
cmd = '#title' cmd = '#title'
if singlecmds[cmd] != 'None': if singlecmds[cmd] is not None:
G.title = singlecmds[cmd] G.title = singlecmds[cmd]
if G.messages: if G.messages:
print('Model title: {}'.format(G.title)) print('Model title: {}'.format(G.title))
@@ -77,7 +77,7 @@ def process_singlecmds(singlecmds, G):
del os.environ['OMP_PLACES'] del os.environ['OMP_PLACES']
del os.environ['OMP_PROC_BIND'] del os.environ['OMP_PROC_BIND']
if singlecmds[cmd] != 'None': if singlecmds[cmd] is not None:
tmp = tuple(int(x) for x in singlecmds[cmd].split()) tmp = tuple(int(x) for x in singlecmds[cmd].split())
if len(tmp) != 1: if len(tmp) != 1:
raise CmdInputError(cmd + ' requires exactly one parameter to specify the number of threads to use') raise CmdInputError(cmd + ' requires exactly one parameter to specify the number of threads to use')
@@ -163,7 +163,7 @@ def process_singlecmds(singlecmds, G):
# Time step stability factor # Time step stability factor
cmd = '#time_step_stability_factor' cmd = '#time_step_stability_factor'
if singlecmds[cmd] != 'None': if singlecmds[cmd] is not None:
tmp = tuple(float(x) for x in singlecmds[cmd].split()) tmp = tuple(float(x) for x in singlecmds[cmd].split())
if len(tmp) != 1: if len(tmp) != 1:
raise CmdInputError(cmd + ' requires exactly one parameter') raise CmdInputError(cmd + ' requires exactly one parameter')
@@ -198,7 +198,7 @@ def process_singlecmds(singlecmds, G):
# PML # PML
cmd = '#pml_cells' cmd = '#pml_cells'
if singlecmds[cmd] != 'None': if singlecmds[cmd] is not None:
tmp = singlecmds[cmd].split() tmp = singlecmds[cmd].split()
if len(tmp) != 1 and len(tmp) != 6: if len(tmp) != 1 and len(tmp) != 6:
raise CmdInputError(cmd + ' requires either one or six parameters') raise CmdInputError(cmd + ' requires either one or six parameters')
@@ -217,7 +217,7 @@ def process_singlecmds(singlecmds, G):
# src_steps # src_steps
cmd = '#src_steps' cmd = '#src_steps'
if singlecmds[cmd] != 'None': if singlecmds[cmd] is not None:
tmp = singlecmds[cmd].split() tmp = singlecmds[cmd].split()
if len(tmp) != 3: if len(tmp) != 3:
raise CmdInputError(cmd + ' requires exactly three parameters') raise CmdInputError(cmd + ' requires exactly three parameters')
@@ -229,7 +229,7 @@ def process_singlecmds(singlecmds, G):
# rx_steps # rx_steps
cmd = '#rx_steps' cmd = '#rx_steps'
if singlecmds[cmd] != 'None': if singlecmds[cmd] is not None:
tmp = singlecmds[cmd].split() tmp = singlecmds[cmd].split()
if len(tmp) != 3: if len(tmp) != 3:
raise CmdInputError(cmd + ' requires exactly three parameters') raise CmdInputError(cmd + ' requires exactly three parameters')
@@ -241,7 +241,7 @@ def process_singlecmds(singlecmds, G):
# Excitation file for user-defined source waveforms # Excitation file for user-defined source waveforms
cmd = '#excitation_file' cmd = '#excitation_file'
if singlecmds[cmd] != 'None': if singlecmds[cmd] is not None:
tmp = singlecmds[cmd].split() tmp = singlecmds[cmd].split()
if len(tmp) != 1: if len(tmp) != 1:
raise CmdInputError(cmd + ' requires exactly one parameter') raise CmdInputError(cmd + ' requires exactly one parameter')

查看文件

@@ -118,11 +118,11 @@ gs = gridspec.GridSpec(1, 3, hspace=0.5)
# Subplot of CPU (OpenMP) threads vs time # # Subplot of CPU (OpenMP) threads vs time #
########################################### ###########################################
ax = plt.subplot(gs[0, 0]) ax = plt.subplot(gs[0, 0])
ax.plot(baseresult['cputhreads'], baseresult['cputimes'], color=next(colors), marker=markers[0], markeredgecolor='None', ms=8, lw=2, label=baseplotlabel) ax.plot(baseresult['cputhreads'], baseresult['cputimes'], color=next(colors), marker=markers[0], markeredgecolor=None, ms=8, lw=2, label=baseplotlabel)
if args.otherresults is not None: if args.otherresults is not None:
for i, result in enumerate(otherresults): for i, result in enumerate(otherresults):
ax.plot(result['cputhreads'], result['cputimes'], color=next(colors), marker=markers[0], markeredgecolor='None', ms=8, lw=2, ls=next(lines), label=otherplotlabels[i]) ax.plot(result['cputhreads'], result['cputimes'], color=next(colors), marker=markers[0], markeredgecolor=None, ms=8, lw=2, ls=next(lines), label=otherplotlabels[i])
ax.set_xlabel('Number of CPU (OpenMP) threads') ax.set_xlabel('Number of CPU (OpenMP) threads')
ax.set_ylabel('Time [s]') ax.set_ylabel('Time [s]')
@@ -139,11 +139,11 @@ ax.set_ylim(0, top=ax.get_ylim()[1] * 1.1)
###################################################### ######################################################
colors = itertools.cycle(colorIDs) # Reset color iterator colors = itertools.cycle(colorIDs) # Reset color iterator
ax = plt.subplot(gs[0, 1]) ax = plt.subplot(gs[0, 1])
ax.plot(baseresult['cputhreads'], baseresult['cputimes'][-1] / baseresult['cputimes'], color=next(colors), marker=markers[0], markeredgecolor='None', ms=8, lw=2, label=baseplotlabel) ax.plot(baseresult['cputhreads'], baseresult['cputimes'][-1] / baseresult['cputimes'], color=next(colors), marker=markers[0], markeredgecolor=None, ms=8, lw=2, label=baseplotlabel)
if args.otherresults is not None: if args.otherresults is not None:
for i, result in enumerate(otherresults): for i, result in enumerate(otherresults):
ax.plot(result['cputhreads'], result['cputimes'][-1] / result['cputimes'], color=next(colors), marker=markers[0], markeredgecolor='None', ms=8, lw=2, ls=next(lines), label=otherplotlabels[i]) ax.plot(result['cputhreads'], result['cputimes'][-1] / result['cputimes'], color=next(colors), marker=markers[0], markeredgecolor=None, ms=8, lw=2, ls=next(lines), label=otherplotlabels[i])
ax.set_xlabel('Number of CPU (OpenMP) threads') ax.set_xlabel('Number of CPU (OpenMP) threads')
ax.set_ylabel('Speed-up factor') ax.set_ylabel('Speed-up factor')
@@ -160,11 +160,11 @@ ax.set_ylim(bottom=1, top=ax.get_ylim()[1] * 1.1)
########################################### ###########################################
colors = itertools.cycle(colorIDs) # Reset color iterator colors = itertools.cycle(colorIDs) # Reset color iterator
ax = plt.subplot(gs[0, 2]) ax = plt.subplot(gs[0, 2])
ax.plot(cells, cpucellspersec / 1e6, color=next(colors), marker=markers[0], markeredgecolor='None', ms=8, lw=2, label=cpuID) ax.plot(cells, cpucellspersec / 1e6, color=next(colors), marker=markers[0], markeredgecolor=None, ms=8, lw=2, label=cpuID)
if gpuIDs: if gpuIDs:
for i in range(gpucellspersec.shape[0]): for i in range(gpucellspersec.shape[0]):
ax.plot(cells, gpucellspersec[i,:] / 1e6, color=next(colors), marker=markers[0], markeredgecolor='None', ms=8, lw=2, label='NVIDIA ' + gpuIDs[i]) ax.plot(cells, gpucellspersec[i,:] / 1e6, color=next(colors), marker=markers[0], markeredgecolor=None, ms=8, lw=2, label='NVIDIA ' + gpuIDs[i])
ax.set_xlabel('Side length of cubic domain [cells]') ax.set_xlabel('Side length of cubic domain [cells]')
ax.set_ylabel('Performance [Mcells/s]') ax.set_ylabel('Performance [Mcells/s]')