你已经派生过 gprMax
镜像自地址
https://gitee.com/sunhf/gprMax.git
已同步 2025-08-08 07:24:19 +08:00
Changed to new-style classes.
Added better dispersion checking for sine, contsine, impulse and user. Separated field array initialisation into its own method.
这个提交包含在:
@@ -23,7 +23,7 @@ from gprMax.constants import c, floattype, complextype
|
|||||||
from gprMax.materials import Material
|
from gprMax.materials import Material
|
||||||
|
|
||||||
|
|
||||||
class FDTDGrid:
|
class FDTDGrid(object):
|
||||||
"""Holds attributes associated with the entire grid. A convenient way for accessing regularly used parameters."""
|
"""Holds attributes associated with the entire grid. A convenient way for accessing regularly used parameters."""
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
@@ -54,25 +54,27 @@ class FDTDGrid:
|
|||||||
self.hertziandipoles = []
|
self.hertziandipoles = []
|
||||||
self.magneticdipoles = []
|
self.magneticdipoles = []
|
||||||
self.transmissionlines = []
|
self.transmissionlines = []
|
||||||
|
self.rxs = []
|
||||||
self.srcstepx = 0
|
self.srcstepx = 0
|
||||||
self.srcstepy = 0
|
self.srcstepy = 0
|
||||||
self.srcstepz = 0
|
self.srcstepz = 0
|
||||||
self.rxstepx = 0
|
self.rxstepx = 0
|
||||||
self.rxstepy = 0
|
self.rxstepy = 0
|
||||||
self.rxstepz = 0
|
self.rxstepz = 0
|
||||||
self.rxs = []
|
|
||||||
self.snapshots = []
|
self.snapshots = []
|
||||||
|
|
||||||
def initialise_std_arrays(self):
|
def initialise_geometry_arrays(self):
|
||||||
"""Initialise an array for volumetric material IDs (solid); boolean arrays for specifying whether materials can have dielectric smoothing (rigid);
|
"""Initialise an array for volumetric material IDs (solid); boolean arrays for specifying whether materials can have dielectric smoothing (rigid);
|
||||||
an array for cell edge IDs (ID); and arrays for the electric and magnetic field components. Solid and ID arrays are initialised to free_space (one); rigid arrays
|
and an array for cell edge IDs (ID). Solid and ID arrays are initialised to free_space (one); rigid arrays to allow dielectric smoothing (zero).
|
||||||
to allow dielectric smoothing (zero).
|
|
||||||
"""
|
"""
|
||||||
self.solid = np.ones((self.nx + 1, self.ny + 1, self.nz + 1), dtype=np.uint32)
|
self.solid = np.ones((self.nx + 1, self.ny + 1, self.nz + 1), dtype=np.uint32)
|
||||||
self.rigidE = np.zeros((12, self.nx + 1, self.ny + 1, self.nz + 1), dtype=np.int8)
|
self.rigidE = np.zeros((12, self.nx + 1, self.ny + 1, self.nz + 1), dtype=np.int8)
|
||||||
self.rigidH = np.zeros((6, self.nx + 1, self.ny + 1, self.nz + 1), dtype=np.int8)
|
self.rigidH = np.zeros((6, self.nx + 1, self.ny + 1, self.nz + 1), dtype=np.int8)
|
||||||
self.IDlookup = {'Ex': 0, 'Ey': 1, 'Ez': 2, 'Hx': 3, 'Hy': 4, 'Hz': 5}
|
self.IDlookup = {'Ex': 0, 'Ey': 1, 'Ez': 2, 'Hx': 3, 'Hy': 4, 'Hz': 5}
|
||||||
self.ID = np.ones((6, self.nx + 1, self.ny + 1, self.nz + 1), dtype=np.uint32)
|
self.ID = np.ones((6, self.nx + 1, self.ny + 1, self.nz + 1), dtype=np.uint32)
|
||||||
|
|
||||||
|
def initialise_field_arrays(self):
|
||||||
|
"""Initialise arrays for the electric and magnetic field components."""
|
||||||
self.Ex = np.zeros((self.nx, self.ny + 1, self.nz + 1), dtype=floattype)
|
self.Ex = np.zeros((self.nx, self.ny + 1, self.nz + 1), dtype=floattype)
|
||||||
self.Ey = np.zeros((self.nx + 1, self.ny, self.nz + 1), dtype=floattype)
|
self.Ey = np.zeros((self.nx + 1, self.ny, self.nz + 1), dtype=floattype)
|
||||||
self.Ez = np.zeros((self.nx + 1, self.ny + 1, self.nz), dtype=floattype)
|
self.Ez = np.zeros((self.nx + 1, self.ny + 1, self.nz), dtype=floattype)
|
||||||
@@ -80,7 +82,7 @@ class FDTDGrid:
|
|||||||
self.Hy = np.zeros((self.nx, self.ny + 1, self.nz), dtype=floattype)
|
self.Hy = np.zeros((self.nx, self.ny + 1, self.nz), dtype=floattype)
|
||||||
self.Hz = np.zeros((self.nx, self.ny, self.nz + 1), dtype=floattype)
|
self.Hz = np.zeros((self.nx, self.ny, self.nz + 1), dtype=floattype)
|
||||||
|
|
||||||
def initialise_std_updatecoeff_arrays(self):
|
def initialise_std_update_coeff_arrays(self):
|
||||||
"""Initialise arrays for storing update coefficients."""
|
"""Initialise arrays for storing update coefficients."""
|
||||||
self.updatecoeffsE = np.zeros((len(self.materials), 5), dtype=floattype)
|
self.updatecoeffsE = np.zeros((len(self.materials), 5), dtype=floattype)
|
||||||
self.updatecoeffsH = np.zeros((len(self.materials), 5), dtype=floattype)
|
self.updatecoeffsH = np.zeros((len(self.materials), 5), dtype=floattype)
|
||||||
@@ -110,8 +112,15 @@ def dispersion_check(G):
|
|||||||
maxfreqs = []
|
maxfreqs = []
|
||||||
for waveform in G.waveforms:
|
for waveform in G.waveforms:
|
||||||
|
|
||||||
|
if waveform.type == 'sine' or waveform.type == 'contsine':
|
||||||
|
maxfreqs.append(4 * waveform.freq)
|
||||||
|
|
||||||
|
elif waveform.type =='impulse':
|
||||||
|
pass
|
||||||
|
|
||||||
|
else:
|
||||||
# User-defined waveform
|
# User-defined waveform
|
||||||
if waveform.uservalues is not None:
|
if waveform.type == 'user':
|
||||||
waveformvalues = waveform.uservalues
|
waveformvalues = waveform.uservalues
|
||||||
|
|
||||||
# Built-in waveform
|
# Built-in waveform
|
||||||
@@ -125,13 +134,6 @@ def dispersion_check(G):
|
|||||||
waveformvalues[timeiter.index] = waveform.calculate_value(timeiter[0], G.dt)
|
waveformvalues[timeiter.index] = waveform.calculate_value(timeiter[0], G.dt)
|
||||||
timeiter.iternext()
|
timeiter.iternext()
|
||||||
|
|
||||||
if waveform.type == 'sine' or waveform.type == 'contsine':
|
|
||||||
maxfreqs.append(4 * waveform.freq)
|
|
||||||
|
|
||||||
elif waveform.type =='impulse':
|
|
||||||
pass
|
|
||||||
|
|
||||||
else:
|
|
||||||
# Calculate magnitude of frequency spectra of waveform
|
# Calculate magnitude of frequency spectra of waveform
|
||||||
power = 20 * np.log10(np.abs(np.fft.fft(waveformvalues))**2)
|
power = 20 * np.log10(np.abs(np.fft.fft(waveformvalues))**2)
|
||||||
freqs = np.fft.fftfreq(power.size, d=G.dt)
|
freqs = np.fft.fftfreq(power.size, d=G.dt)
|
||||||
@@ -160,7 +162,7 @@ def dispersion_check(G):
|
|||||||
resolution = minwavelength / resolvedsteps
|
resolution = minwavelength / resolvedsteps
|
||||||
|
|
||||||
else:
|
else:
|
||||||
resolution = 0
|
resolution = False
|
||||||
|
|
||||||
return resolution
|
return resolution
|
||||||
|
|
||||||
|
在新工单中引用
屏蔽一个用户