perses.annihilation.ncmc_switching.NCMCEngine

class perses.annihilation.ncmc_switching.NCMCEngine(temperature=Quantity(value=300.0, unit=kelvin), functions=None, nsteps=1, steps_per_propagation=1, timestep=Quantity(value=1.0, unit=femtosecond), constraint_tolerance=None, platform=None, write_ncmc_interval=1, measure_shadow_work=False, integrator_splitting='V R O H R V', storage=None, verbose=False, LRUCapacity=10, pressure=None, bond_softening_constant=1.0, angle_softening_constant=1.0)[source]

NCMC switching engine

Examples

Create a transformation for an alanine dipeptide test system where the N-methyl group is eliminated.

>>> from openmmtools import testsystems
>>> testsystem = testsystems.AlanineDipeptideVacuum()
>>> from perses.rjmc.topology_proposal import TopologyProposal
>>> new_to_old_atom_map = { index : index for index in range(testsystem.system.getNumParticles()) if (index > 3) } # all atoms but N-methyl
>>> topology_proposal = TopologyProposal(old_system=testsystem.system, old_topology=testsystem.topology, old_chemical_state_key='AA', new_chemical_state_key='AA', new_system=testsystem.system, new_topology=testsystem.topology, logp_proposal=0.0, new_to_old_atom_map=new_to_old_atom_map, metadata=dict())
>>> ncmc_engine = NCMCEngine(temperature=300.0*unit.kelvin, functions=default_functions, nsteps=50, timestep=1.0*unit.femtoseconds)
>>> positions = testsystem.positions
>>> [positions, logP_delete, potential_delete] = ncmc_engine.integrate(topology_proposal, positions, direction='delete')
>>> [positions, logP_insert, potential_insert] = ncmc_engine.integrate(topology_proposal, positions, direction='insert')
Attributes:
beta

Methods

integrate(topology_proposal, …[, iteration]) Performs NCMC switching to either delete or insert atoms according to the provided topology_proposal.
make_alchemical_system(topology_proposal, …) Generate an alchemically-modified system at the correct atoms based on the topology proposal.
__init__(temperature=Quantity(value=300.0, unit=kelvin), functions=None, nsteps=1, steps_per_propagation=1, timestep=Quantity(value=1.0, unit=femtosecond), constraint_tolerance=None, platform=None, write_ncmc_interval=1, measure_shadow_work=False, integrator_splitting='V R O H R V', storage=None, verbose=False, LRUCapacity=10, pressure=None, bond_softening_constant=1.0, angle_softening_constant=1.0)[source]

This is the base class for NCMC switching between two different systems.

Methods

__init__([temperature, unit, functions, …]) This is the base class for NCMC switching between two different systems.
integrate(topology_proposal, …[, iteration]) Performs NCMC switching to either delete or insert atoms according to the provided topology_proposal.
make_alchemical_system(topology_proposal, …) Generate an alchemically-modified system at the correct atoms based on the topology proposal.

Attributes

beta
integrate(topology_proposal, initial_sampler_state, proposed_sampler_state, iteration=None)[source]

Performs NCMC switching to either delete or insert atoms according to the provided topology_proposal.

For delete, the system is first modified from fully interacting to alchemically modified, and then NCMC switching is used to eliminate atoms. For insert, the system begins with eliminated atoms in an alchemically noninteracting form and NCMC switching is used to turn atoms on, followed by making system real.

Parameters:
topology_proposal : TopologyProposal

Contains old/new Topology and System objects and atom mappings.

initial_sampler_state : openmmtools.states.SamplerState representing the initial (old) system

Configurational properties of the atoms at the beginning of the NCMC switching.

proposed_sampler_state : openmmtools.states.SamplerState representing the proposed (post-geometry new) system

Configurational properties new system atoms at beginning of NCMC switching

iteration : int, optional, default=None

Iteration number, for storage purposes.

Returns:
final_old_sampler_state : openmmtools.State.SamplerState

The final configurational properties of the old system after hybrid alchemical switching

final_sampler_state : openmmtools.states.SamplerState

The final configurational properties after nsteps steps of alchemical switching, and reversion to the nonalchemical system

logP_work : float

The NCMC work contribution to the log acceptance probability (Eqs. 62 and 63)

logP_initial : float

The initial logP of the hybrid configuration

logP_final : float

The final logP of the hybrid configuration

make_alchemical_system(topology_proposal, current_positions, new_positions)[source]

Generate an alchemically-modified system at the correct atoms based on the topology proposal. This method generates a hybrid system using the new HybridTopologyFactory. It memoizes so that calling multiple times (within a recent time period) will immediately return a cached object.

Returns:
hybrid_factory : perses.annihilation.new_relative.HybridTopologyFactory

a factory object containing the hybrid system