Commit 5b34b233 authored by Cristian Lalescu's avatar Cristian Lalescu
Browse files

adds Gauss field par control for `kraichnan_field`

parent 481916bc
...@@ -671,7 +671,20 @@ class DNS(_code): ...@@ -671,7 +671,20 @@ class DNS(_code):
eval('self.parameters_to_parser_arguments(' eval('self.parameters_to_parser_arguments('
'parser_{0},' 'parser_{0},'
'self.NSVEp_extra_parameters)'.format(parser)) 'self.NSVEp_extra_parameters)'.format(parser))
eval('self.parameters_to_parser_arguments('
'parser_{0},'
'self.generate_extra_parameters(\'{0}\'))'.format(parser))
return None return None
def generate_extra_parameters(
self,
dns_type):
pars = {}
if dns_type == 'kraichnan_field':
pars['field_random_seed'] = int(1)
pars['spectrum_slope'] = float(-5./3)
pars['spectrum_k_cutoff'] = float(16)
pars['spectrum_coefficient'] = float(1)
return pars
def prepare_launch( def prepare_launch(
self, self,
args = [], args = [],
...@@ -713,6 +726,9 @@ class DNS(_code): ...@@ -713,6 +726,9 @@ class DNS(_code):
if self.dns_type in extra_parameters.keys(): if self.dns_type in extra_parameters.keys():
for k in extra_parameters[self.dns_type].keys(): for k in extra_parameters[self.dns_type].keys():
self.parameters[k] = extra_parameters[self.dns_type][k] self.parameters[k] = extra_parameters[self.dns_type][k]
additional_parameters = self.generate_extra_parameters(self.dns_type)
for k in additional_parameters.keys():
self.parameters[k] = additional_parameters[k]
if ((self.parameters['niter_todo'] % self.parameters['niter_out']) != 0): if ((self.parameters['niter_todo'] % self.parameters['niter_out']) != 0):
self.parameters['niter_out'] = self.parameters['niter_todo'] self.parameters['niter_out'] = self.parameters['niter_todo']
if len(opt.src_work_dir) == 0: if len(opt.src_work_dir) == 0:
...@@ -1050,7 +1066,13 @@ class DNS(_code): ...@@ -1050,7 +1066,13 @@ class DNS(_code):
f['vorticity/complex/{0}'.format(0)] = data f['vorticity/complex/{0}'.format(0)] = data
f.close() f.close()
# now take care of particles' initial condition # now take care of particles' initial condition
if self.dns_type in ['kraichnan_field', 'static_field', 'NSVEparticles', 'NSVEcomplex_particles', 'NSVEparticles_no_output', 'NSVEp_extra_sampling']: if self.dns_type in [
'kraichnan_field',
'static_field',
'NSVEparticles',
'NSVEcomplex_particles',
'NSVEparticles_no_output',
'NSVEp_extra_sampling']:
self.generate_particle_data(opt = opt) self.generate_particle_data(opt = opt)
return None return None
def launch_jobs( def launch_jobs(
......
...@@ -2,20 +2,20 @@ ...@@ -2,20 +2,20 @@
* * * *
* Copyright 2019 Max Planck Institute for Dynamics and Self-Organization * * Copyright 2019 Max Planck Institute for Dynamics and Self-Organization *
* * * *
* This file is part of bfps. * * This file is part of TurTLE. *
* * * *
* bfps is free software: you can redistribute it and/or modify * * TurTLE is free software: you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published * * it under the terms of the GNU General Public License as published *
* by the Free Software Foundation, either version 3 of the License, * * by the Free Software Foundation, either version 3 of the License, *
* or (at your option) any later version. * * or (at your option) any later version. *
* * * *
* bfps is distributed in the hope that it will be useful, * * TurTLE is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of * * but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. * * GNU General Public License for more details. *
* * * *
* You should have received a copy of the GNU General Public License * * You should have received a copy of the GNU General Public License *
* along with bfps. If not, see <http://www.gnu.org/licenses/> * * along with TurTLE. If not, see <http://www.gnu.org/licenses/> *
* * * *
* Contact: Cristian.Lalescu@ds.mpg.de * * Contact: Cristian.Lalescu@ds.mpg.de *
* * * *
...@@ -101,14 +101,8 @@ int kraichnan_field<rnumber>::initialize(void) ...@@ -101,14 +101,8 @@ int kraichnan_field<rnumber>::initialize(void)
"position/0"); "position/0");
this->particles_sample_writer_mpi->setParticleFileLayout(this->ps->getParticleFileLayout()); this->particles_sample_writer_mpi->setParticleFileLayout(this->ps->getParticleFileLayout());
this->spectrum_slope = -5./3.; DEBUG_MSG("Coefficient: %g\n",
this->spectrum_k_cutoff = 20.; //k_max is approximately N/2 in a N^3 simulation this->spectrum_coefficient);
// Projection factor
this->spectrum_coeff = 3./2.;
DEBUG_MSG("Coefficient: %g\n",
this->spectrum_coeff);
return EXIT_SUCCESS; return EXIT_SUCCESS;
} }
...@@ -124,7 +118,7 @@ int kraichnan_field<rnumber>::step(void) ...@@ -124,7 +118,7 @@ int kraichnan_field<rnumber>::step(void)
this->iteration, this->iteration,
this->spectrum_slope, this->spectrum_slope,
this->spectrum_k_cutoff, this->spectrum_k_cutoff,
this->spectrum_coeff * 3./2.); // incompressibility projection factor this->spectrum_coefficient * 3./2.); // incompressibility projection factor
this->velocity->ift(); this->velocity->ift();
// PUT THE INCOMPRESSIBILITY PROJECTION FACTOR sqrt(2/3) // PUT THE INCOMPRESSIBILITY PROJECTION FACTOR sqrt(2/3)
...@@ -189,7 +183,7 @@ int kraichnan_field<rnumber>::do_stats() ...@@ -189,7 +183,7 @@ int kraichnan_field<rnumber>::do_stats()
std::unique_ptr<double[]> pdata(new double[3*this->ps->getLocalNbParticles()]); std::unique_ptr<double[]> pdata(new double[3*this->ps->getLocalNbParticles()]);
/// copy position data /// copy position data
/// sample position /// sample position
std::copy(this->ps->getParticlesState(), std::copy(this->ps->getParticlesState(),
this->ps->getParticlesState()+3*this->ps->getLocalNbParticles(), this->ps->getParticlesState()+3*this->ps->getLocalNbParticles(),
...@@ -236,6 +230,10 @@ int kraichnan_field<rnumber>::read_parameters(void) ...@@ -236,6 +230,10 @@ int kraichnan_field<rnumber>::read_parameters(void)
this->tracers0_integration_steps = hdf5_tools::read_value<int>(parameter_file, "parameters/tracers0_integration_steps"); this->tracers0_integration_steps = hdf5_tools::read_value<int>(parameter_file, "parameters/tracers0_integration_steps");
this->tracers0_neighbours = hdf5_tools::read_value<int>(parameter_file, "parameters/tracers0_neighbours"); this->tracers0_neighbours = hdf5_tools::read_value<int>(parameter_file, "parameters/tracers0_neighbours");
this->tracers0_smoothness = hdf5_tools::read_value<int>(parameter_file, "parameters/tracers0_smoothness"); this->tracers0_smoothness = hdf5_tools::read_value<int>(parameter_file, "parameters/tracers0_smoothness");
this->spectrum_slope = hdf5_tools::read_value<double>(parameter_file, "parameters/spectrum_slope");
this->spectrum_k_cutoff = hdf5_tools::read_value<double>(parameter_file, "parameters/spectrum_k_cutoff");
this->spectrum_coefficient = hdf5_tools::read_value<double>(parameter_file, "parameters/spectrum_coefficient");
this->field_random_seed = hdf5_tools::read_value<int>(parameter_file, "parameters/field_random_seed");
H5Fclose(parameter_file); H5Fclose(parameter_file);
return EXIT_SUCCESS; return EXIT_SUCCESS;
} }
......
...@@ -3,20 +3,20 @@ ...@@ -3,20 +3,20 @@
* Copyright 2017 Max Planck Institute * * Copyright 2017 Max Planck Institute *
* for Dynamics and Self-Organization * * for Dynamics and Self-Organization *
* * * *
* This file is part of bfps. * * This file is part of TurTLE. *
* * * *
* bfps is free software: you can redistribute it and/or modify * * TurTLE is free software: you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published * * it under the terms of the GNU General Public License as published *
* by the Free Software Foundation, either version 3 of the License, * * by the Free Software Foundation, either version 3 of the License, *
* or (at your option) any later version. * * or (at your option) any later version. *
* * * *
* bfps is distributed in the hope that it will be useful, * * TurTLE is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of * * but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. * * GNU General Public License for more details. *
* * * *
* You should have received a copy of the GNU General Public License * * You should have received a copy of the GNU General Public License *
* along with bfps. If not, see <http://www.gnu.org/licenses/> * * along with TurTLE. If not, see <http://www.gnu.org/licenses/> *
* * * *
* Contact: Cristian.Lalescu@ds.mpg.de * * Contact: Cristian.Lalescu@ds.mpg.de *
* * * *
...@@ -61,7 +61,8 @@ class kraichnan_field: public direct_numerical_simulation ...@@ -61,7 +61,8 @@ class kraichnan_field: public direct_numerical_simulation
field<rnumber, FFTW, THREE> *velocity; field<rnumber, FFTW, THREE> *velocity;
double spectrum_slope; double spectrum_slope;
double spectrum_k_cutoff; double spectrum_k_cutoff;
double spectrum_coeff; double spectrum_coefficient;
int field_random_seed;
/* other stuff */ /* other stuff */
std::unique_ptr<abstract_particles_system<long long int, double>> ps; std::unique_ptr<abstract_particles_system<long long int, double>> ps;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment