Solute-in-solvent alchemical transformation¶
SoluteInSolventAlchemicalFlow
¶
Bases: MartiniFlowProject
Defines the workflow for alchemical transformations of solutes in solvents within the Martini force field framework.
This class extends the MartiniFlowProject, incorporating specific configurations and operations for conducting alchemical transformations. Alchemical transformations involve gradually changing the Hamiltonian of the system to transform a solute into another or modify its interactions with the solvent, which is a common technique in free energy calculations.
Attributes:
Name | Type | Description |
---|---|---|
workspace_path |
str
|
The path to the workspace directory where the project's files are stored. |
mdp_path |
str
|
The path to the directory containing the MDP (Molecular Dynamics Parameters) files. |
itp_files |
dict
|
A dictionary mapping the names of ITP (Include Topology) files to their paths. |
mdp_files |
dict
|
A dictionary mapping the names of MDP files to their paths. |
simulation_settings |
dict
|
A dictionary containing simulation settings such as the number of threads and temperature. |
system_name |
str
|
The name of the system being simulated. |
nomad_workflow |
str
|
The name of the workflow file for integration with the NOMAD framework. |
nomad_top_level_workflow |
str
|
The name of the top-level workflow file for NOMAD. |
state_names |
dict
|
A dictionary mapping state names to their string representations. |
The class provides methods for preparing the system, running production simulations, computing free energies, and generating and uploading workflows to NOMAD, facilitating an automated and scalable approach to molecular simulations.
Source code in martignac/workflows/solute_in_solvent_alchemical.py
compute_free_energy(*jobs)
¶
Computes the free energy difference for alchemical transformations using the MBAR method.
This function aggregates the simulation data from multiple jobs, each representing a different lambda state in the alchemical transformation process. It uses the alchemlyb library's MBAR estimator to calculate the free energy difference between the initial and final states of the transformation. The results, including the mean free energy difference and its standard deviation, are stored in the job document for each job.
The function assumes that the necessary simulation data (XVG files) are already generated and stored by the production phase of the workflow. It leverages the extract_u_nk function from alchemlyb to parse these files and extract the reduced potential energies, which are then combined and passed to the MBAR estimator.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
*jobs |
Job
|
A variable number of job objects, each representing a distinct lambda state in the alchemical transformation process. These jobs should have already completed the production phase, with XVG files available for analysis. |
()
|
Note
This function is part of the SoluteInSolventAlchemicalFlow project and is designed to be used within a signac-flow workflow. It relies on specific project and job structure defined in the MartiniFlowProject class and its derivatives.
Source code in martignac/workflows/solute_in_solvent_alchemical.py
prepare_system(*jobs)
¶
Prepares the system for alchemical transformation simulations by importing necessary data from related projects.
This function is a critical part of the workflow in the SoluteInSolventAlchemicalFlow project. It ensures that all necessary input files and configurations are correctly set up for each job involved in the alchemical transformation process. The function performs several key operations:
- Identifies the job with the lowest lambda state to serve as the primary job for data import.
- Imports solute-related input files from the SoluteGenFlow project into the primary job.
- Imports solvent-related input files from the SolventGenFlow project into the primary job.
- Imports solvation-related input files from the SoluteInSolventGenFlow project into the primary job.
- Replicates the imported data across all other jobs involved in the transformation process.
- Updates the job document to mark the system as prepared for each job.
The function leverages the import_job_from_other_flow
utility to facilitate the import of data between
different projects, ensuring that all necessary files are available for the simulation to proceed.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
*jobs |
Job
|
A variable number of job objects, each representing a distinct simulation job within the alchemical transformation workflow. |
()
|
Source code in martignac/workflows/solute_in_solvent_alchemical.py
production(job)
¶
Executes the production phase of the molecular dynamics simulation for a given job.
This function configures and runs the production phase of the alchemical transformation simulation. It involves setting up the Molecular Dynamics Parameters (MDP) file specific to the lambda state of the job, customizing it for the solute involved, and executing the GROMACS simulation. The function generates and stores the paths to the output XVG and log files in the job document for later analysis.
The MDP file is first templated with the lambda state and solute name, then used to run the simulation with the specified number of threads. This phase is critical for generating the data necessary for free energy calculation.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
job |
Job
|
The job object representing a single simulation job within the alchemical transformation workflow. It contains the state point information, including the lambda state and solute name, and provides context for the simulation, including paths to input and output files. |
required |
Returns:
Name | Type | Description |
---|---|---|
str |
The command executed for the production phase, primarily for logging or debugging purposes. This includes the path to the modified MDP file, the output XVG file for the lambda state, and the log file. |