mdse.rm.runmanager

Orchestrates the execution of multiple molecular dynamics simulations.

This module provides the RunManager class, which is responsible for managing a list of simulation configurations, distributing them for execution (with MPI support), and processing the results into a structured, database-friendly format.

Key functionalities include:

  • Reading simulation configurations, including expanding configurations based on defect structures from a sqlite database.

  • Distributing simulation jobs across multiple processes using an MPI-based work queue.

  • Executing simulations via the SimulationManager.

  • Post-processing simulation results (ResultMD objects) to calculate final properties and format them into OPTIMADE-compliant MongoDBEntry objects.

  • Aggregating results and writing them to a summary JSON file.

Classes

RunManager([simulation_config])

Manages settings, I/O, and execution of molecular dynamics simulations.

class mdse.rm.runmanager.RunManager(simulation_config=None)

Bases: object

Manages settings, I/O, and execution of molecular dynamics simulations.

This class allows for initializing multiple simulations based on configuration, attaching output destinations, executing the simulations, and writing results.

Parameters:

simulation_config (list, optional) – A list of dictionaries where each dictionary contains configuration parameters for a simulation. Defaults to None.

md_simulations

A list of SimulationManager instances representing simulations to run.

Type:

list

outputs

A list of output destinations (e.g., file paths) where results can be written.

Type:

list

run_results(result: ResultMD, config)

Process a finished simulation result and format it as a MongoDB entry.

This method takes a ResultMD object from a completed simulation, calculates a standard set of final properties (e.g., Lindemann index, self-diffusion), and packages the data into an OPTIMADE-compliant MongoDBEntry object.

Parameters:
  • result (ResultMD) – The result object from a completed simulation.

  • config (dict) – The configuration dictionary for the simulation that was run.

Returns:

An OPTIMADE-compliant data object ready for database insertion.

Return type:

MongoDBEntry

run_simulations()

Execute all managed simulations distributing them across MPI ranks if available.

This method implements a master/worker pattern to distribute simulation jobs.

  • If MPI size >= 2: The master (rank 0) sends job indices to worker ranks. Workers execute the simulation, process the results using run_results, and send the MongoDBEntry back to the master.

  • If MPI size < 2: The master rank executes all simulations sequentially in a single process.