smc_lammps package¶
- smc_lammps.main()¶
The entry point for the smc-lammps cli.
Use
smc-lammps -hfor help.See
smc_lammps.run.get_parser()for the parser definition.
Subpackages¶
- smc_lammps.generate package
- Subpackages
- Submodules
- smc_lammps.generate.default_parameters module
ParametersParameters.NParameters.RNA_polymerase_sizeParameters.RNA_polymerase_typeParameters.TParameters.__init__()Parameters.add_RNA_polymeraseParameters.add_side_siteParameters.add_stopper_beadParameters.arm_lengthParameters.arms_angle_ATPParameters.arms_stiffnessParameters.asymmetry_stiffnessParameters.average_steps_per_cycle()Parameters.bridge_widthParameters.cutoff4Parameters.cutoff5Parameters.cutoff6Parameters.cyclesParameters.diameterParameters.dna_configParameters.elbow_attractionParameters.elbow_spacingParameters.elbows_stiffnessParameters.epsilon3Parameters.epsilon4Parameters.epsilon5Parameters.epsilon6Parameters.folding_angle_APOParameters.folding_angle_ATPParameters.folding_stiffnessParameters.forceParameters.gammaParameters.hinge_radiusParameters.kBParameters.kleisin_radiusParameters.loopParameters.max_stepsParameters.nParameters.non_random_stepsParameters.output_stepsParameters.rigid_hingeParameters.runsParameters.seedParameters.sigmaParameters.sigma_SMC_DNAParameters.site_cycle_periodParameters.site_cycle_whenParameters.site_stiffnessParameters.site_toggle_delayParameters.smc_forceParameters.spaced_beads_custom_stiffnessParameters.spaced_beads_full_dnaParameters.spaced_beads_intervalParameters.spaced_beads_sizeParameters.spaced_beads_smc_clearanceParameters.spaced_beads_typeParameters.steps_ADPParameters.steps_APOParameters.steps_ATPParameters.timestepParameters.use_chargesParameters.use_toroidal_hinge
- smc_lammps.generate.generator module
- generator.py
AtomGroupAtomIdentifierAtomTypeBAIBAI_KindBAI_TypeCOORD_TYPEGeneratorGenerator.DynamicCoeffsGenerator.__init__()Generator.add_atom_groups()Generator.atom_group_mapGenerator.baisGenerator.box_widthGenerator.charge_overrideGenerator.check_charges()Generator.get_BAI_coeffs_header()Generator.get_BAI_header()Generator.get_BAI_style_command_name()Generator.get_BAI_styles_command()Generator.get_all_BAI_styles()Generator.get_all_atom_types()Generator.get_all_types()Generator.get_amounts()Generator.get_atom_index()Generator.get_atom_style()Generator.get_atom_style_command()Generator.get_atoms_header()Generator.get_bai_dict_by_type()Generator.get_hybrid_or_single_style()Generator.get_total_atoms()Generator.hybrid_stylesGenerator.molecule_overrideGenerator.move_all_atoms()Generator.pair_interactionsGenerator.random_shiftGenerator.set_system_size()Generator.use_chargesGenerator.write_BAI_coeffs()Generator.write_amounts()Generator.write_atoms()Generator.write_bai()Generator.write_coeffs()Generator.write_full()Generator.write_header()Generator.write_masses()Generator.write_pair_interactions()Generator.write_positions_and_bonds()Generator.write_system_size()Generator.write_types()
MoleculeIdNx3ArrayPairWiseall_tests()main()test_simple_atoms()test_simple_atoms_polymer()test_with_bonds()test_with_pairs()write_if_non_zero()_set_up_atom_group_map()
- smc_lammps.generate.parameters_template module
- smc_lammps.generate.util module
- smc_lammps.post_process package
- smc_lammps.reader package
Submodules¶
smc_lammps.console module¶
- smc_lammps.console.warn(message)¶
Prints the warning message in a panel.
smc_lammps.run module¶
- exception smc_lammps.run.MaxIterationExceeded¶
Bases:
RuntimeErrorRaised when a loop exceeds a large number of iterations.
- MAX_ITER: int = 10000¶
Number of iterations after which a MaxIterationExceeded should be raised.
- class smc_lammps.run.TaskDone(skipped: bool = False)¶
Bases:
objectA task.
Tasks may be skipped, e.g. if the corresponding flag is not set.
- __init__(skipped: bool = False) None¶
- smc_lammps.run.clean(args: Namespace, path: Path) TaskDone¶
Cleans a simulation directory.
Removes all files in a simulation directory, keeping only paremeters.py.
- Parameters:
args – Parsed arguments.
path – Simulation base path.
- Returns:
Task completion information.
- smc_lammps.run.create_perspective_file(args: Namespace, path: Path, subdir: Path | None) Path¶
Creates a new LAMMPS trajectory file, following a certain perspective.
Runs the
smc_lammps.post_process.smc_perspective()script.Currently supports arms and kleisin perspective following the SMC.
- Parameters:
args – Parsed arguments.
path – Simulation base path.
subdir – Directory or file passed via the cli, relative to path.
- Returns:
Task completion information.
- smc_lammps.run.execute(args: Namespace)¶
Executes a sequence of tasks depending on the provided arguments.
- The following tasks are executed (if enabled) in order:
initialize()(only if not initialized yet)
- Parameters:
args – Parsed arguments.
- smc_lammps.run.find_simulation_base_directory(path: Path) tuple[Path, Path | None]¶
Finds the base of a simulation directory.
Finds the base of a simulation directory by traversing up the file tree. The base directory is the (first) directory containing a valid parameters.py file.
Attention
The validity of the parameters.py file is not checked by this function!
- Parameters:
path – Path to start from, may be a file.
- Returns:
Tuple of (base simulation directory, subdirectory to path relative to the base directory if any).
- Raises:
FileNotFoundError – Root directory was reached without any parameters.py files along the way.
MaxIterationExceeded – Exceeded maximum amount of file tree traversal.
- smc_lammps.run.generate(args: Namespace, path: Path) TaskDone¶
Runs the generation script.
Runs the
smc_lammps.generate.generate()script, passing the args.seed as an argument if set.- Parameters:
args – Parsed arguments.
path – Simulation base path.
- Returns:
Task completion information.
- smc_lammps.run.get_lammps_args_list(lammps_vars: Sequence[list[str]]) list[str]¶
Converts argument list of variables to the LAMMPS format.
- Example:
>>> from smc_lammps.run import get_lammps_args_list >>> get_lammps_args_list([['is_restart', '1'], ['seed', '1234']]) ['-var', 'is_restart', '1', '-var', 'seed', '1234']
- Parameters:
lammps_vars – Variable names and values.
- Returns:
LAMMPS variable definitions which can be passed via the cli.
- smc_lammps.run.get_parser() ArgumentParser¶
Returns the parser for the smc-lammps cli.
- Returns:
parser
- smc_lammps.run.get_version() str | None¶
Returns the version of the smc-lammps package.
- Returns:
Version string in the “x.y.z” format, or None if the version could not be obtained.
- smc_lammps.run.initialize(args: Namespace, path: Path) TaskDone¶
Initializes a simulation directory.
Creates the directory if it does not exist yet, and places a template parameters.py file inside.
- Parameters:
args – Parsed arguments.
path – Simulation base path.
- Returns:
Task completion information.
- Raises:
FileExistsError – The path is non-empty and the –force flag is not set.
- smc_lammps.run.keep_every(args: Namespace, path: Path, subdir: Path | None) TaskDone¶
Edits LAMMPS trajecory file in-place, keeping every nth timestep.
- Parameters:
args – Parsed arguments.
path – Simulation base path.
subdir – File passed via the cli, relative to path.
- Returns:
Task completion information.
- smc_lammps.run.main()¶
The entry point for the smc-lammps cli.
Use
smc-lammps -hfor help.See
smc_lammps.run.get_parser()for the parser definition.
- smc_lammps.run.merge(args: Namespace, path: Path) TaskDone¶
Merges lammpstrj files together.
Merges lammpstrj files together by calling
merge_lammpstrj()on any files that match the output.lammpstrj* glob pattern.This can be useful after a restart run.
- Parameters:
args – Parsed arguments.
path – Simulation base path.
- Returns:
Task completion information.
- smc_lammps.run.parse(argv: list[str]) Namespace¶
Parses the argument list and returns argparse Namespace.
Parses the arguments before ‘–’, and sets the sub_args field of the returned object to the remaining arguments after ‘–‘.
- Parameters:
argv – Unprocessed argument list (from sys import argv).
- Returns:
Object holding command line options.
- smc_lammps.run.parse_with_double_dash(parser: ArgumentParser, args: list[str]) tuple[Namespace, list[str]]¶
Parse arguments with ‘–’ splitting.
Parses arguments by splitting before and after ‘–‘. Arguments before ‘–’ are parsed by the provided parser, everything after is collected into a separate, non-parsed list
- Parameters:
parser – Parser for arguments before ‘–‘.
args – Argument list.
- Returns:
Tuple of (parsed arguments before ‘–’, unparsed arguments after ‘–‘).
- smc_lammps.run.perform_run(args: Namespace, path: Path, log_file_name: str = 'log.lammps', **kwargs: str | list[str])¶
Performs a LAMMPS run.
Executes the LAMMPS cli in a new process.
Relevant arguments are passed to LAMMPS, such as -sf and -log.
- Parameters:
args – Parsed arguments.
path – Simulation base path.
log_file_name – File name (relative to output_path) passed to the LAMMPS cli -log argument.
kwargs – These parameters are passed to the LAMMPS cli as variables. lammps_root_dir, output_path, output_file_name.
- Raises:
ValueError – The output_path contains spaces which will (likely) break the LAMMPS script(s).
- smc_lammps.run.post_process(args: Namespace, path: Path) TaskDone¶
Performs post-processing.
Runs the
smc_lammps.post_process.process_displacement()script.- Parameters:
args – Parsed arguments.
path – Simulation base path.
- Returns:
Task completion information.
- smc_lammps.run.quiet_print(quiet: bool, *args, **kwargs)¶
Calls print if quiet is False.
- Parameters:
quiet – if True, do not print.
- smc_lammps.run.restart_run(args: Namespace, path: Path, output_file: Path) TaskDone¶
Performs a LAMMPS restart run.
Calls
smc_lammps.run.perform_run()with the is_restart variable set to ‘1’.- Parameters:
args – Parsed arguments.
path – Simulation base path.
output_file – The output file (e.g. output.lammpstrj) of the run that will be restarted.
- Returns:
Task completion information.
- Raises:
FileNotFoundError – The output_file does not exist.
FileExistsError – Could not find any available file names for the new output.
- smc_lammps.run.run(args: Namespace, path: Path) TaskDone¶
Runs (or restarts) a simulation.
Dispatches to
smc_lammps.run.restart_run()first. If the restart run was skipped, starts a new run viasmc_lammps.run.perform_run().Any existing output_file will only be overwritten if the –force flag is set, otherwise the function will return early.
- Parameters:
args – Parsed arguments.
path – Simulation base path.
- Returns:
Task completion information.
- smc_lammps.run.run_and_handle_error(process: Callable[[], CompletedProcess], ignore_errors: bool, quiet: bool)¶
Runs a process and checks the exit code.
Runs a process and handles any non-zero exit code. If the exit code is non-zero and ignore_errors is false, the script exits.
- Parameters:
process – A function that runs a process when called.
ignore_errors – If True, do not exit when the process exit code is non-zero.
quiet – Passed to quiet_print.
- smc_lammps.run.start_visualize_script(args: Namespace, path: Path, other_args: list[str])¶
Runs the
smc_lammps.post_process.visualize()script.Runs the
smc_lammps.post_process.visualize()script in a new process.- Parameters:
args – Parsed arguments.
path – Simulation base path.
other_args – Arguments passed to the
smc_lammps.post_process.visualize()script.
- smc_lammps.run.visualize(args: Namespace, path: Path, subdir: Path | None) TaskDone¶
Starts VMD with a certain visualization.
- Dispatches to the following tasks in order:
- Parameters:
args – Parsed arguments.
path – Simulation base path.
subdir – Directory or file passed via the cli, relative to path.
- Returns:
Task completion information.
- Raises:
ValueError – The path given by path/subdir is not a file.
- smc_lammps.run.visualize_datafile(args: Namespace, path: Path, subdir: Path | None) TaskDone¶
Starts VMD with the initial datafile loaded.
Loads the datafile_positions (produced by the
smc_lammps.run.generate()step) into VMD.- Parameters:
args – Parsed arguments.
path – Simulation base path.
subdir – Directory or file passed via the cli, relative to path.
- Returns:
Task completion information.
- smc_lammps.run.visualize_follow(args: Namespace, path: Path, subdir: Path | None) TaskDone¶
Creates a perspective file and opens it in VMD.
Runs
smc_lammps.run.create_perspective_file()to generate a new perspective file, followed bysmc_lammps.run.start_visualize_script().- Parameters:
args – Parsed arguments.
path – Simulation base path.
subdir – Directory or file passed via the cli, relative to path.
- Returns:
Task completion information.