Skip to content
Snippets Groups Projects
Commit 0a53773b authored by Cristian Lalescu's avatar Cristian Lalescu
Browse files

__main__ uses _fluid_particle_base directly

parent 3e3cd9b3
No related branches found
No related tags found
No related merge requests found
...@@ -27,7 +27,9 @@ ...@@ -27,7 +27,9 @@
import os import os
import numpy as np import numpy as np
import h5py import h5py
import argparse
import bfps
from ._fluid_base import _fluid_particle_base from ._fluid_base import _fluid_particle_base
class NavierStokes(_fluid_particle_base): class NavierStokes(_fluid_particle_base):
...@@ -970,4 +972,58 @@ class NavierStokes(_fluid_particle_base): ...@@ -970,4 +972,58 @@ class NavierStokes(_fluid_particle_base):
dest = 'particle_rand_seed', dest = 'particle_rand_seed',
default = None) default = None)
return None return None
def launch(
self,
args = [],
**kwargs):
# with the default Lundgren forcing, I can estimate the dissipation
# with nondefault forcing, figure out the amplitude for this viscosity
# yourself
parser = argparse.ArgumentParser('bfps ' + type(self).__name__)
self.add_parser_arguments(parser)
opt = parser.parse_args(args)
self.QR_stats_on = opt.QR_stats
self.parameters['nu'] = (opt.kMeta * 2 / opt.n)**(4./3)
self.parameters['dt'] = (opt.dtfactor / opt.n)
if ((self.parameters['niter_todo'] % self.parameters['niter_out']) != 0):
self.parameters['niter_out'] = self.parameters['niter_todo']
if self.QR_stats_on:
# max_Q_estimate and max_R_estimate are just used for the 2D pdf
# therefore I just want them to be small multiples of mean trS2
# I'm already estimating the dissipation with kMeta...
meantrS2 = (opt.n//2 / opt.kMeta)**4 * self.parameters['nu']**2
self.parameters['max_Q_estimate'] = meantrS2
self.parameters['max_R_estimate'] = .4*meantrS2**1.5
self.pars_from_namespace(opt)
self.fill_up_fluid_code()
self.finalize_code()
self.write_src()
self.set_host_info(bfps.host_info)
if not os.path.exists(os.path.join(self.work_dir, self.simname + '.h5')):
self.write_par()
if self.parameters['nparticles'] > 0:
data = self.generate_tracer_state(
species = 0,
rseed = opt.particle_rand_seed)
for s in range(1, self.particle_species):
self.generate_tracer_state(species = s, data = data)
init_condition_file = os.path.join(
self.work_dir,
self.simname + '_cvorticity_i{0:0>5x}'.format(0))
if not os.path.exists(init_condition_file):
if len(opt.src_simname) > 0:
src_file = os.path.join(
self.work_dir,
opt.src_simname + '_cvorticity_i{0:0>5x}'.format(opt.src_iteration))
os.symlink(src_file, init_condition_file)
else:
self.generate_vector_field(
write_to_file = True,
spectra_slope = 2.0,
amplitude = 0.25)
self.run(
ncpu = opt.ncpu,
njobs = opt.njobs)
return None
...@@ -28,7 +28,6 @@ import sys ...@@ -28,7 +28,6 @@ import sys
import argparse import argparse
import bfps import bfps
from .Launcher import Launcher
from .NavierStokes import NavierStokes from .NavierStokes import NavierStokes
from .FluidConvert import FluidConvert from .FluidConvert import FluidConvert
from .FluidResize import FluidResize from .FluidResize import FluidResize
...@@ -46,12 +45,12 @@ def main(): ...@@ -46,12 +45,12 @@ def main():
'FluidResize'], 'FluidResize'],
type = str) type = str)
# first option is the choice of base class or -h or -v # first option is the choice of base class or -h or -v
# all other options are passed on to the Launcher instance # all other options are passed on to the base_class instance
opt = parser.parse_args(sys.argv[1:2]) opt = parser.parse_args(sys.argv[1:2])
# error is thrown if first option is not a base class, so Launcher # error is thrown if first option is not a base class, so Launcher
# cannot be executed by mistake. # cannot be executed by mistake.
l = eval('Launcher(base_class = {0})'.format(opt.base_class)) c = eval('{0}()'.format(opt.base_class))
l(sys.argv[2:]) c.launch(sys.argv[2:])
return None return None
if __name__ == '__main__': if __name__ == '__main__':
......
...@@ -396,4 +396,8 @@ class _fluid_particle_base(_code): ...@@ -396,4 +396,8 @@ class _fluid_particle_base(_code):
nshells = kspace['nshell'].shape[0] nshells = kspace['nshell'].shape[0]
ofile.close() ofile.close()
return None return None
def launch(
self,
**kwargs):
return None
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment