你已经派生过 gprMax
镜像自地址
https://gitee.com/sunhf/gprMax.git
已同步 2025-08-07 23:14:03 +08:00
Added logging and f-strings.
这个提交包含在:
@@ -28,9 +28,9 @@ from ..fractals import Grass
|
|||||||
from ..materials import Material
|
from ..materials import Material
|
||||||
from ..utilities import round_value
|
from ..utilities import round_value
|
||||||
|
|
||||||
|
|
||||||
log = logging.getLogger(__name__)
|
log = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
class AddGrass(UserObjectGeometry):
|
class AddGrass(UserObjectGeometry):
|
||||||
"""Allows you to add grass with roots to a :class:`gprMax.cmds_geometry.fractal_box.FractalBox` in the model.
|
"""Allows you to add grass with roots to a :class:`gprMax.cmds_geometry.fractal_box.FractalBox` in the model.
|
||||||
|
|
||||||
@@ -49,7 +49,6 @@ class AddGrass(UserObjectGeometry):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, **kwargs):
|
def __init__(self, **kwargs):
|
||||||
"""Constructor."""
|
|
||||||
super().__init__(**kwargs)
|
super().__init__(**kwargs)
|
||||||
self.order = 12
|
self.order = 12
|
||||||
self.hash = '#add_grass'
|
self.hash = '#add_grass'
|
||||||
@@ -195,5 +194,8 @@ class AddGrass(UserObjectGeometry):
|
|||||||
|
|
||||||
volume.fractalsurfaces.append(surface)
|
volume.fractalsurfaces.append(surface)
|
||||||
|
|
||||||
if config.is_messages():
|
log.info(f'{n_blades} blades of grass on surface from {xs * grid.dx:g}m, \
|
||||||
tqdm.write(f'{n_blades} blades of grass on surface from {xs * grid.dx:g}m, {ys * grid.dy:g}m, {zs * grid.dz:g}m, to {xf * grid.dx:g}m, {yf * grid.dy:g}m, {zf * grid.dz:g}m with fractal dimension {surface.dimension:g}, fractal seeding {surface.seed}, and range {limits[0]:g}m to {limits[1]:g}m, added to {surface.operatingonID}.')
|
{ys * grid.dy:g}m, {zs * grid.dz:g}m, to {xf * grid.dx:g}m, \
|
||||||
|
{yf * grid.dy:g}m, {zf * grid.dz:g}m with fractal dimension \
|
||||||
|
{surface.dimension:g}, fractal seeding {surface.seed}, and range \
|
||||||
|
{limits[0]:g}m to {limits[1]:g}m, added to {surface.operatingonID}.')
|
||||||
|
@@ -50,7 +50,6 @@ class AddSurfaceRoughness(UserObjectGeometry):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, **kwargs):
|
def __init__(self, **kwargs):
|
||||||
"""Constructor."""
|
|
||||||
super().__init__(**kwargs)
|
super().__init__(**kwargs)
|
||||||
self.order = 10
|
self.order = 10
|
||||||
self.hash = '#add_surface_roughness'
|
self.hash = '#add_surface_roughness'
|
||||||
@@ -160,5 +159,9 @@ class AddSurfaceRoughness(UserObjectGeometry):
|
|||||||
surface.generate_fractal_surface(grid)
|
surface.generate_fractal_surface(grid)
|
||||||
volume.fractalsurfaces.append(surface)
|
volume.fractalsurfaces.append(surface)
|
||||||
|
|
||||||
if config.is_messages():
|
log.info(f'Fractal surface from {xs * grid.dx:g}m, {ys * grid.dy:g}m, \
|
||||||
log.info(f'Fractal surface from {xs * grid.dx:g}m, {ys * grid.dy:g}m, {zs * grid.dz:g}m, to {xf * grid.dx:g}m, {yf * grid.dy:g}m, {zf * grid.dz:g}m with fractal dimension {surface.dimension:g}, fractal weightings {surface.weighting[0]:g}, {surface.weighting[1]:g}, fractal seeding {surface.seed}, and range {limits[0]:g}m to {limits[1]:g}m, added to {surface.operatingonID}.')
|
{zs * grid.dz:g}m, to {xf * grid.dx:g}m, {yf * grid.dy:g}m, \
|
||||||
|
{zf * grid.dz:g}m with fractal dimension {surface.dimension:g}, \
|
||||||
|
fractal weightings {surface.weighting[0]:g}, {surface.weighting[1]:g}, \
|
||||||
|
fractal seeding {surface.seed}, and range {limits[0]:g}m to \
|
||||||
|
{limits[1]:g}m, added to {surface.operatingonID}.')
|
||||||
|
@@ -24,9 +24,9 @@ from ..exceptions import CmdInputError
|
|||||||
from ..materials import Material
|
from ..materials import Material
|
||||||
from ..utilities import round_value
|
from ..utilities import round_value
|
||||||
|
|
||||||
|
|
||||||
log = logging.getLogger(__name__)
|
log = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
class AddSurfaceWater(UserObjectGeometry):
|
class AddSurfaceWater(UserObjectGeometry):
|
||||||
"""Allows you to add surface water to a :class:`gprMax.cmds_geometry.fractal_box.FractalBox` in the model.
|
"""Allows you to add surface water to a :class:`gprMax.cmds_geometry.fractal_box.FractalBox` in the model.
|
||||||
|
|
||||||
@@ -41,7 +41,6 @@ class AddSurfaceWater(UserObjectGeometry):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, **kwargs):
|
def __init__(self, **kwargs):
|
||||||
"""Constructor."""
|
|
||||||
super().__init__(**kwargs)
|
super().__init__(**kwargs)
|
||||||
self.order = 11
|
self.order = 11
|
||||||
self.hash = '#add_surface_water'
|
self.hash = '#add_surface_water'
|
||||||
@@ -144,5 +143,7 @@ class AddSurfaceWater(UserObjectGeometry):
|
|||||||
if testwater:
|
if testwater:
|
||||||
raise CmdInputError(self.__str__() + ' requires the time step for the model to be less than the relaxation time required to model water.')
|
raise CmdInputError(self.__str__() + ' requires the time step for the model to be less than the relaxation time required to model water.')
|
||||||
|
|
||||||
if config.is_messages():
|
log.info(f'Water on surface from {xs * grid.dx:g}m, {ys * grid.dy:g}m, \
|
||||||
log.info('Water on surface from {xs * grid.dx:g}m, {ys * grid.dy:g}m, {zs * grid.dz:g}m, to {xf * grid.dx:g}m, {yf * grid.dy:g}m, {zf * grid.dz:g}m with depth {filldepth:g}m, added to {surface.operatingonID}.')
|
{zs * grid.dz:g}m, to {xf * grid.dx:g}m, {yf * grid.dy:g}m, \
|
||||||
|
{zf * grid.dz:g}m with depth {filldepth:g}m, added to \
|
||||||
|
{surface.operatingonID}.')
|
||||||
|
@@ -16,8 +16,9 @@
|
|||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with gprMax. If not, see <http://www.gnu.org/licenses/>.
|
# along with gprMax. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
import logging
|
||||||
|
|
||||||
import numpy as np
|
import numpy as np
|
||||||
from tqdm import tqdm
|
|
||||||
|
|
||||||
import gprMax.config as config
|
import gprMax.config as config
|
||||||
from .cmds_geometry import UserObjectGeometry
|
from .cmds_geometry import UserObjectGeometry
|
||||||
@@ -25,6 +26,8 @@ from ..cython.geometry_primitives import build_box
|
|||||||
from ..exceptions import CmdInputError
|
from ..exceptions import CmdInputError
|
||||||
from ..materials import Material
|
from ..materials import Material
|
||||||
|
|
||||||
|
log = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
class Box(UserObjectGeometry):
|
class Box(UserObjectGeometry):
|
||||||
"""Allows you to introduce an orthogonal parallelepiped with specific properties into the model.
|
"""Allows you to introduce an orthogonal parallelepiped with specific properties into the model.
|
||||||
@@ -42,7 +45,6 @@ class Box(UserObjectGeometry):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, **kwargs):
|
def __init__(self, **kwargs):
|
||||||
"""Constructor."""
|
|
||||||
super().__init__(**kwargs)
|
super().__init__(**kwargs)
|
||||||
self.order = 5
|
self.order = 5
|
||||||
self.hash = '#box'
|
self.hash = '#box'
|
||||||
@@ -114,9 +116,8 @@ class Box(UserObjectGeometry):
|
|||||||
|
|
||||||
build_box(xs, xf, ys, yf, zs, zf, numID, numIDx, numIDy, numIDz, averaging, grid.solid, grid.rigidE, grid.rigidH, grid.ID)
|
build_box(xs, xf, ys, yf, zs, zf, numID, numIDx, numIDy, numIDz, averaging, grid.solid, grid.rigidE, grid.rigidH, grid.ID)
|
||||||
|
|
||||||
if config.is_messages():
|
dielectricsmoothing = 'on' if averaging else 'off'
|
||||||
if averaging:
|
log.info(f"Box from {xs * grid.dx:g}m, {ys * grid.dy:g}m, {zs * grid.dz:g}m, \
|
||||||
dielectricsmoothing = 'on'
|
to {xf * grid.dx:g}m, {yf * grid.dy:g}m, {zf * grid.dz:g}m of \
|
||||||
else:
|
material(s) {', '.join(materialsrequested)} created, dielectric \
|
||||||
dielectricsmoothing = 'off'
|
smoothing is {dielectricsmoothing}.")
|
||||||
tqdm.write('Box from {:g}m, {:g}m, {:g}m, to {:g}m, {:g}m, {:g}m of material(s) {} created, dielectric smoothing is {}.'.format(xs * grid.dx, ys * grid.dy, zs * grid.dz, xf * grid.dx, yf * grid.dy, zf * grid.dz, ', '.join(materialsrequested), dielectricsmoothing))
|
|
||||||
|
@@ -16,12 +16,15 @@
|
|||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with gprMax. If not, see <http://www.gnu.org/licenses/>.
|
# along with gprMax. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
import logging
|
||||||
|
|
||||||
|
log = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
class UserObjectGeometry:
|
class UserObjectGeometry:
|
||||||
"""Specific Geometry object."""
|
"""Specific Geometry object."""
|
||||||
|
|
||||||
def __init__(self, **kwargs):
|
def __init__(self, **kwargs):
|
||||||
"""Constructor."""
|
|
||||||
self.kwargs = kwargs
|
self.kwargs = kwargs
|
||||||
# define the order of priority for calling create()
|
# define the order of priority for calling create()
|
||||||
self.order = None
|
self.order = None
|
||||||
@@ -39,7 +42,7 @@ class UserObjectGeometry:
|
|||||||
v = ' '.join([str(el) for el in v])
|
v = ' '.join([str(el) for el in v])
|
||||||
s += str(v) + ' '
|
s += str(v) + ' '
|
||||||
|
|
||||||
return '{}: {}'.format(self.hash, s[:-1])
|
return f'{self.hash}: {s[:-1]}'
|
||||||
|
|
||||||
def params_str(self):
|
def params_str(self):
|
||||||
"""Readble string of parameters given to object."""
|
"""Readble string of parameters given to object."""
|
||||||
@@ -47,3 +50,4 @@ class UserObjectGeometry:
|
|||||||
|
|
||||||
def create(self, grid, uip):
|
def create(self, grid, uip):
|
||||||
"""Create the object and add it to the grid."""
|
"""Create the object and add it to the grid."""
|
||||||
|
log.debug('This method is incomplete')
|
||||||
|
@@ -16,8 +16,8 @@
|
|||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with gprMax. If not, see <http://www.gnu.org/licenses/>.
|
# along with gprMax. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
import logging
|
||||||
import numpy as np
|
import numpy as np
|
||||||
from tqdm import tqdm
|
|
||||||
|
|
||||||
import gprMax.config as config
|
import gprMax.config as config
|
||||||
from .cmds_geometry import UserObjectGeometry
|
from .cmds_geometry import UserObjectGeometry
|
||||||
@@ -25,6 +25,8 @@ from ..cython.geometry_primitives import build_cylinder
|
|||||||
from ..exceptions import CmdInputError
|
from ..exceptions import CmdInputError
|
||||||
from ..materials import Material
|
from ..materials import Material
|
||||||
|
|
||||||
|
log = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
class Cylinder(UserObjectGeometry):
|
class Cylinder(UserObjectGeometry):
|
||||||
"""Allows you to introduce a circular cylinder into the model.
|
"""Allows you to introduce a circular cylinder into the model.
|
||||||
@@ -42,14 +44,13 @@ class Cylinder(UserObjectGeometry):
|
|||||||
:param averaging: y or n, used to switch on and off dielectric smoothing.
|
:param averaging: y or n, used to switch on and off dielectric smoothing.
|
||||||
:type averaging: str, non-optional
|
:type averaging: str, non-optional
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, **kwargs):
|
def __init__(self, **kwargs):
|
||||||
"""Constructor."""
|
|
||||||
super().__init__(**kwargs)
|
super().__init__(**kwargs)
|
||||||
self.order = 6
|
self.order = 6
|
||||||
self.hash = '#cylinder'
|
self.hash = '#cylinder'
|
||||||
|
|
||||||
def create(self, grid, uip):
|
def create(self, grid, uip):
|
||||||
|
|
||||||
try:
|
try:
|
||||||
p1 = self.kwargs['p1']
|
p1 = self.kwargs['p1']
|
||||||
p2 = self.kwargs['p2']
|
p2 = self.kwargs['p2']
|
||||||
@@ -120,9 +121,7 @@ class Cylinder(UserObjectGeometry):
|
|||||||
|
|
||||||
build_cylinder(x1, y1, z1, x2, y2, z2, r, grid.dx, grid.dy, grid.dz, numID, numIDx, numIDy, numIDz, averaging, grid.solid, grid.rigidE, grid.rigidH, grid.ID)
|
build_cylinder(x1, y1, z1, x2, y2, z2, r, grid.dx, grid.dy, grid.dz, numID, numIDx, numIDy, numIDz, averaging, grid.solid, grid.rigidE, grid.rigidH, grid.ID)
|
||||||
|
|
||||||
if config.is_messages():
|
dielectricsmoothing = 'on' if averaging else 'off'
|
||||||
if averaging:
|
log.info(f"Cylinder with face centres {x1:g}m, {y1:g}m, {z1:g}m and {x2:g}m, \
|
||||||
dielectricsmoothing = 'on'
|
{y2:g}m, {z2:g}m, with radius {r:g}m, of material(s) {', '.join(materialsrequested)} \
|
||||||
else:
|
created, dielectric smoothing is {dielectricsmoothing}."
|
||||||
dielectricsmoothing = 'off'
|
|
||||||
tqdm.write('Cylinder with face centres {:g}m, {:g}m, {:g}m and {:g}m, {:g}m, {:g}m, with radius {:g}m, of material(s) {} created, dielectric smoothing is {}.'.format(x1, y1, z1, x2, y2, z2, r, ', '.join(materialsrequested), dielectricsmoothing))
|
|
||||||
|
@@ -16,8 +16,9 @@
|
|||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with gprMax. If not, see <http://www.gnu.org/licenses/>.
|
# along with gprMax. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
import logging
|
||||||
|
|
||||||
import numpy as np
|
import numpy as np
|
||||||
from tqdm import tqdm
|
|
||||||
|
|
||||||
import gprMax.config as config
|
import gprMax.config as config
|
||||||
from .cmds_geometry import UserObjectGeometry
|
from .cmds_geometry import UserObjectGeometry
|
||||||
@@ -25,6 +26,8 @@ from ..cython.geometry_primitives import build_cylindrical_sector
|
|||||||
from ..exceptions import CmdInputError
|
from ..exceptions import CmdInputError
|
||||||
from ..materials import Material
|
from ..materials import Material
|
||||||
|
|
||||||
|
log = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
class CylindricalSector(UserObjectGeometry):
|
class CylindricalSector(UserObjectGeometry):
|
||||||
"""Allows you to introduce a cylindrical sector (shaped like a slice of pie) into the model.
|
"""Allows you to introduce a cylindrical sector (shaped like a slice of pie) into the model.
|
||||||
@@ -54,7 +57,6 @@ class CylindricalSector(UserObjectGeometry):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, **kwargs):
|
def __init__(self, **kwargs):
|
||||||
"""Constructor."""
|
|
||||||
super().__init__(**kwargs)
|
super().__init__(**kwargs)
|
||||||
self.order = 7
|
self.order = 7
|
||||||
self.hash = '#cylindrical_sector'
|
self.hash = '#cylindrical_sector'
|
||||||
@@ -168,12 +170,16 @@ class CylindricalSector(UserObjectGeometry):
|
|||||||
|
|
||||||
build_cylindrical_sector(ctr1, ctr2, level, sectorstartangle, sectorangle, r, normal, thickness, grid.dx, grid.dy, grid.dz, numID, numIDx, numIDy, numIDz, averaging, grid.solid, grid.rigidE, grid.rigidH, grid.ID)
|
build_cylindrical_sector(ctr1, ctr2, level, sectorstartangle, sectorangle, r, normal, thickness, grid.dx, grid.dy, grid.dz, numID, numIDx, numIDy, numIDz, averaging, grid.solid, grid.rigidE, grid.rigidH, grid.ID)
|
||||||
|
|
||||||
if config.is_messages():
|
|
||||||
if thickness > 0:
|
if thickness > 0:
|
||||||
if averaging:
|
dielectricsmoothing = 'on' if averaging else 'off'
|
||||||
dielectricsmoothing = 'on'
|
log.info(f"Cylindrical sector with centre {ctr1:g}m, {ctr2:g}m, \
|
||||||
|
radius {r:g}m, starting angle {(sectorstartangle / (2 * np.pi)) * 360:.1f} \
|
||||||
|
degrees, sector angle {(sectorangle / (2 * np.pi)) * 360:.1f} \
|
||||||
|
degrees, thickness {thickness:g}m, of material(s) \
|
||||||
|
{', '.join(materialsrequested)} created, dielectric smoothing \
|
||||||
|
is {dielectricsmoothing}.")
|
||||||
else:
|
else:
|
||||||
dielectricsmoothing = 'off'
|
log.info(f"Cylindrical sector with centre {ctr1:g}m, {ctr2:g}m, \
|
||||||
tqdm.write('Cylindrical sector with centre {:g}m, {:g}m, radius {:g}m, starting angle {:.1f} degrees, sector angle {:.1f} degrees, thickness {:g}m, of material(s) {} created, dielectric smoothing is {}.'.format(ctr1, ctr2, r, (sectorstartangle / (2 * np.pi)) * 360, (sectorangle / (2 * np.pi)) * 360, thickness, ', '.join(materialsrequested), dielectricsmoothing))
|
radius {r:g}m, starting angle {(sectorstartangle / (2 * np.pi)) * 360:.1f} \
|
||||||
else:
|
degrees, sector angle {(sectorangle / (2 * np.pi)) * 360:.1f} \
|
||||||
tqdm.write('Cylindrical sector with centre {:g}m, {:g}m, radius {:g}m, starting angle {:.1f} degrees, sector angle {:.1f} degrees, of material(s) {} created.'.format(ctr1, ctr2, r, (sectorstartangle / (2 * np.pi)) * 360, (sectorangle / (2 * np.pi)) * 360, ', '.join(materialsrequested)))
|
degrees, of material(s) {', '.join(materialsrequested)} created.")
|
||||||
|
@@ -16,7 +16,7 @@
|
|||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with gprMax. If not, see <http://www.gnu.org/licenses/>.
|
# along with gprMax. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
from tqdm import tqdm
|
import logging
|
||||||
|
|
||||||
import gprMax.config as config
|
import gprMax.config as config
|
||||||
from .cmds_geometry import UserObjectGeometry
|
from .cmds_geometry import UserObjectGeometry
|
||||||
@@ -25,6 +25,8 @@ from ..cython.geometry_primitives import build_edge_y
|
|||||||
from ..cython.geometry_primitives import build_edge_z
|
from ..cython.geometry_primitives import build_edge_z
|
||||||
from ..exceptions import CmdInputError
|
from ..exceptions import CmdInputError
|
||||||
|
|
||||||
|
log = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
class Edge(UserObjectGeometry):
|
class Edge(UserObjectGeometry):
|
||||||
"""Allows you to introduce a wire with specific properties into the model.
|
"""Allows you to introduce a wire with specific properties into the model.
|
||||||
@@ -38,7 +40,6 @@ class Edge(UserObjectGeometry):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, **kwargs):
|
def __init__(self, **kwargs):
|
||||||
"""Constructor."""
|
|
||||||
super().__init__(**kwargs)
|
super().__init__(**kwargs)
|
||||||
self.order = 2
|
self.order = 2
|
||||||
self.hash = '#edge'
|
self.hash = '#edge'
|
||||||
@@ -86,5 +87,6 @@ class Edge(UserObjectGeometry):
|
|||||||
for k in range(zs, zf):
|
for k in range(zs, zf):
|
||||||
build_edge_z(xs, ys, k, material.numID, grid.rigidE, grid.rigidH, grid.ID)
|
build_edge_z(xs, ys, k, material.numID, grid.rigidE, grid.rigidH, grid.ID)
|
||||||
|
|
||||||
if config.is_messages():
|
log.info(f'Edge from {xs * grid.dx:g}m, {ys * grid.dy:g}m, {zs * grid.dz:g}m, \
|
||||||
tqdm.write('Edge from {:g}m, {:g}m, {:g}m, to {:g}m, {:g}m, {:g}m of material {} created.'.format(xs * grid.dx, ys * grid.dy, zs * grid.dz, xf * grid.dx, yf * grid.dy, zf * grid.dz, material_id))
|
to {xf * grid.dx:g}m, {yf * grid.dy:g}m, {zf * grid.dz:g}m of \
|
||||||
|
material {material_id} created.')
|
||||||
|
@@ -16,14 +16,17 @@
|
|||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with gprMax. If not, see <http://www.gnu.org/licenses/>.
|
# along with gprMax. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
import logging
|
||||||
|
|
||||||
import numpy as np
|
import numpy as np
|
||||||
from tqdm import tqdm
|
|
||||||
|
|
||||||
import gprMax.config as config
|
import gprMax.config as config
|
||||||
from .cmds_geometry import UserObjectGeometry
|
from .cmds_geometry import UserObjectGeometry
|
||||||
from ..exceptions import CmdInputError
|
from ..exceptions import CmdInputError
|
||||||
from ..fractals import FractalVolume
|
from ..fractals import FractalVolume
|
||||||
|
|
||||||
|
log = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
class FractalBox(UserObjectGeometry):
|
class FractalBox(UserObjectGeometry):
|
||||||
"""Allows you to introduce an orthogonal parallelepiped with fractal distributed properties which are related to a mixing model or normal material into the model.
|
"""Allows you to introduce an orthogonal parallelepiped with fractal distributed properties which are related to a mixing model or normal material into the model.
|
||||||
@@ -49,7 +52,6 @@ class FractalBox(UserObjectGeometry):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, **kwargs):
|
def __init__(self, **kwargs):
|
||||||
"""Constructor."""
|
|
||||||
super().__init__(**kwargs)
|
super().__init__(**kwargs)
|
||||||
self.order = 9
|
self.order = 9
|
||||||
self.hash = '#fractal_box'
|
self.hash = '#fractal_box'
|
||||||
@@ -63,7 +65,6 @@ class FractalBox(UserObjectGeometry):
|
|||||||
n_materials = self.kwargs['n_materials']
|
n_materials = self.kwargs['n_materials']
|
||||||
mixing_model_id = self.kwargs['mixing_model_id']
|
mixing_model_id = self.kwargs['mixing_model_id']
|
||||||
ID = self.kwargs['id']
|
ID = self.kwargs['id']
|
||||||
|
|
||||||
except KeyError:
|
except KeyError:
|
||||||
raise CmdInputError(self.__str__() + ' Incorrect parameters')
|
raise CmdInputError(self.__str__() + ' Incorrect parameters')
|
||||||
|
|
||||||
@@ -120,11 +121,12 @@ class FractalBox(UserObjectGeometry):
|
|||||||
volume.averaging = averagefractalbox
|
volume.averaging = averagefractalbox
|
||||||
volume.mixingmodel = mixingmodel
|
volume.mixingmodel = mixingmodel
|
||||||
|
|
||||||
if config.is_messages():
|
dielectricsmoothing = 'on' if volume.averaging else 'off'
|
||||||
if volume.averaging:
|
log.info(f'Fractal box {volume.ID} from {xs * grid.dx:g}m, {ys * grid.dy:g}m, \
|
||||||
dielectricsmoothing = 'on'
|
{zs * grid.dz:g}m, to {xf * grid.dx:g}m, {yf * grid.dy:g}m, {zf * grid.dz:g}m \
|
||||||
else:
|
with {volume.operatingonID}, fractal dimension {volume.dimension:g}, fractal \
|
||||||
dielectricsmoothing = 'off'
|
weightings {volume.weighting[0]:g}, {volume.weighting[1]:g}, {volume.weighting[2]:g}, \
|
||||||
tqdm.write('Fractal box {} from {:g}m, {:g}m, {:g}m, to {:g}m, {:g}m, {:g}m with {}, fractal dimension {:g}, fractal weightings {:g}, {:g}, {:g}, fractal seeding {}, with {} material(s) created, dielectric smoothing is {}.'.format(volume.ID, xs * grid.dx, ys * grid.dy, zs * grid.dz, xf * grid.dx, yf * grid.dy, zf * grid.dz, volume.operatingonID, volume.dimension, volume.weighting[0], volume.weighting[1], volume.weighting[2], volume.seed, volume.nbins, dielectricsmoothing))
|
fractal seeding {volume.seed}, with {volume.nbins} material(s) created, \
|
||||||
|
dielectric smoothing is {dielectricsmoothing}.')
|
||||||
|
|
||||||
grid.fractalvolumes.append(volume)
|
grid.fractalvolumes.append(volume)
|
||||||
|
@@ -32,15 +32,12 @@ class FractalBoxBuilder(UserObjectGeometry):
|
|||||||
internally only when surface modification have been made to a fractal box"""
|
internally only when surface modification have been made to a fractal box"""
|
||||||
|
|
||||||
def __init__(self, **kwargs):
|
def __init__(self, **kwargs):
|
||||||
"""Constructor."""
|
|
||||||
super().__init__(**kwargs)
|
super().__init__(**kwargs)
|
||||||
self.order = 13
|
self.order = 13
|
||||||
self.hash = '#fractal_box_modifications'
|
self.hash = '#fractal_box_modifications'
|
||||||
|
|
||||||
def create(self, grid, uip):
|
def create(self, grid, uip):
|
||||||
|
|
||||||
for volume in grid.fractalvolumes:
|
for volume in grid.fractalvolumes:
|
||||||
|
|
||||||
if volume.fractalsurfaces:
|
if volume.fractalsurfaces:
|
||||||
volume.originalxs = volume.xs
|
volume.originalxs = volume.xs
|
||||||
volume.originalxf = volume.xf
|
volume.originalxf = volume.xf
|
||||||
|
@@ -16,26 +16,26 @@
|
|||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with gprMax. If not, see <http://www.gnu.org/licenses/>.
|
# along with gprMax. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
import logging
|
||||||
import os
|
import os
|
||||||
|
|
||||||
from tqdm import tqdm
|
|
||||||
|
|
||||||
import gprMax.config as config
|
import gprMax.config as config
|
||||||
from .cmds_geometry import UserObjectGeometry
|
from .cmds_geometry import UserObjectGeometry
|
||||||
from ..exceptions import CmdInputError
|
from ..exceptions import CmdInputError
|
||||||
|
|
||||||
|
log = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
class GeometryObjectsRead(UserObjectGeometry):
|
class GeometryObjectsRead(UserObjectGeometry):
|
||||||
"""MORE WORK REQUIRED HERE."""
|
|
||||||
|
log.debug('More work required here.')
|
||||||
|
|
||||||
def __init__(self, **kwargs):
|
def __init__(self, **kwargs):
|
||||||
"""Constructor."""
|
|
||||||
self.order = 1
|
self.order = 1
|
||||||
self.hash = '#geometry_objects_read'
|
self.hash = '#geometry_objects_read'
|
||||||
|
|
||||||
def create(self, G, uip):
|
def create(self, G, uip):
|
||||||
"""Create the object and add it to the grid."""
|
"""Create the object and add it to the grid."""
|
||||||
|
|
||||||
try:
|
try:
|
||||||
p1 = self.kwargs['p1']
|
p1 = self.kwargs['p1']
|
||||||
geofile = self.kwargs['geofile']
|
geofile = self.kwargs['geofile']
|
||||||
@@ -101,10 +101,12 @@ class GeometryObjectsRead(UserObjectGeometry):
|
|||||||
G.rigidE[:, xs:xs + rigidE.shape[1], ys:ys + rigidE.shape[2], zs:zs + rigidE.shape[3]] = rigidE
|
G.rigidE[:, xs:xs + rigidE.shape[1], ys:ys + rigidE.shape[2], zs:zs + rigidE.shape[3]] = rigidE
|
||||||
G.rigidH[:, xs:xs + rigidH.shape[1], ys:ys + rigidH.shape[2], zs:zs + rigidH.shape[3]] = rigidH
|
G.rigidH[:, xs:xs + rigidH.shape[1], ys:ys + rigidH.shape[2], zs:zs + rigidH.shape[3]] = rigidH
|
||||||
G.ID[:, xs:xs + ID.shape[1], ys:ys + ID.shape[2], zs:zs + ID.shape[3]] = ID + numexistmaterials
|
G.ID[:, xs:xs + ID.shape[1], ys:ys + ID.shape[2], zs:zs + ID.shape[3]] = ID + numexistmaterials
|
||||||
if G.messages:
|
log.info(f'Geometry objects from file {geofile} inserted at {xs * G.dx:g}m, \
|
||||||
tqdm.write('Geometry objects from file {} inserted at {:g}m, {:g}m, {:g}m, with corresponding materials file {}.'.format(geofile, xs * G.dx, ys * G.dy, zs * G.dz, matfile))
|
{ys * G.dy:g}m, {zs * G.dz:g}m, with corresponding materials \
|
||||||
|
file {matfile}.')
|
||||||
except KeyError:
|
except KeyError:
|
||||||
averaging = False
|
averaging = False
|
||||||
build_voxels_from_array(xs, ys, zs, numexistmaterials, averaging, data, G.solid, G.rigidE, G.rigidH, G.ID)
|
build_voxels_from_array(xs, ys, zs, numexistmaterials, averaging, data, G.solid, G.rigidE, G.rigidH, G.ID)
|
||||||
if G.messages:
|
log.info(f'Geometry objects from file (voxels only){ geofile} \
|
||||||
tqdm.write('Geometry objects from file (voxels only) {} inserted at {:g}m, {:g}m, {:g}m, with corresponding materials file {}.'.format(geofile, xs * G.dx, ys * G.dy, zs * G.dz, matfile))
|
inserted at {xs * G.dx:g}m, {ys * G.dy:g}m, {zs * G.dz:g}m, \
|
||||||
|
with corresponding materials file {matfile}.')
|
||||||
|
@@ -16,7 +16,7 @@
|
|||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with gprMax. If not, see <http://www.gnu.org/licenses/>.
|
# along with gprMax. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
from tqdm import tqdm
|
import logging
|
||||||
|
|
||||||
import gprMax.config as config
|
import gprMax.config as config
|
||||||
from .cmds_geometry import UserObjectGeometry
|
from .cmds_geometry import UserObjectGeometry
|
||||||
@@ -25,6 +25,8 @@ from ..cython.geometry_primitives import build_face_xz
|
|||||||
from ..cython.geometry_primitives import build_face_xy
|
from ..cython.geometry_primitives import build_face_xy
|
||||||
from ..exceptions import CmdInputError
|
from ..exceptions import CmdInputError
|
||||||
|
|
||||||
|
log = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
class Plate(UserObjectGeometry):
|
class Plate(UserObjectGeometry):
|
||||||
"""Allows you to introduce a plate with specific properties into the model.
|
"""Allows you to introduce a plate with specific properties into the model.
|
||||||
@@ -40,17 +42,14 @@ class Plate(UserObjectGeometry):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, **kwargs):
|
def __init__(self, **kwargs):
|
||||||
"""Constructor."""
|
|
||||||
super().__init__(**kwargs)
|
super().__init__(**kwargs)
|
||||||
self.order = 3
|
self.order = 3
|
||||||
self.hash = '#plate'
|
self.hash = '#plate'
|
||||||
|
|
||||||
def create(self, grid, uip):
|
def create(self, grid, uip):
|
||||||
|
|
||||||
try:
|
try:
|
||||||
p1 = self.kwargs['p1']
|
p1 = self.kwargs['p1']
|
||||||
p2 = self.kwargs['p2']
|
p2 = self.kwargs['p2']
|
||||||
|
|
||||||
except KeyError:
|
except KeyError:
|
||||||
raise CmdInputError(self.__str__() + ' 2 points must be specified')
|
raise CmdInputError(self.__str__() + ' 2 points must be specified')
|
||||||
|
|
||||||
@@ -136,5 +135,6 @@ class Plate(UserObjectGeometry):
|
|||||||
for j in range(ys, yf):
|
for j in range(ys, yf):
|
||||||
build_face_xy(i, j, zs, numIDx, numIDy, grid.rigidE, grid.rigidH, grid.ID)
|
build_face_xy(i, j, zs, numIDx, numIDy, grid.rigidE, grid.rigidH, grid.ID)
|
||||||
|
|
||||||
if config.is_messages():
|
log.info(f"Plate from {xs * grid.dx:g}m, {ys * grid.dy:g}m, {zs * grid.dz:g}m, \
|
||||||
tqdm.write('Plate from {:g}m, {:g}m, {:g}m, to {:g}m, {:g}m, {:g}m of material(s) {} created.'.format(xs * grid.dx, ys * grid.dy, zs * grid.dz, xf * grid.dx, yf * grid.dy, zf * grid.dz, ', '.join(materialsrequested)))
|
to {xf * grid.dx:g}m, {yf * grid.dy:g}m, {zf * grid.dz:g}m of \
|
||||||
|
material(s) {', '.join(materialsrequested)} created.")
|
||||||
|
@@ -16,8 +16,9 @@
|
|||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with gprMax. If not, see <http://www.gnu.org/licenses/>.
|
# along with gprMax. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
import logging
|
||||||
|
|
||||||
import numpy as np
|
import numpy as np
|
||||||
from tqdm import tqdm
|
|
||||||
|
|
||||||
import gprMax.config as config
|
import gprMax.config as config
|
||||||
from .cmds_geometry import UserObjectGeometry
|
from .cmds_geometry import UserObjectGeometry
|
||||||
@@ -25,6 +26,8 @@ from ..cython.geometry_primitives import build_sphere
|
|||||||
from ..exceptions import CmdInputError
|
from ..exceptions import CmdInputError
|
||||||
from ..materials import Material
|
from ..materials import Material
|
||||||
|
|
||||||
|
log = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
class Sphere(UserObjectGeometry):
|
class Sphere(UserObjectGeometry):
|
||||||
"""Allows you to introduce a spherical object with specific parameters into the model.
|
"""Allows you to introduce a spherical object with specific parameters into the model.
|
||||||
@@ -42,7 +45,6 @@ class Sphere(UserObjectGeometry):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, **kwargs):
|
def __init__(self, **kwargs):
|
||||||
"""Constructor."""
|
|
||||||
super().__init__(**kwargs)
|
super().__init__(**kwargs)
|
||||||
self.order = 8
|
self.order = 8
|
||||||
self.hash = '#sphere'
|
self.hash = '#sphere'
|
||||||
@@ -113,9 +115,7 @@ class Sphere(UserObjectGeometry):
|
|||||||
|
|
||||||
build_sphere(xc, yc, zc, r, grid.dx, grid.dy, grid.dz, numID, numIDx, numIDy, numIDz, averaging, grid.solid, grid.rigidE, grid.rigidH, grid.ID)
|
build_sphere(xc, yc, zc, r, grid.dx, grid.dy, grid.dz, numID, numIDx, numIDy, numIDz, averaging, grid.solid, grid.rigidE, grid.rigidH, grid.ID)
|
||||||
|
|
||||||
if config.is_messages():
|
dielectricsmoothing = 'on' if averaging else 'off'
|
||||||
if averaging:
|
log.info(f"Sphere with centre {xc * grid.dx:g}m, {yc * grid.dy:g}m, {zc * grid.dz:g}m, \
|
||||||
dielectricsmoothing = 'on'
|
radius {r:g}m, of material(s) {', '.join(materialsrequested)} \
|
||||||
else:
|
created, dielectric smoothing is {dielectricsmoothing}.")
|
||||||
dielectricsmoothing = 'off'
|
|
||||||
tqdm.write('Sphere with centre {:g}m, {:g}m, {:g}m, radius {:g}m, of material(s) {} created, dielectric smoothing is {}.'.format(xc * grid.dx, yc * grid.dy, zc * grid.dz, r, ', '.join(materialsrequested), dielectricsmoothing))
|
|
||||||
|
@@ -16,8 +16,9 @@
|
|||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with gprMax. If not, see <http://www.gnu.org/licenses/>.
|
# along with gprMax. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
import logging
|
||||||
|
|
||||||
import numpy as np
|
import numpy as np
|
||||||
from tqdm import tqdm
|
|
||||||
|
|
||||||
import gprMax.config as config
|
import gprMax.config as config
|
||||||
from .cmds_geometry import UserObjectGeometry
|
from .cmds_geometry import UserObjectGeometry
|
||||||
@@ -25,6 +26,8 @@ from ..cython.geometry_primitives import build_triangle
|
|||||||
from ..exceptions import CmdInputError
|
from ..exceptions import CmdInputError
|
||||||
from ..materials import Material
|
from ..materials import Material
|
||||||
|
|
||||||
|
log = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
class Triangle(UserObjectGeometry):
|
class Triangle(UserObjectGeometry):
|
||||||
"""Allows you to introduce a triangular patch or a triangular prism with specific properties into the model.
|
"""Allows you to introduce a triangular patch or a triangular prism with specific properties into the model.
|
||||||
@@ -46,19 +49,16 @@ class Triangle(UserObjectGeometry):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, **kwargs):
|
def __init__(self, **kwargs):
|
||||||
"""Constructor."""
|
|
||||||
super().__init__(**kwargs)
|
super().__init__(**kwargs)
|
||||||
self.order = 4
|
self.order = 4
|
||||||
self.hash = '#triangle'
|
self.hash = '#triangle'
|
||||||
|
|
||||||
def create(self, grid, uip):
|
def create(self, grid, uip):
|
||||||
|
|
||||||
try:
|
try:
|
||||||
up1 = self.kwargs['p1']
|
up1 = self.kwargs['p1']
|
||||||
up2 = self.kwargs['p2']
|
up2 = self.kwargs['p2']
|
||||||
up3 = self.kwargs['p3']
|
up3 = self.kwargs['p3']
|
||||||
thickness = self.kwargs['thickness']
|
thickness = self.kwargs['thickness']
|
||||||
|
|
||||||
except KeyError:
|
except KeyError:
|
||||||
raise CmdInputError(self.params_str() + ' Specify 3 points and a thickness')
|
raise CmdInputError(self.params_str() + ' Specify 3 points and a thickness')
|
||||||
|
|
||||||
@@ -155,12 +155,13 @@ class Triangle(UserObjectGeometry):
|
|||||||
|
|
||||||
build_triangle(x1, y1, z1, x2, y2, z2, x3, y3, z3, normal, thickness, grid.dx, grid.dy, grid.dz, numID, numIDx, numIDy, numIDz, averaging, grid.solid, grid.rigidE, grid.rigidH, grid.ID)
|
build_triangle(x1, y1, z1, x2, y2, z2, x3, y3, z3, normal, thickness, grid.dx, grid.dy, grid.dz, numID, numIDx, numIDy, numIDz, averaging, grid.solid, grid.rigidE, grid.rigidH, grid.ID)
|
||||||
|
|
||||||
if config.is_messages():
|
|
||||||
if thickness > 0:
|
if thickness > 0:
|
||||||
if averaging:
|
dielectricsmoothing = 'on' if averaging else 'off'
|
||||||
dielectricsmoothing = 'on'
|
log.info(f"Triangle with coordinates {x1:g}m {y1:g}m {z1:g}m, \
|
||||||
|
{x2:g}m {y2:g}m {z2:g}m, {x3:g}m {y3:g}m {z3:g}m and thickness \
|
||||||
|
{thickness:g}m of material(s) {', '.join(materialsrequested)} \
|
||||||
|
created, dielectric smoothing is {dielectricsmoothing}.")
|
||||||
else:
|
else:
|
||||||
dielectricsmoothing = 'off'
|
log.info(f'Triangle with coordinates {x1:g}m {y1:g}m {z1:g}m, \
|
||||||
tqdm.write('Triangle with coordinates {:g}m {:g}m {:g}m, {:g}m {:g}m {:g}m, {:g}m {:g}m {:g}m and thickness {:g}m of material(s) {} created, dielectric smoothing is {}.'.format(x1, y1, z1, x2, y2, z2, x3, y3, z3, thickness, ', '.join(materialsrequested), dielectricsmoothing))
|
{x2:g}m {y2:g}m {z2:g}m, {x3:g}m {y3:g}m {z3:g}m of \
|
||||||
else:
|
material(s) {', '.join(materialsrequested)} created.')
|
||||||
tqdm.write('Triangle with coordinates {:g}m {:g}m {:g}m, {:g}m {:g}m {:g}m, {:g}m {:g}m {:g}m of material(s) {} created.'.format(x1, y1, z1, x2, y2, z2, x3, y3, z3, ', '.join(materialsrequested)))
|
|
||||||
|
在新工单中引用
屏蔽一个用户