Prep
AmberSimPrep
¶
Bases: SimPrep
Prepares files for Amber molecular dynamics simulations.
This class implements the SimPrep
abstract base class to provide a concrete
workflow for preparing input files, run scripts, and other necessary files
specifically for running molecular dynamics simulations using the Amber simulation
package. It handles tasks such as setting up Amber-specific file paths, generating
input files in the Amber format, constructing the command to execute Amber's
pmemd
engine, and managing multi-stage simulations.
get_stage_input_lines(simlify_config)
¶
Prepares the lines for a single Amber simulation stage's input file
(.in
file).
This class method renders the content of the Amber input file based on the
engine.inputs
attribute of the provided SimlifyConfig
object. The
engine.inputs
is expected to be an object with a render
method that
generates the input file content as a list of strings.
PARAMETER | DESCRIPTION |
---|---|
simlify_config
|
The Simlify configuration object containing
the input parameters for the current Amber simulation stage, typically
defined within the
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
list[str]
|
list[str]: A list of strings, where each string represents a line in the
Amber input file ( |
get_stage_run_command(simlify_config)
¶
Prepares the bash command to run a single Amber simulation stage using the
pmemd
engine.
This class method constructs the command-line invocation of Amber's pmemd
engine
based on the provided SimlifyConfig
. It handles different computational platforms,
including serial and MPI execution. If the use_scratch
option is enabled in the
configuration, it also adds commands to check if the simulation has already been
completed and to move the output files from the scratch directory to the designated
output directory.
PARAMETER | DESCRIPTION |
---|---|
simlify_config
|
The Simlify configuration object containing options and parameters for the current Amber simulation stage, such as the input file paths, output directory, and computational platform.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
list[str]
|
A list of strings, where each string represents a line in the bash script that constitutes the command to run the Amber simulation stage. |
RAISES | DESCRIPTION |
---|---|
ValueError
|
If |
Notes
This method relies on the simlify_config
object having been preprocessed by
the prepare_sim_config
method.
Uses the following attributes from simlify_config
:
label
: Unique label for this simulation stage.run.use_scratch
: Boolean indicating whether to use a scratch directory.run.dir_work
: Path to the main working directory.run.dir_output
: Path to the final output directory.engine.cli
: An object representing the Amber command-line interface, with attributes likecompute_platform
,mdin
,mdout
,restrt
, andmdcrd
.temp['cpu_cores']
: The number of CPU cores to use for MPI simulations.
prepare(simlify_config)
¶
Runs all necessary steps to prepare the Amber simulations based on the provided configuration.
This class method orchestrates the complete preparation process for Amber
simulations. It handles both single-stage and multi-stage simulations as
defined in the simlify_config
. For multi-stage simulations, it iterates
through the configured stages, updating the simlify_config
with the
parameters for each stage. For each stage, it calls prepare_sim_config
to preprocess the configuration and then prepare_stage
to generate the
input files and run commands. Finally, if the write
flag in the
configuration is True, it writes the accumulated bash commands to the run
script file specified in the configuration.
PARAMETER | DESCRIPTION |
---|---|
simlify_config
|
The Simlify configuration object containing all the necessary options and parameters for the Amber simulation workflow, including settings for single or multiple stages.
TYPE:
|
Notes
This method assumes that the simlify_config
object is properly initialized
with all the required parameters for the Amber simulation.
prepare_sim_config(simlify_config)
¶
Preprocesses and validates the simulation configuration specifically for Amber simulations.
This static method performs Amber-specific preprocessing and validation of the
SimlifyConfig
object. It sets up various Amber-specific file paths based on
the configuration, such as the paths for the input file (.in
), output file
(.out
), restart file (.rst
), trajectory file (.nc
), and MD info file
(.mdinfo
). It also checks for the existence of the working directory and
creates it if necessary. For MPI-based simulations, it calculates the total
number of CPU cores based on the SLURM configuration.
PARAMETER | DESCRIPTION |
---|---|
simlify_config
|
The Simlify configuration object containing options and
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
SimlifyConfig
|
The modified Simlify configuration object with Amber-specific settings and paths. |
RAISES | DESCRIPTION |
---|---|
ValueError
|
If |
prepare_stage(simlify_config, run_commands=None, write=True)
¶
Writes the input file for a single Amber simulation stage and builds the bash commands to run it.
This class method orchestrates the preparation of a single stage in the Amber
simulation workflow. It first retrieves the input file lines using
get_stage_input_lines
. If the write
flag is True, it writes these lines to
an Amber input file (.in
) in the designated input directory. It then retrieves
the bash commands to run this stage using get_stage_run_command
and appends
them to the cumulative list of run_commands
. This method also handles the
splitting of long simulations into multiple shorter segments if specified in
the configuration.
PARAMETER | DESCRIPTION |
---|---|
simlify_config
|
The Simlify configuration object containing options and parameters for the current Amber simulation stage.
TYPE:
|
run_commands
|
A list of bash commands accumulated from previous stages.
The commands for the current stage will be appended to this list.
Defaults to |
write
|
A boolean flag indicating whether to write the Amber
input file (
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
tuple[list[str], list[str]]
|
A tuple containing two lists: - The lines of the Amber input file generated for this stage. - The updated list of bash commands, including the command(s) for this stage. |
RAISES | DESCRIPTION |
---|---|
ValueError
|
If |
Notes
This method relies on the simlify_config
object having been preprocessed by
the prepare_sim_config
method.