你已经派生过 gprMax
镜像自地址
https://gitee.com/sunhf/gprMax.git
已同步 2025-08-07 15:10:13 +08:00
More progress bar updates for Windows Cmd Prompts.
这个提交包含在:
@@ -154,7 +154,7 @@ def run_std_sim(args, numbermodelruns, inputfile, usernamespace, optparams=None)
|
|||||||
run_model(args, modelrun, numbermodelruns, inputfile, modelusernamespace)
|
run_model(args, modelrun, numbermodelruns, inputfile, modelusernamespace)
|
||||||
tsimend = perf_counter()
|
tsimend = perf_counter()
|
||||||
simcompletestr = '\n== Simulation completed in [HH:MM:SS]: {}'.format(datetime.timedelta(seconds=int(tsimend - tsimstart)))
|
simcompletestr = '\n== Simulation completed in [HH:MM:SS]: {}'.format(datetime.timedelta(seconds=int(tsimend - tsimstart)))
|
||||||
print('{} {}\n'.format(simcompletestr, '=' * (get_terminal_size()[0] - len(simcompletestr))))
|
print('{} {}\n'.format(simcompletestr, '=' * (get_terminal_size()[0] - 1 - len(simcompletestr))))
|
||||||
|
|
||||||
|
|
||||||
def run_benchmark_sim(args, inputfile, usernamespace):
|
def run_benchmark_sim(args, inputfile, usernamespace):
|
||||||
@@ -187,7 +187,7 @@ def run_benchmark_sim(args, inputfile, usernamespace):
|
|||||||
np.savez(os.path.splitext(inputfile)[0], threads=threads, benchtimes=benchtimes, version=__version__)
|
np.savez(os.path.splitext(inputfile)[0], threads=threads, benchtimes=benchtimes, version=__version__)
|
||||||
|
|
||||||
simcompletestr = '\n== Simulation completed'
|
simcompletestr = '\n== Simulation completed'
|
||||||
print('{} {}\n'.format(simcompletestr, '=' * (get_terminal_size()[0] - len(simcompletestr))))
|
print('{} {}\n'.format(simcompletestr, '=' * (get_terminal_size()[0] - 1 - len(simcompletestr))))
|
||||||
|
|
||||||
|
|
||||||
def run_mpi_sim(args, numbermodelruns, inputfile, usernamespace, optparams=None):
|
def run_mpi_sim(args, numbermodelruns, inputfile, usernamespace, optparams=None):
|
||||||
@@ -267,7 +267,7 @@ def run_mpi_sim(args, numbermodelruns, inputfile, usernamespace, optparams=None)
|
|||||||
|
|
||||||
tsimend = perf_counter()
|
tsimend = perf_counter()
|
||||||
simcompletestr = '\n== Simulation completed in [HH:MM:SS]: {}'.format(datetime.timedelta(seconds=int(tsimend - tsimstart)))
|
simcompletestr = '\n== Simulation completed in [HH:MM:SS]: {}'.format(datetime.timedelta(seconds=int(tsimend - tsimstart)))
|
||||||
print('{} {}\n'.format(simcompletestr, '=' * (get_terminal_size()[0] - len(simcompletestr))))
|
print('{} {}\n'.format(simcompletestr, '=' * (get_terminal_size()[0] - 1 - len(simcompletestr))))
|
||||||
|
|
||||||
|
|
||||||
def run_model(args, modelrun, numbermodelruns, inputfile, usernamespace):
|
def run_model(args, modelrun, numbermodelruns, inputfile, usernamespace):
|
||||||
@@ -293,7 +293,7 @@ def run_model(args, modelrun, numbermodelruns, inputfile, usernamespace):
|
|||||||
# 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 'G' not in globals():
|
if 'G' not in globals():
|
||||||
inputfilestr = '\nModel {} of {}, input file: {}'.format(modelrun, numbermodelruns, inputfile)
|
inputfilestr = '\nModel {} of {}, input file: {}'.format(modelrun, numbermodelruns, inputfile)
|
||||||
print(Fore.GREEN + '{} {}\n'.format(inputfilestr, '-' * (get_terminal_size()[0] - len(inputfilestr))))
|
print(Fore.GREEN + '{} {}\n'.format(inputfilestr, '-' * (get_terminal_size()[0] - 1 - len(inputfilestr))))
|
||||||
|
|
||||||
# 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
|
||||||
usernamespace['current_model_run'] = modelrun
|
usernamespace['current_model_run'] = modelrun
|
||||||
@@ -344,7 +344,7 @@ def run_model(args, modelrun, numbermodelruns, inputfile, usernamespace):
|
|||||||
|
|
||||||
# Build the model, i.e. set the material properties (ID) for every edge of every Yee cell
|
# Build the model, i.e. set the material properties (ID) for every edge of every Yee cell
|
||||||
print()
|
print()
|
||||||
pbar = tqdm(total=2, desc='Building FDTD grid', ncols=get_terminal_size()[0], leave='False', bar_format='{desc:30}{percentage:3.0f}%|{bar}{r_bar}')
|
pbar = tqdm(total=2, desc='Building FDTD grid', ncols=get_terminal_size()[0] - 1)
|
||||||
build_electric_components(G.solid, G.rigidE, G.ID, G)
|
build_electric_components(G.solid, G.rigidE, G.ID, G)
|
||||||
pbar.update()
|
pbar.update()
|
||||||
build_magnetic_components(G.solid, G.rigidH, G.ID, G)
|
build_magnetic_components(G.solid, G.rigidH, G.ID, G)
|
||||||
@@ -378,7 +378,7 @@ def run_model(args, modelrun, numbermodelruns, inputfile, usernamespace):
|
|||||||
# If geometry information to be reused between model runs
|
# If geometry information to be reused between model runs
|
||||||
else:
|
else:
|
||||||
inputfilestr = '\nInput file not re-processed'
|
inputfilestr = '\nInput file not re-processed'
|
||||||
print(Fore.GREEN + '{} {}\n'.format(inputfilestr, '-' * (get_terminal_size()[0] - len(inputfilestr))))
|
print(Fore.GREEN + '{} {}\n'.format(inputfilestr, '-' * (get_terminal_size()[0] - 1 - len(inputfilestr))))
|
||||||
|
|
||||||
# Clear arrays for field components
|
# Clear arrays for field components
|
||||||
G.initialise_field_arrays()
|
G.initialise_field_arrays()
|
||||||
@@ -410,7 +410,7 @@ def run_model(args, modelrun, numbermodelruns, inputfile, usernamespace):
|
|||||||
raise GeneralError('No geometry views found.')
|
raise GeneralError('No geometry views found.')
|
||||||
elif G.geometryviews:
|
elif G.geometryviews:
|
||||||
print()
|
print()
|
||||||
for geometryview in tqdm(G.geometryviews, desc='Writing geometry file(s)', unit='files', ncols=get_terminal_size()[0], leave='False', bar_format='{desc:30}{percentage:3.0f}%|{bar}{r_bar}'):
|
for geometryview in tqdm(G.geometryviews, desc='Writing geometry file(s)', unit='files', ncols=get_terminal_size()[0] - 1):
|
||||||
geometryview.write_vtk(modelrun, numbermodelruns, G)
|
geometryview.write_vtk(modelrun, numbermodelruns, G)
|
||||||
# geometryview.write_xdmf(modelrun, numbermodelruns, G)
|
# geometryview.write_xdmf(modelrun, numbermodelruns, G)
|
||||||
|
|
||||||
@@ -437,7 +437,7 @@ def run_model(args, modelrun, numbermodelruns, inputfile, usernamespace):
|
|||||||
# Absolute time
|
# Absolute time
|
||||||
abstime = 0
|
abstime = 0
|
||||||
|
|
||||||
for timestep in tqdm(range(G.iterations), desc='Running model ' + str(modelrun) + ' of ' + str(numbermodelruns), ncols=get_terminal_size()[0], leave='False', bar_format='{desc:30}{percentage:3.0f}%|{bar}{r_bar}'):
|
for timestep in tqdm(range(G.iterations), desc='Running model ' + str(modelrun) + ' of ' + str(numbermodelruns), ncols=get_terminal_size()[0] - 1):
|
||||||
# Store field component values for every receiver and transmission line
|
# Store field component values for every receiver and transmission line
|
||||||
store_outputs(timestep, G.Ex, G.Ey, G.Ez, G.Hx, G.Hy, G.Hz, G)
|
store_outputs(timestep, G.Ex, G.Ey, G.Ez, G.Hx, G.Hy, G.Hz, G)
|
||||||
|
|
||||||
|
@@ -42,7 +42,7 @@ def process_geometrycmds(geometry, G):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
for object in tqdm(geometry, desc='Processing geometry cmds', unit='cmds', ncols=get_terminal_size()[0], leave='False', bar_format='{desc:30}{percentage:3.0f}%|{bar}{r_bar}'):
|
for object in tqdm(geometry, desc='Processing geometry cmds', unit='cmds', ncols=get_terminal_size()[0] - 1):
|
||||||
tmp = object.split()
|
tmp = object.split()
|
||||||
|
|
||||||
if tmp[0] == '#geometry_objects_file:':
|
if tmp[0] == '#geometry_objects_file:':
|
||||||
|
@@ -23,6 +23,8 @@ import pickle
|
|||||||
from shutil import get_terminal_size
|
from shutil import get_terminal_size
|
||||||
from time import perf_counter
|
from time import perf_counter
|
||||||
|
|
||||||
|
from colorama import init, Fore, Style
|
||||||
|
init()
|
||||||
import numpy as np
|
import numpy as np
|
||||||
|
|
||||||
from gprMax.constants import floattype
|
from gprMax.constants import floattype
|
||||||
@@ -72,7 +74,9 @@ def run_opt_sim(args, numbermodelruns, inputfile, usernamespace):
|
|||||||
|
|
||||||
# Select OA
|
# Select OA
|
||||||
OA, N, cols, k, s, t = construct_OA(optparams)
|
OA, N, cols, k, s, t = construct_OA(optparams)
|
||||||
print('\n{}\nTaguchi optimisation...\n'.format('-' * get_terminal_size()[0]))
|
|
||||||
|
taguchistr = '\nTaguchi optimisation'
|
||||||
|
print('{} {}\n'.format(taguchistr, '-' * (get_terminal_size()[0] - 1 - len(taguchistr))))
|
||||||
print('\tOrthogonal array: {:g} experiments per iteration, {:g} parameters ({:g} will be used), {:g} levels, and strength {:g}'.format(N, cols, k, s, t))
|
print('\tOrthogonal array: {:g} experiments per iteration, {:g} parameters ({:g} will be used), {:g} levels, and strength {:g}'.format(N, cols, k, s, t))
|
||||||
tmp = [(k, v) for k, v in optparams.items()]
|
tmp = [(k, v) for k, v in optparams.items()]
|
||||||
print('\tParameters to optimise with ranges: {}'.format(str(tmp).strip('[]')))
|
print('\tParameters to optimise with ranges: {}'.format(str(tmp).strip('[]')))
|
||||||
@@ -134,8 +138,8 @@ def run_opt_sim(args, numbermodelruns, inputfile, usernamespace):
|
|||||||
|
|
||||||
# Rename confirmation experiment output file so that it is retained for each iteraction
|
# Rename confirmation experiment output file so that it is retained for each iteraction
|
||||||
os.rename(outputfile, os.path.splitext(outputfile)[0] + '_final' + str(iteration + 1) + '.out')
|
os.rename(outputfile, os.path.splitext(outputfile)[0] + '_final' + str(iteration + 1) + '.out')
|
||||||
|
|
||||||
print('\nTaguchi optimisation, iteration {} completed. History of optimal parameter values {} and of fitness values {}'.format(iteration + 1, dict(optparamshist), fitnessvalueshist, '-' * get_terminal_size()[0]))
|
print(Fore.GREEN + '\nTaguchi optimisation, iteration {} completed. History of optimal parameter values {} and of fitness values {}'.format(iteration + 1, dict(optparamshist), fitnessvalueshist) + Style.RESET_ALL)
|
||||||
iteration += 1
|
iteration += 1
|
||||||
|
|
||||||
# Stop optimisation if stopping criterion has been reached
|
# Stop optimisation if stopping criterion has been reached
|
||||||
@@ -162,7 +166,7 @@ def run_opt_sim(args, numbermodelruns, inputfile, usernamespace):
|
|||||||
|
|
||||||
print('\nTaguchi optimisation completed after {} iteration(s).\nHistory of optimal parameter values {} and of fitness values {}'.format(iteration, dict(optparamshist), fitnessvalueshist))
|
print('\nTaguchi optimisation completed after {} iteration(s).\nHistory of optimal parameter values {} and of fitness values {}'.format(iteration, dict(optparamshist), fitnessvalueshist))
|
||||||
simcompletestr = '\n== Simulation completed in [HH:MM:SS]: {}'.format(datetime.timedelta(seconds=int(tsimend - tsimstart)))
|
simcompletestr = '\n== Simulation completed in [HH:MM:SS]: {}'.format(datetime.timedelta(seconds=int(tsimend - tsimstart)))
|
||||||
print('{} {}\n'.format(simcompletestr, '=' * (get_terminal_size()[0] - len(simcompletestr))))
|
print('{} {}\n'.format(simcompletestr, '=' * (get_terminal_size()[0] - 1 - len(simcompletestr))))
|
||||||
|
|
||||||
|
|
||||||
def taguchi_code_blocks(inputfile, taguchinamespace):
|
def taguchi_code_blocks(inputfile, taguchinamespace):
|
||||||
|
在新工单中引用
屏蔽一个用户