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 https://stackoverflow.com/questions/2130016/splitting-a-list-into-n-parts-of-approximately-equal-length

>>> 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.