你已经派生过 gprMax
镜像自地址
https://gitee.com/sunhf/gprMax.git
已同步 2025-08-08 07:24:19 +08:00
Refactor ExcitationFile UserObject
For now, left waveforms inside FDTDGrid because for a user defined wave, the time array may be created based on the dt of the grid.
这个提交包含在:
@@ -26,6 +26,7 @@ from scipy import interpolate
|
|||||||
|
|
||||||
import gprMax.config as config
|
import gprMax.config as config
|
||||||
from gprMax.grid.fdtd_grid import FDTDGrid
|
from gprMax.grid.fdtd_grid import FDTDGrid
|
||||||
|
from gprMax.model import Model
|
||||||
from gprMax.user_inputs import MainGridUserInput
|
from gprMax.user_inputs import MainGridUserInput
|
||||||
|
|
||||||
from .cmds_geometry.cmds_geometry import (
|
from .cmds_geometry.cmds_geometry import (
|
||||||
@@ -74,8 +75,8 @@ class UserObjectMulti(ABC):
|
|||||||
return f"{self.hash}: {s[:-1]}"
|
return f"{self.hash}: {s[:-1]}"
|
||||||
|
|
||||||
@abstractmethod
|
@abstractmethod
|
||||||
def build(self, grid: FDTDGrid, uip: MainGridUserInput):
|
def build(self, model: Model, uip: MainGridUserInput):
|
||||||
"""Creates object and adds it to grid."""
|
"""Creates object and adds it to model."""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
# TODO: Check if this is actually needed
|
# TODO: Check if this is actually needed
|
||||||
@@ -114,7 +115,7 @@ class ExcitationFile(UserObjectMulti):
|
|||||||
self.order = 1
|
self.order = 1
|
||||||
self.hash = "#excitation_file"
|
self.hash = "#excitation_file"
|
||||||
|
|
||||||
def build(self, grid, uip):
|
def build(self, model, uip):
|
||||||
try:
|
try:
|
||||||
kwargs = {}
|
kwargs = {}
|
||||||
excitationfile = self.kwargs["filepath"]
|
excitationfile = self.kwargs["filepath"]
|
||||||
@@ -136,6 +137,7 @@ class ExcitationFile(UserObjectMulti):
|
|||||||
if not excitationfile.exists():
|
if not excitationfile.exists():
|
||||||
excitationfile = Path(config.sim_config.input_file_path.parent, excitationfile)
|
excitationfile = Path(config.sim_config.input_file_path.parent, excitationfile)
|
||||||
|
|
||||||
|
grid = uip.grid
|
||||||
logger.info(self.grid_name(grid) + f"Excitation file: {excitationfile}")
|
logger.info(self.grid_name(grid) + f"Excitation file: {excitationfile}")
|
||||||
|
|
||||||
# Get waveform names
|
# Get waveform names
|
||||||
@@ -153,7 +155,7 @@ class ExcitationFile(UserObjectMulti):
|
|||||||
waveformvalues = waveformvalues[:, 1:]
|
waveformvalues = waveformvalues[:, 1:]
|
||||||
timestr = "user-defined time array"
|
timestr = "user-defined time array"
|
||||||
else:
|
else:
|
||||||
waveformtime = np.arange(0, grid.timewindow + grid.dt, grid.dt)
|
waveformtime = np.arange(0, model.timewindow + grid.dt, grid.dt)
|
||||||
timestr = "simulation time array"
|
timestr = "simulation time array"
|
||||||
|
|
||||||
for i, waveformID in enumerate(waveformIDs):
|
for i, waveformID in enumerate(waveformIDs):
|
||||||
|
在新工单中引用
屏蔽一个用户