Skip to content
Snippets Groups Projects
Commit 952c8a5b authored by Cristian Lalescu's avatar Cristian Lalescu
Browse files

add amplitude parameter for field generator

parent 3309a4f6
No related branches found
No related tags found
No related merge requests found
......@@ -273,6 +273,7 @@ class fluid_particle_base(bfps.code):
self,
rseed = 7547,
spectra_slope = 1.,
amplitude = 1.,
precision = 'single',
iteration = 0,
field_name = 'vorticity',
......@@ -282,17 +283,20 @@ class fluid_particle_base(bfps.code):
self.parameters['nz']//2,
self.parameters['ny']//2,
self.parameters['nx']//2,
p = spectra_slope).astype(self.ctype)
p = spectra_slope,
amplitude = amplitude).astype(self.ctype)
Kdata01 = bfps.tools.generate_data_3D(
self.parameters['nz']//2,
self.parameters['ny']//2,
self.parameters['nx']//2,
p = spectra_slope).astype(self.ctype)
p = spectra_slope,
amplitude = amplitude).astype(self.ctype)
Kdata02 = bfps.tools.generate_data_3D(
self.parameters['nz']//2,
self.parameters['ny']//2,
self.parameters['nx']//2,
p = spectra_slope).astype(self.ctype)
p = spectra_slope,
amplitude = amplitude).astype(self.ctype)
Kdata0 = np.zeros(
Kdata00.shape + (3,),
Kdata00.dtype)
......
......@@ -30,13 +30,14 @@ import numpy as np
def generate_data_3D(
n0, n1, n2,
dtype = np.complex128,
p = 1.5):
p = 1.5,
amplitude = 0.5):
"""
generate something that has the proper shape
"""
assert(n0 % 2 == 0 and n1 % 2 == 0 and n2 % 2 == 0)
a = np.zeros((n1, n0, n2/2+1), dtype = dtype)
a[:] = np.random.randn(*a.shape) + 1j*np.random.randn(*a.shape)
a[:] = amplitude*(np.random.randn(*a.shape) + 1j*np.random.randn(*a.shape))
k, j, i = np.mgrid[-n1/2+1:n1/2+1, -n0/2+1:n0/2+1, 0:n2/2+1]
k = (k**2 + j**2 + i**2)**.5
k = np.roll(k, n1//2+1, axis = 0)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment