你已经派生过 gprMax
镜像自地址
https://gitee.com/sunhf/gprMax.git
已同步 2025-08-08 07:24:19 +08:00
Tidying and docs for cone and ellipsoid
这个提交包含在:
@@ -46,7 +46,7 @@ class Cone(UserObjectGeometry):
|
||||
|
||||
def __init__(self, **kwargs):
|
||||
super().__init__(**kwargs)
|
||||
self.hash = '#cylinder'
|
||||
self.hash = '#cone'
|
||||
|
||||
def create(self, grid, uip):
|
||||
try:
|
||||
@@ -55,7 +55,7 @@ class Cone(UserObjectGeometry):
|
||||
r1 = self.kwargs['r1']
|
||||
r2 = self.kwargs['r2']
|
||||
except KeyError:
|
||||
logger.exception(f'{self.__str__()} please specify 2 points and two radii')
|
||||
logger.exception(f'{self.__str__()} please specify two points and two radii')
|
||||
raise
|
||||
|
||||
# Check averaging
|
||||
@@ -85,15 +85,17 @@ class Cone(UserObjectGeometry):
|
||||
x2, y2, z2 = uip.round_to_grid(p2)
|
||||
|
||||
if r1 < 0:
|
||||
logger.exception(f'{self.__str__()} the radius of the first face {r1:g} should be a positive value.')
|
||||
logger.exception(f'{self.__str__()} the radius of the first face ' +
|
||||
f'{r1:g} should be a positive value.')
|
||||
raise ValueError
|
||||
|
||||
if r2 < 0:
|
||||
logger.exception(f'{self.__str__()} the radius of the second face {r2:g} should be a positive value.')
|
||||
logger.exception(f'{self.__str__()} the radius of the second face ' +
|
||||
f'{r2:g} should be a positive value.')
|
||||
raise ValueError
|
||||
|
||||
if r1 == 0 and r2 == 0:
|
||||
logger.exception(f'{self.__str__()} not both radii can be zero.')
|
||||
logger.exception(f'{self.__str__()} both radii cannot be zero.')
|
||||
raise ValueError
|
||||
|
||||
# Look up requested materials in existing list of material instances
|
||||
@@ -137,8 +139,8 @@ class Cone(UserObjectGeometry):
|
||||
grid.materials.append(m)
|
||||
|
||||
build_cone(x1, y1, z1, x2, y2, z2, r1, r2, grid.dx, grid.dy, grid.dz,
|
||||
numID, numIDx, numIDy, numIDz, averaging, grid.solid,
|
||||
grid.rigidE, grid.rigidH, grid.ID)
|
||||
numID, numIDx, numIDy, numIDz, averaging, grid.solid,
|
||||
grid.rigidE, grid.rigidH, grid.ID)
|
||||
|
||||
dielectricsmoothing = 'on' if averaging else 'off'
|
||||
logger.info(f"{self.grid_name(grid)}Cone with face centres {p3[0]:g}m, " +
|
||||
|
@@ -32,9 +32,9 @@ class Ellipsoid(UserObjectGeometry):
|
||||
|
||||
Attributes:
|
||||
p1: list of the coordinates (x,y,z) of the centre of the ellipsoid.
|
||||
xr: float of x semiaxis of the ellipsoid.
|
||||
xy: float of y semiaxis of the ellipsoid.
|
||||
xz: float of z semiaxis of the ellipsoid.
|
||||
xr: float for x-semiaxis of the elliposid.
|
||||
xy: float for y-semiaxis of the ellipsoid.
|
||||
xz: float for z-semiaxis of the ellipsoid.
|
||||
material_id: string for the material identifier that must correspond
|
||||
to material that has already been defined.
|
||||
material_ids: list of material identifiers in the x, y, z directions.
|
||||
@@ -53,7 +53,8 @@ class Ellipsoid(UserObjectGeometry):
|
||||
zr = self.kwargs['zr']
|
||||
|
||||
except KeyError:
|
||||
logger.exception(f'{self.__str__()} please specify a point and the three semiaxes.')
|
||||
logger.exception(f'{self.__str__()} please specify a point and ' +
|
||||
f'the three semiaxes.')
|
||||
raise
|
||||
|
||||
# Check averaging
|
||||
@@ -76,9 +77,8 @@ class Ellipsoid(UserObjectGeometry):
|
||||
logger.exception(f'{self.__str__()} no materials have been specified')
|
||||
raise
|
||||
|
||||
# Centre of sphere
|
||||
# Centre of ellipsoid
|
||||
p2 = uip.round_to_grid_static_point(p1)
|
||||
#xc, yc, zc = uip.round_to_grid(p1)
|
||||
xc, yc, zc = uip.discretise_point(p1)
|
||||
|
||||
# Look up requested materials in existing list of material instances
|
||||
@@ -122,11 +122,12 @@ class Ellipsoid(UserObjectGeometry):
|
||||
grid.materials.append(m)
|
||||
|
||||
build_ellipsoid(xc, yc, zc, xr, yr, zr, grid.dx, grid.dy, grid.dz, numID,
|
||||
numIDx, numIDy, numIDz, averaging, grid.solid,
|
||||
grid.rigidE, grid.rigidH, grid.ID)
|
||||
numIDx, numIDy, numIDz, averaging, grid.solid,
|
||||
grid.rigidE, grid.rigidH, grid.ID)
|
||||
|
||||
dielectricsmoothing = 'on' if averaging else 'off'
|
||||
logger.info(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, y-semiaxis {yr:g}m and z-semiaxis {zr:g}m of material(s) " +
|
||||
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"{', '.join(materialsrequested)} created, dielectric " +
|
||||
f"smoothing is {dielectricsmoothing}.")
|
||||
|
@@ -70,16 +70,11 @@ class Sphere(UserObjectGeometry):
|
||||
except KeyError:
|
||||
logger.exception(f'{self.__str__()} no materials have been specified')
|
||||
raise
|
||||
|
||||
|
||||
# Centre of sphere
|
||||
|
||||
p2 = uip.round_to_grid_static_point(p1)
|
||||
#xc, yc, zc = uip.round_to_grid(p1)
|
||||
xc, yc, zc = uip.discretise_point(p1)
|
||||
|
||||
|
||||
|
||||
|
||||
# Look up requested materials in existing list of material instances
|
||||
materials = [y for x in materialsrequested for y in grid.materials if y.ID == x]
|
||||
|
||||
|
@@ -917,7 +917,6 @@ cpdef void build_cylinder(
|
||||
averaging, solid, rigidE, rigidH, ID)
|
||||
|
||||
|
||||
|
||||
cpdef void build_cone(
|
||||
float x1,
|
||||
float y1,
|
||||
@@ -966,7 +965,7 @@ cpdef void build_cone(
|
||||
|
||||
Rmax = np.amax([r1, r2])
|
||||
|
||||
# Check if cylinder is aligned with an axis
|
||||
# Check if cone is aligned with an axis
|
||||
x_align = y_align = z_align = 0
|
||||
# x-aligned
|
||||
if (round_value(y1 / dy) == round_value(y2 / dy) and
|
||||
@@ -983,7 +982,7 @@ cpdef void build_cone(
|
||||
round_value(y1 / dy) == round_value(y2 / dy)):
|
||||
z_align = 1
|
||||
|
||||
# Calculate a bounding box for the cylinder
|
||||
# Calculate a bounding box for the cone
|
||||
if x1 < x2:
|
||||
if x_align:
|
||||
xs = round_value(x1 / dx)
|
||||
@@ -1041,7 +1040,7 @@ cpdef void build_cone(
|
||||
if zf > solid.shape[2]:
|
||||
zf = solid.shape[2]
|
||||
|
||||
# x-aligned cylinder
|
||||
# x-aligned cone
|
||||
if x_align:
|
||||
for j in range(ys, yf):
|
||||
for k in range(zs, zf):
|
||||
@@ -1049,7 +1048,7 @@ cpdef void build_cone(
|
||||
if np.sqrt((j * dy + 0.5 * dy - y1)**2 + (k * dz + 0.5 * dz - z1)**2) <= ((i-xs)/(xf-xs))*(r2-r1) + r1:
|
||||
build_voxel(i, j, k, numID, numIDx, numIDy, numIDz,
|
||||
averaging, solid, rigidE, rigidH, ID)
|
||||
# y-aligned cylinder
|
||||
# y-aligned cone
|
||||
elif y_align:
|
||||
for i in range(xs, xf):
|
||||
for k in range(zs, zf):
|
||||
@@ -1057,7 +1056,7 @@ cpdef void build_cone(
|
||||
if np.sqrt((i * dx + 0.5 * dx - x1)**2 + (k * dz + 0.5 * dz - z1)**2) <= ((j-ys)/(yf-ys))*(r2-r1) + r1:
|
||||
build_voxel(i, j, k, numID, numIDx, numIDy, numIDz,
|
||||
averaging, solid, rigidE, rigidH, ID)
|
||||
# z-aligned cylinder
|
||||
# z-aligned cone
|
||||
elif z_align:
|
||||
for i in range(xs, xf):
|
||||
for j in range(ys, yf):
|
||||
@@ -1068,7 +1067,7 @@ cpdef void build_cone(
|
||||
|
||||
# Not aligned with any axis
|
||||
else:
|
||||
# Vectors between centres of cylinder faces
|
||||
# Vectors between centres of cone faces
|
||||
f1f2 = np.array([x2 - x1, y2 - y1, z2 - z1], dtype=np.float32)
|
||||
f2f1 = np.array([x1 - x2, y1 - y2, z1 - z2], dtype=np.float32)
|
||||
|
||||
@@ -1078,17 +1077,16 @@ cpdef void build_cone(
|
||||
|
||||
height = f1f2mag
|
||||
|
||||
|
||||
for i in range(xs, xf):
|
||||
for j in range(ys, yf):
|
||||
for k in range(zs, zf):
|
||||
# Build flag - default false, set to True if point is in cylinder
|
||||
# Build flag - default false, set to True if point is in cone
|
||||
build = 0
|
||||
# Vector from centre of first cylinder face to test point
|
||||
# Vector from centre of first cone face to test point
|
||||
f1pt = np.array([i * dx + 0.5 * dx - x1,
|
||||
j * dy + 0.5 * dy - y1,
|
||||
k * dz + 0.5 * dz - z1], dtype=np.float32)
|
||||
# Vector from centre of second cylinder face to test point
|
||||
# Vector from centre of second cone face to test point
|
||||
f2pt = np.array([i * dx + 0.5 * dx - x2,
|
||||
j * dy + 0.5 * dy - y2,
|
||||
k * dz + 0.5 * dz - z2], dtype=np.float32)
|
||||
@@ -1129,10 +1127,6 @@ cpdef void build_cone(
|
||||
averaging, solid, rigidE, rigidH, ID)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
cpdef void build_sphere(
|
||||
int xc,
|
||||
int yc,
|
||||
@@ -1269,7 +1263,6 @@ cpdef void build_ellipsoid(
|
||||
averaging, solid, rigidE, rigidH, ID)
|
||||
|
||||
|
||||
|
||||
cpdef void build_voxels_from_array(
|
||||
int xs,
|
||||
int ys,
|
||||
|
在新工单中引用
屏蔽一个用户