你已经派生过 gprMax
镜像自地址
https://gitee.com/sunhf/gprMax.git
已同步 2025-08-07 15:10:13 +08:00
Merge pull request #383 from Sai-Suraj-27/f-strings
Reformatted few files according to latest python standards.
这个提交包含在:
@@ -44,10 +44,7 @@ for obj in gssi_objects:
|
||||
scene.add(obj)
|
||||
|
||||
gv1 = gprMax.GeometryView(
|
||||
p1=(0, 0, 0),
|
||||
p2=(x, y, z),
|
||||
dl=(dl, dl, dl),
|
||||
filename="antenna_like_GSSI_400", output_type="n"
|
||||
p1=(0, 0, 0), p2=(x, y, z), dl=(dl, dl, dl), filename="antenna_like_GSSI_400", output_type="n"
|
||||
)
|
||||
gv2 = gprMax.GeometryView(
|
||||
p1=(ant_pos[0] - 0.150, ant_pos[1] - 0.150, ant_pos[2]),
|
||||
|
@@ -1263,8 +1263,8 @@ class AddDebyeDispersion(UserObjectMulti):
|
||||
|
||||
logger.info(
|
||||
f"{self.grid_name(grid)}Debye disperion added to {disp_material.ID} "
|
||||
f"with delta_eps_r={', '.join('%4.2f' % deltaer for deltaer in disp_material.deltaer)}, "
|
||||
f"and tau={', '.join('%4.3e' % tau for tau in disp_material.tau)} secs created."
|
||||
f"with delta_eps_r={', '.join(f'{deltaer:4.2f}' for deltaer in disp_material.deltaer)}, "
|
||||
f"and tau={', '.join(f'{tau:4.3e}' for tau in disp_material.tau)} secs created."
|
||||
)
|
||||
|
||||
|
||||
@@ -1342,9 +1342,9 @@ class AddLorentzDispersion(UserObjectMulti):
|
||||
|
||||
logger.info(
|
||||
f"{self.grid_name(grid)}Lorentz disperion added to {disp_material.ID} "
|
||||
f"with delta_eps_r={', '.join('%4.2f' % deltaer for deltaer in disp_material.deltaer)}, "
|
||||
f"omega={', '.join('%4.3e' % omega for omega in disp_material.tau)} secs, "
|
||||
f"and gamma={', '.join('%4.3e' % delta for delta in disp_material.alpha)} created."
|
||||
f"with delta_eps_r={', '.join(f'{deltaer:4.2f}' for deltaer in disp_material.deltaer)}, "
|
||||
f"omega={', '.join(f'{omega:4.3e}' for omega in disp_material.tau)} secs, "
|
||||
f"and gamma={', '.join(f'{delta:4.3e}' for delta in disp_material.alpha)} created."
|
||||
)
|
||||
|
||||
|
||||
@@ -1416,8 +1416,8 @@ class AddDrudeDispersion(UserObjectMulti):
|
||||
|
||||
logger.info(
|
||||
f"{self.grid_name(grid)}Drude disperion added to {disp_material.ID} "
|
||||
f"with omega={', '.join('%4.3e' % omega for omega in disp_material.tau)} secs, "
|
||||
f"and gamma={', '.join('%4.3e' % alpha for alpha in disp_material.alpha)} secs created."
|
||||
f"with omega={', '.join(f'{omega:4.3e}' for omega in disp_material.tau)} secs, "
|
||||
f"and gamma={', '.join(f'{alpha:4.3e}' for alpha in disp_material.alpha)} secs created."
|
||||
)
|
||||
|
||||
|
||||
|
@@ -47,8 +47,7 @@ help_msg = {
|
||||
"scenes": "(list, req): Scenes to run the model. Multiple scene objects "
|
||||
"can given in order to run multiple simulation runs. Each scene "
|
||||
"must contain the essential simulation objects",
|
||||
"inputfile": "(str, opt): Input file path. Can also run simulation by "
|
||||
"providing an input file.",
|
||||
"inputfile": "(str, opt): Input file path. Can also run simulation by " "providing an input file.",
|
||||
"outputfile": "(str, req): File path to the output data file.",
|
||||
"n": "(int, req): Number of required simulation runs.",
|
||||
"i": "(int, opt): Model number to start/restart simulation from. It would "
|
||||
@@ -60,20 +59,16 @@ help_msg = {
|
||||
"models to be farmed out using a MPI task farm, e.g. to create a "
|
||||
"B-scan with 60 traces and use MPI to farm out each trace. For "
|
||||
"further details see the performance section of the User Guide.",
|
||||
"gpu": "(list/bool, opt): Flag to use NVIDIA GPU or list of NVIDIA GPU "
|
||||
"device ID(s) for specific GPU card(s).",
|
||||
"opencl": "(list/bool, opt): Flag to use OpenCL or list of OpenCL device "
|
||||
"ID(s) for specific compute device(s).",
|
||||
"gpu": "(list/bool, opt): Flag to use NVIDIA GPU or list of NVIDIA GPU " "device ID(s) for specific GPU card(s).",
|
||||
"opencl": "(list/bool, opt): Flag to use OpenCL or list of OpenCL device " "ID(s) for specific compute device(s).",
|
||||
"subgrid": "(bool, opt): Flag to use sub-gridding.",
|
||||
"autotranslate": "(bool, opt): For sub-gridding - auto translate objects "
|
||||
"with main grid coordinates to their equivalent local "
|
||||
"grid coordinate within the subgrid. If this option is "
|
||||
"off users must specify sub-grid object point within the "
|
||||
"global subgrid space.",
|
||||
"geometry_only": "(bool, opt): Build a model and produce any geometry "
|
||||
"views but do not run the simulation.",
|
||||
"geometry_fixed": "(bool, opt): Run a series of models where the geometry "
|
||||
"does not change between models.",
|
||||
"geometry_only": "(bool, opt): Build a model and produce any geometry " "views but do not run the simulation.",
|
||||
"geometry_fixed": "(bool, opt): Run a series of models where the geometry " "does not change between models.",
|
||||
"write_processed": "(bool, opt): Writes another input file after any "
|
||||
"Python code (#python blocks) and in the original input "
|
||||
"file has been processed.",
|
||||
|
@@ -19,6 +19,7 @@
|
||||
import logging
|
||||
|
||||
from .cmds_multiuse import (
|
||||
PMLCFS,
|
||||
AddDebyeDispersion,
|
||||
AddDrudeDispersion,
|
||||
AddLorentzDispersion,
|
||||
@@ -30,7 +31,6 @@ from .cmds_multiuse import (
|
||||
Material,
|
||||
MaterialList,
|
||||
MaterialRange,
|
||||
PMLCFS,
|
||||
Rx,
|
||||
RxArray,
|
||||
Snapshot,
|
||||
@@ -403,7 +403,7 @@ def process_multicmds(multicmds):
|
||||
material_list = MaterialList(list_of_materials=lmats, id=tmp[tokens - 1])
|
||||
scene_objects.append(material_list)
|
||||
|
||||
cmdname = '#pml_cfs'
|
||||
cmdname = "#pml_cfs"
|
||||
if multicmds[cmdname] is not None:
|
||||
for cmdinstance in multicmds[cmdname]:
|
||||
tmp = cmdinstance.split()
|
||||
@@ -412,7 +412,8 @@ def process_multicmds(multicmds):
|
||||
logger.exception("'" + cmdname + ": " + " ".join(tmp) + "'" + " requires exactly twelve parameters")
|
||||
raise ValueError
|
||||
|
||||
pml_cfs = PMLCFS(alphascalingprofile=tmp[0],
|
||||
pml_cfs = PMLCFS(
|
||||
alphascalingprofile=tmp[0],
|
||||
alphascalingdirection=tmp[1],
|
||||
alphamin=tmp[2],
|
||||
alphamax=tmp[3],
|
||||
@@ -423,7 +424,8 @@ def process_multicmds(multicmds):
|
||||
sigmascalingprofile=tmp[8],
|
||||
sigmascalingdirection=tmp[9],
|
||||
sigmamin=tmp[10],
|
||||
sigmamax=tmp[11])
|
||||
sigmamax=tmp[11],
|
||||
)
|
||||
|
||||
scene_objects.append(pml_cfs)
|
||||
|
||||
|
@@ -135,14 +135,18 @@ def process_singlecmds(singlecmds):
|
||||
logger.exception(f"{cmd} requires either one or six parameter(s)")
|
||||
raise ValueError
|
||||
|
||||
if 'pml_formulation' in locals():
|
||||
if "pml_formulation" in locals():
|
||||
if len(tmp) == 1:
|
||||
pml_props = PMLProps(formulation=pml_formulation, thickness=int(tmp[0]))
|
||||
else:
|
||||
pml_props = PMLProps(
|
||||
formulation=pml_formulation,
|
||||
x0=int(tmp[0]), y0=int(tmp[1]), z0=int(tmp[2]),
|
||||
xmax=int(tmp[3]), ymax=int(tmp[4]), zmax=int(tmp[5])
|
||||
x0=int(tmp[0]),
|
||||
y0=int(tmp[1]),
|
||||
z0=int(tmp[2]),
|
||||
xmax=int(tmp[3]),
|
||||
ymax=int(tmp[4]),
|
||||
zmax=int(tmp[5]),
|
||||
)
|
||||
else:
|
||||
if len(tmp) == 1:
|
||||
|
@@ -632,20 +632,20 @@ def process_materials(G):
|
||||
]
|
||||
if config.get_model_config().materials["maxpoles"] > 0:
|
||||
if "debye" in material.type:
|
||||
materialtext.append("\n".join("{:g}".format(deltaer) for deltaer in material.deltaer))
|
||||
materialtext.append("\n".join("{:g}".format(tau) for tau in material.tau))
|
||||
materialtext.append("\n".join(f"{deltaer:g}" for deltaer in material.deltaer))
|
||||
materialtext.append("\n".join(f"{tau:g}" for tau in material.tau))
|
||||
materialtext.extend(["", "", ""])
|
||||
elif "lorentz" in material.type:
|
||||
materialtext.append(", ".join("{:g}".format(deltaer) for deltaer in material.deltaer))
|
||||
materialtext.append(", ".join(f"{deltaer:g}" for deltaer in material.deltaer))
|
||||
materialtext.append("")
|
||||
materialtext.append(", ".join("{:g}".format(tau) for tau in material.tau))
|
||||
materialtext.append(", ".join("{:g}".format(alpha) for alpha in material.alpha))
|
||||
materialtext.append(", ".join(f"{tau:g}" for tau in material.tau))
|
||||
materialtext.append(", ".join(f"{alpha:g}" for alpha in material.alpha))
|
||||
materialtext.append("")
|
||||
elif "drude" in material.type:
|
||||
materialtext.extend(["", ""])
|
||||
materialtext.append(", ".join("{:g}".format(tau) for tau in material.tau))
|
||||
materialtext.append(", ".join(f"{tau:g}" for tau in material.tau))
|
||||
materialtext.append("")
|
||||
materialtext.append(", ".join("{:g}".format(alpha) for alpha in material.alpha))
|
||||
materialtext.append(", ".join(f"{alpha:g}" for alpha in material.alpha))
|
||||
else:
|
||||
materialtext.extend(["", "", "", "", ""])
|
||||
|
||||
|
@@ -24,6 +24,7 @@ import numpy as np
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def diff_output_files(filename1, filename2):
|
||||
"""Calculates differences between two output files.
|
||||
|
||||
|
@@ -50,8 +50,9 @@ fig, ax = plt.subplots(
|
||||
)
|
||||
|
||||
for x, model in enumerate(testmodels):
|
||||
time, datadiffs = diff_output_files(fn.parent.joinpath(basename + "_ref.h5"),
|
||||
fn.parent.joinpath(basename + str(x + 1) + ".h5"))
|
||||
time, datadiffs = diff_output_files(
|
||||
fn.parent.joinpath(basename + "_ref.h5"), fn.parent.joinpath(basename + str(x + 1) + ".h5")
|
||||
)
|
||||
|
||||
# Print maximum error value
|
||||
start = 210
|
||||
|
@@ -74,9 +74,7 @@ for x, PMLID in enumerate(PMLIDs):
|
||||
ax.set_ylabel(f"{output} error [dB]")
|
||||
|
||||
# Save a PDF/PNG of the figure
|
||||
fig.savefig(basename + "_diffs_" + PMLID + ".pdf", dpi=None, format='pdf', bbox_inches='tight', pad_inches=0.1)
|
||||
fig.savefig(basename + "_diffs_" + PMLID + ".pdf", dpi=None, format="pdf", bbox_inches="tight", pad_inches=0.1)
|
||||
# fig.savefig(basename + "_diffs_" + PMLID + ".png", dpi=150, format='png', bbox_inches='tight', pad_inches=0.1)
|
||||
|
||||
plt.show()
|
||||
|
||||
|
||||
|
@@ -65,10 +65,10 @@ if epsr:
|
||||
wavelength = v1 / f
|
||||
|
||||
# Print some useful information
|
||||
logger.info("Centre frequency: {} GHz".format(f / 1e9))
|
||||
logger.info(f"Centre frequency: {f / 1000000000.0} GHz")
|
||||
if epsr:
|
||||
logger.info("Critical angle for Er {} is {} degrees".format(epsr, thetac))
|
||||
logger.info("Wavelength: {:.3f} m".format(wavelength))
|
||||
logger.info(f"Critical angle for Er {epsr} is {thetac} degrees")
|
||||
logger.info(f"Wavelength: {wavelength:.3f} m")
|
||||
logger.info(
|
||||
"Observation distance(s) from {:.3f} m ({:.1f} wavelengths) to {:.3f} m ({:.1f} wavelengths)".format(
|
||||
radii[0], radii[0] / wavelength, radii[-1], radii[-1] / wavelength
|
||||
@@ -204,4 +204,4 @@ for radius in range(0, len(radii)):
|
||||
|
||||
# Save pattern to numpy file
|
||||
np.save(os.path.splitext(outputfile)[0], patternsave)
|
||||
logger.info("Written Numpy file: {}.npy".format(os.path.splitext(outputfile)[0]))
|
||||
logger.info(f"Written Numpy file: {os.path.splitext(outputfile)[0]}.npy")
|
||||
|
@@ -65,7 +65,7 @@ if epsr:
|
||||
logger.info(f"Centre frequency: {f / 1000000000.0} GHz")
|
||||
if epsr:
|
||||
logger.info(f"Critical angle for Er {epsr} is {thetac} degrees")
|
||||
logger.info("Wavelength: {:.3f} m".format(wavelength))
|
||||
logger.info(f"Wavelength: {wavelength:.3f} m")
|
||||
logger.info(
|
||||
"Observation distance(s) from {:.3f} m ({:.1f} wavelengths) to {:.3f} m ({:.1f} wavelengths)".format(
|
||||
radii[0], radii[0] / wavelength, radii[-1], radii[-1] / wavelength
|
||||
@@ -107,7 +107,7 @@ for patt in range(0, len(radii)):
|
||||
# Replace any NaNs or Infs from zero division
|
||||
power[np.invert(np.isfinite(power))] = 0
|
||||
|
||||
ax.plot(theta, power, label="{:.2f}m".format(radii[patt]), marker=".", ms=6, lw=1.5)
|
||||
ax.plot(theta, power, label=f"{radii[patt]:.2f}m", marker=".", ms=6, lw=1.5)
|
||||
|
||||
# Add Hertzian dipole plot
|
||||
# hertzplot1 = np.append(hertzian[0, :], hertzian[0, 0]) # Append start value to close circle
|
||||
|
@@ -220,14 +220,12 @@ class Relaxation(object):
|
||||
print(f" |{'e_inf':^14s}|{'De':^14s}|{'log(tau_0)':^25s}|")
|
||||
print("_" * 65)
|
||||
for i in range(0, len(tau)):
|
||||
print("Debye {0:}|{1:^14.5f}|{2:^14.5f}|{3:^25.5f}|".format(i + 1, ee / len(tau), weights[i], tau[i]))
|
||||
print(f"Debye {i + 1}|{ee / len(tau):^14.5f}|{weights[i]:^14.5f}|{tau[i]:^25.5f}|")
|
||||
print("_" * 65)
|
||||
|
||||
# Print the Debye expnasion in a gprMax format
|
||||
material_prop = []
|
||||
material_prop.append(
|
||||
"#material: {} {} {} {} {}\n".format(ee, self.sigma, self.mu, self.mu_sigma, self.material_name)
|
||||
)
|
||||
material_prop.append(f"#material: {ee} {self.sigma} {self.mu} {self.mu_sigma} {self.material_name}\n")
|
||||
print(material_prop[0], end="")
|
||||
dispersion_prop = f"#add_dispersion_debye: {len(tau)}"
|
||||
for i in range(len(tau)):
|
||||
|
在新工单中引用
屏蔽一个用户