你已经派生过 gprMax
镜像自地址
https://gitee.com/sunhf/gprMax.git
已同步 2025-08-08 15:27:57 +08:00
Remove shifting zero frequency from fractal surfaces
这个提交包含在:
@@ -26,6 +26,10 @@ from gprMax.config cimport float_or_double_complex
|
|||||||
cpdef void generate_fractal2D(
|
cpdef void generate_fractal2D(
|
||||||
int nx,
|
int nx,
|
||||||
int ny,
|
int ny,
|
||||||
|
int ox,
|
||||||
|
int oy,
|
||||||
|
int gx,
|
||||||
|
int gy,
|
||||||
int nthreads,
|
int nthreads,
|
||||||
float D,
|
float D,
|
||||||
np.float64_t[:] weighting,
|
np.float64_t[:] weighting,
|
||||||
@@ -50,12 +54,16 @@ cpdef void generate_fractal2D(
|
|||||||
|
|
||||||
cdef Py_ssize_t i, j
|
cdef Py_ssize_t i, j
|
||||||
cdef double v2x, v2y, rr, B
|
cdef double v2x, v2y, rr, B
|
||||||
|
cdef int sx, sy
|
||||||
|
|
||||||
|
sx = gx // 2
|
||||||
|
sy = gy // 2
|
||||||
|
|
||||||
for i in prange(nx, nogil=True, schedule='static', num_threads=nthreads):
|
for i in prange(nx, nogil=True, schedule='static', num_threads=nthreads):
|
||||||
for j in range(ny):
|
for j in range(ny):
|
||||||
# Positional vector for current position
|
# Positional vector for current position
|
||||||
v2x = weighting[0] * i
|
v2x = weighting[0] * ((i + ox + sx) % gx)
|
||||||
v2y = weighting[1] * j
|
v2y = weighting[1] * ((j + oy + sy) % gy)
|
||||||
|
|
||||||
# Calulate norm of v2 - v1
|
# Calulate norm of v2 - v1
|
||||||
rr = ((v2x - v1[0])**2 + (v2y - v1[1])**2)**(1/2)
|
rr = ((v2x - v1[0])**2 + (v2y - v1[1])**2)**(1/2)
|
||||||
|
@@ -108,11 +108,13 @@ class FractalSurface:
|
|||||||
|
|
||||||
# 2D FFT
|
# 2D FFT
|
||||||
A = fftpack.fftn(A)
|
A = fftpack.fftn(A)
|
||||||
# Shift the zero frequency component to the centre of the array
|
|
||||||
A = fftpack.fftshift(A)
|
|
||||||
|
|
||||||
# Generate fractal
|
# Generate fractal
|
||||||
generate_fractal2D(
|
generate_fractal2D(
|
||||||
|
surfacedims[0],
|
||||||
|
surfacedims[1],
|
||||||
|
0,
|
||||||
|
0,
|
||||||
surfacedims[0],
|
surfacedims[0],
|
||||||
surfacedims[1],
|
surfacedims[1],
|
||||||
config.get_model_config().ompthreads,
|
config.get_model_config().ompthreads,
|
||||||
@@ -122,8 +124,7 @@ class FractalSurface:
|
|||||||
A,
|
A,
|
||||||
self.fractalsurface,
|
self.fractalsurface,
|
||||||
)
|
)
|
||||||
# Shift the zero frequency component to start of the array
|
|
||||||
self.fractalsurface = fftpack.ifftshift(self.fractalsurface)
|
|
||||||
# Set DC component of FFT to zero
|
# Set DC component of FFT to zero
|
||||||
self.fractalsurface[0, 0] = 0
|
self.fractalsurface[0, 0] = 0
|
||||||
# Take the real part (numerical errors can give rise to an imaginary part)
|
# Take the real part (numerical errors can give rise to an imaginary part)
|
||||||
|
@@ -223,27 +223,21 @@ class FractalBox(RotatableMixin, GeometryUserObject):
|
|||||||
for surface in self.volume.fractalsurfaces:
|
for surface in self.volume.fractalsurfaces:
|
||||||
if surface.surfaceID == "xminus":
|
if surface.surfaceID == "xminus":
|
||||||
if surface.fractalrange[0] < self.volume.xs:
|
if surface.fractalrange[0] < self.volume.xs:
|
||||||
self.volume.nx += self.volume.xs - surface.fractalrange[0]
|
|
||||||
self.volume.xs = surface.fractalrange[0]
|
self.volume.xs = surface.fractalrange[0]
|
||||||
elif surface.surfaceID == "xplus":
|
elif surface.surfaceID == "xplus":
|
||||||
if surface.fractalrange[1] > self.volume.xf:
|
if surface.fractalrange[1] > self.volume.xf:
|
||||||
self.volume.nx += surface.fractalrange[1] - self.volume.xf
|
|
||||||
self.volume.xf = surface.fractalrange[1]
|
self.volume.xf = surface.fractalrange[1]
|
||||||
elif surface.surfaceID == "yminus":
|
elif surface.surfaceID == "yminus":
|
||||||
if surface.fractalrange[0] < self.volume.ys:
|
if surface.fractalrange[0] < self.volume.ys:
|
||||||
self.volume.ny += self.volume.ys - surface.fractalrange[0]
|
|
||||||
self.volume.ys = surface.fractalrange[0]
|
self.volume.ys = surface.fractalrange[0]
|
||||||
elif surface.surfaceID == "yplus":
|
elif surface.surfaceID == "yplus":
|
||||||
if surface.fractalrange[1] > self.volume.yf:
|
if surface.fractalrange[1] > self.volume.yf:
|
||||||
self.volume.ny += surface.fractalrange[1] - self.volume.yf
|
|
||||||
self.volume.yf = surface.fractalrange[1]
|
self.volume.yf = surface.fractalrange[1]
|
||||||
elif surface.surfaceID == "zminus":
|
elif surface.surfaceID == "zminus":
|
||||||
if surface.fractalrange[0] < self.volume.zs:
|
if surface.fractalrange[0] < self.volume.zs:
|
||||||
self.volume.nz += self.volume.zs - surface.fractalrange[0]
|
|
||||||
self.volume.zs = surface.fractalrange[0]
|
self.volume.zs = surface.fractalrange[0]
|
||||||
elif surface.surfaceID == "zplus":
|
elif surface.surfaceID == "zplus":
|
||||||
if surface.fractalrange[1] > self.volume.zf:
|
if surface.fractalrange[1] > self.volume.zf:
|
||||||
self.volume.nz += surface.fractalrange[1] - self.volume.zf
|
|
||||||
self.volume.zf = surface.fractalrange[1]
|
self.volume.zf = surface.fractalrange[1]
|
||||||
|
|
||||||
# If there is only 1 bin then a normal material is being used,
|
# If there is only 1 bin then a normal material is being used,
|
||||||
|
在新工单中引用
屏蔽一个用户