Formatting and comments update.

这个提交包含在:
Craig Warren
2016-08-04 12:08:12 +01:00
父节点 35d0efeb40
当前提交 a39dcd3d98

查看文件

@@ -33,7 +33,7 @@ from ._version import __version__
from .constants import c, e0, m0, z0 from .constants import c, e0, m0, z0
from .exceptions import GeneralError from .exceptions import GeneralError
from .fields_update import update_electric, update_magnetic, update_electric_dispersive_multipole_A, update_electric_dispersive_multipole_B, update_electric_dispersive_1pole_A, update_electric_dispersive_1pole_B from .fields_update import update_electric, update_magnetic, update_electric_dispersive_multipole_A, update_electric_dispersive_multipole_B, update_electric_dispersive_1pole_A, update_electric_dispersive_1pole_B
from .grid import FDTDGrid, dispersion_check, Ix, Iy, Iz from .grid import FDTDGrid, dispersion_check
from .input_cmds_geometry import process_geometrycmds from .input_cmds_geometry import process_geometrycmds
from .input_cmds_file import process_python_include_code, write_processed_file, check_cmd_names from .input_cmds_file import process_python_include_code, write_processed_file, check_cmd_names
from .input_cmds_multiuse import process_multicmds from .input_cmds_multiuse import process_multicmds
@@ -172,6 +172,7 @@ def run_benchmark_sim(args, inputfile, usernamespace):
benchtimes = np.zeros(len(threads)) benchtimes = np.zeros(len(threads))
numbermodelruns = len(threads) numbermodelruns = len(threads)
usernamespace['number_model_runs'] = numbermodelruns
tsimstart = perf_counter() tsimstart = perf_counter()
for modelrun in range(1, numbermodelruns + 1): for modelrun in range(1, numbermodelruns + 1):
os.environ['OMP_NUM_THREADS'] = str(threads[modelrun - 1]) os.environ['OMP_NUM_THREADS'] = str(threads[modelrun - 1])
@@ -181,7 +182,7 @@ def run_benchmark_sim(args, inputfile, usernamespace):
# Save number of threads and benchmarking times to NumPy archive # Save number of threads and benchmarking times to NumPy archive
threads = np.array(threads) threads = np.array(threads)
np.savez(os.path.splitext(inputfile)[0], threads=threads, benchtimes=benchtimes) np.savez(os.path.splitext(inputfile)[0], threads=threads, benchtimes=benchtimes, version=__version__)
print('\nTotal simulation time [HH:MM:SS]: {}'.format(datetime.timedelta(seconds=int(tsimend - tsimstart)))) print('\nTotal simulation time [HH:MM:SS]: {}'.format(datetime.timedelta(seconds=int(tsimend - tsimstart))))
@@ -215,7 +216,7 @@ def run_mpi_sim(args, numbermodelruns, inputfile, usernamespace, optparams=None)
closedworkers = 0 closedworkers = 0
print('Master: PID {} on {} using {} workers.'.format(os.getpid(), name, numworkers)) print('Master: PID {} on {} using {} workers.'.format(os.getpid(), name, numworkers))
while closedworkers < numworkers: while closedworkers < numworkers:
data = comm.recv(source=MPI.ANY_SOURCE, tag=MPI.ANY_TAG, status=status) # data = comm.recv(source=MPI.ANY_SOURCE, tag=MPI.ANY_TAG, status=status) # Check if this line is really needed
source = status.Get_source() source = status.Get_source()
tag = status.Get_tag() tag = status.Get_tag()
@@ -281,7 +282,7 @@ def run_model(args, modelrun, numbermodelruns, inputfile, usernamespace):
global G global G
# Normal model reading/building process; bypassed if geometry information to be reused # Normal model reading/building process; bypassed if geometry information to be reused
if not 'G' in globals(): if 'G' not in globals():
print('\n{}\n\nModel input file: {}\n'.format(68 * '*', inputfile)) print('\n{}\n\nModel input file: {}\n'.format(68 * '*', inputfile))
# Add the current model run to namespace that can be accessed by user in any Python code blocks in input file # Add the current model run to namespace that can be accessed by user in any Python code blocks in input file
@@ -519,8 +520,8 @@ def run_model(args, modelrun, numbermodelruns, inputfile, usernamespace):
write_hdf5(outputfile, G.Ex, G.Ey, G.Ez, G.Hx, G.Hy, G.Hz, G) write_hdf5(outputfile, G.Ex, G.Ey, G.Ez, G.Hx, G.Hy, G.Hz, G)
tsolveend = perf_counter() tsolveend = perf_counter()
print('\n\nSolving took [HH:MM:SS]: {}'.format(datetime.timedelta(seconds=int(tsolveend - tsolvestart)))) print('\n\nSolving took [HH:MM:SS]: {} @ {:g} cells/s'.format(datetime.timedelta(seconds=int(tsolveend - tsolvestart)), (G.nx * G.ny * G.nz) / (tsolveend - tsolvestart)))
print('Peak memory (approx) used: {}'.format(human_size(p.memory_info().rss))) print('Memory (RAM) usage: ~{}'.format(human_size(p.memory_info().rss)))
################################## ##################################
# End - Main FDTD calculations # # End - Main FDTD calculations #
@@ -531,7 +532,3 @@ def run_model(args, modelrun, numbermodelruns, inputfile, usernamespace):
del G del G
return int(tsolveend - tsolvestart) return int(tsolveend - tsolvestart)