你已经派生过 gprMax
镜像自地址
https://gitee.com/sunhf/gprMax.git
已同步 2025-08-08 15:27:57 +08:00
Check if should use model or subgrid iterations
A subgrid may have a different number of iterations to the main model. The correct one should be used when creating sources.
这个提交包含在:
@@ -438,7 +438,8 @@ class VoltageSource(UserObjectMulti):
|
||||
v.stop = model.timewindow
|
||||
startstop = " "
|
||||
|
||||
v.calculate_waveform_values(model.iterations, grid.dt)
|
||||
iterations = grid.iterations if isinstance(grid, SubGridBaseGrid) else model.iterations
|
||||
v.calculate_waveform_values(iterations, grid.dt)
|
||||
|
||||
logger.info(
|
||||
f"{self.grid_name(grid)}Voltage source with polarity "
|
||||
@@ -577,7 +578,8 @@ class HertzianDipole(UserObjectMulti):
|
||||
h.stop = model.timewindow
|
||||
startstop = " "
|
||||
|
||||
h.calculate_waveform_values(model.iterations, grid.dt)
|
||||
iterations = grid.iterations if isinstance(grid, SubGridBaseGrid) else model.iterations
|
||||
h.calculate_waveform_values(iterations, grid.dt)
|
||||
|
||||
if config.get_model_config().mode == "2D":
|
||||
logger.info(
|
||||
@@ -726,7 +728,8 @@ class MagneticDipole(UserObjectMulti):
|
||||
m.stop = model.timewindow
|
||||
startstop = " "
|
||||
|
||||
m.calculate_waveform_values(model.iterations, grid.dt)
|
||||
iterations = grid.iterations if isinstance(grid, SubGridBaseGrid) else model.iterations
|
||||
m.calculate_waveform_values(iterations, grid.dt)
|
||||
|
||||
logger.info(
|
||||
f"{self.grid_name(grid)}Magnetic dipole with polarity "
|
||||
@@ -836,7 +839,8 @@ class TransmissionLine(UserObjectMulti):
|
||||
)
|
||||
raise ValueError
|
||||
|
||||
t = TransmissionLineUser(grid)
|
||||
iterations = grid.iterations if isinstance(grid, SubGridBaseGrid) else model.iterations
|
||||
t = TransmissionLineUser(iterations, grid.dt)
|
||||
t.polarisation = polarisation
|
||||
t.xcoord = xcoord
|
||||
t.ycoord = ycoord
|
||||
@@ -884,7 +888,7 @@ class TransmissionLine(UserObjectMulti):
|
||||
t.stop = model.timewindow
|
||||
startstop = " "
|
||||
|
||||
t.calculate_waveform_values(model.iterations, grid.dt)
|
||||
t.calculate_waveform_values(iterations, grid.dt)
|
||||
t.calculate_incident_V_I(grid)
|
||||
|
||||
logger.info(
|
||||
@@ -963,6 +967,8 @@ class Rx(UserObjectMulti):
|
||||
r.xcoord, r.ycoord, r.zcoord = p
|
||||
r.xcoordorigin, r.ycoordorigin, r.zcoordorigin = p
|
||||
|
||||
iterations = grid.iterations if isinstance(grid, SubGridBaseGrid) else model.iterations
|
||||
|
||||
try:
|
||||
r.ID = self.kwargs["id"]
|
||||
outputs = self.kwargs["outputs"]
|
||||
@@ -971,7 +977,7 @@ class Rx(UserObjectMulti):
|
||||
r.ID = f"{r.__class__.__name__}({str(r.xcoord)},{str(r.ycoord)},{str(r.zcoord)})"
|
||||
for key in RxUser.defaultoutputs:
|
||||
r.outputs[key] = np.zeros(
|
||||
model.iterations, dtype=config.sim_config.dtypes["float_or_double"]
|
||||
iterations, dtype=config.sim_config.dtypes["float_or_double"]
|
||||
)
|
||||
else:
|
||||
outputs.sort()
|
||||
@@ -984,7 +990,7 @@ class Rx(UserObjectMulti):
|
||||
for field in outputs:
|
||||
if field in allowableoutputs:
|
||||
r.outputs[field] = np.zeros(
|
||||
model.iterations, dtype=config.sim_config.dtypes["float_or_double"]
|
||||
iterations, dtype=config.sim_config.dtypes["float_or_double"]
|
||||
)
|
||||
else:
|
||||
logger.exception(
|
||||
@@ -1076,6 +1082,8 @@ class RxArray(UserObjectMulti):
|
||||
f"{dx * grid.dx:g}m, {dy * grid.dy:g}m, {dz * grid.dz:g}m"
|
||||
)
|
||||
|
||||
iterations = grid.iterations if isinstance(grid, SubGridBaseGrid) else model.iterations
|
||||
|
||||
for x in range(xs, xf + 1, dx):
|
||||
for y in range(ys, yf + 1, dy):
|
||||
for z in range(zs, zf + 1, dz):
|
||||
@@ -1093,7 +1101,7 @@ class RxArray(UserObjectMulti):
|
||||
r.ID = f"{r.__class__.__name__}({str(x)},{str(y)},{str(z)})"
|
||||
for key in RxUser.defaultoutputs:
|
||||
r.outputs[key] = np.zeros(
|
||||
model.iterations, dtype=config.sim_config.dtypes["float_or_double"]
|
||||
iterations, dtype=config.sim_config.dtypes["float_or_double"]
|
||||
)
|
||||
logger.info(
|
||||
f" Receiver at {p5[0]:g}m, {p5[1]:g}m, "
|
||||
|
@@ -330,14 +330,16 @@ class TransmissionLine(Source):
|
||||
which is attached virtually to a grid cell.
|
||||
"""
|
||||
|
||||
def __init__(self, G):
|
||||
def __init__(self, iterations: int, dt: float):
|
||||
"""
|
||||
Args:
|
||||
G: FDTDGrid class describing a grid in a model.
|
||||
iterations: number of iterations
|
||||
dt: time step of the grid
|
||||
"""
|
||||
|
||||
super().__init__()
|
||||
self.resistance = None
|
||||
self.iterations = iterations
|
||||
|
||||
# Coefficients for ABC termination of end of the transmission line
|
||||
self.abcv0 = 0
|
||||
@@ -345,11 +347,11 @@ class TransmissionLine(Source):
|
||||
|
||||
# Spatial step of transmission line (N.B if the magic time step is
|
||||
# used it results in instabilities for certain impedances)
|
||||
self.dl = np.sqrt(3) * config.c * G.dt
|
||||
self.dl = np.sqrt(3) * config.c * dt
|
||||
|
||||
# Number of cells in the transmission line (initially a long line to
|
||||
# calculate incident voltage and current); consider putting ABCs/PML at end
|
||||
self.nl = round_value(0.667 * G.iterations)
|
||||
self.nl = round_value(0.667 * self.iterations)
|
||||
|
||||
# Cell position of the one-way injector excitation in the transmission line
|
||||
self.srcpos = 5
|
||||
@@ -359,10 +361,10 @@ class TransmissionLine(Source):
|
||||
|
||||
self.voltage = np.zeros(self.nl, dtype=config.sim_config.dtypes["float_or_double"])
|
||||
self.current = np.zeros(self.nl, dtype=config.sim_config.dtypes["float_or_double"])
|
||||
self.Vinc = np.zeros(G.iterations, dtype=config.sim_config.dtypes["float_or_double"])
|
||||
self.Iinc = np.zeros(G.iterations, dtype=config.sim_config.dtypes["float_or_double"])
|
||||
self.Vtotal = np.zeros(G.iterations, dtype=config.sim_config.dtypes["float_or_double"])
|
||||
self.Itotal = np.zeros(G.iterations, dtype=config.sim_config.dtypes["float_or_double"])
|
||||
self.Vinc = np.zeros(self.iterations, dtype=config.sim_config.dtypes["float_or_double"])
|
||||
self.Iinc = np.zeros(self.iterations, dtype=config.sim_config.dtypes["float_or_double"])
|
||||
self.Vtotal = np.zeros(self.iterations, dtype=config.sim_config.dtypes["float_or_double"])
|
||||
self.Itotal = np.zeros(self.iterations, dtype=config.sim_config.dtypes["float_or_double"])
|
||||
|
||||
def calculate_incident_V_I(self, G):
|
||||
"""Calculates the incident voltage and current with a long length
|
||||
@@ -373,7 +375,7 @@ class TransmissionLine(Source):
|
||||
G: FDTDGrid class describing a grid in a model.
|
||||
"""
|
||||
|
||||
for iteration in range(G.iterations):
|
||||
for iteration in range(self.iterations):
|
||||
self.Iinc[iteration] = self.current[self.antpos]
|
||||
self.Vinc[iteration] = self.voltage[self.antpos]
|
||||
self.update_current(iteration, G)
|
||||
|
在新工单中引用
屏蔽一个用户