mythos.simulators.oxdna

oxDNA simulator module.

Submodules

Attributes

CMAKE_BIN_ENV_VAR

ERR_BUILD_SETUP_FAILED

ERR_INPUT_FILE_NOT_FOUND

ERR_MISSING_REQUIRED_KEYS

MAKE_BIN_ENV_VAR

Classes

UmbrellaEnergyInfo

Wraps a DataFrame of energy values to enable filtering by type.

oxDNASimulator

A sampler base on running an oxDNA simulation.

oxDNAUmbrellaSampler

An oxDNA sampler for umbrella sampling simulations.

Functions

_guess_binary_location(→ pathlib.Path | None)

Guess the location of a binary.

Package Contents

mythos.simulators.oxdna.CMAKE_BIN_ENV_VAR = 'CMAKE_BIN_PATH'
mythos.simulators.oxdna.ERR_BUILD_SETUP_FAILED = 'OXDNA build setup failed wiht return code: {}'
mythos.simulators.oxdna.ERR_INPUT_FILE_NOT_FOUND = 'Input file not found: {}'
mythos.simulators.oxdna.ERR_MISSING_REQUIRED_KEYS = 'Missing required keys: {}'
mythos.simulators.oxdna.MAKE_BIN_ENV_VAR = 'MAKE_BIN_PATH'
class mythos.simulators.oxdna.UmbrellaEnergyInfo(data=None, index: pandas._typing.Axes | None = None, columns: pandas._typing.Axes | None = None, dtype: pandas._typing.Dtype | None = None, copy: bool | None = None)[source]

Bases: pandas.DataFrame

Wraps a DataFrame of energy values to enable filtering by type.

mythos.simulators.oxdna._guess_binary_location(bin_name: str, env_var: str) pathlib.Path | None[source]

Guess the location of a binary.

class mythos.simulators.oxdna.oxDNASimulator[source]

Bases: mythos.simulators.base.InputDirSimulator

A sampler base on running an oxDNA simulation.

This simulator runs an oxDNA simulation in a subprocess, first compiling oxDNA from source with the provided parameters, or by using a precompiled binary (in the case parameter updates are not desired).

Parameters:
  • input_dir – Path to the directory containing the oxDNA input file.

  • energy_fn – The energy function to use for default parameter updates.

  • n_build_threads – Number of threads to use when building oxDNA from source.

  • logger_config – Configuration for the logger.

  • binary_path – Path to a precompiled oxDNA binary to use. This is mutually exclusive with source_path. When provided, the binary will be called and no recompilation will be performed. In such a case, parameters cannot be updated, and if supplied to the run will result in an error unless ignore_params is set to True.

  • source_path – Path to the oxDNA source code to compile. Updating parameters in this simulator requires compiling oxDNA from source with the parameters built into the object code.

  • ignore_params – Whether to ignore provided parameters when running the simulation. This argument is required to be True if there is no source_path set and parameters are passed.

  • overwrite_input – Whether to overwrite the input directory or copy it. If this is False (default), the contents of the input_dir will be copied to a temporary directory for running the simulation to avoid overwriting input.

  • input_overrides – Key-value pairs to override in the input file. The values accept scalar values that can be converted to str. For example: {“T”: “275K”, “steps”: 10000}. WARNING: no validation is performed on the provided key-value pairs.

energy_fn: mythos.energy.base.EnergyFunction
n_build_threads: int = 4
logger_config: dict[str, Any] | None = None
binary_path: pathlib.Path | None = None
source_path: pathlib.Path | None = None
ignore_params: bool = False
input_overrides: dict[str, Any]
__post_init__(*args, **kwds) None[source]

Check the validity of the configuration.

with_cached_build(binary_path: pathlib.Path) None[source]

Switch to use a precompiled binary.

This may be useful when running on a cluster with a shared file system, or running on a single machine, particularly in cases where:

N_simulators * n_build_threads > N_cpu_cores.

Caution: the user is responsible for ensuring that the binary at provided path is pre-built for the appropriate parameter set, there is no check performed at simulation run-time to verify this.

run_simulation(input_dir: pathlib.Path, opt_params: mythos.utils.types.Params | None = None, seed: float | None = None, **_) mythos.simulators.base.SimulatorOutput[source]

Run the simulation in the given input directory.

_read_trajectory(input_dir: pathlib.Path) mythos.simulators.io.SimulatorTrajectory[source]
build(*, input_dir: pathlib.Path, new_params: mythos.utils.types.Params, input_config: dict | None = None) None[source]

Update the simulation.

This function will recompile the oxDNA binary with the new parameters.

class mythos.simulators.oxdna.oxDNAUmbrellaSampler[source]

Bases: oxDNASimulator

An oxDNA sampler for umbrella sampling simulations.

This simulator extends the oxDNASimulator to handle extra data related to umbrella sampling. The input directory must be setup for umbrella sampling with the appropriate configurations, including order parameters and weights file, among other relevant settings.

Based on the last histogram written by oxDNA, the simulator will compute a reweighted set of weights in the “weight” key of the output state, which can be passed back in on subsequent runs.

The run method takes optional weights DataFrame to use for reweighting. If provided, this will overwrite the weights file in the input directory before running the simulation. The dataframe will be written space-separated without a header, but otherwise unmodified. Ensure it has the appropriate fields and order.

exposed_observables: ClassVar[list[str]] = ['trajectory', 'energy_info']
__post_init__(*args, **kwds) None[source]

Check the validity of the configuration.

run_simulation(input_dir: pathlib.Path, opt_params: mythos.utils.types.Params | None = None, weights: pandas.DataFrame | None = None, **kwargs) mythos.simulators.base.SimulatorOutput[source]

Run the simulation in the given input directory.