你已经派生过 gprMax
镜像自地址
https://gitee.com/sunhf/gprMax.git
已同步 2025-08-07 15:10:13 +08:00
Cleanups, formatting and comments.
这个提交包含在:
@@ -946,14 +946,25 @@ class TransmissionLine(UserObjectMulti):
|
||||
grid.transmissionlines.append(t)
|
||||
|
||||
|
||||
"""
|
||||
------------------------------------------------------------------------------
|
||||
Add the UserMultiObject Class for the Discrete Plane Wave Implementation
|
||||
------------------------------------------------------------------------------
|
||||
"""
|
||||
class DiscretePlaneWave(UserObjectMulti):
|
||||
"""
|
||||
Specifies a plane wave implemented using the discrete plane wave formulation.
|
||||
|
||||
Attributes:
|
||||
theta: float required for propagation angle (degrees) of wave.
|
||||
phi: float required for propagation angle (degrees) of wave.
|
||||
psi: float required for polarisation of wave.
|
||||
delta_theta: float optional for tolerance of theta angle to nearest
|
||||
rational angle.
|
||||
delta_phi: float optional for tolerance to phi angle to nearest
|
||||
rational angle.
|
||||
p1: tuple required for the lower left position (x, y, z) of the total
|
||||
field, scattered field (TFSF) box.
|
||||
p1: tuple required for the upper right position (x, y, z) of the total
|
||||
field, scattered field (TFSF) box.
|
||||
waveform_id: string required for identifier of waveform used with source.
|
||||
start: float optional to delay start time (secs) of source.
|
||||
stop: float optional to time (secs) to remove source.
|
||||
"""
|
||||
|
||||
def __init__(self, **kwargs):
|
||||
@@ -978,7 +989,7 @@ class DiscretePlaneWave(UserObjectMulti):
|
||||
except KeyError:
|
||||
dtheta = 1.0
|
||||
dphi = 1.0
|
||||
|
||||
|
||||
# Warn about using a discrete plane wave on GPU
|
||||
if config.sim_config.general["solver"] in ["cuda", "opencl"]:
|
||||
logger.exception(
|
||||
@@ -989,20 +1000,26 @@ class DiscretePlaneWave(UserObjectMulti):
|
||||
|
||||
# Check if there is a waveformID in the waveforms list
|
||||
if not any(x.ID == waveform_id for x in grid.waveforms):
|
||||
logger.exception(f"{self.params_str()} there is no waveform " + f"with the identifier {waveform_id}.")
|
||||
logger.exception(
|
||||
f"{self.params_str()} there is no waveform "
|
||||
+ f"with the identifier {waveform_id}."
|
||||
)
|
||||
raise ValueError
|
||||
if (theta > 180):
|
||||
theta -= (np.floor(theta/180) * 180.0)
|
||||
if (phi > 360):
|
||||
phi -= (np.floor(phi/360) * 360.0)
|
||||
if (psi > 360):
|
||||
psi -= (np.floor(psi/360) * 360.0)
|
||||
|
||||
if theta > 180:
|
||||
theta -= np.floor(theta / 180) * 180.0
|
||||
if phi > 360:
|
||||
phi -= np.floor(phi / 360) * 360.0
|
||||
if psi > 360:
|
||||
psi -= np.floor(psi / 360) * 360.0
|
||||
|
||||
x_start, y_start, z_start = uip.check_src_rx_point(p1, self.params_str())
|
||||
x_stop, y_stop, z_stop = uip.check_src_rx_point(p2, self.params_str())
|
||||
|
||||
DPW = DiscretePlaneWaveUser(grid)
|
||||
DPW.corners = np.array([x_start, y_start, z_start, x_stop, y_stop, z_stop], dtype=np.int32)
|
||||
DPW.corners = np.array(
|
||||
[x_start, y_start, z_start, x_stop, y_stop, z_stop], dtype=np.int32
|
||||
)
|
||||
DPW.waveformID = waveform_id
|
||||
DPW.initializeDiscretePlaneWave(psi, phi, dphi, theta, dtheta, grid)
|
||||
|
||||
@@ -1017,61 +1034,68 @@ class DiscretePlaneWave(UserObjectMulti):
|
||||
stop = self.kwargs["stop"]
|
||||
if start < 0:
|
||||
logger.exception(
|
||||
self.params_str() + (" delay of the initiation " "of the source should not " "be less than zero."))
|
||||
self.params_str()
|
||||
+ (
|
||||
" delay of the initiation "
|
||||
"of the source should not "
|
||||
"be less than zero."
|
||||
)
|
||||
)
|
||||
raise ValueError
|
||||
if stop < 0:
|
||||
logger.exception(self.params_str() + (" time to remove the " "source should not be " "less than zero."))
|
||||
logger.exception(
|
||||
self.params_str()
|
||||
+ (" time to remove the source should not be less than zero.")
|
||||
)
|
||||
raise ValueError
|
||||
if stop - start <= 0:
|
||||
logger.exception(self.params_str() + (" duration of the source " "should not be zero or " "less."))
|
||||
logger.exception(
|
||||
self.params_str()
|
||||
+ (" duration of the source should not be zero or less.")
|
||||
)
|
||||
raise ValueError
|
||||
DPW.start = start
|
||||
DPW.stop = min(stop, grid.timewindow)
|
||||
startstop = f" start time {t.start:g} secs, finish time " + f"{t.stop:g} secs "
|
||||
startstop = f" start time {t.start:g} secs, finish time {t.stop:g} secs "
|
||||
except KeyError:
|
||||
DPW.start = 0
|
||||
DPW.stop = grid.timewindow
|
||||
startstop = " "
|
||||
|
||||
precompute = True
|
||||
if(precompute == True):
|
||||
if precompute:
|
||||
DPW.calculate_waveform_values(grid)
|
||||
|
||||
|
||||
logger.info(
|
||||
f"{self.grid_name(grid)} Discrete Plane Wave within the TFSF Box "
|
||||
f"{self.grid_name(grid)} Discrete Plane Wave within the TFSF Box "
|
||||
+ f"spanning from {p1} m to {p2} m, incident in the direction "
|
||||
+ f"theta {theta} degrees and phi {phi} degrees "
|
||||
+ startstop
|
||||
+ f"using waveform {DPW.waveformID} created."
|
||||
)
|
||||
phi_approx = np.arctan2(DPW.m[1]/grid.dy, DPW.m[0]/grid.dx)*180/np.pi
|
||||
theta_approx = np.arctan2( np.sqrt( (DPW.m[0]/grid.dx)*(DPW.m[0]/grid.dx) + (DPW.m[1]/grid.dy)*(DPW.m[1]/grid.dy) ),
|
||||
DPW.m[2]/grid.dz) * 180/np.pi
|
||||
phi_approx = np.arctan2(DPW.m[1] / grid.dy, DPW.m[0] / grid.dx) * 180 / np.pi
|
||||
theta_approx = (
|
||||
np.arctan2(
|
||||
np.sqrt(
|
||||
(DPW.m[0] / grid.dx) * (DPW.m[0] / grid.dx)
|
||||
+ (DPW.m[1] / grid.dy) * (DPW.m[1] / grid.dy)
|
||||
),
|
||||
DPW.m[2] / grid.dz,
|
||||
)
|
||||
* 180
|
||||
/ np.pi
|
||||
)
|
||||
logger.info(
|
||||
f"Since {self.grid_name(grid)} Discrete Plane Wave has been discretized "
|
||||
+ f"the angles have been approzimated to the nearest rational angles "
|
||||
+ f"with some small tolerance levels. The chosen rational integers are "
|
||||
+ "the angles have been approximated to the nearest rational angles "
|
||||
+ "with some small tolerance levels. The chosen rational integers are "
|
||||
+ f"[m_x, m_y, m_z] : {DPW.m[:3]}. The approximated angles are : \n"
|
||||
+ "Approximated Phi : {:.3f}".format(phi_approx) + "\nApproximated Theta : {:.3f} .".format(theta_approx)
|
||||
+ "Approximated Phi : {:.3f}".format(phi_approx)
|
||||
+ "\nApproximated Theta : {:.3f} .".format(theta_approx)
|
||||
)
|
||||
|
||||
grid.discreteplanewaves.append(DPW)
|
||||
|
||||
'''
|
||||
DPW = []
|
||||
start = time.time()
|
||||
for i in range(self.noOfWaves):
|
||||
DPW.append(DiscretePlaneWaveUser(self.time_duration, self.dimensions, number_x, number_y, number_z))
|
||||
|
||||
SpaceGrid = TFSFBoxUser(number_x, number_y, number_z, self.corners, self.time_duration, self.dimensions, self.noOfWaves)
|
||||
SpaceGrid.getFields(DPW, self.snapshot, angles, number, self.dx, self.dy, self.dz, self.dt, self.ppw)
|
||||
'''
|
||||
"""
|
||||
------------------------------------------------------------------------------
|
||||
End of the UserMultiObject Class for the Discrete Plane Wave Implementation
|
||||
------------------------------------------------------------------------------
|
||||
"""
|
||||
|
||||
|
||||
class Rx(UserObjectMulti):
|
||||
"""Specifies output points in the model.
|
||||
|
在新工单中引用
屏蔽一个用户