你已经派生过 gprMax
镜像自地址
https://gitee.com/sunhf/gprMax.git
已同步 2025-08-07 23:14:03 +08:00
updated a few lines of code to make them more cleaner.
这个提交包含在:
@@ -74,7 +74,7 @@ class AddGrass(UserObjectGeometry):
|
|||||||
limits = self.kwargs['limits']
|
limits = self.kwargs['limits']
|
||||||
n_blades = self.kwargs['n_blades']
|
n_blades = self.kwargs['n_blades']
|
||||||
except KeyError:
|
except KeyError:
|
||||||
logger.exception(self.__str__() + ' requires at least eleven parameters')
|
logger.exception(f'{self.__str__()} requires at least eleven parameters')
|
||||||
raise
|
raise
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
@@ -68,18 +68,16 @@ class AddSurfaceWater(UserObjectGeometry):
|
|||||||
fractal_box_id = self.kwargs['fractal_box_id']
|
fractal_box_id = self.kwargs['fractal_box_id']
|
||||||
depth = self.kwargs['depth']
|
depth = self.kwargs['depth']
|
||||||
except KeyError:
|
except KeyError:
|
||||||
logger.exception(self.__str__() + ' requires exactly eight parameters')
|
logger.exception(f'{self.__str__()} requires exactly eight parameters')
|
||||||
raise
|
raise
|
||||||
|
|
||||||
if self.do_rotate:
|
if self.do_rotate:
|
||||||
self._do_rotate()
|
self._do_rotate()
|
||||||
|
|
||||||
# Get the correct fractal volume
|
if volumes := [volume for volume in grid.fractalvolumes if volume.ID == fractal_box_id]:
|
||||||
volumes = [volume for volume in grid.fractalvolumes if volume.ID == fractal_box_id]
|
|
||||||
if volumes:
|
|
||||||
volume = volumes[0]
|
volume = volumes[0]
|
||||||
else:
|
else:
|
||||||
logger.exception(self.__str__() + f' cannot find FractalBox {fractal_box_id}')
|
logger.exception(f'{self.__str__()} cannot find FractalBox {fractal_box_id}')
|
||||||
raise ValueError
|
raise ValueError
|
||||||
|
|
||||||
p1, p2 = uip.check_box_points(p1, p2, self.__str__())
|
p1, p2 = uip.check_box_points(p1, p2, self.__str__())
|
||||||
@@ -87,18 +85,18 @@ class AddSurfaceWater(UserObjectGeometry):
|
|||||||
xf, yf, zf = p2
|
xf, yf, zf = p2
|
||||||
|
|
||||||
if depth <= 0:
|
if depth <= 0:
|
||||||
logger.exception(self.__str__() + ' requires a positive value for ' +
|
logger.exception(f'{self.__str__()} requires a positive value for the ' +
|
||||||
'the depth of water')
|
f'depth of water')
|
||||||
raise ValueError
|
raise ValueError
|
||||||
|
|
||||||
# Check for valid orientations
|
# Check for valid orientations
|
||||||
if xs == xf:
|
if xs == xf:
|
||||||
if ys == yf or zs == zf:
|
if ys == yf or zs == zf:
|
||||||
logger.exception(self.__str__() + ' dimensions are not specified correctly')
|
logger.exception(f'{self.__str__()} dimensions are not specified correctly')
|
||||||
raise ValueError
|
raise ValueError
|
||||||
if xs != volume.xs and xs != volume.xf:
|
if xs not in [volume.xs, volume.xf]:
|
||||||
logger.exception(self.__str__() + ' can only be used on the ' +
|
logger.exception(f'{self.__str__()} can only be used on the external surfaces '
|
||||||
'external surfaces of a fractal box')
|
f'of a fractal box')
|
||||||
raise ValueError
|
raise ValueError
|
||||||
# xminus surface
|
# xminus surface
|
||||||
if xs == volume.xs:
|
if xs == volume.xs:
|
||||||
@@ -110,12 +108,12 @@ class AddSurfaceWater(UserObjectGeometry):
|
|||||||
filldepth = filldepthcells * grid.dx
|
filldepth = filldepthcells * grid.dx
|
||||||
|
|
||||||
elif ys == yf:
|
elif ys == yf:
|
||||||
if xs == xf or zs == zf:
|
if zs == zf:
|
||||||
logger.exception(self.__str__() + ' dimensions are not specified correctly')
|
logger.exception(f'{self.__str__()} dimensions are not specified correctly')
|
||||||
raise ValueError
|
raise ValueError
|
||||||
if ys != volume.ys and ys != volume.yf:
|
if ys not in [volume.ys, volume.yf]:
|
||||||
logger.exception(self.__str__() + ' can only be used on the ' +
|
logger.exception(f'{self.__str__()} can only be used on the external surfaces ' +
|
||||||
'external surfaces of a fractal box')
|
f'of a fractal box')
|
||||||
raise ValueError
|
raise ValueError
|
||||||
# yminus surface
|
# yminus surface
|
||||||
if ys == volume.ys:
|
if ys == volume.ys:
|
||||||
@@ -127,12 +125,9 @@ class AddSurfaceWater(UserObjectGeometry):
|
|||||||
filldepth = filldepthcells * grid.dy
|
filldepth = filldepthcells * grid.dy
|
||||||
|
|
||||||
elif zs == zf:
|
elif zs == zf:
|
||||||
if xs == xf or ys == yf:
|
if zs not in [volume.zs, volume.zf]:
|
||||||
logger.exception(self.__str__() + ' dimensions are not specified correctly')
|
logger.exception(f'{self.__str__()} can only be used on the external surfaces '
|
||||||
raise ValueError
|
f'of a fractal box')
|
||||||
if zs != volume.zs and zs != volume.zf:
|
|
||||||
logger.exception(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:
|
||||||
@@ -144,38 +139,35 @@ class AddSurfaceWater(UserObjectGeometry):
|
|||||||
filldepth = filldepthcells * grid.dz
|
filldepth = filldepthcells * grid.dz
|
||||||
|
|
||||||
else:
|
else:
|
||||||
logger.exception(self.__str__() + ' dimensions are not specified correctly')
|
logger.exception(f'{self.__str__()} dimensions are not specified correctly')
|
||||||
raise ValueError
|
raise ValueError
|
||||||
|
|
||||||
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(self.__str__() + f' specified surface {requestedsurface} ' +
|
logger.exception(f'{self.__str__()} specified surface {requestedsurface} ' +
|
||||||
'does not have a rough surface applied')
|
f'does not have a rough surface applied')
|
||||||
raise ValueError
|
raise ValueError
|
||||||
|
|
||||||
surface.filldepth = filldepthcells
|
surface.filldepth = filldepthcells
|
||||||
|
|
||||||
# Check that requested fill depth falls within range of surface roughness
|
# Check that requested fill depth falls within range of surface roughness
|
||||||
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(self.__str__() + ' requires a value for the depth ' +
|
logger.exception(f'{self.__str__()} requires a value for the depth of water that lies with the ' +
|
||||||
'of water that lies with the range of the requested ' +
|
f'range of the requested surface roughness')
|
||||||
'surface roughness')
|
|
||||||
raise ValueError
|
raise ValueError
|
||||||
|
|
||||||
# Check to see if water has been already defined as a material
|
# Check to see if water has been already defined as a material
|
||||||
if not any(x.ID == 'water' for x in grid.materials):
|
if all(x.ID != 'water' for x in grid.materials):
|
||||||
create_water(grid)
|
create_water(grid)
|
||||||
|
|
||||||
# Check if time step for model is suitable for using water
|
# Check if time step for model is suitable for using water
|
||||||
water = next((x for x in grid.materials if x.ID == 'water'))
|
water = next((x for x in grid.materials if x.ID == 'water'))
|
||||||
testwater = next((x for x in water.tau if x < grid.dt), None)
|
if testwater := next((x for x in water.tau if x < grid.dt), None):
|
||||||
if testwater:
|
logger.exception(f'{self.__str__()} requires the time step for the model '
|
||||||
logger.exception(self.__str__() + ' requires the time step for the ' +
|
f'to be less than the relaxation time required to model water.')
|
||||||
'model to be less than the relaxation time required ' +
|
|
||||||
'to model water.')
|
|
||||||
raise ValueError
|
raise ValueError
|
||||||
|
|
||||||
logger.info(self.grid_name(grid) + f'Water on surface from {xs * grid.dx:g}m, ' +
|
logger.info(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}.')
|
||||||
|
@@ -65,7 +65,7 @@ class Box(UserObjectGeometry):
|
|||||||
p1 = self.kwargs['p1']
|
p1 = self.kwargs['p1']
|
||||||
p2 = self.kwargs['p2']
|
p2 = self.kwargs['p2']
|
||||||
except KeyError:
|
except KeyError:
|
||||||
logger.exception(self.__str__() + ' Please specify two points.')
|
logger.exception(f'{self.__str__()} Please specify two points.')
|
||||||
raise
|
raise
|
||||||
|
|
||||||
if self.do_rotate:
|
if self.do_rotate:
|
||||||
@@ -80,7 +80,7 @@ class Box(UserObjectGeometry):
|
|||||||
try:
|
try:
|
||||||
materialsrequested = self.kwargs['material_ids']
|
materialsrequested = self.kwargs['material_ids']
|
||||||
except KeyError:
|
except KeyError:
|
||||||
logger.exception(self.__str__() + ' No materials have been specified')
|
logger.exception(f'{self.__str__()} No materials have been specified')
|
||||||
raise
|
raise
|
||||||
|
|
||||||
# Check averaging
|
# Check averaging
|
||||||
@@ -103,7 +103,7 @@ class Box(UserObjectGeometry):
|
|||||||
|
|
||||||
if len(materials) != len(materialsrequested):
|
if len(materials) != len(materialsrequested):
|
||||||
notfound = [x for x in materialsrequested if x not in materials]
|
notfound = [x for x in materialsrequested if x not in materials]
|
||||||
logger.exception(self.__str__() + f' material(s) {notfound} do not exist')
|
logger.exception(f'{self.__str__()} material(s) {notfound} do not exist')
|
||||||
raise ValueError
|
raise ValueError
|
||||||
|
|
||||||
# Isotropic case
|
# Isotropic case
|
||||||
|
@@ -172,7 +172,11 @@ class MPIContext(Context):
|
|||||||
'should be equal to number of GPUs + 1.')
|
'should be equal to number of GPUs + 1.')
|
||||||
raise ValueError
|
raise ValueError
|
||||||
|
|
||||||
jobs = [{'i': i} for i in self.model_range]
|
# Create job list
|
||||||
|
jobs = []
|
||||||
|
for i in self.model_range:
|
||||||
|
jobs.append({'i': i})
|
||||||
|
|
||||||
# Send the workers to their work loop
|
# Send the workers to their work loop
|
||||||
executor.start()
|
executor.start()
|
||||||
if executor.is_master():
|
if executor.is_master():
|
||||||
|
在新工单中引用
屏蔽一个用户