你已经派生过 gprMax
镜像自地址
https://gitee.com/sunhf/gprMax.git
已同步 2025-08-08 07:24:19 +08:00
Move srcsteps and rxsteps into Model class
这个提交包含在:
@@ -378,16 +378,16 @@ class RxSteps(UserObjectSingle):
|
|||||||
super().__init__(**kwargs)
|
super().__init__(**kwargs)
|
||||||
self.order = 9
|
self.order = 9
|
||||||
|
|
||||||
def build(self, G, uip):
|
def build(self, model, uip):
|
||||||
try:
|
try:
|
||||||
G.rxsteps = uip.discretise_point(self.kwargs["p1"])
|
model.rxsteps = uip.discretise_point(self.kwargs["p1"])
|
||||||
except KeyError:
|
except KeyError:
|
||||||
logger.exception(f"{self.__str__()} requires exactly three parameters")
|
logger.exception(f"{self.__str__()} requires exactly three parameters")
|
||||||
raise
|
raise
|
||||||
|
|
||||||
logger.info(
|
logger.info(
|
||||||
f"All receivers will step {G.rxsteps[0] * G.dx:g}m, "
|
f"All receivers will step {model.rxsteps[0] * model.dx:g}m, "
|
||||||
f"{G.rxsteps[1] * G.dy:g}m, {G.rxsteps[2] * G.dz:g}m "
|
f"{model.rxsteps[1] * model.dy:g}m, {model.rxsteps[2] * model.dz:g}m "
|
||||||
"for each model run."
|
"for each model run."
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@@ -68,7 +68,10 @@ def write_hdf5_outputfile(outputfile: Path, title: str, model):
|
|||||||
f = h5py.File(outputfile, "w")
|
f = h5py.File(outputfile, "w")
|
||||||
f.attrs["gprMax"] = __version__
|
f.attrs["gprMax"] = __version__
|
||||||
f.attrs["Title"] = title
|
f.attrs["Title"] = title
|
||||||
write_hd5_data(f, model.G, model.iterations)
|
f.attrs["Iterations"] = model.iterations
|
||||||
|
f.attrs["srcsteps"] = model.srcsteps
|
||||||
|
f.attrs["rxsteps"] = model.rxsteps
|
||||||
|
write_hd5_data(f, model.G)
|
||||||
|
|
||||||
# Write meta data and data for any subgrids
|
# Write meta data and data for any subgrids
|
||||||
sg_rxs = [True for sg in model.subgrids if sg.rxs]
|
sg_rxs = [True for sg in model.subgrids if sg.rxs]
|
||||||
@@ -76,12 +79,12 @@ def write_hdf5_outputfile(outputfile: Path, title: str, model):
|
|||||||
if sg_rxs or sg_tls:
|
if sg_rxs or sg_tls:
|
||||||
for sg in model.subgrids:
|
for sg in model.subgrids:
|
||||||
grp = f.create_group(f"/subgrids/{sg.name}")
|
grp = f.create_group(f"/subgrids/{sg.name}")
|
||||||
write_hd5_data(grp, sg, sg.iterations, is_subgrid=True)
|
write_hd5_data(grp, sg, is_subgrid=True)
|
||||||
|
|
||||||
logger.basic(f"Written output file: {outputfile.name}")
|
logger.basic(f"Written output file: {outputfile.name}")
|
||||||
|
|
||||||
|
|
||||||
def write_hd5_data(basegrp, grid, iterations, is_subgrid=False):
|
def write_hd5_data(basegrp, grid, is_subgrid=False):
|
||||||
"""Writes grid meta data and data to HDF5 group.
|
"""Writes grid meta data and data to HDF5 group.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
@@ -91,7 +94,6 @@ def write_hd5_data(basegrp, grid, iterations, is_subgrid=False):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
# Write meta data for grid
|
# Write meta data for grid
|
||||||
basegrp.attrs["Iterations"] = iterations
|
|
||||||
basegrp.attrs["nx_ny_nz"] = (grid.nx, grid.ny, grid.nz)
|
basegrp.attrs["nx_ny_nz"] = (grid.nx, grid.ny, grid.nz)
|
||||||
basegrp.attrs["dx_dy_dz"] = (grid.dx, grid.dy, grid.dz)
|
basegrp.attrs["dx_dy_dz"] = (grid.dx, grid.dy, grid.dz)
|
||||||
basegrp.attrs["dt"] = grid.dt
|
basegrp.attrs["dt"] = grid.dt
|
||||||
@@ -100,11 +102,12 @@ def write_hd5_data(basegrp, grid, iterations, is_subgrid=False):
|
|||||||
)
|
)
|
||||||
basegrp.attrs["nsrc"] = nsrc
|
basegrp.attrs["nsrc"] = nsrc
|
||||||
basegrp.attrs["nrx"] = len(grid.rxs)
|
basegrp.attrs["nrx"] = len(grid.rxs)
|
||||||
basegrp.attrs["srcsteps"] = grid.srcsteps
|
|
||||||
basegrp.attrs["rxsteps"] = grid.rxsteps
|
|
||||||
|
|
||||||
if is_subgrid:
|
if is_subgrid:
|
||||||
# Write additional meta data about subgrid
|
# Write additional meta data about subgrid
|
||||||
|
basegrp.attrs["Iterations"] = grid.iterations
|
||||||
|
basegrp.attrs["srcsteps"] = grid.srcsteps
|
||||||
|
basegrp.attrs["rxsteps"] = grid.rxsteps
|
||||||
basegrp.attrs["is_os_sep"] = grid.is_os_sep
|
basegrp.attrs["is_os_sep"] = grid.is_os_sep
|
||||||
basegrp.attrs["pml_separation"] = grid.pml_separation
|
basegrp.attrs["pml_separation"] = grid.pml_separation
|
||||||
basegrp.attrs["subgrid_pml_thickness"] = grid.pmls["thickness"]["x0"]
|
basegrp.attrs["subgrid_pml_thickness"] = grid.pmls["thickness"]["x0"]
|
||||||
|
@@ -110,8 +110,6 @@ class FDTDGrid:
|
|||||||
self.magneticdipoles: List[MagneticDipole] = []
|
self.magneticdipoles: List[MagneticDipole] = []
|
||||||
self.transmissionlines: List[TransmissionLine] = []
|
self.transmissionlines: List[TransmissionLine] = []
|
||||||
self.rxs: List[Rx] = []
|
self.rxs: List[Rx] = []
|
||||||
self.srcsteps: List[int] = [0, 0, 0]
|
|
||||||
self.rxsteps: List[int] = [0, 0, 0]
|
|
||||||
self.snapshots: List[Snapshot] = []
|
self.snapshots: List[Snapshot] = []
|
||||||
|
|
||||||
self.averagevolumeobjects = True
|
self.averagevolumeobjects = True
|
||||||
@@ -233,18 +231,18 @@ class FDTDGrid:
|
|||||||
item.ycoord = item.ycoordorigin + step_number * step_size[1]
|
item.ycoord = item.ycoordorigin + step_number * step_size[1]
|
||||||
item.zcoord = item.zcoordorigin + step_number * step_size[2]
|
item.zcoord = item.zcoordorigin + step_number * step_size[2]
|
||||||
|
|
||||||
def update_simple_source_positions(self, step: int = 0) -> None:
|
def update_simple_source_positions(self, step_size: List[int], step: int = 0) -> None:
|
||||||
try:
|
try:
|
||||||
self._update_positions(
|
self._update_positions(
|
||||||
itertools.chain(self.hertziandipoles, self.magneticdipoles), self.srcsteps, step
|
itertools.chain(self.hertziandipoles, self.magneticdipoles), step_size, step
|
||||||
)
|
)
|
||||||
except ValueError as e:
|
except ValueError as e:
|
||||||
logger.exception("Source(s) will be stepped to a position outside the domain.")
|
logger.exception("Source(s) will be stepped to a position outside the domain.")
|
||||||
raise ValueError from e
|
raise ValueError from e
|
||||||
|
|
||||||
def update_receiver_positions(self, step: int = 0) -> None:
|
def update_receiver_positions(self, step_size: List[int], step: int = 0) -> None:
|
||||||
try:
|
try:
|
||||||
self._update_positions(self.rxs, self.rxsteps, step)
|
self._update_positions(self.rxs, step_size, step)
|
||||||
except ValueError as e:
|
except ValueError as e:
|
||||||
logger.exception("Receiver(s) will be stepped to a position outside the domain.")
|
logger.exception("Receiver(s) will be stepped to a position outside the domain.")
|
||||||
raise ValueError from e
|
raise ValueError from e
|
||||||
|
@@ -62,6 +62,9 @@ class Model:
|
|||||||
self.iterations = 0 # Total number of iterations
|
self.iterations = 0 # Total number of iterations
|
||||||
self.timewindow = 0.0
|
self.timewindow = 0.0
|
||||||
|
|
||||||
|
self.srcsteps: List[int] = [0, 0, 0]
|
||||||
|
self.rxsteps: List[int] = [0, 0, 0]
|
||||||
|
|
||||||
self.G = self._create_grid()
|
self.G = self._create_grid()
|
||||||
self.subgrids: List[SubGridBaseGrid] = []
|
self.subgrids: List[SubGridBaseGrid] = []
|
||||||
|
|
||||||
@@ -173,8 +176,8 @@ class Model:
|
|||||||
|
|
||||||
# Adjust position of simple sources and receivers if required
|
# Adjust position of simple sources and receivers if required
|
||||||
model_num = config.sim_config.current_model
|
model_num = config.sim_config.current_model
|
||||||
G.update_simple_source_positions(step=model_num)
|
G.update_simple_source_positions(self.srcsteps, step=model_num)
|
||||||
G.update_receiver_positions(step=model_num)
|
G.update_receiver_positions(self.rxsteps, step=model_num)
|
||||||
|
|
||||||
# Write files for any geometry views and geometry object outputs
|
# Write files for any geometry views and geometry object outputs
|
||||||
if (
|
if (
|
||||||
|
在新工单中引用
屏蔽一个用户