Fixed int/float bug with fractal dim & simplified fractal dim behaviour

这个提交包含在:
craig-warren
2023-12-22 21:23:48 +00:00
父节点 76ab1a7c46
当前提交 7a82e0a926
共有 2 个文件被更改,包括 10 次插入14 次删除

查看文件

@@ -27,7 +27,7 @@ cpdef void generate_fractal2D(
int nx,
int ny,
int nthreads,
int b,
float D,
np.float64_t[:] weighting,
np.float64_t[:] v1,
np.complex128_t[:, ::1] A,
@@ -38,7 +38,7 @@ cpdef void generate_fractal2D(
Args:
nx, ny: int for fractal surface size in cells.
nthreads: int for number of threads to use
b: int for constant related to fractal dimension.
D: float for fractal dimension.
weighting: memoryview for access to weighting vector.
v1: memoryview for access to positional vector at centre of array,
scaled by weighting.
@@ -59,7 +59,7 @@ cpdef void generate_fractal2D(
# Calulate norm of v2 - v1
rr = ((v2x - v1[0])**2 + (v2y - v1[1])**2)**(1/2)
B = rr**b
B = rr**D
if B == 0:
B = 0.9
@@ -71,7 +71,7 @@ cpdef void generate_fractal3D(
int ny,
int nz,
int nthreads,
int b,
float D,
np.float64_t[:] weighting,
np.float64_t[:] v1,
np.complex128_t[:, :, ::1] A,
@@ -82,7 +82,7 @@ cpdef void generate_fractal3D(
Args:
nx, ny, nz: int for fractal volume size in cells.
nthreads: int for number of threads to use
b: int for constant related to fractal dimension.
D: float for fractal dimension.
weighting: memoryview for access to weighting vector.
v1: memoryview for access to positional vector at centre of array,
scaled by weighting.
@@ -105,7 +105,7 @@ cpdef void generate_fractal3D(
# Calulate norm of v2 - v1
rr = ((v2x - v1[0])**2 + (v2y - v1[1])**2 + (v2z - v1[2])**2)**(1/2)
B = rr**b
B = rr**D
if B == 0:
B = 0.9

查看文件

@@ -56,9 +56,7 @@ class FractalSurface:
self.nz = zf - zs
self.dtype = np.dtype(np.complex128)
self.seed = seed
self.dimension = dimension
# Constant related to fractal dimension from: http://dx.doi.org/10.1017/CBO9781139174695
self.b = -(2 * self.dimension - 7) / 2
self.dimension = dimension # Fractal dimension from: http://dx.doi.org/10.1017/CBO9781139174695
self.weighting = np.array([1, 1], dtype=np.float64)
self.fractalrange = (0, 0)
self.filldepth = 0
@@ -100,7 +98,7 @@ class FractalSurface:
surfacedims[0],
surfacedims[1],
config.get_model_config().ompthreads,
self.b,
self.dimension,
self.weighting,
v1,
A,
@@ -159,9 +157,7 @@ class FractalVolume:
self.averaging = False
self.dtype = np.dtype(np.complex128)
self.seed = seed
self.dimension = dimension
# Constant related to fractal dimension from: http://dx.doi.org/10.1017/CBO9781139174695
self.b = -(2 * self.dimension - 7) / 2
self.dimension = dimension # Fractal dimension from: http://dx.doi.org/10.1017/CBO9781139174695
self.weighting = np.array([1, 1, 1], dtype=np.float64)
self.nbins = 0
self.fractalsurfaces = []
@@ -207,7 +203,7 @@ class FractalVolume:
self.ny,
self.nz,
config.get_model_config().ompthreads,
self.b,
self.dimension,
self.weighting,
v1,
A,