Run a simulation from Python#
You will learn: how to drive ACEMD from a Python script using the acemd() function, including overriding input-file options at call time.
Prerequisites:
ACEMD installed (see Installation).
A directory with an
input.yamland the referenced structure/coordinates files.
Setup#
from acemd import acemd
Run a simulation from a directory#
acemd() takes a directory containing input.yaml and runs the simulation there — equivalent to cd-ing into that directory and calling acemd on the command line:
acemd(".") # current directory
acemd("/tmp/my_simulation")
Override input-file options#
Any input-file option (lowercased) is accepted as a keyword argument. The keyword overrides the value from input.yaml:
acemd("/tmp/my_simulation", run="2ns")
acemd("/tmp/my_simulation", run="2ns", barostat=True)
This is convenient for sweeps — e.g. running the same setup at different temperatures or for different lengths without editing the input file each time.
Override CLI flags#
Command-line flags also pass through as keywords (lowercased name, same value):
acemd("/tmp/my_simulation", device=[0, 1])
acemd("/tmp/my_simulation", precision="single")
Use a non-default input file name#
By default ACEMD looks for input.yaml. Use the inputfile keyword to load a different file from inside the directory:
acemd("/tmp/my_simulation", inputfile="equilibration.yaml")
Gotchas#
acemd()blocks until the simulation completes — use a job scheduler or subprocess if you need it to run in the background.
See also#
Set up equilibration and production — Python helpers that generate the
input.yamlfor you.