Skip to main content

Open source implementation of multiple minimum Monte Carlo

Project description

Multiple Minimum Monte Carlo

pypi Ruff

This package will help you perform a multiple minumum Monte Carlo conformer search as described in Chang et al., 1989. It is built to be used with an ASE calculator and ASE optimization tools but user-defined optimization strategies can be employed as well.

Installation

This package can be installed with pip

pip install multiple-minimum-monte-carlo

Tutorial

To run a search, you need to initialize Conformer, Calculation, and ConformerEnsemble objects. Conformer objects require either an input xyz or SMILES string. The default Calculation object is ASEOptimization which requires an ASE optimization routine (like FIRE) and an ASE calculator (the example below uses the aimnet calculator which will need to be installed separately from this package). ConformerEnsemble objects require a Conformer and Calculation object.

from ase.optimize.fire import FIRE
from ase.io import write
from aimnet.calculators import AIMNet2ASE
from multiple_minimum_monte_carlo.conformer import Conformer
from multiple_minimum_monte_carlo.calculation import ASEOptimization
from multiple_minimum_monte_carlo.conformer_ensemble import ConformerEnsemble

smiles = "CC(=O)Oc1ccccc1C(=O)O"
conformer = Conformer(smiles=smiles)
optimizer = ASEOptimization(calc=AIMNet2ASE(), optimizer=FIRE)
conformer_ensemble = ConformerEnsemble(conformer=conformer, calc=optimizer)

To run the search, call run_monte_carlo with the ConformerEnsemble object

conformer_ensemble.run_monte_carlo()

final_ensemble will be a list of coordinate arrays that arranged by their energy (lowest energy first). To read out the minimum energy compound, do this

from ase.io import write
conformer.atoms.set_positions(conformer_ensemble.final_ensemble[0])
write("lowest_energy_conformer.xyz", conformer.atoms, format="xyz")

To perform batched calculations (which will perform multiple Monte Carlo steps at once and optimize all of the sampled conformers simultaneously), we will need to use a batched optimizer. In the example below, we will use the torchsim batched calculator with the uma-s-1 MLIP (which both need to be installed separately from this package)

from multiple_minimum_monte_carlo.batch_calculation import TorchSimCalculation
from torch_sim.models.fairchem import FairChemModel
from torch_sim.optimizers import Optimizer

model = FairChemModel(model=None, model_name="uma-s-1",task_name="omol", cpu=True)
calc = TorchSimCalculation(model=model, optimizer=Optimizer.fire, max_cycles=500)
conformer_ensemble = ConformerEnsemble(conformer=conformer, calc=calc)

A note about parallel calculations

As opposed to batched calculations, you can also do calculations in parallel with a Calculation object by setting parallel=True in the ConformerEnsemble object. However, this requires that the multiprocessing start method "fork" is used which may be incompatible with certain workflows.

A note about just using input xyz structure

When you only include an input xyz structure, this code uses rdkit to construct the SMILES string. However, occassionally this will fail (i.e. when the structure is more ambiguous like a transition state). In this case, including the SMILES string will fix this issue, but the SMILES string needs to be mapped to the structure. The easiest way to do this is to use an atom-mapped SMILES string (the hydrogens also need to be mapped!) and set mapped=True in your Conformer object

User-Defined Calculation

To define a Calculation object, a class will need three function: init, run, and energy. init initializes the class with whatever information is necessary. run performs an optimization. It takes an ase.Atoms object and a list of atoms to constrain and returns an np array of cartesian coordinates (in angstroms) and a float with the energy of the conformation (in kcal/mol). energy calculates the energy of a conformer. It takes an ase.Atoms object and returns a float the with energy (in kcal/mol)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

multiple_minimum_monte_carlo-0.0.14.tar.gz (23.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

multiple_minimum_monte_carlo-0.0.14-py3-none-any.whl (22.0 kB view details)

Uploaded Python 3

File details

Details for the file multiple_minimum_monte_carlo-0.0.14.tar.gz.

File metadata

File hashes

Hashes for multiple_minimum_monte_carlo-0.0.14.tar.gz
Algorithm Hash digest
SHA256 bb913f397649146f33857baadb7041017f41132b746db5392bd082a73667c7e4
MD5 3bda55573bd15fc7d229066f04e8226a
BLAKE2b-256 96c9e3ff4e897aef78c3c77cb13b7621aca3e27253f89c67a87413cf6b8f805a

See more details on using hashes here.

File details

Details for the file multiple_minimum_monte_carlo-0.0.14-py3-none-any.whl.

File metadata

File hashes

Hashes for multiple_minimum_monte_carlo-0.0.14-py3-none-any.whl
Algorithm Hash digest
SHA256 960f597f6a0c3155dac5fed1891ee2e7f0e362fe6360bf219e91a161a100a6e9
MD5 330e865fc506fa4a4aa8bf6f6d9bdcaf
BLAKE2b-256 be5bccfd54f430edd4224ad077d643169260a138a876886c76ffe444d25bf68f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page