Run API¶
-
runana.run.
execute
(programs, input_file, dirs, chain_iters={}, product_iters={}, co_iters={}, just_replace={}, filter_func='f90nml', use_stdin=False, calc_all=<function calc_all>, **kwargs)[source]¶ Run sequence of programs with different parameters defined by iters.
Parameters: - programs (list) – List of strings with names of programs. Should contain absolute paths. Could alternately contain functions
- input_file (str) – Input file
- dirs (str or runana.run.Dirs) – Base directory in which programs will be run
- chain_iters (dict) – Entries of the form {‘Name of parameter’:[values to replace with]}
- product_iters (dict) – Like chain_iters, but runs all combinations
- co_iters (dict) – Runs with several parameters changing simultanously
- just_replace (dict) – Entries of the form {‘Name of parameter’:value to replace with}
- filter_func (str) – Which filter function to use. Options are listed as keys in the INPUT_FILE_FILTERS dictionary
- use_stdin (bool) – send in the content of the filtered input file through stdin rather passing the name of the input file as the first command line argument
- calc_all (func) – Hook for the parallel decorator, please ignore this argument
-
runana.run.
execute_lock_par
(lock, parallel, *args, **kwargs)[source]¶ Convenience function for running execute with a lock and/or in parallel
-
runana.run.
generate_seq
(start, incr, nvalues=0, incr_func=<built-in function add>)[source]¶ Iterator that returns a sequence of numbers
Parameters: incr_func (func or str) – function used to increment the return value. Can be one of the strings ‘add’, ‘mul’ or ‘div’
-
runana.run.
generate_list
(*args, **kwargs)[source]¶ Wrap of generate_seq that returns a list instead of an iterator
-
class
runana.run.
Dirs
(scratch_base, local_scratch_base=None, copy_2_scratch=['*.txt', '*.nml', '*.stdout', '*.dat'])[source]¶ Container class for names of directories
Parameters: - scratch_base (str) – Directory prefix
- local_scratch_base (str) – Prefix for directory in which programs are run. If None then scratch_base is used
- copy_2_scratch (list) – List of strings that are globbed and copied from the local scratch directory to scratch directory
-
runana.run.
print_time
(file_=<_io.TextIOWrapper name='<stdout>' mode='w' encoding='UTF-8'>)[source]¶ Contextmanager that prints how much time was spent in it
-
runana.input_file_handling.
filter_inp_file_upname
(inp_file_in, inp_file_out, replace_with_these)[source]¶ Replaces elements in inp_file_in and places the result in inp_file_out
replace_with_these is a dict with entries of the form {‘Name of parameter’:value to replace with}
This version replaces entries that is one line below a string matching Name of parameter, in the same position as the string
-
runana.input_file_handling.
filter_inp_file_f90nml
(inp_file_in, inp_file_out, replace_with_these)[source]¶ Replaces elements in inp_file_in and places the result in inp_file_out
replace_with_these is a dict with entries of the form {‘Name of parameter’:value to replace with}
This version works on namelist files using the f90nml package
-
runana.input_file_handling.
INP_FILE_FILTERS
= {'f90nml': <function filter_inp_file_f90nml>, 'positional': <function filter_inp_file_positional>, 'upname': <function filter_inp_file_upname>}¶ Available input file filter functions
Extra functions¶
Automated convergence testing¶
-
class
runana.run.
ConvCrit
(data_read, eps=0.001, conv_func=<function rel_err_rel_var>, itermax=10, common_start=False)[source]¶ Contains information on how to check for convergence.
Parameters: - data_read (func) – Function which will be executed in the directory in which the programs was run. It should return the observable in terms of which convergence is sought
- eps (float) – Desired precision
- conv_funv (func) – Function that calculates convergence criterion. It should take 4 arguments, f(O1,O2,x1,x2), where x1 and x2 are the values of the numerical parameter at the current and previous calculation and O1 and O2 are the corresponding observable values
-
runana.run.
rel_err_rel_var
(O1, O2, x1, x2)[source]¶ Estimate of relative error abs(x2/(x2-x1)*(O1-O2)/O2)
-
runana.run.
auto_conv
(programs, inp_file, dirs, conv_crit, chain_iters, product_iters={}, co_iters={}, just_replace={}, auto_converge_var=<function auto_converge_var>, auto_conv_sub=<function auto_conv_sub>)[source]¶ Run programs until converged or chain_iters is exhausted.
Parameters: - programs (list) – List of strings with names of programs. Should contain absolute paths. Could alternately contain functions
- input_file (str) – Input file
- dirs (str or runana.run.Dirs) – Base directory in which programs will be run
- conv_crit (runana.run.ConvCrit) – Object specifying type of convergence
- chain_iters (dict) – Entries of the form {‘Name of parameter’:[values to replace with]}
- product_iters (dict) – Like chain_iters, but runs all combinations
- co_iters (dict) – Runs with several parameters changing simultanously
- use_stdin (bool) – send in the content of the filtered input file through stdin rather passing the name of the input file as the first command line argument
-
runana.run.
auto_conv_rerun
(fun)[source]¶ Decorator for rerunning
auto_conv()
, until convergence is achieved in the first two calculations for each parameter. This is useful for cases where parameters are strongly correlated