From ddbc00898348c731fa95071cf0c9512e042dc486 Mon Sep 17 00:00:00 2001 From: Dimitar Vlaykov <dimitar@maipo.nld.ds.mpg.de> Date: Wed, 30 Mar 2016 18:01:53 +0200 Subject: [PATCH] nothing is working --- bfps/_fluid_base.py | 1 + bfps/cpp/fluid_solver_base.cpp | 4 ++-- bfps/tools.py | 35 ++++++++++++++++++++++++++++++++++ setup.py | 6 ++---- 4 files changed, 40 insertions(+), 6 deletions(-) diff --git a/bfps/_fluid_base.py b/bfps/_fluid_base.py index 65c83c44..0afc7596 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 2cbe4198..483afc27 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 936e1bf1..f9c146dc 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 e9b6cce9..c899856c 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() -- GitLab