diff --git a/bfps/_fluid_base.py b/bfps/_fluid_base.py index 65c83c44fdf1c2b9bc843197a993d1da4fa83f84..0afc7596525791e997d7f0fbed0586dc7e35e2a6 100644 --- a/bfps/_fluid_base.py +++ b/bfps/_fluid_base.py @@ -347,6 +347,7 @@ class _fluid_particle_base(_code): field_name = 'vorticity', write_to_file = False): np.random.seed(rseed) + #to switch to constant field, add/delete _uniform from the three calls below Kdata00 = tools.generate_data_3D( self.parameters['nz']//2, self.parameters['ny']//2, diff --git a/bfps/cpp/fluid_solver_base.cpp b/bfps/cpp/fluid_solver_base.cpp index 2cbe41980161f691c25f4dbaf998a1276fd4b07f..483afc278556fdfc9c276266feb97c3b3cae66e4 100644 --- a/bfps/cpp/fluid_solver_base.cpp +++ b/bfps/cpp/fluid_solver_base.cpp @@ -24,7 +24,7 @@ -#define NDEBUG +//#define NDEBUG #include <cassert> #include <cmath> @@ -441,7 +441,7 @@ void fluid_solver_base<R>::compute_vector_gradient(FFTW(complex) *A, FFTW(comple dz_u = A + 2*this->cd->local_size; \ CLOOP_K2( \ this, \ - if (k2 <= this->kM2) \ + /*if (k2 <= this->kM2)*/ \ { \ tindex = 3*cindex; \ for (int cc=0; cc<3; cc++) \ diff --git a/bfps/tools.py b/bfps/tools.py index 936e1bf1e95738c86fa3abbc420f2ba631b5da53..f9c146dc4c1f03174d4e8fdbad71a49aac1a7513 100644 --- a/bfps/tools.py +++ b/bfps/tools.py @@ -28,6 +28,41 @@ import sys import math import numpy as np +def generate_data_3D_uniform( + n0, n1, n2, + dtype = np.complex128, + p = 1.5, + amplitude = 0.5): + """returns the Fourier representation of a constant field. + + The generated field is scalar (single component), in practice a + 3D ``numpy`` complex-valued array. + The field will use the FFTW representation, with the slowest + direction corresponding to :math:`y`, the intermediate to :math:`z` + and the fastest direction to :math:`x`. + + :param n0: number of :math:`z` nodes on real-space grid + :param n1: number of :math:`y` nodes on real-space grid + :param n2: number of :math:`x` nodes on real-space grid + :param dtype: data type to use, (default=numpy.complex128) + :param p: exponent for powerlaw to use in spectrum + :param amplitude: prefactor that field is multiplied with + :type n0: int + :type n1: int + :type n2: int + :type dtype: numpy.dtype + :type p: float + :type amplitude: float + + :returns: ``a``, a complex valued 3D ``numpy.array`` that uses the + FFTW layout. + """ + assert(n0 % 2 == 0 and n1 % 2 == 0 and n2 % 2 == 0) + a = np.zeros((n1, n0, n2/2+1), dtype = dtype) + a[0]=1. + return a + + def generate_data_3D( n0, n1, n2, dtype = np.complex128, diff --git a/setup.py b/setup.py index e9b6cce9a62fb319307d1105c4a7632a1cd6c12b..c899856c8d7679967d8e4b955170898c4f0f0d61 100644 --- a/setup.py +++ b/setup.py @@ -35,11 +35,10 @@ import subprocess import pickle - ### compiler configuration # check if .config/bfps/machine_settings.py file exists, create it if not homefolder = os.path.expanduser('~') -bfpsfolder = os.path.join(homefolder, '.config/', 'bfps') +bfpsfolder = os.path.join(homefolder, '.config', 'bfps') if not os.path.exists(os.path.join(bfpsfolder, 'machine_settings.py')): if not os.path.isdir(bfpsfolder): os.mkdir(bfpsfolder) @@ -51,12 +50,11 @@ if not os.path.exists(os.path.join(bfpsfolder, 'host_information.py')): open(os.path.join(bfpsfolder, 'host_information.py'), 'w').write('host_info = {\'type\' : \'none\'}\n') shutil.copyfile('./machine_settings_py.py', os.path.join(bfpsfolder, 'machine_settings.py')) -sys.path.append(bfpsfolder) +sys.path.insert(0, bfpsfolder) # import stuff required for compilation of static library from machine_settings import include_dirs, library_dirs, extra_compile_args, extra_libraries - ### package versioning # get current time now = datetime.datetime.now()