# Run a simulation from Python **You will learn:** how to drive ACEMD from a Python script using the {py:func}`~acemd.acemd.acemd` function, including overriding input-file options at call time. **Prerequisites:** - ACEMD installed (see [Installation](../installation.md)). - A directory with an `input.yaml` and the referenced structure/coordinates files. ## Setup ```python from acemd import acemd ``` ## Run a simulation from a directory {py:func}`~acemd.acemd.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: ```python 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`: ```python 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): ```python 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: ```python acemd("/tmp/my_simulation", inputfile="equilibration.yaml") ``` ## Gotchas - {py:func}`~acemd.acemd.acemd` blocks until the simulation completes — use a job scheduler or subprocess if you need it to run in the background. ## See also - {py:func}`~acemd.acemd.acemd` - [Set up equilibration and production](equilibrate-and-produce.md) — Python helpers that generate the `input.yaml` for you. - [Input options](../reference/input-options.md) - [Command-line arguments](../reference/cli.md)