你已经派生过 gprMax
镜像自地址
https://gitee.com/sunhf/gprMax.git
已同步 2025-08-07 15:10:13 +08:00
Merge pull request #365 from Sai-Suraj-27/optimizing
Removed un-necessary string concatenations and Refactored few functions.
这个提交包含在:
@@ -98,11 +98,11 @@ class AddGrass(UserObjectGeometry):
|
|||||||
xf, yf, zf = p2
|
xf, yf, zf = p2
|
||||||
|
|
||||||
if frac_dim < 0:
|
if frac_dim < 0:
|
||||||
logger.exception(f"{self.__str__()} requires a positive value for " + "the fractal dimension")
|
logger.exception(f"{self.__str__()} requires a positive value for the fractal dimension")
|
||||||
raise ValueError
|
raise ValueError
|
||||||
if limits[0] < 0 or limits[1] < 0:
|
if limits[0] < 0 or limits[1] < 0:
|
||||||
logger.exception(
|
logger.exception(
|
||||||
f"{self.__str__()} requires a positive value for " + "the minimum and maximum heights for grass blades"
|
f"{self.__str__()} requires a positive value for the minimum and maximum heights for grass blades"
|
||||||
)
|
)
|
||||||
raise ValueError
|
raise ValueError
|
||||||
|
|
||||||
@@ -118,7 +118,7 @@ class AddGrass(UserObjectGeometry):
|
|||||||
# xminus surface
|
# xminus surface
|
||||||
if xs == volume.xs:
|
if xs == volume.xs:
|
||||||
logger.exception(
|
logger.exception(
|
||||||
f"{self.__str__()} grass can only be specified " + "on surfaces in the positive axis direction"
|
f"{self.__str__()} grass can only be specified on surfaces in the positive axis direction"
|
||||||
)
|
)
|
||||||
raise ValueError
|
raise ValueError
|
||||||
# xplus surface
|
# xplus surface
|
||||||
@@ -126,8 +126,8 @@ class AddGrass(UserObjectGeometry):
|
|||||||
if fractalrange[1] > grid.nx:
|
if fractalrange[1] > grid.nx:
|
||||||
logger.exception(
|
logger.exception(
|
||||||
f"{self.__str__()} cannot apply grass to "
|
f"{self.__str__()} cannot apply grass to "
|
||||||
+ "fractal box as it would exceed the domain "
|
"fractal box as it would exceed the domain "
|
||||||
+ "size in the x direction"
|
"size in the x direction"
|
||||||
)
|
)
|
||||||
raise ValueError
|
raise ValueError
|
||||||
requestedsurface = "xplus"
|
requestedsurface = "xplus"
|
||||||
@@ -143,7 +143,7 @@ class AddGrass(UserObjectGeometry):
|
|||||||
# yminus surface
|
# yminus surface
|
||||||
if ys == volume.ys:
|
if ys == volume.ys:
|
||||||
logger.exception(
|
logger.exception(
|
||||||
f"{self.__str__()} grass can only be specified " + "on surfaces in the positive axis direction"
|
f"{self.__str__()} grass can only be specified on surfaces in the positive axis direction"
|
||||||
)
|
)
|
||||||
raise ValueError
|
raise ValueError
|
||||||
# yplus surface
|
# yplus surface
|
||||||
@@ -151,8 +151,8 @@ class AddGrass(UserObjectGeometry):
|
|||||||
if fractalrange[1] > grid.ny:
|
if fractalrange[1] > grid.ny:
|
||||||
logger.exception(
|
logger.exception(
|
||||||
f"{self.__str__()} cannot apply grass to "
|
f"{self.__str__()} cannot apply grass to "
|
||||||
+ "fractal box as it would exceed the domain "
|
"fractal box as it would exceed the domain "
|
||||||
+ "size in the y direction"
|
"size in the y direction"
|
||||||
)
|
)
|
||||||
raise ValueError
|
raise ValueError
|
||||||
requestedsurface = "yplus"
|
requestedsurface = "yplus"
|
||||||
@@ -165,7 +165,7 @@ class AddGrass(UserObjectGeometry):
|
|||||||
# zminus surface
|
# zminus surface
|
||||||
if zs == volume.zs:
|
if zs == volume.zs:
|
||||||
logger.exception(
|
logger.exception(
|
||||||
f"{self.__str__()} grass can only be specified " + "on surfaces in the positive axis direction"
|
f"{self.__str__()} grass can only be specified on surfaces in the positive axis direction"
|
||||||
)
|
)
|
||||||
raise ValueError
|
raise ValueError
|
||||||
# zplus surface
|
# zplus surface
|
||||||
@@ -173,8 +173,8 @@ class AddGrass(UserObjectGeometry):
|
|||||||
if fractalrange[1] > grid.nz:
|
if fractalrange[1] > grid.nz:
|
||||||
logger.exception(
|
logger.exception(
|
||||||
f"{self.__str__()} cannot apply grass to "
|
f"{self.__str__()} cannot apply grass to "
|
||||||
+ "fractal box as it would exceed the domain "
|
"fractal box as it would exceed the domain "
|
||||||
+ "size in the z direction"
|
"size in the z direction"
|
||||||
)
|
)
|
||||||
raise ValueError
|
raise ValueError
|
||||||
requestedsurface = "zplus"
|
requestedsurface = "zplus"
|
||||||
@@ -195,7 +195,7 @@ class AddGrass(UserObjectGeometry):
|
|||||||
if n_blades > surface.fractalsurface.shape[0] * surface.fractalsurface.shape[1]:
|
if n_blades > surface.fractalsurface.shape[0] * surface.fractalsurface.shape[1]:
|
||||||
logger.exception(
|
logger.exception(
|
||||||
f"{self.__str__()} the specified surface is not large "
|
f"{self.__str__()} the specified surface is not large "
|
||||||
+ "enough for the number of grass blades/roots specified"
|
"enough for the number of grass blades/roots specified"
|
||||||
)
|
)
|
||||||
raise ValueError
|
raise ValueError
|
||||||
|
|
||||||
@@ -244,7 +244,7 @@ class AddGrass(UserObjectGeometry):
|
|||||||
if testgrass:
|
if testgrass:
|
||||||
logger.exception(
|
logger.exception(
|
||||||
f"{self.__str__()} requires the time step for the "
|
f"{self.__str__()} requires the time step for the "
|
||||||
+ "model to be less than the relaxation time required to model grass."
|
"model to be less than the relaxation time required to model grass."
|
||||||
)
|
)
|
||||||
raise ValueError
|
raise ValueError
|
||||||
|
|
||||||
@@ -252,9 +252,9 @@ class AddGrass(UserObjectGeometry):
|
|||||||
|
|
||||||
logger.info(
|
logger.info(
|
||||||
f"{self.grid_name(grid)}{n_blades} blades of grass on surface from "
|
f"{self.grid_name(grid)}{n_blades} blades of grass on surface from "
|
||||||
+ f"{xs * grid.dx:g}m, {ys * grid.dy:g}m, {zs * grid.dz:g}m, "
|
f"{xs * grid.dx:g}m, {ys * grid.dy:g}m, {zs * grid.dz:g}m, "
|
||||||
+ f"to {xf * grid.dx:g}m, {yf * grid.dy:g}m, {zf * grid.dz:g}m "
|
f"to {xf * grid.dx:g}m, {yf * grid.dy:g}m, {zf * grid.dz:g}m "
|
||||||
+ f"with fractal dimension {surface.dimension:g}, fractal seeding "
|
f"with fractal dimension {surface.dimension:g}, fractal seeding "
|
||||||
+ f"{surface.seed}, and range {limits[0]:g}m to {limits[1]:g}m, "
|
f"{surface.seed}, and range {limits[0]:g}m to {limits[1]:g}m, "
|
||||||
+ f"added to {surface.operatingonID}."
|
f"added to {surface.operatingonID}."
|
||||||
)
|
)
|
||||||
|
@@ -82,8 +82,8 @@ class AddSurfaceRoughness(UserObjectGeometry):
|
|||||||
except KeyError:
|
except KeyError:
|
||||||
logger.warning(
|
logger.warning(
|
||||||
f"{self.__str__()} no value for seed detected. This "
|
f"{self.__str__()} no value for seed detected. This "
|
||||||
+ "means you will get a different fractal distribution "
|
"means you will get a different fractal distribution "
|
||||||
+ "every time the model runs."
|
"every time the model runs."
|
||||||
)
|
)
|
||||||
seed = None
|
seed = None
|
||||||
|
|
||||||
@@ -108,13 +108,13 @@ class AddSurfaceRoughness(UserObjectGeometry):
|
|||||||
if weighting[0] < 0:
|
if weighting[0] < 0:
|
||||||
logger.exception(
|
logger.exception(
|
||||||
f"{self.__str__()} requires a positive value for the "
|
f"{self.__str__()} requires a positive value for the "
|
||||||
+ "fractal weighting in the first direction of the surface"
|
"fractal weighting in the first direction of the surface"
|
||||||
)
|
)
|
||||||
raise ValueError
|
raise ValueError
|
||||||
if weighting[1] < 0:
|
if weighting[1] < 0:
|
||||||
logger.exception(
|
logger.exception(
|
||||||
f"{self.__str__()} requires a positive value for the "
|
f"{self.__str__()} requires a positive value for the "
|
||||||
+ "fractal weighting in the second direction of the surface"
|
"fractal weighting in the second direction of the surface"
|
||||||
)
|
)
|
||||||
raise ValueError
|
raise ValueError
|
||||||
|
|
||||||
@@ -124,7 +124,7 @@ class AddSurfaceRoughness(UserObjectGeometry):
|
|||||||
logger.exception(f"{self.__str__()} dimensions are not specified correctly")
|
logger.exception(f"{self.__str__()} dimensions are not specified correctly")
|
||||||
raise ValueError
|
raise ValueError
|
||||||
if xs not in [volume.xs, volume.xf]:
|
if xs not in [volume.xs, volume.xf]:
|
||||||
logger.exception(f"{self.__str__()} can only be used on the external " + "surfaces of a fractal box")
|
logger.exception(f"{self.__str__()} can only be used on the external surfaces of a fractal box")
|
||||||
raise ValueError
|
raise ValueError
|
||||||
fractalrange = (round_value(limits[0] / grid.dx), round_value(limits[1] / grid.dx))
|
fractalrange = (round_value(limits[0] / grid.dx), round_value(limits[1] / grid.dx))
|
||||||
# xminus surface
|
# xminus surface
|
||||||
@@ -132,9 +132,9 @@ class AddSurfaceRoughness(UserObjectGeometry):
|
|||||||
if fractalrange[0] < 0 or fractalrange[1] > volume.xf:
|
if fractalrange[0] < 0 or fractalrange[1] > volume.xf:
|
||||||
logger.exception(
|
logger.exception(
|
||||||
f"{self.__str__()} cannot apply fractal surface "
|
f"{self.__str__()} cannot apply fractal surface "
|
||||||
+ "to fractal box as it would exceed either the "
|
"to fractal box as it would exceed either the "
|
||||||
+ "upper coordinates of the fractal box or the "
|
"upper coordinates of the fractal box or the "
|
||||||
+ "domain in the x direction"
|
"domain in the x direction"
|
||||||
)
|
)
|
||||||
raise ValueError
|
raise ValueError
|
||||||
requestedsurface = "xminus"
|
requestedsurface = "xminus"
|
||||||
@@ -143,9 +143,9 @@ class AddSurfaceRoughness(UserObjectGeometry):
|
|||||||
if fractalrange[0] < volume.xs or fractalrange[1] > grid.nx:
|
if fractalrange[0] < volume.xs or fractalrange[1] > grid.nx:
|
||||||
logger.exception(
|
logger.exception(
|
||||||
f"{self.__str__()} cannot apply fractal surface "
|
f"{self.__str__()} cannot apply fractal surface "
|
||||||
+ "to fractal box as it would exceed either the "
|
"to fractal box as it would exceed either the "
|
||||||
+ "lower coordinates of the fractal box or the "
|
"lower coordinates of the fractal box or the "
|
||||||
+ "domain in the x direction"
|
"domain in the x direction"
|
||||||
)
|
)
|
||||||
raise ValueError
|
raise ValueError
|
||||||
requestedsurface = "xplus"
|
requestedsurface = "xplus"
|
||||||
@@ -163,9 +163,9 @@ class AddSurfaceRoughness(UserObjectGeometry):
|
|||||||
if fractalrange[0] < 0 or fractalrange[1] > volume.yf:
|
if fractalrange[0] < 0 or fractalrange[1] > volume.yf:
|
||||||
logger.exception(
|
logger.exception(
|
||||||
f"{self.__str__()} cannot apply fractal surface "
|
f"{self.__str__()} cannot apply fractal surface "
|
||||||
+ "to fractal box as it would exceed either the "
|
"to fractal box as it would exceed either the "
|
||||||
+ "upper coordinates of the fractal box or the "
|
"upper coordinates of the fractal box or the "
|
||||||
+ "domain in the y direction"
|
"domain in the y direction"
|
||||||
)
|
)
|
||||||
raise ValueError
|
raise ValueError
|
||||||
requestedsurface = "yminus"
|
requestedsurface = "yminus"
|
||||||
@@ -174,9 +174,9 @@ class AddSurfaceRoughness(UserObjectGeometry):
|
|||||||
if fractalrange[0] < volume.ys or fractalrange[1] > grid.ny:
|
if fractalrange[0] < volume.ys or fractalrange[1] > grid.ny:
|
||||||
logger.exception(
|
logger.exception(
|
||||||
f"{self.__str__()} cannot apply fractal surface "
|
f"{self.__str__()} cannot apply fractal surface "
|
||||||
+ "to fractal box as it would exceed either the "
|
"to fractal box as it would exceed either the "
|
||||||
+ "lower coordinates of the fractal box or the "
|
"lower coordinates of the fractal box or the "
|
||||||
+ "domain in the y direction"
|
"domain in the y direction"
|
||||||
)
|
)
|
||||||
raise ValueError
|
raise ValueError
|
||||||
requestedsurface = "yplus"
|
requestedsurface = "yplus"
|
||||||
@@ -191,9 +191,9 @@ class AddSurfaceRoughness(UserObjectGeometry):
|
|||||||
if fractalrange[0] < 0 or fractalrange[1] > volume.zf:
|
if fractalrange[0] < 0 or fractalrange[1] > volume.zf:
|
||||||
logger.exception(
|
logger.exception(
|
||||||
f"{self.__str__()} cannot apply fractal surface "
|
f"{self.__str__()} cannot apply fractal surface "
|
||||||
+ "to fractal box as it would exceed either the "
|
"to fractal box as it would exceed either the "
|
||||||
+ "upper coordinates of the fractal box or the "
|
"upper coordinates of the fractal box or the "
|
||||||
+ "domain in the x direction"
|
"domain in the x direction"
|
||||||
)
|
)
|
||||||
raise ValueError
|
raise ValueError
|
||||||
requestedsurface = "zminus"
|
requestedsurface = "zminus"
|
||||||
@@ -202,9 +202,9 @@ class AddSurfaceRoughness(UserObjectGeometry):
|
|||||||
if fractalrange[0] < volume.zs or fractalrange[1] > grid.nz:
|
if fractalrange[0] < volume.zs or fractalrange[1] > grid.nz:
|
||||||
logger.exception(
|
logger.exception(
|
||||||
f"{self.__str__()} cannot apply fractal surface "
|
f"{self.__str__()} cannot apply fractal surface "
|
||||||
+ "to fractal box as it would exceed either the "
|
"to fractal box as it would exceed either the "
|
||||||
+ "lower coordinates of the fractal box or the "
|
"lower coordinates of the fractal box or the "
|
||||||
+ "domain in the z direction"
|
"domain in the z direction"
|
||||||
)
|
)
|
||||||
raise ValueError
|
raise ValueError
|
||||||
requestedsurface = "zplus"
|
requestedsurface = "zplus"
|
||||||
@@ -226,7 +226,7 @@ class AddSurfaceRoughness(UserObjectGeometry):
|
|||||||
# List of existing surfaces IDs
|
# List of existing surfaces IDs
|
||||||
existingsurfaceIDs = [x.surfaceID for x in volume.fractalsurfaces]
|
existingsurfaceIDs = [x.surfaceID for x in volume.fractalsurfaces]
|
||||||
if surface.surfaceID in existingsurfaceIDs:
|
if surface.surfaceID in existingsurfaceIDs:
|
||||||
logger.exception(f"{self.__str__()} has already been used on the " + f"{surface.surfaceID} surface")
|
logger.exception(f"{self.__str__()} has already been used on the {surface.surfaceID} surface")
|
||||||
raise ValueError
|
raise ValueError
|
||||||
|
|
||||||
surface.generate_fractal_surface()
|
surface.generate_fractal_surface()
|
||||||
@@ -234,10 +234,10 @@ class AddSurfaceRoughness(UserObjectGeometry):
|
|||||||
|
|
||||||
logger.info(
|
logger.info(
|
||||||
f"{self.grid_name(grid)}Fractal surface from {xs * grid.dx:g}m, "
|
f"{self.grid_name(grid)}Fractal surface from {xs * grid.dx:g}m, "
|
||||||
+ f"{ys * grid.dy:g}m, {zs * grid.dz:g}m, to {xf * grid.dx:g}m, "
|
f"{ys * grid.dy:g}m, {zs * grid.dz:g}m, to {xf * grid.dx:g}m, "
|
||||||
+ f"{yf * grid.dy:g}m, {zf * grid.dz:g}m with fractal dimension "
|
f"{yf * grid.dy:g}m, {zf * grid.dz:g}m with fractal dimension "
|
||||||
+ f"{surface.dimension:g}, fractal weightings {surface.weighting[0]:g}, "
|
f"{surface.dimension:g}, fractal weightings {surface.weighting[0]:g}, "
|
||||||
+ f"{surface.weighting[1]:g}, fractal seeding {surface.seed}, "
|
f"{surface.weighting[1]:g}, fractal seeding {surface.seed}, "
|
||||||
+ f"and range {limits[0]:g}m to {limits[1]:g}m, added to "
|
f"and range {limits[0]:g}m to {limits[1]:g}m, added to "
|
||||||
+ f"{surface.operatingonID}."
|
f"{surface.operatingonID}."
|
||||||
)
|
)
|
||||||
|
@@ -85,7 +85,7 @@ class AddSurfaceWater(UserObjectGeometry):
|
|||||||
xf, yf, zf = p2
|
xf, yf, zf = p2
|
||||||
|
|
||||||
if depth <= 0:
|
if depth <= 0:
|
||||||
logger.exception(f"{self.__str__()} requires a positive value for the " + f"depth of water")
|
logger.exception(f"{self.__str__()} requires a positive value for the depth of water")
|
||||||
raise ValueError
|
raise ValueError
|
||||||
|
|
||||||
# Check for valid orientations
|
# Check for valid orientations
|
||||||
@@ -94,7 +94,7 @@ class AddSurfaceWater(UserObjectGeometry):
|
|||||||
logger.exception(f"{self.__str__()} dimensions are not specified correctly")
|
logger.exception(f"{self.__str__()} dimensions are not specified correctly")
|
||||||
raise ValueError
|
raise ValueError
|
||||||
if xs not in [volume.xs, volume.xf]:
|
if xs not in [volume.xs, volume.xf]:
|
||||||
logger.exception(f"{self.__str__()} can only be used on the external surfaces " f"of a fractal box")
|
logger.exception(f"{self.__str__()} can only be used on the external surfaces of a fractal box")
|
||||||
raise ValueError
|
raise ValueError
|
||||||
# xminus surface
|
# xminus surface
|
||||||
if xs == volume.xs:
|
if xs == volume.xs:
|
||||||
@@ -110,7 +110,7 @@ class AddSurfaceWater(UserObjectGeometry):
|
|||||||
logger.exception(f"{self.__str__()} dimensions are not specified correctly")
|
logger.exception(f"{self.__str__()} dimensions are not specified correctly")
|
||||||
raise ValueError
|
raise ValueError
|
||||||
if ys not in [volume.ys, volume.yf]:
|
if ys not in [volume.ys, volume.yf]:
|
||||||
logger.exception(f"{self.__str__()} can only be used on the external surfaces " + f"of a fractal box")
|
logger.exception(f"{self.__str__()} can only be used on the external surfaces of a fractal box")
|
||||||
raise ValueError
|
raise ValueError
|
||||||
# yminus surface
|
# yminus surface
|
||||||
if ys == volume.ys:
|
if ys == volume.ys:
|
||||||
@@ -123,7 +123,7 @@ class AddSurfaceWater(UserObjectGeometry):
|
|||||||
|
|
||||||
elif zs == zf:
|
elif zs == zf:
|
||||||
if zs not in [volume.zs, volume.zf]:
|
if zs not in [volume.zs, volume.zf]:
|
||||||
logger.exception(f"{self.__str__()} can only be used on the external surfaces " f"of a fractal box")
|
logger.exception(f"{self.__str__()} can only be used on the external surfaces of a fractal box")
|
||||||
raise ValueError
|
raise ValueError
|
||||||
# zminus surface
|
# zminus surface
|
||||||
if zs == volume.zs:
|
if zs == volume.zs:
|
||||||
@@ -141,7 +141,7 @@ class AddSurfaceWater(UserObjectGeometry):
|
|||||||
surface = next((x for x in volume.fractalsurfaces if x.surfaceID == requestedsurface), None)
|
surface = next((x for x in volume.fractalsurfaces if x.surfaceID == requestedsurface), None)
|
||||||
if not surface:
|
if not surface:
|
||||||
logger.exception(
|
logger.exception(
|
||||||
f"{self.__str__()} specified surface {requestedsurface} " + f"does not have a rough surface applied"
|
f"{self.__str__()} specified surface {requestedsurface} does not have a rough surface applied"
|
||||||
)
|
)
|
||||||
raise ValueError
|
raise ValueError
|
||||||
|
|
||||||
@@ -151,7 +151,7 @@ class AddSurfaceWater(UserObjectGeometry):
|
|||||||
if surface.filldepth < surface.fractalrange[0] or surface.filldepth > surface.fractalrange[1]:
|
if surface.filldepth < surface.fractalrange[0] or surface.filldepth > surface.fractalrange[1]:
|
||||||
logger.exception(
|
logger.exception(
|
||||||
f"{self.__str__()} requires a value for the depth of water that lies with the "
|
f"{self.__str__()} requires a value for the depth of water that lies with the "
|
||||||
+ f"range of the requested surface roughness"
|
f"range of the requested surface roughness"
|
||||||
)
|
)
|
||||||
raise ValueError
|
raise ValueError
|
||||||
|
|
||||||
@@ -170,7 +170,7 @@ class AddSurfaceWater(UserObjectGeometry):
|
|||||||
|
|
||||||
logger.info(
|
logger.info(
|
||||||
f"{self.grid_name(grid)}Water on surface from {xs * grid.dx:g}m, "
|
f"{self.grid_name(grid)}Water on surface from {xs * grid.dx:g}m, "
|
||||||
+ f"{ys * grid.dy:g}m, {zs * grid.dz:g}m, to {xf * grid.dx:g}m, "
|
f"{ys * grid.dy:g}m, {zs * grid.dz:g}m, to {xf * grid.dx:g}m, "
|
||||||
+ f"{yf * grid.dy:g}m, {zf * grid.dz:g}m with depth {filldepth:g}m, "
|
f"{yf * grid.dy:g}m, {zf * grid.dz:g}m with depth {filldepth:g}m, "
|
||||||
+ f"added to {surface.operatingonID}."
|
f"added to {surface.operatingonID}."
|
||||||
)
|
)
|
||||||
|
@@ -157,7 +157,7 @@ class Box(UserObjectGeometry):
|
|||||||
|
|
||||||
logger.info(
|
logger.info(
|
||||||
f"{self.grid_name(grid)}Box from {p5[0]:g}m, {p5[1]:g}m, "
|
f"{self.grid_name(grid)}Box from {p5[0]:g}m, {p5[1]:g}m, "
|
||||||
+ f"{p5[2]:g}m, to {p6[0]:g}m, {p6[1]:g}m, {p6[2]:g}m of "
|
f"{p5[2]:g}m, to {p6[0]:g}m, {p6[1]:g}m, {p6[2]:g}m of "
|
||||||
+ f"material(s) {', '.join(materialsrequested)} created, "
|
f"material(s) {', '.join(materialsrequested)} created, "
|
||||||
+ f"dielectric smoothing is {dielectricsmoothing}."
|
f"dielectric smoothing is {dielectricsmoothing}."
|
||||||
)
|
)
|
||||||
|
@@ -85,11 +85,11 @@ class Cone(UserObjectGeometry):
|
|||||||
x2, y2, z2 = uip.round_to_grid(p2)
|
x2, y2, z2 = uip.round_to_grid(p2)
|
||||||
|
|
||||||
if r1 < 0:
|
if r1 < 0:
|
||||||
logger.exception(f"{self.__str__()} the radius of the first face " + f"{r1:g} should be a positive value.")
|
logger.exception(f"{self.__str__()} the radius of the first face {r1:g} should be a positive value.")
|
||||||
raise ValueError
|
raise ValueError
|
||||||
|
|
||||||
if r2 < 0:
|
if r2 < 0:
|
||||||
logger.exception(f"{self.__str__()} the radius of the second face " + f"{r2:g} should be a positive value.")
|
logger.exception(f"{self.__str__()} the radius of the second face {r2:g} should be a positive value.")
|
||||||
raise ValueError
|
raise ValueError
|
||||||
|
|
||||||
if r1 == 0 and r2 == 0:
|
if r1 == 0 and r2 == 0:
|
||||||
@@ -158,7 +158,7 @@ class Cone(UserObjectGeometry):
|
|||||||
dielectricsmoothing = "on" if averaging else "off"
|
dielectricsmoothing = "on" if averaging else "off"
|
||||||
logger.info(
|
logger.info(
|
||||||
f"{self.grid_name(grid)}Cone with face centres {p3[0]:g}m, "
|
f"{self.grid_name(grid)}Cone with face centres {p3[0]:g}m, "
|
||||||
+ f"{p3[1]:g}m, {p3[2]:g}m and {p4[0]:g}m, {p4[1]:g}m, {p4[2]:g}m, "
|
f"{p3[1]:g}m, {p3[2]:g}m and {p4[0]:g}m, {p4[1]:g}m, {p4[2]:g}m, "
|
||||||
+ f"with radii {r1:g}m and {r2:g}, of material(s) {', '.join(materialsrequested)} "
|
f"with radii {r1:g}m and {r2:g}, of material(s) {', '.join(materialsrequested)} "
|
||||||
+ f"created, dielectric smoothing is {dielectricsmoothing}."
|
f"created, dielectric smoothing is {dielectricsmoothing}."
|
||||||
)
|
)
|
||||||
|
@@ -146,7 +146,7 @@ class Cylinder(UserObjectGeometry):
|
|||||||
dielectricsmoothing = "on" if averaging else "off"
|
dielectricsmoothing = "on" if averaging else "off"
|
||||||
logger.info(
|
logger.info(
|
||||||
f"{self.grid_name(grid)}Cylinder with face centres {p3[0]:g}m, "
|
f"{self.grid_name(grid)}Cylinder with face centres {p3[0]:g}m, "
|
||||||
+ f"{p3[1]:g}m, {p3[2]:g}m and {p4[0]:g}m, {p4[1]:g}m, {p4[2]:g}m, "
|
f"{p3[1]:g}m, {p3[2]:g}m and {p4[0]:g}m, {p4[1]:g}m, {p4[2]:g}m, "
|
||||||
+ f"with radius {r:g}m, of material(s) {', '.join(materialsrequested)} "
|
f"with radius {r:g}m, of material(s) {', '.join(materialsrequested)} "
|
||||||
+ f"created, dielectric smoothing is {dielectricsmoothing}."
|
f"created, dielectric smoothing is {dielectricsmoothing}."
|
||||||
)
|
)
|
||||||
|
@@ -94,17 +94,15 @@ class CylindricalSector(UserObjectGeometry):
|
|||||||
sectorangle = 2 * np.pi * (end / 360)
|
sectorangle = 2 * np.pi * (end / 360)
|
||||||
|
|
||||||
if normal not in ["x", "y", "z"]:
|
if normal not in ["x", "y", "z"]:
|
||||||
logger.exception(f"{self.__str__()} the normal direction must be either " + f"x, y or z.")
|
logger.exception(f"{self.__str__()} the normal direction must be either x, y or z.")
|
||||||
raise ValueError
|
raise ValueError
|
||||||
if r <= 0:
|
if r <= 0:
|
||||||
logger.exception(f"{self.__str__()} the radius {r:g} should be a positive value.")
|
logger.exception(f"{self.__str__()} the radius {r:g} should be a positive value.")
|
||||||
if sectorstartangle < 0 or sectorangle <= 0:
|
if sectorstartangle < 0 or sectorangle <= 0:
|
||||||
logger.exception(f"{self.__str__()} the starting angle and sector angle should be " + f"a positive values.")
|
logger.exception(f"{self.__str__()} the starting angle and sector angle should be a positive values.")
|
||||||
raise ValueError
|
raise ValueError
|
||||||
if sectorstartangle >= 2 * np.pi or sectorangle >= 2 * np.pi:
|
if sectorstartangle >= 2 * np.pi or sectorangle >= 2 * np.pi:
|
||||||
logger.exception(
|
logger.exception(f"{self.__str__()} the starting angle and sector angle must be less than 360 degrees.")
|
||||||
f"{self.__str__()} the starting angle and sector angle must be " + f"less than 360 degrees."
|
|
||||||
)
|
|
||||||
raise ValueError
|
raise ValueError
|
||||||
|
|
||||||
# Look up requested materials in existing list of material instances
|
# Look up requested materials in existing list of material instances
|
||||||
@@ -195,18 +193,18 @@ class CylindricalSector(UserObjectGeometry):
|
|||||||
dielectricsmoothing = "on" if averaging else "off"
|
dielectricsmoothing = "on" if averaging else "off"
|
||||||
logger.info(
|
logger.info(
|
||||||
f"{self.grid_name(grid)}Cylindrical sector with centre "
|
f"{self.grid_name(grid)}Cylindrical sector with centre "
|
||||||
+ f"{ctr1:g}m, {ctr2:g}m, radius {r:g}m, starting angle "
|
f"{ctr1:g}m, {ctr2:g}m, radius {r:g}m, starting angle "
|
||||||
+ f"{(sectorstartangle / (2 * np.pi)) * 360:.1f} degrees, "
|
f"{(sectorstartangle / (2 * np.pi)) * 360:.1f} degrees, "
|
||||||
+ f"sector angle {(sectorangle / (2 * np.pi)) * 360:.1f} degrees, "
|
f"sector angle {(sectorangle / (2 * np.pi)) * 360:.1f} degrees, "
|
||||||
+ f"thickness {thickness:g}m, of material(s) {', '.join(materialsrequested)} "
|
f"thickness {thickness:g}m, of material(s) {', '.join(materialsrequested)} "
|
||||||
+ f"created, dielectric smoothing is {dielectricsmoothing}."
|
f"created, dielectric smoothing is {dielectricsmoothing}."
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
logger.info(
|
logger.info(
|
||||||
f"{self.grid_name(grid)}Cylindrical sector with centre "
|
f"{self.grid_name(grid)}Cylindrical sector with centre "
|
||||||
+ f"{ctr1:g}m, {ctr2:g}m, radius {r:g}m, starting angle "
|
f"{ctr1:g}m, {ctr2:g}m, radius {r:g}m, starting angle "
|
||||||
+ f"{(sectorstartangle / (2 * np.pi)) * 360:.1f} degrees, "
|
f"{(sectorstartangle / (2 * np.pi)) * 360:.1f} degrees, "
|
||||||
+ f"sector angle {(sectorangle / (2 * np.pi)) * 360:.1f} "
|
f"sector angle {(sectorangle / (2 * np.pi)) * 360:.1f} "
|
||||||
+ f"degrees, of material(s) {', '.join(materialsrequested)} "
|
f"degrees, of material(s) {', '.join(materialsrequested)} "
|
||||||
+ f"created."
|
f"created."
|
||||||
)
|
)
|
||||||
|
@@ -103,6 +103,6 @@ class Edge(UserObjectGeometry):
|
|||||||
|
|
||||||
logger.info(
|
logger.info(
|
||||||
f"{self.grid_name(grid)}Edge from {p3[0]:g}m, {p3[1]:g}m, "
|
f"{self.grid_name(grid)}Edge from {p3[0]:g}m, {p3[1]:g}m, "
|
||||||
+ f"{p3[2]:g}m, to {p4[0]:g}m, {p4[1]:g}m, {p4[2]:g}m of "
|
f"{p3[2]:g}m, to {p4[0]:g}m, {p4[1]:g}m, {p4[2]:g}m of "
|
||||||
+ f"material {material_id} created."
|
f"material {material_id} created."
|
||||||
)
|
)
|
||||||
|
@@ -53,7 +53,7 @@ class Ellipsoid(UserObjectGeometry):
|
|||||||
zr = self.kwargs["zr"]
|
zr = self.kwargs["zr"]
|
||||||
|
|
||||||
except KeyError:
|
except KeyError:
|
||||||
logger.exception(f"{self.__str__()} please specify a point and " + f"the three semiaxes.")
|
logger.exception(f"{self.__str__()} please specify a point and the three semiaxes.")
|
||||||
raise
|
raise
|
||||||
|
|
||||||
# Check averaging
|
# Check averaging
|
||||||
@@ -140,8 +140,8 @@ class Ellipsoid(UserObjectGeometry):
|
|||||||
dielectricsmoothing = "on" if averaging else "off"
|
dielectricsmoothing = "on" if averaging else "off"
|
||||||
logger.info(
|
logger.info(
|
||||||
f"{self.grid_name(grid)}Ellipsoid with centre {p2[0]:g}m, "
|
f"{self.grid_name(grid)}Ellipsoid with centre {p2[0]:g}m, "
|
||||||
+ f"{p2[1]:g}m, {p2[2]:g}m, x-semiaxis {xr:g}m, "
|
f"{p2[1]:g}m, {p2[2]:g}m, x-semiaxis {xr:g}m, "
|
||||||
+ f"y-semiaxis {yr:g}m and z-semiaxis {zr:g}m of material(s) "
|
f"y-semiaxis {yr:g}m and z-semiaxis {zr:g}m of material(s) "
|
||||||
+ f"{', '.join(materialsrequested)} created, dielectric "
|
f"{', '.join(materialsrequested)} created, dielectric "
|
||||||
+ f"smoothing is {dielectricsmoothing}."
|
f"smoothing is {dielectricsmoothing}."
|
||||||
)
|
)
|
||||||
|
@@ -87,8 +87,8 @@ class FractalBox(UserObjectGeometry):
|
|||||||
except KeyError:
|
except KeyError:
|
||||||
logger.warning(
|
logger.warning(
|
||||||
f"{self.__str__()} no value for seed detected. This "
|
f"{self.__str__()} no value for seed detected. This "
|
||||||
+ "means you will get a different fractal distribution "
|
"means you will get a different fractal distribution "
|
||||||
+ "every time the model runs."
|
"every time the model runs."
|
||||||
)
|
)
|
||||||
seed = None
|
seed = None
|
||||||
|
|
||||||
@@ -112,24 +112,18 @@ class FractalBox(UserObjectGeometry):
|
|||||||
xf, yf, zf = p2
|
xf, yf, zf = p2
|
||||||
|
|
||||||
if frac_dim < 0:
|
if frac_dim < 0:
|
||||||
logger.exception(f"{self.__str__()} requires a positive value for the " + "fractal dimension")
|
logger.exception(f"{self.__str__()} requires a positive value for the fractal dimension")
|
||||||
raise ValueError
|
raise ValueError
|
||||||
if weighting[0] < 0:
|
if weighting[0] < 0:
|
||||||
logger.exception(
|
logger.exception(f"{self.__str__()} requires a positive value for the fractal weighting in the x direction")
|
||||||
f"{self.__str__()} requires a positive value for the " + "fractal weighting in the x direction"
|
|
||||||
)
|
|
||||||
raise ValueError
|
raise ValueError
|
||||||
if weighting[1] < 0:
|
if weighting[1] < 0:
|
||||||
logger.exception(
|
logger.exception(f"{self.__str__()} requires a positive value for the fractal weighting in the y direction")
|
||||||
f"{self.__str__()} requires a positive value for the " + "fractal weighting in the y direction"
|
|
||||||
)
|
|
||||||
raise ValueError
|
raise ValueError
|
||||||
if weighting[2] < 0:
|
if weighting[2] < 0:
|
||||||
logger.exception(
|
logger.exception(f"{self.__str__()} requires a positive value for the fractal weighting in the z direction")
|
||||||
f"{self.__str__()} requires a positive value for the " + "fractal weighting in the z direction"
|
|
||||||
)
|
|
||||||
if n_materials < 0:
|
if n_materials < 0:
|
||||||
logger.exception(f"{self.__str__()} requires a positive value for the " + "number of bins")
|
logger.exception(f"{self.__str__()} requires a positive value for the number of bins")
|
||||||
raise ValueError
|
raise ValueError
|
||||||
|
|
||||||
# Find materials to use to build fractal volume, either from mixing
|
# Find materials to use to build fractal volume, either from mixing
|
||||||
@@ -140,15 +134,11 @@ class FractalBox(UserObjectGeometry):
|
|||||||
|
|
||||||
if mixingmodel:
|
if mixingmodel:
|
||||||
if nbins == 1:
|
if nbins == 1:
|
||||||
logger.exception(
|
logger.exception(f"{self.__str__()} must be used with more than one material from the mixing model.")
|
||||||
f"{self.__str__()} must be used with more than " + "one material from the mixing model."
|
|
||||||
)
|
|
||||||
raise ValueError
|
raise ValueError
|
||||||
if isinstance(mixingmodel, ListMaterial) and nbins > len(mixingmodel.mat):
|
if isinstance(mixingmodel, ListMaterial) and nbins > len(mixingmodel.mat):
|
||||||
logger.exception(
|
logger.exception(
|
||||||
f"{self.__str__()} too many materials/bins "
|
f"{self.__str__()} too many materials/bins " "requested compared to materials in " "mixing model."
|
||||||
+ "requested compared to materials in "
|
|
||||||
+ "mixing model."
|
|
||||||
)
|
)
|
||||||
raise ValueError
|
raise ValueError
|
||||||
# Create materials from mixing model as number of bins now known
|
# Create materials from mixing model as number of bins now known
|
||||||
@@ -173,13 +163,13 @@ class FractalBox(UserObjectGeometry):
|
|||||||
dielectricsmoothing = "on" if volume.averaging else "off"
|
dielectricsmoothing = "on" if volume.averaging else "off"
|
||||||
logger.info(
|
logger.info(
|
||||||
f"{self.grid_name(grid)}Fractal box {volume.ID} from "
|
f"{self.grid_name(grid)}Fractal box {volume.ID} from "
|
||||||
+ f"{p3[0]:g}m, {p3[1]:g}m, {p3[2]:g}m, to {p4[0]:g}m, "
|
f"{p3[0]:g}m, {p3[1]:g}m, {p3[2]:g}m, to {p4[0]:g}m, "
|
||||||
+ f"{p4[1]:g}m, {p4[2]:g}m with {volume.operatingonID}, "
|
f"{p4[1]:g}m, {p4[2]:g}m with {volume.operatingonID}, "
|
||||||
+ f"fractal dimension {volume.dimension:g}, fractal weightings "
|
f"fractal dimension {volume.dimension:g}, fractal weightings "
|
||||||
+ f"{volume.weighting[0]:g}, {volume.weighting[1]:g}, "
|
f"{volume.weighting[0]:g}, {volume.weighting[1]:g}, "
|
||||||
+ f"{volume.weighting[2]:g}, fractal seeding {volume.seed}, "
|
f"{volume.weighting[2]:g}, fractal seeding {volume.seed}, "
|
||||||
+ f"with {volume.nbins} material(s) created, dielectric smoothing "
|
f"with {volume.nbins} material(s) created, dielectric smoothing "
|
||||||
+ f"is {dielectricsmoothing}."
|
f"is {dielectricsmoothing}."
|
||||||
)
|
)
|
||||||
|
|
||||||
grid.fractalvolumes.append(volume)
|
grid.fractalvolumes.append(volume)
|
||||||
|
@@ -388,8 +388,8 @@ class FractalBoxBuilder(UserObjectGeometry):
|
|||||||
if volume.nbins == 1:
|
if volume.nbins == 1:
|
||||||
logger.exception(
|
logger.exception(
|
||||||
f"{self.__str__()} is being used with a "
|
f"{self.__str__()} is being used with a "
|
||||||
+ "single material and no modifications, "
|
"single material and no modifications, "
|
||||||
+ "therefore please use a #box command instead."
|
"therefore please use a #box command instead."
|
||||||
)
|
)
|
||||||
raise ValueError
|
raise ValueError
|
||||||
else:
|
else:
|
||||||
|
@@ -108,8 +108,8 @@ class GeometryObjectsRead(UserObjectGeometry):
|
|||||||
):
|
):
|
||||||
logger.exception(
|
logger.exception(
|
||||||
f"{self.__str__()} requires the spatial resolution "
|
f"{self.__str__()} requires the spatial resolution "
|
||||||
+ "of the geometry objects file to match the spatial "
|
"of the geometry objects file to match the spatial "
|
||||||
+ "resolution of the model"
|
"resolution of the model"
|
||||||
)
|
)
|
||||||
raise ValueError
|
raise ValueError
|
||||||
|
|
||||||
@@ -134,9 +134,9 @@ class GeometryObjectsRead(UserObjectGeometry):
|
|||||||
grid.ID[:, xs : xs + ID.shape[1], ys : ys + ID.shape[2], zs : zs + ID.shape[3]] = ID + numexistmaterials
|
grid.ID[:, xs : xs + ID.shape[1], ys : ys + ID.shape[2], zs : zs + ID.shape[3]] = ID + numexistmaterials
|
||||||
logger.info(
|
logger.info(
|
||||||
f"{self.grid_name(grid)}Geometry objects from file {geofile} "
|
f"{self.grid_name(grid)}Geometry objects from file {geofile} "
|
||||||
+ f"inserted at {xs * grid.dx:g}m, {ys * grid.dy:g}m, "
|
f"inserted at {xs * grid.dx:g}m, {ys * grid.dy:g}m, "
|
||||||
+ f"{zs * grid.dz:g}m, with corresponding materials file "
|
f"{zs * grid.dz:g}m, with corresponding materials file "
|
||||||
+ f"{matfile}."
|
f"{matfile}."
|
||||||
)
|
)
|
||||||
except KeyError:
|
except KeyError:
|
||||||
averaging = False
|
averaging = False
|
||||||
@@ -155,7 +155,7 @@ class GeometryObjectsRead(UserObjectGeometry):
|
|||||||
)
|
)
|
||||||
logger.info(
|
logger.info(
|
||||||
f"{self.grid_name(grid)}Geometry objects from file "
|
f"{self.grid_name(grid)}Geometry objects from file "
|
||||||
+ f"(voxels only){geofile} inserted at {xs * grid.dx:g}m, "
|
f"(voxels only){geofile} inserted at {xs * grid.dx:g}m, "
|
||||||
+ f"{ys * grid.dy:g}m, {zs * grid.dz:g}m, with corresponding "
|
f"{ys * grid.dy:g}m, {zs * grid.dz:g}m, with corresponding "
|
||||||
+ f"materials file {matfile}."
|
f"materials file {matfile}."
|
||||||
)
|
)
|
||||||
|
@@ -148,6 +148,6 @@ class Plate(UserObjectGeometry):
|
|||||||
|
|
||||||
logger.info(
|
logger.info(
|
||||||
f"{self.grid_name(grid)}Plate from {p3[0]:g}m, {p3[1]:g}m, "
|
f"{self.grid_name(grid)}Plate from {p3[0]:g}m, {p3[1]:g}m, "
|
||||||
+ f"{p3[2]:g}m, to {p4[0]:g}m, {p4[1]:g}m, {p4[2]:g}m of "
|
f"{p3[2]:g}m, to {p4[0]:g}m, {p4[1]:g}m, {p4[2]:g}m of "
|
||||||
+ f"material(s) {', '.join(materialsrequested)} created."
|
f"material(s) {', '.join(materialsrequested)} created."
|
||||||
)
|
)
|
||||||
|
@@ -133,7 +133,7 @@ class Sphere(UserObjectGeometry):
|
|||||||
dielectricsmoothing = "on" if averaging else "off"
|
dielectricsmoothing = "on" if averaging else "off"
|
||||||
logger.info(
|
logger.info(
|
||||||
f"{self.grid_name(grid)}Sphere with centre {p2[0]:g}m, "
|
f"{self.grid_name(grid)}Sphere with centre {p2[0]:g}m, "
|
||||||
+ f"{p2[1]:g}m, {p2[2]:g}m, radius {r:g}m, of material(s) "
|
f"{p2[1]:g}m, {p2[2]:g}m, radius {r:g}m, of material(s) "
|
||||||
+ f"{', '.join(materialsrequested)} created, dielectric "
|
f"{', '.join(materialsrequested)} created, dielectric "
|
||||||
+ f"smoothing is {dielectricsmoothing}."
|
f"smoothing is {dielectricsmoothing}."
|
||||||
)
|
)
|
||||||
|
@@ -205,15 +205,15 @@ class Triangle(UserObjectGeometry):
|
|||||||
dielectricsmoothing = "on" if averaging else "off"
|
dielectricsmoothing = "on" if averaging else "off"
|
||||||
logger.info(
|
logger.info(
|
||||||
f"{self.grid_name(grid)}Triangle with coordinates "
|
f"{self.grid_name(grid)}Triangle with coordinates "
|
||||||
+ f"{p4[0]:g}m {p4[1]:g}m {p4[2]:g}m, {p5[0]:g}m {p5[1]:g}m "
|
f"{p4[0]:g}m {p4[1]:g}m {p4[2]:g}m, {p5[0]:g}m {p5[1]:g}m "
|
||||||
+ f"{p5[2]:g}m, {p6[0]:g}m {p6[1]:g}m {p6[2]:g}m and thickness "
|
f"{p5[2]:g}m, {p6[0]:g}m {p6[1]:g}m {p6[2]:g}m and thickness "
|
||||||
+ f"{thickness:g}m of material(s) {', '.join(materialsrequested)} "
|
f"{thickness:g}m of material(s) {', '.join(materialsrequested)} "
|
||||||
+ f"created, dielectric smoothing is {dielectricsmoothing}."
|
f"created, dielectric smoothing is {dielectricsmoothing}."
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
logger.info(
|
logger.info(
|
||||||
f"{self.grid_name(grid)}Triangle with coordinates "
|
f"{self.grid_name(grid)}Triangle with coordinates "
|
||||||
+ f"{p4[0]:g}m {p4[1]:g}m {p4[2]:g}m, {p5[0]:g}m {p5[1]:g}m "
|
f"{p4[0]:g}m {p4[1]:g}m {p4[2]:g}m, {p5[0]:g}m {p5[1]:g}m "
|
||||||
+ f"{p5[2]:g}m, {p6[0]:g}m {p6[1]:g}m {p6[2]:g}m of material(s) "
|
f"{p5[2]:g}m, {p6[0]:g}m {p6[1]:g}m {p6[2]:g}m of material(s) "
|
||||||
+ f"{', '.join(materialsrequested)} created."
|
f"{', '.join(materialsrequested)} created."
|
||||||
)
|
)
|
||||||
|
@@ -113,12 +113,12 @@ class Waveform(UserObjectMulti):
|
|||||||
wavetype = self.kwargs["wave_type"].lower()
|
wavetype = self.kwargs["wave_type"].lower()
|
||||||
except KeyError:
|
except KeyError:
|
||||||
logger.exception(
|
logger.exception(
|
||||||
f"{self.params_str()} must have one of the " + f"following types {','.join(WaveformUser.types)}."
|
f"{self.params_str()} must have one of the following types {','.join(WaveformUser.types)}."
|
||||||
)
|
)
|
||||||
raise
|
raise
|
||||||
if wavetype not in WaveformUser.types:
|
if wavetype not in WaveformUser.types:
|
||||||
logger.exception(
|
logger.exception(
|
||||||
f"{self.params_str()} must have one of the " + f"following types {','.join(WaveformUser.types)}."
|
f"{self.params_str()} must have one of the following types {','.join(WaveformUser.types)}."
|
||||||
)
|
)
|
||||||
raise ValueError
|
raise ValueError
|
||||||
|
|
||||||
@@ -267,7 +267,7 @@ class VoltageSource(UserObjectMulti):
|
|||||||
|
|
||||||
# Check if there is a waveformID in the waveforms list
|
# Check if there is a waveformID in the waveforms list
|
||||||
if not any(x.ID == waveform_id for x in grid.waveforms):
|
if not any(x.ID == waveform_id for x in grid.waveforms):
|
||||||
logger.exception(self.params_str() + (" there is no waveform with " "the identifier " f"{waveform_id}."))
|
logger.exception(self.params_str() + (" there is no waveform with " "the identifier {waveform_id}."))
|
||||||
raise ValueError
|
raise ValueError
|
||||||
|
|
||||||
v = VoltageSourceUser()
|
v = VoltageSourceUser()
|
||||||
@@ -296,7 +296,7 @@ class VoltageSource(UserObjectMulti):
|
|||||||
raise ValueError
|
raise ValueError
|
||||||
v.start = start
|
v.start = start
|
||||||
v.stop = min(stop, grid.timewindow)
|
v.stop = min(stop, grid.timewindow)
|
||||||
startstop = f" start time {v.start:g} secs, finish time " f"{v.stop:g} secs "
|
startstop = f" start time {v.start:g} secs, finish time {v.stop:g} secs "
|
||||||
except KeyError:
|
except KeyError:
|
||||||
v.start = 0
|
v.start = 0
|
||||||
v.stop = grid.timewindow
|
v.stop = grid.timewindow
|
||||||
@@ -386,7 +386,7 @@ class HertzianDipole(UserObjectMulti):
|
|||||||
|
|
||||||
# Check if there is a waveformID in the waveforms list
|
# Check if there is a waveformID in the waveforms list
|
||||||
if not any(x.ID == waveform_id for x in grid.waveforms):
|
if not any(x.ID == waveform_id for x in grid.waveforms):
|
||||||
logger.exception(f"{self.params_str()} there is no waveform " + f"with the identifier {waveform_id}.")
|
logger.exception(f"{self.params_str()} there is no waveform with the identifier {waveform_id}.")
|
||||||
raise ValueError
|
raise ValueError
|
||||||
|
|
||||||
h = HertzianDipoleUser()
|
h = HertzianDipoleUser()
|
||||||
@@ -415,18 +415,18 @@ class HertzianDipole(UserObjectMulti):
|
|||||||
stop = self.kwargs["stop"]
|
stop = self.kwargs["stop"]
|
||||||
if start < 0:
|
if start < 0:
|
||||||
logger.exception(
|
logger.exception(
|
||||||
f"{self.params_str()} delay of the initiation of the " + f"source should not be less than zero."
|
f"{self.params_str()} delay of the initiation of the source should not be less than zero."
|
||||||
)
|
)
|
||||||
raise ValueError
|
raise ValueError
|
||||||
if stop < 0:
|
if stop < 0:
|
||||||
logger.exception(f"{self.params_str()} time to remove the source " + f"should not be less than zero.")
|
logger.exception(f"{self.params_str()} time to remove the source should not be less than zero.")
|
||||||
raise ValueError
|
raise ValueError
|
||||||
if stop - start <= 0:
|
if stop - start <= 0:
|
||||||
logger.exception(f"{self.params_str()} duration of the source should not be zero or less.")
|
logger.exception(f"{self.params_str()} duration of the source should not be zero or less.")
|
||||||
raise ValueError
|
raise ValueError
|
||||||
h.start = start
|
h.start = start
|
||||||
h.stop = min(stop, grid.timewindow)
|
h.stop = min(stop, grid.timewindow)
|
||||||
startstop = f" start time {h.start:g} secs, finish time " f"{h.stop:g} secs "
|
startstop = f" start time {h.start:g} secs, finish time {h.stop:g} secs "
|
||||||
except KeyError:
|
except KeyError:
|
||||||
h.start = 0
|
h.start = 0
|
||||||
h.stop = grid.timewindow
|
h.stop = grid.timewindow
|
||||||
@@ -527,7 +527,7 @@ class MagneticDipole(UserObjectMulti):
|
|||||||
|
|
||||||
# Check if there is a waveformID in the waveforms list
|
# Check if there is a waveformID in the waveforms list
|
||||||
if not any(x.ID == waveform_id for x in grid.waveforms):
|
if not any(x.ID == waveform_id for x in grid.waveforms):
|
||||||
logger.exception(f"{self.params_str()} there is no waveform " + f"with the identifier {waveform_id}.")
|
logger.exception(f"{self.params_str()} there is no waveform with the identifier {waveform_id}.")
|
||||||
raise ValueError
|
raise ValueError
|
||||||
|
|
||||||
m = MagneticDipoleUser()
|
m = MagneticDipoleUser()
|
||||||
@@ -558,7 +558,7 @@ class MagneticDipole(UserObjectMulti):
|
|||||||
raise ValueError
|
raise ValueError
|
||||||
m.start = start
|
m.start = start
|
||||||
m.stop = min(stop, grid.timewindow)
|
m.stop = min(stop, grid.timewindow)
|
||||||
startstop = f" start time {m.start:g} secs, " f"finish time {m.stop:g} secs "
|
startstop = f" start time {m.start:g} secs, finish time {m.stop:g} secs "
|
||||||
except KeyError:
|
except KeyError:
|
||||||
m.start = 0
|
m.start = 0
|
||||||
m.stop = grid.timewindow
|
m.stop = grid.timewindow
|
||||||
@@ -568,7 +568,7 @@ class MagneticDipole(UserObjectMulti):
|
|||||||
|
|
||||||
logger.info(
|
logger.info(
|
||||||
f"{self.grid_name(grid)}Magnetic dipole with polarity "
|
f"{self.grid_name(grid)}Magnetic dipole with polarity "
|
||||||
+ f"{m.polarisation} at {p2[0]:g}m, {p2[1]:g}m, {p2[2]:g}m,"
|
f"{m.polarisation} at {p2[0]:g}m, {p2[1]:g}m, {p2[2]:g}m,"
|
||||||
+ startstop
|
+ startstop
|
||||||
+ f"using waveform {m.waveformID} created."
|
+ f"using waveform {m.waveformID} created."
|
||||||
)
|
)
|
||||||
@@ -627,8 +627,8 @@ class TransmissionLine(UserObjectMulti):
|
|||||||
if config.sim_config.general["solver"] in ["cuda", "opencl"]:
|
if config.sim_config.general["solver"] in ["cuda", "opencl"]:
|
||||||
logger.exception(
|
logger.exception(
|
||||||
f"{self.params_str()} cannot currently be used "
|
f"{self.params_str()} cannot currently be used "
|
||||||
+ "with the CUDA or OpenCL-based solver. Consider "
|
"with the CUDA or OpenCL-based solver. Consider "
|
||||||
+ "using a #voltage_source instead."
|
"using a #voltage_source instead."
|
||||||
)
|
)
|
||||||
raise ValueError
|
raise ValueError
|
||||||
|
|
||||||
@@ -661,14 +661,14 @@ class TransmissionLine(UserObjectMulti):
|
|||||||
if resistance <= 0 or resistance >= config.sim_config.em_consts["z0"]:
|
if resistance <= 0 or resistance >= config.sim_config.em_consts["z0"]:
|
||||||
logger.exception(
|
logger.exception(
|
||||||
f"{self.params_str()} requires a resistance "
|
f"{self.params_str()} requires a resistance "
|
||||||
+ "greater than zero and less than the impedance "
|
"greater than zero and less than the impedance "
|
||||||
+ "of free space, i.e. 376.73 Ohms."
|
"of free space, i.e. 376.73 Ohms."
|
||||||
)
|
)
|
||||||
raise ValueError
|
raise ValueError
|
||||||
|
|
||||||
# Check if there is a waveformID in the waveforms list
|
# Check if there is a waveformID in the waveforms list
|
||||||
if not any(x.ID == waveform_id for x in grid.waveforms):
|
if not any(x.ID == waveform_id for x in grid.waveforms):
|
||||||
logger.exception(f"{self.params_str()} there is no waveform " + f"with the identifier {waveform_id}.")
|
logger.exception(f"{self.params_str()} there is no waveform with the identifier {waveform_id}.")
|
||||||
raise ValueError
|
raise ValueError
|
||||||
|
|
||||||
t = TransmissionLineUser(grid)
|
t = TransmissionLineUser(grid)
|
||||||
@@ -697,7 +697,7 @@ class TransmissionLine(UserObjectMulti):
|
|||||||
raise ValueError
|
raise ValueError
|
||||||
t.start = start
|
t.start = start
|
||||||
t.stop = min(stop, grid.timewindow)
|
t.stop = min(stop, grid.timewindow)
|
||||||
startstop = f" start time {t.start:g} secs, finish time " + f"{t.stop:g} secs "
|
startstop = f" start time {t.start:g} secs, finish time {t.stop:g} secs "
|
||||||
except KeyError:
|
except KeyError:
|
||||||
t.start = 0
|
t.start = 0
|
||||||
t.stop = grid.timewindow
|
t.stop = grid.timewindow
|
||||||
@@ -846,19 +846,17 @@ class RxArray(UserObjectMulti):
|
|||||||
dx, dy, dz = uip.discretise_point(dl)
|
dx, dy, dz = uip.discretise_point(dl)
|
||||||
|
|
||||||
if xs > xf or ys > yf or zs > zf:
|
if xs > xf or ys > yf or zs > zf:
|
||||||
logger.exception(
|
logger.exception(f"{self.params_str()} the lower coordinates should be less than the upper coordinates.")
|
||||||
f"{self.params_str()} the lower coordinates " + "should be less than the upper coordinates."
|
|
||||||
)
|
|
||||||
raise ValueError
|
raise ValueError
|
||||||
if dx < 0 or dy < 0 or dz < 0:
|
if dx < 0 or dy < 0 or dz < 0:
|
||||||
logger.exception(f"{self.params_str()} the step size should not " + "be less than zero.")
|
logger.exception(f"{self.params_str()} the step size should not be less than zero.")
|
||||||
raise ValueError
|
raise ValueError
|
||||||
if dx < 1:
|
if dx < 1:
|
||||||
if dx == 0:
|
if dx == 0:
|
||||||
dx = 1
|
dx = 1
|
||||||
else:
|
else:
|
||||||
logger.exception(
|
logger.exception(
|
||||||
f"{self.params_str()} the step size should " + "not be less than the spatial discretisation."
|
f"{self.params_str()} the step size should not be less than the spatial discretisation."
|
||||||
)
|
)
|
||||||
raise ValueError
|
raise ValueError
|
||||||
if dy < 1:
|
if dy < 1:
|
||||||
@@ -866,7 +864,7 @@ class RxArray(UserObjectMulti):
|
|||||||
dy = 1
|
dy = 1
|
||||||
else:
|
else:
|
||||||
logger.exception(
|
logger.exception(
|
||||||
f"{self.params_str()} the step size should " + "not be less than the spatial discretisation."
|
f"{self.params_str()} the step size should not be less than the spatial discretisation."
|
||||||
)
|
)
|
||||||
raise ValueError
|
raise ValueError
|
||||||
if dz < 1:
|
if dz < 1:
|
||||||
@@ -874,7 +872,7 @@ class RxArray(UserObjectMulti):
|
|||||||
dz = 1
|
dz = 1
|
||||||
else:
|
else:
|
||||||
logger.exception(
|
logger.exception(
|
||||||
f"{self.params_str()} the step size should " + "not be less than the spatial discretisation."
|
f"{self.params_str()} the step size should not be less than the spatial discretisation."
|
||||||
)
|
)
|
||||||
raise ValueError
|
raise ValueError
|
||||||
|
|
||||||
@@ -974,7 +972,7 @@ class Snapshot(UserObjectMulti):
|
|||||||
if time > 0:
|
if time > 0:
|
||||||
iterations = round_value((time / grid.dt)) + 1
|
iterations = round_value((time / grid.dt)) + 1
|
||||||
else:
|
else:
|
||||||
logger.exception(f"{self.params_str()} time value must be " + "greater than zero.")
|
logger.exception(f"{self.params_str()} time value must be greater than zero.")
|
||||||
raise ValueError
|
raise ValueError
|
||||||
|
|
||||||
try:
|
try:
|
||||||
@@ -1009,12 +1007,10 @@ class Snapshot(UserObjectMulti):
|
|||||||
outputs = dict.fromkeys(SnapshotUser.allowableoutputs, True)
|
outputs = dict.fromkeys(SnapshotUser.allowableoutputs, True)
|
||||||
|
|
||||||
if dx < 0 or dy < 0 or dz < 0:
|
if dx < 0 or dy < 0 or dz < 0:
|
||||||
logger.exception(f"{self.params_str()} the step size should not " + "be less than zero.")
|
logger.exception(f"{self.params_str()} the step size should not be less than zero.")
|
||||||
raise ValueError
|
raise ValueError
|
||||||
if dx < 1 or dy < 1 or dz < 1:
|
if dx < 1 or dy < 1 or dz < 1:
|
||||||
logger.exception(
|
logger.exception(f"{self.params_str()} the step size should not be less than the spatial discretisation.")
|
||||||
f"{self.params_str()} the step size should not " + "be less than the spatial discretisation."
|
|
||||||
)
|
|
||||||
raise ValueError
|
raise ValueError
|
||||||
if iterations <= 0 or iterations > grid.iterations:
|
if iterations <= 0 or iterations > grid.iterations:
|
||||||
logger.exception(f"{self.params_str()} time value is not valid.")
|
logger.exception(f"{self.params_str()} time value is not valid.")
|
||||||
@@ -1064,26 +1060,26 @@ class Material(UserObjectMulti):
|
|||||||
|
|
||||||
if er < 1:
|
if er < 1:
|
||||||
logger.exception(
|
logger.exception(
|
||||||
f"{self.params_str()} requires a positive value of " + f"one or greater for static (DC) permittivity."
|
f"{self.params_str()} requires a positive value of one or greater for static (DC) permittivity."
|
||||||
)
|
)
|
||||||
raise ValueError
|
raise ValueError
|
||||||
if se != "inf":
|
if se != "inf":
|
||||||
se = float(se)
|
se = float(se)
|
||||||
if se < 0:
|
if se < 0:
|
||||||
logger.exception(f"{self.params_str()} requires a positive " + f"value for electric conductivity.")
|
logger.exception(f"{self.params_str()} requires a positive value for electric conductivity.")
|
||||||
raise ValueError
|
raise ValueError
|
||||||
else:
|
else:
|
||||||
se = float("inf")
|
se = float("inf")
|
||||||
if mr < 1:
|
if mr < 1:
|
||||||
logger.exception(
|
logger.exception(
|
||||||
f"{self.params_str()} requires a positive value of " + f"one or greater for magnetic permeability."
|
f"{self.params_str()} requires a positive value of one or greater for magnetic permeability."
|
||||||
)
|
)
|
||||||
raise ValueError
|
raise ValueError
|
||||||
if sm < 0:
|
if sm < 0:
|
||||||
logger.exception(f"{self.params_str()} requires a positive value " + f"for magnetic loss.")
|
logger.exception(f"{self.params_str()} requires a positive value for magnetic loss.")
|
||||||
raise ValueError
|
raise ValueError
|
||||||
if any(x.ID == material_id for x in grid.materials):
|
if any(x.ID == material_id for x in grid.materials):
|
||||||
logger.exception(f"{self.params_str()} with ID {material_id} " + f"already exists")
|
logger.exception(f"{self.params_str()} with ID {material_id} already exists")
|
||||||
raise ValueError
|
raise ValueError
|
||||||
|
|
||||||
# Create a new instance of the Material class material
|
# Create a new instance of the Material class material
|
||||||
@@ -1137,7 +1133,7 @@ class AddDebyeDispersion(UserObjectMulti):
|
|||||||
raise
|
raise
|
||||||
|
|
||||||
if poles < 0:
|
if poles < 0:
|
||||||
logger.exception(f"{self.params_str()} requires a positive value " + "for number of poles.")
|
logger.exception(f"{self.params_str()} requires a positive value for number of poles.")
|
||||||
raise ValueError
|
raise ValueError
|
||||||
|
|
||||||
# Look up requested materials in existing list of material instances
|
# Look up requested materials in existing list of material instances
|
||||||
@@ -1163,9 +1159,7 @@ class AddDebyeDispersion(UserObjectMulti):
|
|||||||
disp_material.deltaer.append(er_delta[i])
|
disp_material.deltaer.append(er_delta[i])
|
||||||
disp_material.tau.append(tau[i])
|
disp_material.tau.append(tau[i])
|
||||||
else:
|
else:
|
||||||
logger.exception(
|
logger.exception(f"{self.params_str()} requires positive values for the permittivity difference.")
|
||||||
f"{self.params_str()} requires positive " + "values for the permittivity difference."
|
|
||||||
)
|
|
||||||
raise ValueError
|
raise ValueError
|
||||||
if disp_material.poles > config.get_model_config().materials["maxpoles"]:
|
if disp_material.poles > config.get_model_config().materials["maxpoles"]:
|
||||||
config.get_model_config().materials["maxpoles"] = disp_material.poles
|
config.get_model_config().materials["maxpoles"] = disp_material.poles
|
||||||
@@ -1212,7 +1206,7 @@ class AddLorentzDispersion(UserObjectMulti):
|
|||||||
raise
|
raise
|
||||||
|
|
||||||
if poles < 0:
|
if poles < 0:
|
||||||
logger.exception(f"{self.params_str()} requires a positive value " + "for number of poles.")
|
logger.exception(f"{self.params_str()} requires a positive value for number of poles.")
|
||||||
raise ValueError
|
raise ValueError
|
||||||
|
|
||||||
# Look up requested materials in existing list of material instances
|
# Look up requested materials in existing list of material instances
|
||||||
@@ -1254,9 +1248,9 @@ class AddLorentzDispersion(UserObjectMulti):
|
|||||||
|
|
||||||
logger.info(
|
logger.info(
|
||||||
f"{self.grid_name(grid)}Lorentz disperion added to {disp_material.ID} "
|
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"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"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"and gamma={', '.join('%4.3e' % delta for delta in disp_material.alpha)} created."
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@@ -1284,11 +1278,11 @@ class AddDrudeDispersion(UserObjectMulti):
|
|||||||
alpha = self.kwargs["alpha"]
|
alpha = self.kwargs["alpha"]
|
||||||
material_ids = self.kwargs["material_ids"]
|
material_ids = self.kwargs["material_ids"]
|
||||||
except KeyError:
|
except KeyError:
|
||||||
logger.exception(f"{self.params_str()} requires at least four " + "parameters.")
|
logger.exception(f"{self.params_str()} requires at least four parameters.")
|
||||||
raise
|
raise
|
||||||
|
|
||||||
if poles < 0:
|
if poles < 0:
|
||||||
logger.exception(f"{self.params_str()} requires a positive value " + "for number of poles.")
|
logger.exception(f"{self.params_str()} requires a positive value for number of poles.")
|
||||||
raise ValueError
|
raise ValueError
|
||||||
|
|
||||||
# Look up requested materials in existing list of material instances
|
# Look up requested materials in existing list of material instances
|
||||||
@@ -1364,30 +1358,30 @@ class SoilPeplinski(UserObjectMulti):
|
|||||||
water_fraction_upper = self.kwargs["water_fraction_upper"]
|
water_fraction_upper = self.kwargs["water_fraction_upper"]
|
||||||
ID = self.kwargs["id"]
|
ID = self.kwargs["id"]
|
||||||
except KeyError:
|
except KeyError:
|
||||||
logger.exception(f"{self.params_str()} requires at exactly seven " + "parameters.")
|
logger.exception(f"{self.params_str()} requires at exactly seven parameters.")
|
||||||
raise
|
raise
|
||||||
|
|
||||||
if sand_fraction < 0:
|
if sand_fraction < 0:
|
||||||
logger.exception(f"{self.params_str()} requires a positive value " + "for the sand fraction.")
|
logger.exception(f"{self.params_str()} requires a positive value for the sand fraction.")
|
||||||
raise ValueError
|
raise ValueError
|
||||||
if clay_fraction < 0:
|
if clay_fraction < 0:
|
||||||
logger.exception(f"{self.params_str()} requires a positive value " + "for the clay fraction.")
|
logger.exception(f"{self.params_str()} requires a positive value for the clay fraction.")
|
||||||
raise ValueError
|
raise ValueError
|
||||||
if bulk_density < 0:
|
if bulk_density < 0:
|
||||||
logger.exception(f"{self.params_str()} requires a positive value " + "for the bulk density.")
|
logger.exception(f"{self.params_str()} requires a positive value for the bulk density.")
|
||||||
raise ValueError
|
raise ValueError
|
||||||
if sand_density < 0:
|
if sand_density < 0:
|
||||||
logger.exception(f"{self.params_str()} requires a positive value " + "for the sand particle density.")
|
logger.exception(f"{self.params_str()} requires a positive value for the sand particle density.")
|
||||||
raise ValueError
|
raise ValueError
|
||||||
if water_fraction_lower < 0:
|
if water_fraction_lower < 0:
|
||||||
logger.exception(
|
logger.exception(
|
||||||
f"{self.params_str()} requires a positive value " + "for the lower limit of the water volumetric "
|
f"{self.params_str()} requires a positive value for the lower limit of the water volumetric "
|
||||||
"fraction."
|
"fraction."
|
||||||
)
|
)
|
||||||
raise ValueError
|
raise ValueError
|
||||||
if water_fraction_upper < 0:
|
if water_fraction_upper < 0:
|
||||||
logger.exception(
|
logger.exception(
|
||||||
f"{self.params_str()} requires a positive value " + "for the upper limit of the water volumetric "
|
f"{self.params_str()} requires a positive value for the upper limit of the water volumetric "
|
||||||
"fraction."
|
"fraction."
|
||||||
)
|
)
|
||||||
raise ValueError
|
raise ValueError
|
||||||
@@ -1403,10 +1397,10 @@ class SoilPeplinski(UserObjectMulti):
|
|||||||
|
|
||||||
logger.info(
|
logger.info(
|
||||||
f"{self.grid_name(grid)}Mixing model (Peplinski) used to "
|
f"{self.grid_name(grid)}Mixing model (Peplinski) used to "
|
||||||
+ f"create {s.ID} with sand fraction {s.S:g}, clay fraction "
|
f"create {s.ID} with sand fraction {s.S:g}, clay fraction "
|
||||||
+ f"{s.C:g}, bulk density {s.rb:g}g/cm3, sand particle "
|
f"{s.C:g}, bulk density {s.rb:g}g/cm3, sand particle "
|
||||||
+ f"density {s.rs:g}g/cm3, and water volumetric fraction "
|
f"density {s.rs:g}g/cm3, and water volumetric fraction "
|
||||||
+ f"{s.mu[0]:g} to {s.mu[1]:g} created."
|
f"{s.mu[0]:g} to {s.mu[1]:g} created."
|
||||||
)
|
)
|
||||||
|
|
||||||
grid.mixingmodels.append(s)
|
grid.mixingmodels.append(s)
|
||||||
@@ -1444,46 +1438,44 @@ class MaterialRange(UserObjectMulti):
|
|||||||
ro_upper = self.kwargs["ro_upper"]
|
ro_upper = self.kwargs["ro_upper"]
|
||||||
ID = self.kwargs["id"]
|
ID = self.kwargs["id"]
|
||||||
except KeyError:
|
except KeyError:
|
||||||
logger.exception(f"{self.params_str()} requires at exactly nine " + "parameters.")
|
logger.exception(f"{self.params_str()} requires at exactly nine parameters.")
|
||||||
raise
|
raise
|
||||||
|
|
||||||
if er_lower < 1:
|
if er_lower < 1:
|
||||||
logger.exception(
|
logger.exception(
|
||||||
f"{self.params_str()} requires a value greater or equal to 1 "
|
f"{self.params_str()} requires a value greater or equal to 1 "
|
||||||
+ "for the lower range of relative permittivity."
|
"for the lower range of relative permittivity."
|
||||||
)
|
)
|
||||||
raise ValueError
|
raise ValueError
|
||||||
if mr_lower < 1:
|
if mr_lower < 1:
|
||||||
logger.exception(
|
logger.exception(
|
||||||
f"{self.params_str()} requires a value greater or equal to 1 "
|
f"{self.params_str()} requires a value greater or equal to 1 "
|
||||||
+ "for the lower range of relative magnetic permeability."
|
"for the lower range of relative magnetic permeability."
|
||||||
)
|
)
|
||||||
raise ValueError
|
raise ValueError
|
||||||
if sigma_lower < 0:
|
if sigma_lower < 0:
|
||||||
logger.exception(f"{self.params_str()} requires a positive value " + "for the lower limit of conductivity.")
|
logger.exception(f"{self.params_str()} requires a positive value for the lower limit of conductivity.")
|
||||||
raise ValueError
|
raise ValueError
|
||||||
if ro_lower < 0:
|
if ro_lower < 0:
|
||||||
logger.exception(f"{self.params_str()} requires a positive value " + "for the lower range magnetic loss.")
|
logger.exception(f"{self.params_str()} requires a positive value for the lower range magnetic loss.")
|
||||||
raise ValueError
|
raise ValueError
|
||||||
if er_upper < 1:
|
if er_upper < 1:
|
||||||
logger.exception(
|
logger.exception(
|
||||||
f"{self.params_str()} requires a value greater or equal to 1"
|
f"{self.params_str()} requires a value greater or equal to 1"
|
||||||
+ "for the upper range of relative permittivity."
|
"for the upper range of relative permittivity."
|
||||||
)
|
)
|
||||||
raise ValueError
|
raise ValueError
|
||||||
if mr_upper < 1:
|
if mr_upper < 1:
|
||||||
logger.exception(
|
logger.exception(
|
||||||
f"{self.params_str()} requires a value greater or equal to 1"
|
f"{self.params_str()} requires a value greater or equal to 1"
|
||||||
+ "for the upper range of relative magnetic permeability"
|
"for the upper range of relative magnetic permeability"
|
||||||
)
|
)
|
||||||
raise ValueError
|
raise ValueError
|
||||||
if sigma_upper < 0:
|
if sigma_upper < 0:
|
||||||
logger.exception(f"{self.params_str()} requires a positive value " + "for the upper range of conductivity.")
|
logger.exception(f"{self.params_str()} requires a positive value for the upper range of conductivity.")
|
||||||
raise ValueError
|
raise ValueError
|
||||||
if ro_upper < 0:
|
if ro_upper < 0:
|
||||||
logger.exception(
|
logger.exception(f"{self.params_str()} requires a positive value for the upper range of magnetic loss.")
|
||||||
f"{self.params_str()} requires a positive value " + "for the upper range of magnetic loss."
|
|
||||||
)
|
|
||||||
|
|
||||||
if any(x.ID == ID for x in grid.mixingmodels):
|
if any(x.ID == ID for x in grid.mixingmodels):
|
||||||
logger.exception(f"{self.params_str()} with ID {ID} already exists")
|
logger.exception(f"{self.params_str()} with ID {ID} already exists")
|
||||||
@@ -1495,9 +1487,9 @@ class MaterialRange(UserObjectMulti):
|
|||||||
|
|
||||||
logger.info(
|
logger.info(
|
||||||
f"{self.grid_name(grid)}Material properties used to "
|
f"{self.grid_name(grid)}Material properties used to "
|
||||||
+ f"create {s.ID} with range(s) {s.er[0]:g} to {s.er[1]:g}, relative permittivity "
|
f"create {s.ID} with range(s) {s.er[0]:g} to {s.er[1]:g}, relative permittivity "
|
||||||
+ f"{s.sig[0]:g} to {s.sig[1]:g}, S/m conductivity, {s.mu[0]:g} to {s.mu[1]:g} relative magnetic permeability "
|
f"{s.sig[0]:g} to {s.sig[1]:g}, S/m conductivity, {s.mu[0]:g} to {s.mu[1]:g} relative magnetic permeability "
|
||||||
+ f"{s.ro[0]:g} to {s.ro[1]:g} Ohm/m magnetic loss, created"
|
f"{s.ro[0]:g} to {s.ro[1]:g} Ohm/m magnetic loss, created"
|
||||||
)
|
)
|
||||||
|
|
||||||
grid.mixingmodels.append(s)
|
grid.mixingmodels.append(s)
|
||||||
@@ -1521,7 +1513,7 @@ class MaterialList(UserObjectMulti):
|
|||||||
list_of_materials = self.kwargs["list_of_materials"]
|
list_of_materials = self.kwargs["list_of_materials"]
|
||||||
ID = self.kwargs["id"]
|
ID = self.kwargs["id"]
|
||||||
except KeyError:
|
except KeyError:
|
||||||
logger.exception(f"{self.params_str()} requires at at least 2 " + "parameters.")
|
logger.exception(f"{self.params_str()} requires at at least 2 parameters.")
|
||||||
raise
|
raise
|
||||||
|
|
||||||
if any(x.ID == ID for x in grid.mixingmodels):
|
if any(x.ID == ID for x in grid.mixingmodels):
|
||||||
@@ -1530,9 +1522,7 @@ class MaterialList(UserObjectMulti):
|
|||||||
|
|
||||||
s = ListMaterialUser(ID, list_of_materials)
|
s = ListMaterialUser(ID, list_of_materials)
|
||||||
|
|
||||||
logger.info(
|
logger.info(f"{self.grid_name(grid)}A list of materials used to create {s.ID} that includes {s.mat}, created")
|
||||||
f"{self.grid_name(grid)}A list of materials used to " + f"create {s.ID} that includes {s.mat}, created"
|
|
||||||
)
|
|
||||||
|
|
||||||
grid.mixingmodels.append(s)
|
grid.mixingmodels.append(s)
|
||||||
|
|
||||||
@@ -1579,7 +1569,7 @@ class GeometryView(UserObjectMulti):
|
|||||||
output_type = self.kwargs["output_type"].lower()
|
output_type = self.kwargs["output_type"].lower()
|
||||||
filename = self.kwargs["filename"]
|
filename = self.kwargs["filename"]
|
||||||
except KeyError:
|
except KeyError:
|
||||||
logger.exception(f"{self.params_str()} requires exactly eleven " + "parameters.")
|
logger.exception(f"{self.params_str()} requires exactly eleven parameters.")
|
||||||
raise
|
raise
|
||||||
|
|
||||||
GeometryViewUser = self.geometry_view_constructor(grid, output_type)
|
GeometryViewUser = self.geometry_view_constructor(grid, output_type)
|
||||||
@@ -1597,25 +1587,23 @@ class GeometryView(UserObjectMulti):
|
|||||||
dx, dy, dz = uip.discretise_static_point(dl)
|
dx, dy, dz = uip.discretise_static_point(dl)
|
||||||
|
|
||||||
if dx < 0 or dy < 0 or dz < 0:
|
if dx < 0 or dy < 0 or dz < 0:
|
||||||
logger.exception(f"{self.params_str()} the step size should not be " + "less than zero.")
|
logger.exception(f"{self.params_str()} the step size should not be less than zero.")
|
||||||
raise ValueError
|
raise ValueError
|
||||||
if dx > grid.nx or dy > grid.ny or dz > grid.nz:
|
if dx > grid.nx or dy > grid.ny or dz > grid.nz:
|
||||||
logger.exception(f"{self.params_str()} the step size should be " + "less than the domain size.")
|
logger.exception(f"{self.params_str()} the step size should be less than the domain size.")
|
||||||
raise ValueError
|
raise ValueError
|
||||||
if dx < 1 or dy < 1 or dz < 1:
|
if dx < 1 or dy < 1 or dz < 1:
|
||||||
logger.exception(
|
logger.exception(f"{self.params_str()} the step size should not be less than the spatial discretisation.")
|
||||||
f"{self.params_str()} the step size should not " + "be less than the spatial discretisation."
|
|
||||||
)
|
|
||||||
raise ValueError
|
raise ValueError
|
||||||
if output_type not in ["n", "f"]:
|
if output_type not in ["n", "f"]:
|
||||||
logger.exception(f"{self.params_str()} requires type to be either " + "n (normal) or f (fine).")
|
logger.exception(f"{self.params_str()} requires type to be either n (normal) or f (fine).")
|
||||||
raise ValueError
|
raise ValueError
|
||||||
if output_type == "f" and (dx * grid.dx != grid.dx or dy * grid.dy != grid.dy or dz * grid.dz != grid.dz):
|
if output_type == "f" and (dx * grid.dx != grid.dx or dy * grid.dy != grid.dy or dz * grid.dz != grid.dz):
|
||||||
logger.exception(
|
logger.exception(
|
||||||
f"{self.params_str()} requires the spatial "
|
f"{self.params_str()} requires the spatial "
|
||||||
+ "discretisation for the geometry view to be the "
|
"discretisation for the geometry view to be the "
|
||||||
+ "same as the model for geometry view of "
|
"same as the model for geometry view of "
|
||||||
+ "type f (fine)"
|
"type f (fine)"
|
||||||
)
|
)
|
||||||
raise ValueError
|
raise ValueError
|
||||||
|
|
||||||
@@ -1623,10 +1611,10 @@ class GeometryView(UserObjectMulti):
|
|||||||
|
|
||||||
logger.info(
|
logger.info(
|
||||||
f"{self.grid_name(grid)}Geometry view from {p3[0]:g}m, "
|
f"{self.grid_name(grid)}Geometry view from {p3[0]:g}m, "
|
||||||
+ f"{p3[1]:g}m, {p3[2]:g}m, to {p4[0]:g}m, {p4[1]:g}m, "
|
f"{p3[1]:g}m, {p3[2]:g}m, to {p4[0]:g}m, {p4[1]:g}m, "
|
||||||
+ f"{p4[2]:g}m, discretisation {dx * grid.dx:g}m, "
|
f"{p4[2]:g}m, discretisation {dx * grid.dx:g}m, "
|
||||||
+ f"{dy * grid.dy:g}m, {dz * grid.dz:g}m, with filename "
|
f"{dy * grid.dy:g}m, {dz * grid.dz:g}m, with filename "
|
||||||
+ f"base {g.filename} created."
|
f"base {g.filename} created."
|
||||||
)
|
)
|
||||||
|
|
||||||
grid.geometryviews.append(g)
|
grid.geometryviews.append(g)
|
||||||
@@ -1656,7 +1644,7 @@ class GeometryObjectsWrite(UserObjectMulti):
|
|||||||
p2 = self.kwargs["p2"]
|
p2 = self.kwargs["p2"]
|
||||||
basefilename = self.kwargs["filename"]
|
basefilename = self.kwargs["filename"]
|
||||||
except KeyError:
|
except KeyError:
|
||||||
logger.exception(f"{self.params_str()} requires exactly seven " + "parameters.")
|
logger.exception(f"{self.params_str()} requires exactly seven parameters.")
|
||||||
raise
|
raise
|
||||||
|
|
||||||
p1, p2 = uip.check_box_points(p1, p2, self.params_str())
|
p1, p2 = uip.check_box_points(p1, p2, self.params_str())
|
||||||
@@ -1721,7 +1709,7 @@ class PMLCFS(UserObjectMulti):
|
|||||||
sigmamin = self.kwargs["sigmamin"]
|
sigmamin = self.kwargs["sigmamin"]
|
||||||
sigmamax = self.kwargs["sigmamax"]
|
sigmamax = self.kwargs["sigmamax"]
|
||||||
except KeyError:
|
except KeyError:
|
||||||
logger.exception(f"{self.params_str()} requires exactly twelve " + "parameters.")
|
logger.exception(f"{self.params_str()} requires exactly twelve parameters.")
|
||||||
raise
|
raise
|
||||||
|
|
||||||
if (
|
if (
|
||||||
@@ -1730,7 +1718,7 @@ class PMLCFS(UserObjectMulti):
|
|||||||
or sigmascalingprofile not in CFSParameter.scalingprofiles.keys()
|
or sigmascalingprofile not in CFSParameter.scalingprofiles.keys()
|
||||||
):
|
):
|
||||||
logger.exception(
|
logger.exception(
|
||||||
f"{self.params_str()} must have scaling type " + f"{','.join(CFSParameter.scalingprofiles.keys())}"
|
f"{self.params_str()} must have scaling type {','.join(CFSParameter.scalingprofiles.keys())}"
|
||||||
)
|
)
|
||||||
raise ValueError
|
raise ValueError
|
||||||
if (
|
if (
|
||||||
@@ -1738,9 +1726,7 @@ class PMLCFS(UserObjectMulti):
|
|||||||
or kappascalingdirection not in CFSParameter.scalingdirections
|
or kappascalingdirection not in CFSParameter.scalingdirections
|
||||||
or sigmascalingdirection not in CFSParameter.scalingdirections
|
or sigmascalingdirection not in CFSParameter.scalingdirections
|
||||||
):
|
):
|
||||||
logger.exception(
|
logger.exception(f"{self.params_str()} must have scaling type {','.join(CFSParameter.scalingdirections)}")
|
||||||
f"{self.params_str()} must have scaling type " + f"{','.join(CFSParameter.scalingdirections)}"
|
|
||||||
)
|
|
||||||
raise ValueError
|
raise ValueError
|
||||||
if (
|
if (
|
||||||
float(alphamin) < 0
|
float(alphamin) < 0
|
||||||
@@ -1749,7 +1735,7 @@ class PMLCFS(UserObjectMulti):
|
|||||||
or float(kappamax) < 0
|
or float(kappamax) < 0
|
||||||
or float(sigmamin) < 0
|
or float(sigmamin) < 0
|
||||||
):
|
):
|
||||||
logger.exception(f"{self.params_str()} minimum and maximum scaling " + "values must be greater than zero.")
|
logger.exception(f"{self.params_str()} minimum and maximum scaling values must be greater than zero.")
|
||||||
raise ValueError
|
raise ValueError
|
||||||
# TODO: Fix handling of kappa for 2nd order PMLs
|
# TODO: Fix handling of kappa for 2nd order PMLs
|
||||||
# if float(kappamin) < 1:
|
# if float(kappamin) < 1:
|
||||||
@@ -1795,7 +1781,7 @@ class PMLCFS(UserObjectMulti):
|
|||||||
grid.pmls["cfs"].append(cfs)
|
grid.pmls["cfs"].append(cfs)
|
||||||
|
|
||||||
if len(grid.pmls["cfs"]) > 2:
|
if len(grid.pmls["cfs"]) > 2:
|
||||||
logger.exception(f"{self.params_str()} can only be used up to two " + "times, for up to a 2nd order PML.")
|
logger.exception(f"{self.params_str()} can only be used up to two times, for up to a 2nd order PML.")
|
||||||
raise ValueError
|
raise ValueError
|
||||||
|
|
||||||
|
|
||||||
@@ -1814,4 +1800,4 @@ class Subgrid(UserObjectMulti):
|
|||||||
self.children_geometry.append(node)
|
self.children_geometry.append(node)
|
||||||
else:
|
else:
|
||||||
logger.exception("This object is unknown to gprMax.")
|
logger.exception("This object is unknown to gprMax.")
|
||||||
raise ValueError
|
raise ValueError
|
||||||
|
@@ -348,8 +348,8 @@ class SrcSteps(UserObjectSingle):
|
|||||||
|
|
||||||
logger.info(
|
logger.info(
|
||||||
f"Simple sources will step {G.srcsteps[0] * G.dx:g}m, "
|
f"Simple sources will step {G.srcsteps[0] * G.dx:g}m, "
|
||||||
+ f"{G.srcsteps[1] * G.dy:g}m, {G.srcsteps[2] * G.dz:g}m "
|
f"{G.srcsteps[1] * G.dy:g}m, {G.srcsteps[2] * G.dz:g}m "
|
||||||
+ "for each model run."
|
"for each model run."
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@@ -373,8 +373,8 @@ class RxSteps(UserObjectSingle):
|
|||||||
|
|
||||||
logger.info(
|
logger.info(
|
||||||
f"All receivers will step {G.rxsteps[0] * G.dx:g}m, "
|
f"All receivers will step {G.rxsteps[0] * G.dx:g}m, "
|
||||||
+ f"{G.rxsteps[1] * G.dy:g}m, {G.rxsteps[2] * G.dz:g}m "
|
f"{G.rxsteps[1] * G.dy:g}m, {G.rxsteps[2] * G.dz:g}m "
|
||||||
+ "for each model run."
|
"for each model run."
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@@ -418,8 +418,7 @@ class ExcitationFile(UserObjectSingle):
|
|||||||
logger.info(f"Excitation file: {excitationfile}")
|
logger.info(f"Excitation file: {excitationfile}")
|
||||||
|
|
||||||
# Get waveform names
|
# Get waveform names
|
||||||
with open(excitationfile, "r") as f:
|
waveformIDs = np.loadtxt(excitationfile, max_rows=1, dtype=str)
|
||||||
waveformIDs = f.readline().split()
|
|
||||||
|
|
||||||
# Read all waveform values into an array
|
# Read all waveform values into an array
|
||||||
waveformvalues = np.loadtxt(excitationfile, skiprows=1, dtype=config.sim_config.dtypes["float_or_double"])
|
waveformvalues = np.loadtxt(excitationfile, skiprows=1, dtype=config.sim_config.dtypes["float_or_double"])
|
||||||
@@ -434,12 +433,12 @@ class ExcitationFile(UserObjectSingle):
|
|||||||
waveformtime = np.arange(0, G.timewindow + G.dt, G.dt)
|
waveformtime = np.arange(0, G.timewindow + G.dt, G.dt)
|
||||||
timestr = "simulation time array"
|
timestr = "simulation time array"
|
||||||
|
|
||||||
for waveform in range(len(waveformIDs)):
|
for waveformID in waveformIDs:
|
||||||
if any(x.ID == waveformIDs[waveform] for x in G.waveforms):
|
if any(x.ID == waveformID for x in G.waveforms):
|
||||||
logger.exception(f"Waveform with ID {waveformIDs[waveform]} already exists")
|
logger.exception(f"Waveform with ID {waveformID} already exists")
|
||||||
raise ValueError
|
raise ValueError
|
||||||
w = Waveform()
|
w = Waveform()
|
||||||
w.ID = waveformIDs[waveform]
|
w.ID = waveformID
|
||||||
w.type = "user"
|
w.type = "user"
|
||||||
|
|
||||||
# Select correct column of waveform values depending on array shape
|
# Select correct column of waveform values depending on array shape
|
||||||
@@ -462,8 +461,8 @@ class ExcitationFile(UserObjectSingle):
|
|||||||
|
|
||||||
logger.info(
|
logger.info(
|
||||||
f"User waveform {w.ID} created using {timestr} and, if "
|
f"User waveform {w.ID} created using {timestr} and, if "
|
||||||
+ f"required, interpolation parameters (kind: {kwargs['kind']}, "
|
f"required, interpolation parameters (kind: {kwargs['kind']}, "
|
||||||
+ f"fill value: {kwargs['fill_value']})."
|
f"fill value: {kwargs['fill_value']})."
|
||||||
)
|
)
|
||||||
|
|
||||||
G.waveforms.append(w)
|
G.waveforms.append(w)
|
||||||
|
@@ -96,7 +96,7 @@ class Context:
|
|||||||
"""Prints the total simulation time based on context."""
|
"""Prints the total simulation time based on context."""
|
||||||
s = (
|
s = (
|
||||||
f"\n=== Simulation completed in "
|
f"\n=== Simulation completed in "
|
||||||
+ f"{humanize.precisedelta(datetime.timedelta(seconds=self.tsimend - self.tsimstart), format='%0.4f')}"
|
f"{humanize.precisedelta(datetime.timedelta(seconds=self.tsimend - self.tsimstart), format='%0.4f')}"
|
||||||
)
|
)
|
||||||
logger.basic(f"{s} {'=' * (get_terminal_width() - 1 - len(s))}\n")
|
logger.basic(f"{s} {'=' * (get_terminal_width() - 1 - len(s))}\n")
|
||||||
|
|
||||||
|
@@ -427,19 +427,11 @@ def dispersion_analysis(G):
|
|||||||
results["error"] = "user waveform detected."
|
results["error"] = "user waveform detected."
|
||||||
|
|
||||||
else:
|
else:
|
||||||
# User-defined waveform
|
# Time to analyse waveform - 4*pulse_width as using entire
|
||||||
if waveform.type == "user":
|
# time window can result in demanding FFT
|
||||||
iterations = G.iterations
|
waveform.calculate_coefficients()
|
||||||
|
iterations = round_value(4 * waveform.chi / G.dt)
|
||||||
# Built-in waveform
|
iterations = min(iterations, G.iterations)
|
||||||
else:
|
|
||||||
# Time to analyse waveform - 4*pulse_width as using entire
|
|
||||||
# time window can result in demanding FFT
|
|
||||||
waveform.calculate_coefficients()
|
|
||||||
iterations = round_value(4 * waveform.chi / G.dt)
|
|
||||||
if iterations > G.iterations:
|
|
||||||
iterations = G.iterations
|
|
||||||
|
|
||||||
waveformvalues = np.zeros(G.iterations)
|
waveformvalues = np.zeros(G.iterations)
|
||||||
for iteration in range(G.iterations):
|
for iteration in range(G.iterations):
|
||||||
waveformvalues[iteration] = waveform.calculate_value(iteration * G.dt, G.dt)
|
waveformvalues[iteration] = waveform.calculate_value(iteration * G.dt, G.dt)
|
||||||
|
@@ -185,8 +185,7 @@ def write_processed_file(processedlines):
|
|||||||
f.write(f"{item}")
|
f.write(f"{item}")
|
||||||
|
|
||||||
logger.info(
|
logger.info(
|
||||||
f"Written input commands, after processing any Python "
|
f"Written input commands, after processing any Python code and include commands, to file: {processedfile}\n"
|
||||||
+ f"code and include commands, to file: {processedfile}\n"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@@ -64,9 +64,7 @@ def process_singlecmds(singlecmds):
|
|||||||
if singlecmds[cmd] is not 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:
|
||||||
logger.exception(
|
logger.exception(f"{cmd} requires exactly one parameter to specify the number of CPU OpenMP threads to use")
|
||||||
f"{cmd} requires exactly one parameter to specify " + f"the number of CPU OpenMP threads to use"
|
|
||||||
)
|
|
||||||
raise ValueError
|
raise ValueError
|
||||||
|
|
||||||
omp_threads = OMPThreads(n=tmp[0])
|
omp_threads = OMPThreads(n=tmp[0])
|
||||||
@@ -106,7 +104,7 @@ def process_singlecmds(singlecmds):
|
|||||||
if len(tmp) != 1:
|
if len(tmp) != 1:
|
||||||
logger.exception(
|
logger.exception(
|
||||||
f"{cmd} requires exactly one parameter to specify the "
|
f"{cmd} requires exactly one parameter to specify the "
|
||||||
+ f"time window. Either in seconds or number of iterations."
|
f"time window. Either in seconds or number of iterations."
|
||||||
)
|
)
|
||||||
raise ValueError
|
raise ValueError
|
||||||
tmp = tmp[0].lower()
|
tmp = tmp[0].lower()
|
||||||
|
@@ -317,9 +317,8 @@ class PeplinskiSoil:
|
|||||||
# Check to see if the material already exists before creating a new one
|
# Check to see if the material already exists before creating a new one
|
||||||
requiredID = "|{:.4f}|".format(float(muiter[0]))
|
requiredID = "|{:.4f}|".format(float(muiter[0]))
|
||||||
material = next((x for x in G.materials if x.ID == requiredID), None)
|
material = next((x for x in G.materials if x.ID == requiredID), None)
|
||||||
if muiter.index == 0:
|
if muiter.index == 0 and material:
|
||||||
if material:
|
self.matID.append(material.numID)
|
||||||
self.matID.append(material.numID)
|
|
||||||
if not material:
|
if not material:
|
||||||
m = DispersiveMaterial(len(G.materials), requiredID)
|
m = DispersiveMaterial(len(G.materials), requiredID)
|
||||||
m.type = "debye"
|
m.type = "debye"
|
||||||
@@ -412,9 +411,8 @@ class RangeMaterial:
|
|||||||
# Check to see if the material already exists before creating a new one
|
# Check to see if the material already exists before creating a new one
|
||||||
requiredID = f"|{float(er):.4f}+{float(se):.4f}+{float(mr):.4f}+{float(sm):.4f}|"
|
requiredID = f"|{float(er):.4f}+{float(se):.4f}+{float(mr):.4f}+{float(sm):.4f}|"
|
||||||
material = next((x for x in G.materials if x.ID == requiredID), None)
|
material = next((x for x in G.materials if x.ID == requiredID), None)
|
||||||
if iter == 0:
|
if iter == 0 and material:
|
||||||
if material:
|
self.matID.append(material.numID)
|
||||||
self.matID.append(material.numID)
|
|
||||||
if not material:
|
if not material:
|
||||||
m = Material(len(G.materials), requiredID)
|
m = Material(len(G.materials), requiredID)
|
||||||
m.type = ""
|
m.type = ""
|
||||||
|
@@ -208,22 +208,7 @@ class Snapshot:
|
|||||||
G: FDTDGrid class describing a grid in a model.
|
G: FDTDGrid class describing a grid in a model.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
celldata = {}
|
celldata = {k: self.snapfields[k] for k in ["Ex", "Ey", "Ez", "Hx", "Hy", "Hz"] if self.outputs.get(k)}
|
||||||
|
|
||||||
for k, v in self.outputs.items():
|
|
||||||
if v:
|
|
||||||
if k == "Ex":
|
|
||||||
celldata[k] = self.snapfields["Ex"]
|
|
||||||
if k == "Ey":
|
|
||||||
celldata[k] = self.snapfields["Ey"]
|
|
||||||
if k == "Ez":
|
|
||||||
celldata[k] = self.snapfields["Ez"]
|
|
||||||
if k == "Hx":
|
|
||||||
celldata[k] = self.snapfields["Hx"]
|
|
||||||
if k == "Hy":
|
|
||||||
celldata[k] = self.snapfields["Hy"]
|
|
||||||
if k == "Hz":
|
|
||||||
celldata[k] = self.snapfields["Hz"]
|
|
||||||
|
|
||||||
imageToVTK(
|
imageToVTK(
|
||||||
str(self.filename.with_suffix("")),
|
str(self.filename.with_suffix("")),
|
||||||
@@ -255,24 +240,10 @@ class Snapshot:
|
|||||||
f.attrs["dx_dy_dz"] = (self.dx * G.dx, self.dy * G.dy, self.dz * G.dz)
|
f.attrs["dx_dy_dz"] = (self.dx * G.dx, self.dy * G.dy, self.dz * G.dz)
|
||||||
f.attrs["time"] = self.time * G.dt
|
f.attrs["time"] = self.time * G.dt
|
||||||
|
|
||||||
if self.outputs["Ex"]:
|
for key in ["Ex", "Ey", "Ez", "Hx", "Hy", "Hz"]:
|
||||||
f["Ex"] = self.snapfields["Ex"]
|
if self.outputs[key]:
|
||||||
pbar.update(n=self.snapfields["Ex"].nbytes)
|
f[key] = self.snapfields[key]
|
||||||
if self.outputs["Ey"]:
|
pbar.update(n=self.snapfields[key].nbytes)
|
||||||
f["Ey"] = self.snapfields["Ey"]
|
|
||||||
pbar.update(n=self.snapfields["Ey"].nbytes)
|
|
||||||
if self.outputs["Ez"]:
|
|
||||||
f["Ez"] = self.snapfields["Ez"]
|
|
||||||
pbar.update(n=self.snapfields["Ez"].nbytes)
|
|
||||||
if self.outputs["Hx"]:
|
|
||||||
f["Hx"] = self.snapfields["Hx"]
|
|
||||||
pbar.update(n=self.snapfields["Hx"].nbytes)
|
|
||||||
if self.outputs["Hy"]:
|
|
||||||
f["Hy"] = self.snapfields["Hy"]
|
|
||||||
pbar.update(n=self.snapfields["Hy"].nbytes)
|
|
||||||
if self.outputs["Hz"]:
|
|
||||||
f["Hz"] = self.snapfields["Hz"]
|
|
||||||
pbar.update(n=self.snapfields["Hz"].nbytes)
|
|
||||||
|
|
||||||
f.close()
|
f.close()
|
||||||
|
|
||||||
|
@@ -70,9 +70,9 @@ class UserInput:
|
|||||||
# Incorrect index
|
# Incorrect index
|
||||||
i = p[v.index(err.args[0])]
|
i = p[v.index(err.args[0])]
|
||||||
if name:
|
if name:
|
||||||
s = f"\n'{cmd_str}' {err.args[0]} {name}-coordinate {i * dl:g} " + "is not within the model domain"
|
s = f"\n'{cmd_str}' {err.args[0]} {name}-coordinate {i * dl:g} is not within the model domain"
|
||||||
else:
|
else:
|
||||||
s = f"\n'{cmd_str}' {err.args[0]}-coordinate {i * dl:g} is not " + "within the model domain"
|
s = f"\n'{cmd_str}' {err.args[0]}-coordinate {i * dl:g} is not within the model domain"
|
||||||
logger.exception(s)
|
logger.exception(s)
|
||||||
raise
|
raise
|
||||||
|
|
||||||
@@ -108,7 +108,7 @@ class MainGridUserInput(UserInput):
|
|||||||
p = self.check_point(p, cmd_str, name)
|
p = self.check_point(p, cmd_str, name)
|
||||||
|
|
||||||
if self.grid.within_pml(p):
|
if self.grid.within_pml(p):
|
||||||
logger.warning(f"'{cmd_str}' sources and receivers should not " + "normally be positioned within the PML.")
|
logger.warning(f"'{cmd_str}' sources and receivers should not normally be positioned within the PML.")
|
||||||
|
|
||||||
return p
|
return p
|
||||||
|
|
||||||
@@ -117,7 +117,7 @@ class MainGridUserInput(UserInput):
|
|||||||
p2 = self.check_point(p2, cmd_str, name="upper")
|
p2 = self.check_point(p2, cmd_str, name="upper")
|
||||||
|
|
||||||
if np.greater(p1, p2).any():
|
if np.greater(p1, p2).any():
|
||||||
logger.exception(f"'{cmd_str}' the lower coordinates should be less " + "than the upper coordinates.")
|
logger.exception(f"'{cmd_str}' the lower coordinates should be less than the upper coordinates.")
|
||||||
raise ValueError
|
raise ValueError
|
||||||
|
|
||||||
return p1, p2
|
return p1, p2
|
||||||
@@ -186,7 +186,7 @@ class SubgridUserInput(MainGridUserInput):
|
|||||||
# Provide user within a warning if they have placed objects within
|
# Provide user within a warning if they have placed objects within
|
||||||
# the OS non-working region.
|
# the OS non-working region.
|
||||||
if np.less(p_t, self.inner_bound).any() or np.greater(p_t, self.outer_bound).any():
|
if np.less(p_t, self.inner_bound).any() or np.greater(p_t, self.outer_bound).any():
|
||||||
logger.warning(f"'{cmd_str}' this object traverses the Outer " + "Surface. This is an advanced feature.")
|
logger.warning(f"'{cmd_str}' this object traverses the Outer Surface. This is an advanced feature.")
|
||||||
return p_t
|
return p_t
|
||||||
|
|
||||||
def discretise_static_point(self, p):
|
def discretise_static_point(self, p):
|
||||||
|
@@ -137,8 +137,8 @@ for i, model in enumerate(testmodels):
|
|||||||
if filetest[path + outputstest[0]].dtype != fileref[path + outputsref[0]].dtype:
|
if filetest[path + outputstest[0]].dtype != fileref[path + outputsref[0]].dtype:
|
||||||
logger.warning(
|
logger.warning(
|
||||||
f"Type of floating point number in test model "
|
f"Type of floating point number in test model "
|
||||||
+ f"({filetest[path + outputstest[0]].dtype}) does not "
|
f"({filetest[path + outputstest[0]].dtype}) does not "
|
||||||
+ f"match type in reference solution ({fileref[path + outputsref[0]].dtype})\n"
|
f"match type in reference solution ({fileref[path + outputsref[0]].dtype})\n"
|
||||||
)
|
)
|
||||||
float_or_doubleref = fileref[path + outputsref[0]].dtype
|
float_or_doubleref = fileref[path + outputsref[0]].dtype
|
||||||
float_or_doubletest = filetest[path + outputstest[0]].dtype
|
float_or_doubletest = filetest[path + outputstest[0]].dtype
|
||||||
@@ -271,11 +271,11 @@ for name, data in sorted(testresults.items()):
|
|||||||
if "analytical" in name:
|
if "analytical" in name:
|
||||||
logger.info(
|
logger.info(
|
||||||
f"Test '{name}.in' using v.{data['Test version']} compared "
|
f"Test '{name}.in' using v.{data['Test version']} compared "
|
||||||
+ f"to analytical solution. Max difference {data['Max diff']:.2f}dB."
|
f"to analytical solution. Max difference {data['Max diff']:.2f}dB."
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
logger.info(
|
logger.info(
|
||||||
f"Test '{name}.in' using v.{data['Test version']} compared to "
|
f"Test '{name}.in' using v.{data['Test version']} compared to "
|
||||||
+ f"reference solution using v.{data['Ref version']}. Max difference "
|
f"reference solution using v.{data['Ref version']}. Max difference "
|
||||||
+ f"{data['Max diff']:.2f}dB."
|
f"{data['Max diff']:.2f}dB."
|
||||||
)
|
)
|
||||||
|
@@ -169,10 +169,10 @@ if __name__ == "__main__":
|
|||||||
|
|
||||||
# Check waveform parameters
|
# Check waveform parameters
|
||||||
if args.type.lower() not in Waveform.types:
|
if args.type.lower() not in Waveform.types:
|
||||||
logging.exception(f"The waveform must have one of the following types " + f"{', '.join(Waveform.types)}")
|
logging.exception(f"The waveform must have one of the following types {', '.join(Waveform.types)}")
|
||||||
raise ValueError
|
raise ValueError
|
||||||
if args.freq <= 0:
|
if args.freq <= 0:
|
||||||
logging.exception("The waveform requires an excitation frequency value of " + "greater than zero")
|
logging.exception("The waveform requires an excitation frequency value of greater than zero")
|
||||||
raise ValueError
|
raise ValueError
|
||||||
|
|
||||||
# Create waveform instance
|
# Create waveform instance
|
||||||
|
@@ -55,11 +55,7 @@ class Cursor(object):
|
|||||||
) # Convert pixel values from float (0-1) to integer (0-255)
|
) # Convert pixel values from float (0-1) to integer (0-255)
|
||||||
match = pixel_match(materials, pixel)
|
match = pixel_match(materials, pixel)
|
||||||
if match is False:
|
if match is False:
|
||||||
logger.info(
|
logger.info(f"x, y: {int(x)} {int(y)} px; RGB: {pixel[:-1]}; material ID: {len(self.materials)}")
|
||||||
"x, y: {} {} px; RGB: {}; material ID: {}".format(
|
|
||||||
int(x), int(y), pixel[:-1], len(self.materials)
|
|
||||||
)
|
|
||||||
)
|
|
||||||
materials.append(pixel)
|
materials.append(pixel)
|
||||||
|
|
||||||
|
|
||||||
@@ -103,7 +99,7 @@ if __name__ == "__main__":
|
|||||||
imdata = np.rot90(im, k=3) # Rotate 90CW
|
imdata = np.rot90(im, k=3) # Rotate 90CW
|
||||||
imdata = np.floor(imdata * 255).astype(np.int16) # Convert pixel values from float (0-1) to integer (0-255)
|
imdata = np.floor(imdata * 255).astype(np.int16) # Convert pixel values from float (0-1) to integer (0-255)
|
||||||
|
|
||||||
logger.info("Reading PNG image file: {}".format(os.path.split(args.imagefile)[1]))
|
logger.info(f"Reading PNG image file: {os.path.split(args.imagefile)[1]}")
|
||||||
logger.info(
|
logger.info(
|
||||||
" 1. Select discrete material colours by clicking on parts of the image.\n 2. When all materials have been selected close the image."
|
" 1. Select discrete material colours by clicking on parts of the image.\n 2. When all materials have been selected close the image."
|
||||||
)
|
)
|
||||||
@@ -122,7 +118,7 @@ if __name__ == "__main__":
|
|||||||
dx_dy_dz = (args.dxdydz[0][0], args.dxdydz[0][1], args.dxdydz[0][2])
|
dx_dy_dz = (args.dxdydz[0][0], args.dxdydz[0][1], args.dxdydz[0][2])
|
||||||
|
|
||||||
# Filename for geometry (HDF5) file
|
# Filename for geometry (HDF5) file
|
||||||
hdf5file = os.path.splitext(args.imagefile)[0] + ".h5"
|
hdf5file = f"{os.path.splitext(args.imagefile)[0]}.h5"
|
||||||
|
|
||||||
# Array to store geometry data (initialised as background, i.e. -1)
|
# Array to store geometry data (initialised as background, i.e. -1)
|
||||||
data = np.ones((imdata.shape[0], imdata.shape[1], args.zcells), dtype=np.int16) * -1
|
data = np.ones((imdata.shape[0], imdata.shape[1], args.zcells), dtype=np.int16) * -1
|
||||||
@@ -140,4 +136,4 @@ if __name__ == "__main__":
|
|||||||
# Write data to file
|
# Write data to file
|
||||||
fout.create_dataset("data", data=data)
|
fout.create_dataset("data", data=data)
|
||||||
|
|
||||||
logger.info("Written HDF5 file: {}".format(os.path.split(hdf5file)[1]))
|
logger.info(f"Written HDF5 file: {os.path.split(hdf5file)[1]}")
|
||||||
|
在新工单中引用
屏蔽一个用户