Commit f312fbc7 authored by Cristian Lalescu's avatar Cristian Lalescu
Browse files

Merge branch 'feature/exec-name' into develop

parents bf509869 ac587668
...@@ -28,6 +28,7 @@ import numpy as np ...@@ -28,6 +28,7 @@ import numpy as np
import pickle import pickle
import os import os
from ._fluid_base import _fluid_particle_base from ._fluid_base import _fluid_particle_base
import bfps
class FluidConvert(_fluid_particle_base): class FluidConvert(_fluid_particle_base):
"""This class is meant to be used for conversion of native DNS field """This class is meant to be used for conversion of native DNS field
...@@ -37,14 +38,14 @@ class FluidConvert(_fluid_particle_base): ...@@ -37,14 +38,14 @@ class FluidConvert(_fluid_particle_base):
""" """
def __init__( def __init__(
self, self,
name = 'FluidConvert', name = 'FluidConvert-v' + bfps.__version__,
work_dir = './', work_dir = './',
simname = 'test', simname = 'test',
fluid_precision = 'single', fluid_precision = 'single',
use_fftw_wisdom = True): use_fftw_wisdom = True):
_fluid_particle_base.__init__( _fluid_particle_base.__init__(
self, self,
name = name, name = name + '-' + fluid_precision,
work_dir = work_dir, work_dir = work_dir,
simname = simname, simname = simname,
dtype = fluid_precision, dtype = fluid_precision,
......
...@@ -38,17 +38,17 @@ class FluidResize(_fluid_particle_base): ...@@ -38,17 +38,17 @@ class FluidResize(_fluid_particle_base):
""" """
def __init__( def __init__(
self, self,
name = 'FluidResize', name = 'FluidResize-v' + bfps.__version__,
work_dir = './', work_dir = './',
simname = 'test', simname = 'test',
dtype = np.float32, fluid_precision = 'single',
use_fftw_wisdom = False): use_fftw_wisdom = False):
_fluid_particle_base.__init__( _fluid_particle_base.__init__(
self, self,
name = name, name = name + '-' + fluid_precision,
work_dir = work_dir, work_dir = work_dir,
simname = simname, simname = simname,
dtype = dtype, dtype = fluid_precision,
use_fftw_wisdom = use_fftw_wisdom) use_fftw_wisdom = use_fftw_wisdom)
self.parameters['src_simname'] = 'test' self.parameters['src_simname'] = 'test'
self.parameters['dst_iter'] = 0 self.parameters['dst_iter'] = 0
......
...@@ -41,7 +41,7 @@ class NavierStokes(_fluid_particle_base): ...@@ -41,7 +41,7 @@ class NavierStokes(_fluid_particle_base):
""" """
def __init__( def __init__(
self, self,
name = 'NavierStokes', name = 'NavierStokes-v' + bfps.__version__,
work_dir = './', work_dir = './',
simname = 'test', simname = 'test',
fluid_precision = 'single', fluid_precision = 'single',
...@@ -54,7 +54,7 @@ class NavierStokes(_fluid_particle_base): ...@@ -54,7 +54,7 @@ class NavierStokes(_fluid_particle_base):
self.fftw_plan_rigor = fftw_plan_rigor self.fftw_plan_rigor = fftw_plan_rigor
_fluid_particle_base.__init__( _fluid_particle_base.__init__(
self, self,
name = name, name = name + '-' + fluid_precision,
work_dir = work_dir, work_dir = work_dir,
simname = simname, simname = simname,
dtype = fluid_precision, dtype = fluid_precision,
...@@ -62,8 +62,8 @@ class NavierStokes(_fluid_particle_base): ...@@ -62,8 +62,8 @@ class NavierStokes(_fluid_particle_base):
self.parameters['nu'] = 0.1 self.parameters['nu'] = 0.1
self.parameters['fmode'] = 1 self.parameters['fmode'] = 1
self.parameters['famplitude'] = 0.5 self.parameters['famplitude'] = 0.5
self.parameters['fk0'] = 1.5 self.parameters['fk0'] = 2.0
self.parameters['fk1'] = 3.0 self.parameters['fk1'] = 4.0
self.parameters['forcing_type'] = 'linear' self.parameters['forcing_type'] = 'linear'
self.parameters['histogram_bins'] = 256 self.parameters['histogram_bins'] = 256
self.parameters['max_velocity_estimate'] = 1.0 self.parameters['max_velocity_estimate'] = 1.0
...@@ -943,10 +943,6 @@ class NavierStokes(_fluid_particle_base): ...@@ -943,10 +943,6 @@ class NavierStokes(_fluid_particle_base):
type = int, type = int,
dest = 'src_iteration', dest = 'src_iteration',
default = 0) default = 0)
parser.add_argument(
'--precision',
type = str, dest = 'precision',
default = 'single')
parser.add_argument( parser.add_argument(
'--njobs', '--njobs',
type = int, dest = 'njobs', type = int, dest = 'njobs',
...@@ -984,6 +980,11 @@ class NavierStokes(_fluid_particle_base): ...@@ -984,6 +980,11 @@ class NavierStokes(_fluid_particle_base):
self.QR_stats_on = opt.QR_stats self.QR_stats_on = opt.QR_stats
self.parameters['nu'] = (opt.kMeta * 2 / opt.n)**(4./3) self.parameters['nu'] = (opt.kMeta * 2 / opt.n)**(4./3)
self.parameters['dt'] = (opt.dtfactor / opt.n) self.parameters['dt'] = (opt.dtfactor / opt.n)
# custom famplitude for 288 and 576
if opt.n == 288:
self.parameters['famplitude'] = 0.45
elif opt.n == 576:
self.parameters['famplitude'] = 0.47
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 self.QR_stats_on: if self.QR_stats_on:
...@@ -993,7 +994,9 @@ class NavierStokes(_fluid_particle_base): ...@@ -993,7 +994,9 @@ class NavierStokes(_fluid_particle_base):
meantrS2 = (opt.n//2 / opt.kMeta)**4 * self.parameters['nu']**2 meantrS2 = (opt.n//2 / opt.kMeta)**4 * self.parameters['nu']**2
self.parameters['max_Q_estimate'] = meantrS2 self.parameters['max_Q_estimate'] = meantrS2
self.parameters['max_R_estimate'] = .4*meantrS2**1.5 self.parameters['max_R_estimate'] = .4*meantrS2**1.5
# add QR suffix to code name, since we now expect additional
# datasets in the .h5 file
self.name += '-QR'
if len(opt.src_work_dir) == 0: if len(opt.src_work_dir) == 0:
opt.src_work_dir = opt.work_dir opt.src_work_dir = opt.work_dir
self.pars_from_namespace(opt) self.pars_from_namespace(opt)
......
...@@ -37,17 +37,36 @@ def main(): ...@@ -37,17 +37,36 @@ def main():
'-v', '--version', '-v', '--version',
action = 'version', action = 'version',
version = '%(prog)s ' + bfps.__version__) version = '%(prog)s ' + bfps.__version__)
NSoptions = ['NavierStokes',
'NavierStokes-single',
'NavierStokes-double',
'NS',
'NS-single',
'NS-double']
FRoptions = ['FluidResize',
'FluidResize-single',
'FluidResize-double',
'FR',
'FR-single',
'FR-double']
parser.add_argument( parser.add_argument(
'base_class', 'base_class',
choices = ['NavierStokes', choices = NSoptions + FRoptions,
'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 base_class 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 launch # error is thrown if first option is not a base class, so launch
# cannot be executed by mistake. # cannot be executed by mistake.
c = eval('{0}()'.format(opt.base_class)) if 'double' in opt.base_class:
precision = 'double'
else:
precision = 'single'
if opt.base_class in NSoptions:
base_class = NavierStokes
elif opt.base_class in FRoptions:
base_class = FluidResize
c = base_class(fluid_precision = precision)
c.launch(args = sys.argv[2:]) c.launch(args = sys.argv[2:])
return None return None
......
...@@ -198,7 +198,7 @@ class _code(_base): ...@@ -198,7 +198,7 @@ class _code(_base):
self.write_sge_file( self.write_sge_file(
file_name = os.path.join(self.work_dir, qsub_script_name), file_name = os.path.join(self.work_dir, qsub_script_name),
nprocesses = ncpu, nprocesses = ncpu,
name_of_run = self.name + '_' + suffix, name_of_run = suffix,
command_atoms = command_atoms[3:], command_atoms = command_atoms[3:],
hours = hours, hours = hours,
minutes = minutes, minutes = minutes,
...@@ -210,7 +210,7 @@ class _code(_base): ...@@ -210,7 +210,7 @@ class _code(_base):
qsub_atoms += ['-hold_jid', job_name_list[-1]] qsub_atoms += ['-hold_jid', job_name_list[-1]]
subprocess.call(qsub_atoms + [qsub_script_name]) subprocess.call(qsub_atoms + [qsub_script_name])
os.chdir(current_dir) os.chdir(current_dir)
job_name_list.append(self.name + '_' + suffix) job_name_list.append(suffix)
elif self.host_info['type'] == 'pc': elif self.host_info['type'] == 'pc':
os.chdir(self.work_dir) os.chdir(self.work_dir)
os.environ['LD_LIBRARY_PATH'] += ':{0}'.format(bfps.lib_dir) os.environ['LD_LIBRARY_PATH'] += ':{0}'.format(bfps.lib_dir)
......
...@@ -48,7 +48,7 @@ class _fluid_particle_base(_code): ...@@ -48,7 +48,7 @@ class _fluid_particle_base(_code):
work_dir = work_dir, work_dir = work_dir,
simname = simname) simname = simname)
self.use_fftw_wisdom = use_fftw_wisdom self.use_fftw_wisdom = use_fftw_wisdom
self.name = name + '_' + simname self.name = name
self.particle_species = 0 self.particle_species = 0
if dtype in [np.float32, np.float64]: if dtype in [np.float32, np.float64]:
self.dtype = dtype self.dtype = dtype
...@@ -395,4 +395,9 @@ class _fluid_particle_base(_code): ...@@ -395,4 +395,9 @@ class _fluid_particle_base(_code):
nshells = kspace['nshell'].shape[0] nshells = kspace['nshell'].shape[0]
ofile.close() ofile.close()
return None return None
def specific_parser_arguments(
self,
parser):
_code.specific_parser_arguments(self, parser)
return None
...@@ -92,7 +92,7 @@ parser.add_argument( ...@@ -92,7 +92,7 @@ parser.add_argument(
def double(opt): def double(opt):
old_simname = 'N{0:0>3x}'.format(opt.n) old_simname = 'N{0:0>3x}'.format(opt.n)
new_simname = 'N{0:0>3x}'.format(opt.n*2) new_simname = 'N{0:0>3x}'.format(opt.n*2)
c = FluidResize(dtype = opt.precision) c = FluidResize(fluid_precision = opt.precision)
c.launch( c.launch(
args = ['--simname', old_simname + '_double', args = ['--simname', old_simname + '_double',
'--wd', opt.work_dir, '--wd', opt.work_dir,
......
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