diff --git a/CMakeLists.txt b/CMakeLists.txt index a2a18ce081039e32df522b993c3a60e9e5e78514..a9d0425fdbed5c8b4f5c7dab2dae54afdad2256b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -415,6 +415,10 @@ if (BUILD_TESTING) NAME test_Parseval COMMAND turtle.test_Parseval WORKING_DIRECTORY ${TEST_OUTPUT_DIRECTORY}) + add_test( + NAME test_statistics + COMMAND turtle.test_statistics + WORKING_DIRECTORY ${TEST_OUTPUT_DIRECTORY}) ### basic particle functionality add_test( NAME test_particles diff --git a/TurTLE/DNS.py b/TurTLE/DNS.py index b3e7c76a96cd9afabfc25f0118f5d23ee81802dc..9b1bff221ee57e977a617869706b50dffb82ad52 100644 --- a/TurTLE/DNS.py +++ b/TurTLE/DNS.py @@ -350,7 +350,9 @@ class DNS(_code): 'R_ij(t)', 'vel_max(t)', 'renergy(t)', - 'renstrophy(t)']: + 'renstrophy(t)', + 'iter0', + 'iter1']: if k in pp_file.keys(): self.statistics[k] = pp_file[k][...] # sanity check --- Parseval theorem check @@ -452,6 +454,60 @@ class DNS(_code): self.statistics['D'] = self.statistics['Lint'] * self.statistics['diss'] / self.statistics['Uint']**3 self.statistics['Taylor_microscale'] = self.statistics['lambda'] return None + def read_moments( + self, + quantity = 'velocity', + base_group = 'statistics', + pp_file = None, + iteration_range = None): + assert(len(self.statistics.keys()) > 0) + if type(pp_file) == type(None): + pp_file = self.get_data_file() + if type(iteration_range) == type(None): + iteration_range = [self.statistics['iter0'], self.statistics['iter1']] + mm = pp_file[base_group + '/moments/' + quantity][ + iteration_range[0]//self.parameters['niter_stat']:iteration_range[1]//self.parameters['niter_stat']] + mm = np.mean(mm, axis = 0) + return mm + def read_histogram( + self, + quantity = 'velocity', + base_group = 'statistics', + pp_file = None, + iteration_range = None, + max_estimate = None): + assert(len(self.statistics.keys()) > 0) + if type(pp_file) == type(None): + pp_file = self.get_data_file() + if type(iteration_range) == type(None): + iteration_range = [self.statistics['iter0'], self.statistics['iter1']] + if type(max_estimate) == type(None): + max_estimate = self.parameters['max_' + quantity + '_estimate'] + hh = pp_file[base_group + '/histograms/' + quantity][ + iteration_range[0]//self.parameters['niter_stat']:iteration_range[1]//self.parameters['niter_stat']] + hh = np.mean(hh, axis = 0) + if (hh.shape[-1] == 4): + hh = hh[..., :3] + max_estimate /= 3**0.5 + bb0 = np.linspace(-max_estimate, max_estimate, self.parameters['histogram_bins']+1) + bb = (bb0[1:] + bb0[:-1])*0.5 + npoints = np.round(np.mean(np.sum(hh, axis = 0))) + if (int(npoints) != self.parameters['nx']*self.parameters['ny']*self.parameters['nz']): + print('Warning: maximum estimates were wrong, histogram does not capture all values of ' + quantity + '.') + print('Total number of points is {0}, histogram captures {1} points.'.format( + self.parameters['nx']*self.parameters['ny']*self.parameters['nz'], + npoints)) + pdf = hh / (npoints * (bb[1] - bb[0])) + return bb, hh, pdf + def compute_statistics_error( + self, + **kwargs): + mm = self.read_moments(**kwargs) + bb, hh, pdf = self.read_histogram(**kwargs) + alt_mm2 = np.sum(pdf*(bb[:, None]**2)*(bb[1] - bb[0]), axis = 0) + relative_error = np.abs(mm[2, :3] - alt_mm2) / (mm[2, :3]) + assert(relative_error.max() < 0.01) + return relative_error.max() def set_plt_style( self, style = {'dashes' : (None, None)}): diff --git a/TurTLE/PP.py b/TurTLE/PP.py index f653f5dbd9b9cb05fdad85529bf625a90f674b5a..d77d550fab534e8337f1a28da3cf170bb747957b 100644 --- a/TurTLE/PP.py +++ b/TurTLE/PP.py @@ -125,7 +125,7 @@ class PP(_code): self.parameters['fk1'] = float(4.0) self.parameters['forcing_type'] = 'linear' self.pp_parameters = {} - self.pp_parameters['iteration_list'] = np.zeros(1).astype(np.int) + self.pp_parameters['iteration_list'] = np.zeros(1).astype(int) return None def extra_postprocessing_parameters( self, @@ -205,7 +205,7 @@ class PP(_code): pp_file['ii1'] = ii1 pp_file['t'] = (self.parameters['dt']* self.parameters['niter_stat']* - (np.arange(ii0, ii1+1).astype(np.float))) + (np.arange(ii0, ii1+1).astype(float))) pp_file['energy(t, k)'] = ( data_file['statistics/spectra/velocity_velocity'][ii0:ii1+1, :, 0, 0] + data_file['statistics/spectra/velocity_velocity'][ii0:ii1+1, :, 1, 1] + @@ -468,7 +468,7 @@ class PP(_code): niter_out = self.get_data_file()['parameters/niter_out'][...] assert(opt.iter0 % niter_out == 0) self.pp_parameters['iteration_list'] = np.arange( - opt.iter0, opt.iter1+niter_out, niter_out, dtype = np.int) + opt.iter0, opt.iter1+niter_out, niter_out, dtype = int) return opt def launch( self, diff --git a/TurTLE/TEST.py b/TurTLE/TEST.py index 72fc9609ea962787550a6082d3b1e65f0bb0f69e..7095f59ac74c978aae3c54f611fedcee85519f35 100644 --- a/TurTLE/TEST.py +++ b/TurTLE/TEST.py @@ -460,13 +460,13 @@ class TEST(_code): (self.parameters['tracers{0}_integration_steps'.format(s)],) + pbase_shape + (ncomponents,)), - dtype = np.float) + dtype = np.float64) ofile['tracers{0}/state'.format(s)].create_dataset( '0', shape = ( pbase_shape + (ncomponents,)), - dtype = np.float) + dtype = np.float64) if type(particle_initial_condition) == type(None): ofile['tracers0/state/0'][:] = np.random.random(pbase_shape + (ncomponents,))*2*np.pi else: diff --git a/TurTLE/_base.py b/TurTLE/_base.py index da1c91fc8a44b3270d77e6c30c4c9124d9d0cc8b..e445e8d05f25236d7514be1b1b96d855f8f21f22 100644 --- a/TurTLE/_base.py +++ b/TurTLE/_base.py @@ -78,7 +78,7 @@ class _base(object): src_txt += 'std::vector<' if parameters[key[i]].dtype == np.float64: src_txt += 'double' - elif parameters[key[i]].dtype == np.int: + elif parameters[key[i]].dtype == int: src_txt += 'int' src_txt += '> ' + key[i] + ';\n' else: @@ -137,7 +137,7 @@ class _base(object): '}\n' + 'else printf({0}, "NULL");\n'.format(key_prefix + key[i])) elif type(parameters[key[i]]) == np.ndarray: - if parameters[key[i]].dtype in [np.int, np.int64, np.int32]: + if parameters[key[i]].dtype in [int, np.int64, np.int32]: template_par = 'int' elif parameters[key[i]].dtype == np.float64: template_par = 'double' @@ -164,7 +164,7 @@ class _base(object): '.size(); array_counter++)\n' + '{\n' + 'DEBUG_MSG("' + key[i] + '[%d] = %') - if self.parameters[key[i]].dtype == np.int: + if self.parameters[key[i]].dtype == int: src_txt += 'd' elif self.parameters[key[i]].dtype == np.float64: src_txt += 'g' diff --git a/TurTLE/_code.py b/TurTLE/_code.py index fcd6ac5b4181fdf75b27ba920aa43caa28c5ec57..a26e564af1d74da484c27d383bc4fead55fc4709 100644 --- a/TurTLE/_code.py +++ b/TurTLE/_code.py @@ -47,151 +47,10 @@ class _code(_base): work_dir = './', simname = 'test'): _base.__init__(self, work_dir = work_dir, simname = simname) - self.version_message = ( - '/***********************************************************************\n' + - '* this code automatically generated by TurTLE\n' + - '* version {0}\n'.format(TurTLE.__version__) + - '***********************************************************************/\n\n\n') - self.includes = """ - //begincpp - #include "base.hpp" - #include "fluid_solver.hpp" - #include "scope_timer.hpp" - #include "fftw_interface.hpp" - #include <iostream> - #include <hdf5.h> - #include <string> - #include <cstring> - #include <fftw3-mpi.h> - #include <omp.h> - #include <fenv.h> - #include <cstdlib> - //endcpp - """ - self.variables = 'int myrank, nprocs;\n' - self.variables += 'int iteration;\n' - self.variables += 'char simname[256], fname[256];\n' - self.variables += ('hid_t parameter_file, stat_file, Cdset;\n') - self.definitions = '' - self.main_start = """ - //begincpp - int main(int argc, char *argv[]) - { - if(getenv("TURTLE_FPE_OFF") == nullptr || getenv("TURTLE_FPE_OFF") != std::string("TRUE")){ - feenableexcept(FE_INVALID | FE_OVERFLOW); - } - else{ - std::cout << "FPE have been turned OFF" << std::endl; - } - if (argc != 2) - { - std::cerr << "Wrong number of command line arguments. Stopping." << std::endl; - MPI_Finalize(); - return EXIT_SUCCESS; - } - #ifdef NO_FFTWOMP - MPI_Init(&argc, &argv); - MPI_Comm_rank(MPI_COMM_WORLD, &myrank); - MPI_Comm_size(MPI_COMM_WORLD, &nprocs); - fftw_mpi_init(); - fftwf_mpi_init(); - DEBUG_MSG("There are %d processes\\n", nprocs); - #else - int mpiprovided; - MPI_Init_thread(&argc, &argv, MPI_THREAD_FUNNELED, &mpiprovided); - assert(mpiprovided >= MPI_THREAD_FUNNELED); - MPI_Comm_rank(MPI_COMM_WORLD, &myrank); - MPI_Comm_size(MPI_COMM_WORLD, &nprocs); - const int nbThreads = omp_get_max_threads(); - DEBUG_MSG("Number of threads for the FFTW = %d\\n", nbThreads); - if (nbThreads > 1){ - fftw_init_threads(); - fftwf_init_threads(); - } - fftw_mpi_init(); - fftwf_mpi_init(); - DEBUG_MSG("There are %d processes and %d threads\\n", nprocs, nbThreads); - if (nbThreads > 1){ - fftw_plan_with_nthreads(nbThreads); - fftwf_plan_with_nthreads(nbThreads); - } - #endif - strcpy(simname, argv[1]); - snprintf(fname, 255, "%s.h5", simname); - parameter_file = H5Fopen(fname, H5F_ACC_RDONLY, H5P_DEFAULT); - Cdset = H5Dopen(parameter_file, "iteration", H5P_DEFAULT); - H5Dread( - Cdset, - H5T_NATIVE_INT, - H5S_ALL, - H5S_ALL, - H5P_DEFAULT, - &iteration); - DEBUG_MSG("simname is %s and iteration is %d\\n", - simname, iteration); - H5Dclose(Cdset); - H5Fclose(parameter_file); - read_parameters(); - if (myrank == 0) - { - // set caching parameters - hid_t fapl = H5Pcreate(H5P_FILE_ACCESS); - herr_t cache_err = H5Pset_cache(fapl, 0, 521, 134217728, 1.0); - DEBUG_MSG("when setting stat_file cache I got %d\\n", cache_err); - stat_file = H5Fopen(fname, H5F_ACC_RDWR, fapl); - } - { - TIMEZONE("code::main_start"); - //endcpp - """ - for ostream in ['cout', 'cerr']: - self.main_start += 'if (myrank == 0) std::{1} << "{0}" << std::endl;'.format( - self.version_message, ostream).replace('\n', '\\n') + '\n' - self.main_end = """ - //begincpp - } - // clean up - if (myrank == 0) - { - Cdset = H5Dopen(stat_file, "iteration", H5P_DEFAULT); - H5Dwrite(Cdset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, &iteration); - H5Dclose(Cdset); - H5Fclose(stat_file); - } - fftwf_mpi_cleanup(); - fftw_mpi_cleanup(); - #ifndef NO_FFTWOMP - if (nbThreads > 1){ - fftw_cleanup_threads(); - fftwf_cleanup_threads(); - } - #endif - #ifdef USE_TIMINGOUTPUT - global_timer_manager.show(MPI_COMM_WORLD); - global_timer_manager.showHtml(MPI_COMM_WORLD); - #endif - MPI_Finalize(); - return EXIT_SUCCESS; - } - //endcpp - """ self.host_info = host_info - self.main = '' self.check_current_vorticity_exists = True self.check_current_velocity_exists = False return None - def write_src(self): - with open(self.name + '.cpp', 'w') as outfile: - outfile.write(self.version_message) - outfile.write(self.includes) - outfile.write(self.cdef_pars()) - outfile.write(self.variables) - outfile.write(self.cread_pars()) - outfile.write(self.definitions) - outfile.write(self.main_start) - outfile.write(self.main) - outfile.write(self.main_end) - return None def compile_code( self, no_debug = True): diff --git a/TurTLE/test/test_Heun_p2p.py b/TurTLE/test/test_Heun_p2p.py index 7947ded4da7e908e6db037bedbd719518786ddd7..170144723d405d95baaca2687ddbc496b1808375 100644 --- a/TurTLE/test/test_Heun_p2p.py +++ b/TurTLE/test/test_Heun_p2p.py @@ -59,7 +59,7 @@ class ADNS(TurTLE.DNS): for hh in self.include_list]) self.name = 'NSVEparticle_set' self.dns_type = 'NSVEparticle_set' - self.definitions += open( + self.definitions = open( os.path.join( cpp_location, 'NSVEparticle_set.hpp'), 'r').read() self.definitions += open( diff --git a/TurTLE/test/test_collisions.py b/TurTLE/test/test_collisions.py index cf3afd9c608e7b24a9cf7e498be209e387fcba52..ae82a5f015e6c0895c83c392edf61d5222ed3371 100644 --- a/TurTLE/test/test_collisions.py +++ b/TurTLE/test/test_collisions.py @@ -74,7 +74,7 @@ class ADNS_Stokes_test(TurTLE.DNS): for hh in self.include_list]) self.name = 'NSVEparticles_stokes_set' self.dns_type = 'NSVE_Stokes_growing_subset' - self.definitions += open( + self.definitions = open( os.path.join( cpp_location, 'p2p_stokes_collisions_growing_subset.hpp'), 'r').read() self.definitions += open( @@ -150,11 +150,11 @@ class ADNS_Stokes_test(TurTLE.DNS): data_file['tracers{0}/rhs'.format(species)].create_dataset( '0', shape = (integration_steps, nn, ncomponents,), - dtype = np.float) + dtype = float) dset = data_file['tracers{0}/state'.format(species)].create_dataset( '0', shape = (nn, ncomponents,), - dtype = np.float) + dtype = float) if not type(rseed) == type(None): np.random.seed(rseed) cc = int(0) diff --git a/TurTLE/test/test_interpolation_methods.py b/TurTLE/test/test_interpolation_methods.py index 50a58328ae3037b053a69a851bac3c6de2b6d428..9c900813cc10aef8f33ee04fa407bfe3a2662302 100644 --- a/TurTLE/test/test_interpolation_methods.py +++ b/TurTLE/test/test_interpolation_methods.py @@ -59,11 +59,11 @@ def main(): err = np.abs(phi0 - phi1) err_mean_2.append(err.mean()) err_max_2.append(err.max()) - neighbour_list = np.array([1, 2, 3, 4]).astype(np.float) + neighbour_list = np.array([1, 2, 3, 4]).astype(float) a.plot(neighbour_list, err_mean_1, marker = '.', label = 'm=1, mean') a.plot(neighbour_list, err_max_1, marker = '.', label = 'm=1, max') a.plot(neighbour_list, 1e-4*neighbour_list**(-4), color = 'black', dashes = (2, 2)) - neighbour_list = np.array([2, 3, 4]).astype(np.float) + neighbour_list = np.array([2, 3, 4]).astype(float) a.plot(neighbour_list, err_mean_2, marker = '.', label = 'm=2, mean') a.plot(neighbour_list, err_max_2, marker = '.', label = 'm=2, max') diff --git a/TurTLE/test/test_particle_deleter.py b/TurTLE/test/test_particle_deleter.py index af8fb85170bb6ca76aa856ab09dc1ff7a22c59a8..551a0756c5e3b4eba11372f91c8fd0f11ae921f8 100644 --- a/TurTLE/test/test_particle_deleter.py +++ b/TurTLE/test/test_particle_deleter.py @@ -66,7 +66,7 @@ class ADNS(TurTLE.DNS): for hh in self.include_list]) self.name = 'particle_deleter' self.dns_type = 'particle_deleter' - self.definitions += open( + self.definitions = open( os.path.join( cpp_location, self.dns_type + '.hpp'), 'r').read() self.definitions += open( diff --git a/TurTLE/test/test_particle_integration.py b/TurTLE/test/test_particle_integration.py index def55e5bde50af678b758e49aef7c21d027678b0..644c00a4ab355a58add373bec3c8e59a92d18935 100644 --- a/TurTLE/test/test_particle_integration.py +++ b/TurTLE/test/test_particle_integration.py @@ -100,11 +100,11 @@ def main(): # err = np.abs(phi0 - phi1) # err_mean_2.append(err.mean()) # err_max_2.append(err.max()) - #neighbour_list = np.array([1, 2, 3, 4]).astype(np.float) + #neighbour_list = np.array([1, 2, 3, 4]).astype(float) #a.plot(neighbour_list, err_mean_1, marker = '.', label = 'm=1, mean') #a.plot(neighbour_list, err_max_1, marker = '.', label = 'm=1, max') #a.plot(neighbour_list, 1e-4*neighbour_list**(-4), color = 'black', dashes = (2, 2)) - #neighbour_list = np.array([2, 3, 4]).astype(np.float) + #neighbour_list = np.array([2, 3, 4]).astype(float) #a.plot(neighbour_list, err_mean_2, marker = '.', label = 'm=2, mean') #a.plot(neighbour_list, err_max_2, marker = '.', label = 'm=2, max') diff --git a/TurTLE/test/test_particles.py b/TurTLE/test/test_particles.py index f3afb7f7cbd659311845a6d0c32f00fa9653b022..7c1baa2a521f7c4b1e329094647f221603d28a84 100644 --- a/TurTLE/test/test_particles.py +++ b/TurTLE/test/test_particles.py @@ -59,7 +59,7 @@ def main(): np.sum(x**2, axis = -1).flatten()**.5, bins = np.linspace(0, 2, 40)) bb = (bins[:-1] + bins[1:])/2 - pp = hist.astype(np.float) / (np.sum(hist) * (bb[1] - bb[0])) + pp = hist.astype(float) / (np.sum(hist) * (bb[1] - bb[0])) a.plot(bb, pp, label = '{0}'.format(iteration)) a.legend(loc = 'best') f.tight_layout() @@ -74,7 +74,7 @@ def main(): np.sum(x**2, axis = -1).flatten()**.5, bins = 40) bb = (bins[:-1] + bins[1:])/2 - pp = hist.astype(np.float) / (np.sum(hist) * (bb[1] - bb[0])) + pp = hist.astype(float) / (np.sum(hist) * (bb[1] - bb[0])) a.plot(bb, pp, label = '{0}'.format(iteration)) a.legend(loc = 'best') f.tight_layout() @@ -89,7 +89,7 @@ def main(): np.sum(x**2, axis = -1).flatten()**.5, bins = np.linspace(0, 2, 40)) bb = (bins[:-1] + bins[1:])/2 - pp = hist.astype(np.float) / (np.sum(hist) * (bb[1] - bb[0])) + pp = hist.astype(float) / (np.sum(hist) * (bb[1] - bb[0])) a.plot(bb, pp, label = '{0}'.format(iteration)) a.legend(loc = 'best') f.tight_layout() @@ -121,7 +121,7 @@ def main(): x.flatten(), bins = 100) bb = (bins[:-1] + bins[1:])/2 - pp = hist.astype(np.float) / (np.sum(hist) * (bb[1] - bb[0])) + pp = hist.astype(float) / (np.sum(hist) * (bb[1] - bb[0])) a.plot(bb, pp, label = '{0}'.format(iteration)) a.legend(loc = 'best') f.tight_layout() diff --git a/TurTLE/test/test_statistics.py b/TurTLE/test/test_statistics.py new file mode 100644 index 0000000000000000000000000000000000000000..7094a5f657766dc17db86a392eb137079ed54287 --- /dev/null +++ b/TurTLE/test/test_statistics.py @@ -0,0 +1,32 @@ +import TurTLE +from TurTLE import DNS +import numpy as np + +def main(): + c = DNS() + c.launch([ + 'NSVE', + '--simname', 'test_statistics', + '--src-simname', 'B32p1e4', + '--src-wd', TurTLE.data_dir, + '--niter_todo', '32', + '--niter_stat', '1', + '--max_velocity_estimate', '10', + '--max_vorticity_estimate', '20']) + c.compute_statistics() + + # velocity + mm = c.read_moments() + bb, hh, pdf = c.read_histogram() + print(c.compute_statistics_error()) + print(mm[2, 3]*0.5, c.statistics['energy']) + + # vorticity + mm = c.read_moments(quantity = 'vorticity') + bb, hh, pdf = c.read_histogram(quantity = 'vorticity') + print(c.compute_statistics_error(quantity = 'vorticity')) + print(mm[2, 3]*0.5, c.statistics['enstrophy']) + return None + +if __name__ == '__main__': + main() diff --git a/TurTLE/test/test_turtle_NSVE_Stokes_particles.py b/TurTLE/test/test_turtle_NSVE_Stokes_particles.py index 400a0cdb12ba0790343489a8570f9383a16daa80..acc67272843995bbe64dec0bbdf6a060d8d64d5b 100644 --- a/TurTLE/test/test_turtle_NSVE_Stokes_particles.py +++ b/TurTLE/test/test_turtle_NSVE_Stokes_particles.py @@ -83,7 +83,7 @@ def main(): time_values = np.arange(0, niterations*dt, dt) numerics, = plt.plot(time_values, particle_momentum, alpha = 1, lw=2) plt.plot(time_values, - theory_exponential(time_values, f2['parameters/initial_particle_vel'],np.float(drag_coeff)), + theory_exponential(time_values, f2['parameters/initial_particle_vel'],float(drag_coeff)), color='black', ls = '--') plt.plot(0,0,color=numerics.get_color(),label=r'drag coefficient '+drag_coeff) j+=1 diff --git a/TurTLE/tools.py b/TurTLE/tools.py index 6d3869854a9070eaeca2c1bc8149e38637730df7..1fab1c18a6329a05826ce6e19ffca2e05dfcf60e 100644 --- a/TurTLE/tools.py +++ b/TurTLE/tools.py @@ -258,7 +258,7 @@ def get_fornberg_coeffs( coeffs.append([]) for j in range(len(d)): coeffs[-1].append(d[m][N][j]) - return np.array(coeffs).astype(np.float) + return np.array(coeffs).astype(float) def particle_finite_diff_test( c, diff --git a/examples/convergence/fields_temporal.py b/examples/convergence/fields_temporal.py index d5e271be336b70303c6e2845a438293930834a6e..eb20cef121fba83b7c300cff2ef64639754c1b72 100644 --- a/examples/convergence/fields_temporal.py +++ b/examples/convergence/fields_temporal.py @@ -161,7 +161,7 @@ def plot_error_field(err_vs_t = False): error_list[2], marker = '.', label = 'NSVE vs NSE') - fl = np.array(factor_list).astype(np.float) + fl = np.array(factor_list).astype(float) for ee in [2, 3]: a.plot(fl[:2], error_list[0][0] * fl[:2]**(-ee), dashes = (ee, ee), diff --git a/examples/convergence/particles_temporal.py b/examples/convergence/particles_temporal.py index c7b0ac15573a97031bd9a72e706674d03f6d8a8f..190bfa89f8a6990754ccc495401fa493fcf075bf 100644 --- a/examples/convergence/particles_temporal.py +++ b/examples/convergence/particles_temporal.py @@ -166,7 +166,7 @@ def plot_error_particles(): f = plt.figure() a = f.add_subplot(111) factor_list = [1, 2] - factor_list = np.array(factor_list).astype(np.float) + factor_list = np.array(factor_list).astype(float) for neighbours, smoothness in neighbours_smoothness_list: interp_name = 'I{0}O{1}'.format(2*neighbours+2, 2*smoothness+1) err_max_list = [] diff --git a/meta/count_nmodes.py b/meta/count_nmodes.py index 19af4ab332067ba72758bbc5244b33c8ea569dc0..d3b55587850f4ee2d137074d0dd5e46eadff7fb9 100644 --- a/meta/count_nmodes.py +++ b/meta/count_nmodes.py @@ -1,7 +1,7 @@ import numpy as np def count_expensive(fk0, fk1): - kcomponent = np.arange(-np.floor(fk1)-1, np.floor(fk1)+2, 1).astype(np.float) + kcomponent = np.arange(-np.floor(fk1)-1, np.floor(fk1)+2, 1).astype(float) ksize = (kcomponent[:, None, None]**2 + kcomponent[None, :, None]**2 + kcomponent[None, None, :]**2)**.5 diff --git a/projects/sedimenting_rods/GCDNS.py b/projects/sedimenting_rods/GCDNS.py index 670c910d270d3b5fb60aaf255b1b8f438cd0c77a..e7232dfcfc866b921f0693776d1e22cd572dfac9 100644 --- a/projects/sedimenting_rods/GCDNS.py +++ b/projects/sedimenting_rods/GCDNS.py @@ -47,7 +47,7 @@ class GCDNS(TurTLE.DNS): 'tracers0_u_sed' : np.array([1.0],dtype='float64'), 'l_factor' : float(1.0), 't_factor' : float(1.0), - 'many_integration_steps' : np.array([2]).astype(np.int), + 'many_integration_steps' : np.array([2]).astype(int), } return None def write_src( @@ -127,11 +127,11 @@ class GCDNS(TurTLE.DNS): data_file['tracers{0}/rhs'.format(species)].create_dataset( '0', shape = (integration_steps, nn, ncomponents,), - dtype = np.float) + dtype = np.float64) dset = data_file['tracers{0}/state'.format(species)].create_dataset( '0', shape = (nn, ncomponents,), - dtype = np.float) + dtype = np.float64) if not type(rseed) == type(None): np.random.seed(rseed) cc = int(0) diff --git a/setup.py.in b/setup.py.in index 87261d3275b2fe97190e7268771ddd8660f3b3b5..984a8993a1aedbbcae15267b7dcd24fb87012fe8 100644 --- a/setup.py.in +++ b/setup.py.in @@ -47,6 +47,7 @@ setup( 'turtle.test_NSVEparticles = TurTLE.test.test_turtle_NSVEparticles:main', 'turtle.test_particles = TurTLE.test.test_particles:main', 'turtle.test_Parseval = TurTLE.test.test_Parseval:main', + 'turtle.test_statistics = TurTLE.test.test_statistics:main', 'turtle.test_fftw = TurTLE.test.test_fftw:main', 'turtle.test_Heun_p2p = TurTLE.test.test_Heun_p2p:main', 'turtle.test_particle_deleter = TurTLE.test.test_particle_deleter:main', diff --git a/tests/test_field_class.py b/tests/test_field_class.py index ef0cc8513c3bb289c018afb9f4a4e726a5e8a728..7bd9e7ab38cd41b336fd065a4aa96ddbcf74de1c 100644 --- a/tests/test_field_class.py +++ b/tests/test_field_class.py @@ -129,8 +129,8 @@ def main(): f['scal/real/0'] = rdata f['vec/complex/0'] = np.array([cdata, cdata, cdata]).reshape(cdata.shape + (3,)) f['vec/real/0'] = np.array([rdata, rdata, rdata]).reshape(rdata.shape + (3,)) - f['moments/scal'] = np.zeros(shape = (1, 10)).astype(np.float) - f['histograms/scal'] = np.zeros(shape = (1, 64)).astype(np.float) + f['moments/scal'] = np.zeros(shape = (1, 10)).astype(float) + f['histograms/scal'] = np.zeros(shape = (1, 64)).astype(float) kspace = tf.get_kspace() nshells = kspace['nshell'].shape[0] f['spectra/scal'] = np.zeros(shape = (1, nshells)).astype(np.float64)