Removed un-necessary concatenations while using f-strings.

这个提交包含在:
Sai-Suraj-27
2023-08-04 00:21:33 +05:30
父节点 68c069259a
当前提交 a87da89d94
共有 15 个文件被更改,包括 126 次插入138 次删除

查看文件

@@ -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."
) )