diff --git a/TurTLE/test/test_particle_clouds.py b/TurTLE/test/test_particle_clouds.py index f72071143778bb79cbe2ea1128769c9c32004f5e..068cc4811a92c0b7ca6f82b6978b0959f069eb65 100644 --- a/TurTLE/test/test_particle_clouds.py +++ b/TurTLE/test/test_particle_clouds.py @@ -33,22 +33,22 @@ import sys import TurTLE from TurTLE import DNS - -def main(): +def basic_test(): nclouds = 10 nparticles_per_cloud = 1000 nparticles = nclouds*nparticles_per_cloud niterations = 32 c = DNS() c.dns_type = 'NSVEparticles' - c.parameters['nparticles'] = nparticles - c.parameters['tracers1_integration_steps'] = 4 - c.generate_tracer_state(rseed = 2, species = 1) - del c.parameters['nparticles'] - del c.parameters['tracers1_integration_steps'] + c.simname = 'basic_cloud_test' + f0 = h5py.File( + os.path.join( + os.path.join(TurTLE.lib_dir, 'test'), + 'B32p1e4_checkpoint_0.h5'), + 'r') ic_file = h5py.File(c.get_checkpoint_0_fname(), 'a') - ic_file['tracers0/state/0'] = ic_file['tracers1/state/0'][...].reshape(nclouds, nparticles_per_cloud, 3) - ic_file['tracers0/rhs/0'] = ic_file['tracers1/rhs/0'][...].reshape(4, nclouds, nparticles_per_cloud, 3) + ic_file['tracers0/state/0'] = f0['tracers0/state/0'][...].reshape(nclouds, nparticles_per_cloud, 3) + ic_file['tracers0/rhs/0'] = f0['tracers0/rhs/0'][...].reshape(4, nclouds, nparticles_per_cloud, 3) ic_file.close() c.launch( ['NSVEparticles', @@ -57,12 +57,14 @@ def main(): '--forcing_type', 'linear', '--src-wd', TurTLE.lib_dir + '/test', '--src-iteration', '0', + '--simname', c.simname, '--np', '4', '--ntpp', '1', '--fftw_plan_rigor', 'FFTW_PATIENT', '--niter_todo', '{0}'.format(niterations), '--niter_out', '{0}'.format(niterations), '--niter_stat', '1', + '--checkpoints_per_file', '{0}'.format(3), '--nparticles', '{0}'.format(nparticles), '--njobs', '2', '--wd', './']) @@ -79,6 +81,7 @@ def main(): x0 = f0['tracers0/state/{0}'.format(iteration)][...] x1 = f1['tracers0/state/{0}'.format(iteration)][...].reshape(x0.shape) traj_error = np.max(np.abs(x0 - x1)) + print(traj_error) y0 = f0['tracers0/rhs/{0}'.format(iteration)][...] y1 = f1['tracers0/rhs/{0}'.format(iteration)][...].reshape(y0.shape) rhs_error = np.max(np.abs(y0 - y1)) @@ -88,6 +91,59 @@ def main(): print('SUCCESS! Basic test passed.') return None +def nasty_test(): + nclouds = 10 + nparticles_per_cloud = 1000000 + nparticles = nclouds*nparticles_per_cloud + niterations = 32 + c = DNS() + c.dns_type = 'NSVEparticles' + c.simname = 'nasty_cloud_test' + c.parameters['nparticles'] = nparticles + c.parameters['tracers1_integration_steps'] = 4 + c.generate_tracer_state(rseed = 2, species = 1) + del c.parameters['nparticles'] + del c.parameters['tracers1_integration_steps'] + ic_file = h5py.File(c.get_checkpoint_0_fname(), 'a') + ic_file['tracers0/state/0'] = ic_file['tracers1/state/0'][...].reshape(nclouds, nparticles_per_cloud, 3) + ic_file['tracers0/rhs/0'] = ic_file['tracers1/rhs/0'][...].reshape(4, nclouds, nparticles_per_cloud, 3) + # put all particles in single z cell + ic_file['tracers0/state/0'][..., 2] = 0.0001 + # put one cloud on another process + ic_file['tracers0/state/0'][1, :, 2] = np.pi + 0.0001 + ic_file.close() + c.launch( + ['NSVEparticles', + '-n', '32', + '--src-simname', 'B32p1e4', + '--simname', c.simname, + '--forcing_type', 'linear', + '--src-wd', TurTLE.lib_dir + '/test', + '--src-iteration', '0', + '--np', '4', + '--ntpp', '1', + '--fftw_plan_rigor', 'FFTW_PATIENT', + '--niter_todo', '{0}'.format(niterations), + '--niter_out', '{0}'.format(niterations), + '--niter_stat', '1', + '--nparticles', '{0}'.format(nparticles), + '--njobs', '2', + '--wd', './']) + f0 = h5py.File( + os.path.join( + os.path.join(TurTLE.lib_dir, 'test'), + 'B32p1e4_checkpoint_0.h5'), + 'r') + f1 = h5py.File(c.get_checkpoint_0_fname(), 'r') + print('SUCCESS! Nasty test passed.') + return None + + +def main(): + basic_test() + nasty_test() + return None + if __name__ == '__main__': main()