fstio
This module provides some utility input / output functions for use with the FEASST simulation program.
- fstio.dict_to_argparse(dictionary)[source]
Converts a dictionary to a string that argparse may read from command line
>>> from pyfeasst import fstio >>> params = {'run_type': 0, 'feasst_install': '/path/to/feasst/', 'queue_flags': ""} >>> fstio.dict_to_argparse(params) ' --run_type 0 --feasst_install /path/to/feasst/ --queue_flags ""'
- fstio.vector3d_to_list(vec)[source]
Converts a swig stl vector to python list
>>> from pyfeasst import fstio >>> fstio.vector3d_to_list([[[[0]]]]) [[[[0]]]]
- fstio.read_checkpoint(filename)[source]
Return contents of checkpoint file as a string
>>> from pyfeasst import fstio >>> table = fstio.read_checkpoint('../../tests/tutorial_0_table.txt') >>> table[:13] '6867 11 11 11'
- fstio.all_sims_complete(filename, num_sims)[source]
Read filename and see if all sim ID’s from [0, num_sims-1] are present (e.g., complete). If no file is present, also consider the simulation incomplete.
>>> from pyfeasst import fstio >>> all_sims_complete('../../tests/lj_sim_ids.txt', 8) True >>> all_sims_complete('../../tests/lj_sim_ids2.txt', 8) False >>> all_sims_complete('../../tests/not_a_file.txt', 8) False
- fstio.slurm_single_node(params)[source]
Write slurm script to fill one node.
- Parameters:
params (dict) – Must have the following keys: procs_per_node: number of processors per node, procs_per_sim: number of processors per simulation, minutes: maximum number of minutes for job in queue, prefix: prefix for all output file names, script: script file name, sim_id_file: filename to write simulation id’s for later checking of status, max_restarts: maximum number of restarts, node: node index. Optional keys: scratch: location of local scratch space on HPC node (disabled by default), scratch_hours_per_sync: hours between synching scratch to destination (default: 5).
This function also adds the key ‘queue_command’ to the params dictionary, which is assumed to output the job id.
- fstio.run_single(sim, params, args, sim_node_dependent_params, write_feasst_script, post_process)[source]
Run a single simulation. If all simulations are complete, run PostProcess.
- fstio.split(a, n)[source]
-
>>> from pyfeasst import fstio >>> list(fstio.split(range(11), 3)) [range(0, 4), range(4, 8), range(8, 11)]
- fstio.run_simulations(params, queue_function, args, write_feasst_script=None, client=None, sim_node_dependent_params=None, post_process=None)[source]
Run a simulation either locally in the shell or queue on HPC nodes
- Parameters:
params (dict) – Must have the following keys: sim_id_file: filename to write simulation id’s for later checking of status, prefix: prefix for all output file names, max_restarts: maximum number of restarts, procs_per_node: number of processors per node, procs_per_sim: number of processors per sim, num_nodes: number of nodes, node: node index.
sim_node_dependent_params (function) – The name of the function that assigns parameters based on the sim and node. The only argument is the parameters.
write_feasst_script (function) – The name of the function to write the feasst text interface file, which has the first argment as the parameters and the second argument as the filename.
client (function) – If write_feasst_script is None, instead run in server mode with default port 54321 and default buffer_size 1000.
post_process (function) – The name of the function to post process all simulations once complete, and has the only argument as the params.
queue_function (function) – The name of the function to queue one node and has the only argument as the params.
args (namespace) – Arguments from argparse.
- fstio.combine_tables_two_rigid_body(prefix, suffix, num_procs, num_header_lines=6)[source]
Combine table files generated in parallel by TableTwoRigidBody3D.
- fstio.num_sites_in_fstprt(fstprt_file, feasst_install='')[source]
Return the integer number of sites in a fstprt file
- Parameters:
fstprt_file (str) – The name of the fstprt file which describes a particle.
feasst_install (str) – An option to provide the path to the feasst build directory in order to convert a fstprt_file which begins with the characters ‘/feasst’ to the feasst directory.
>>> from pyfeasst import fstio >>> fstio.num_sites_in_fstprt('../../../particle/lj.txt') 1 >>> fstio.num_sites_in_fstprt('../../../particle/n-butane.txt') 4 >>> fstio.num_sites_in_fstprt('/feasst/particle/n-butane.txt', '../../../build/') 4
- fstio.write_linear_grow_file(filename, num_sites=None, gce=0, ref='', num_steps=4, base_weight=1, conf=0, conf2=-1, particle_type=0, angle=True, dihedral=True, particle_file=None, feasst_install=None)[source]
Write TrialGrowFile input files for linear chain particles.
- Parameters:
filename (str) – The name of the file to write the TrialGrowFile text.
num_sites (int) – The number of sites in the linear chain particle. If None, obtain num_sites from the particle_file.
gce (int) – If 0, write only canonical ensemble trials. If 1, write only grand canonical ensemble insertion and deletion trials. If 2, write only grand canonical ensemble insertion trials If 3, wirte only Gibbs particle transfer trials.
ref (str) – The name of the reference potential to be used for dual-cut configurational bias. If empty, do not use a reference potential.
num_steps (int) – The number of steps to be used for (dual-cut) configurational bias.
base_weight (float) – The weight used for determining the probability of attempting a trial.
conf (int) – The configuration name for the trial (see System).
conf2 (int) – The second configuration name for the trial used with gibbs transfers only.
particle_type (int) – Type of particle in configuration.
angle (bool) – True if there are angle potentials present in the linear chain.
dihedral (bool) – True if there are dihedral potentials present in the linear chain.
particle_file (str) – If not None, use the particle_file to find the site names.
feasst_install (str) – An option to provide the path to the feasst build directory in order to convert a particle_file which begins with the characters ‘/feasst’ to the feasst directory.
The weight for trial moves is the base weight, but reptations are divided by 4 and partial regrowth weights are divided by the number of stages.
Reptations has been disabled because there is an issue with them.
>>> from pyfeasst import fstio >>> fstio.write_linear_grow_file("grow_grand_canonical.txt", num_sites=3, gce=1, ref="noixn", num_steps=4) >>> with open('grow_grand_canonical.txt') as file1: ... lines = file1.readlines() >>> lines[0] 'TrialGrowFile\n' >>> lines[1] '\n' >>> lines[2] 'particle_type=0 weight=1 transfer=true site=2 num_steps=4 ref=noixn\n' >>> fstio.write_linear_grow_file("grow_grand_canonical.txt", gce=1, ref="dccb", num_steps=4, particle_file='../../../particle/spce_new.txt') >>> with open('grow_grand_canonical.txt') as file1: ... lines = file1.readlines() >>> lines[2] 'particle_type=0 weight=1 transfer=true site=H2 num_steps=4 ref=dccb\n'