Giter Club home page Giter Club logo

msibi's Introduction

MultiState Iterative Boltzmann Inversion (MS-IBI)


pytest codecov Citing MSIBI

A package to help you manage and run coarse-grain potential optimizations using multistate iterative Boltzmann inversion.

Installing MSIBI

Install from conda-forge:

conda install -c conda-forge msibi

Install from source:

git clone https://github.com/cmelab/msibi.git
cd msibi
conda env create -f environment.yml
conda activate msibi
pip install .

Using MSIBI

The MSIBI package is designed to be very object oriented. Any force optimization runs requires at least one msibi.state.State instance, msibi.force.Force instance and msibi.optimize.MSIBI instance. More state and forces can be added as needed.

MSIBI uses Hoomd-Blue to run optimization simulations. It is not required that you be familiar with Hoomd to use MSIBI as the simulation script is automatically generated and ran. However, it is required that you pass in the choice of Hoomd method, Hoomd neighbor list, and Hoomd thermostat to the msibi.optimize.MSIBI instance.

Example: Single state, single force

  • Here is an example of learning a pair potential using a single state point with only one bead type.
import hoomd
from msibi import MSIBI, State, Pair 

optimizer = MSIBI(
	nlist=hoomd.md.nlist.Cell,
	integrator=hoomd.md.methods.ConstantVolume,
	thermostat=hoomd.md.methods.thermostats.MTTK,
	dt=0.0001,
	gsd_period=int(1e4)
)

# Create a State instance, pass in a path to the target trajectory
stateA = State(name="A", kT=2.0, traj_file="stateA.gsd", alpha=1.0, n_frames=50)
optimizer.add_state(stateA)

# Create a Pair instance to be optimized
pairAA = Pair(type1="A", type2="A", optimize=True, r_cut=3.0, nbins=100) 
# Call the set_lj() method to set an initial guess potential
pairAA.set_lj(r_min=0.001, r_cut=3.0, epsilon=1.0, sigma=1.0)
optimizer.add_force(pairAA)

# Run 20 MSIBI iterations
optimizer.run_optimization(n_steps=2e6, n_iterations=20)
pairAA.save_potential("AA_final.csv")

Example: Multiple states, multiple forces

  • Here is an example of learning a pair potential using multiple state points.
  • In this example, we set fixed bond and angle potentials which are assumed to have been learned from previous MSIBI runs.
import hoomd
from msibi import MSIBI, State, Pair, Bond, Angle 

optimizer = MSIBI(
	nlist=hoomd.md.nlist.Cell,
	integrator=hoomd.md.methods.ConstantVolume,
	thermostat=hoomd.md.methods.thermostats.MTTK,
	dt=0.0001,
	gsd_period=int(1e4)
)

# Create 3 State instances, pass in a path to the target trajectory
stateA = State(name="A", kT=2.0, traj_file="stateA.gsd", alpha=0.2, n_frames=50)
stateB = State(name="B", kT=4.0, traj_file="stateB.gsd", alpha=0.5, n_frames=50)
stateC = State(name="C", kT=6.0, traj_file="stateC.gsd", alpha=0.3, n_frames=50)
optimizer.add_state(stateA)
optimizer.add_state(stateB)
optimizer.add_state(stateC)

# Add bond and angle forces learned from previous MSIBI runs
bondAA = Bond(type1="A", type2="A", optimize=False)
bondAA.set_from_file("bondAA.csv")
optimize.add_force(bondAA)

angleAA = Angle(type1="A", type2="A", type3="A", optimize=False)
angleAA.set_from_file("angleAA.csv")
optimize.add_force(angleAA)

# Create a Pair instance to be optimized.
pairAA = Pair(type1="A", type2="A", optimize=True, r_cut=3.0, nbins=100) 
# Call the set_lj() method to set an initial guess potential
pairAA.set_lj(r_min=0.001, r_cut=3.0, epsilon=1.0, sigma=1.0)
optimizer.add_force(pairAA)

# Run 20 MSIBI iterations
optimizer.run_optimization(n_steps=2e6, n_iterations=20)
pairAA.save_potential("AA_final.csv")

Citing MSIBI

Details of the underlying method and its validation can be found here.

If you use this package, please cite the above paper. The BibTeX reference is

@article{Moore2014,
      author = "Moore, Timothy C. and Iacovella, Christopher R. and McCabe, Clare",
      title = "Derivation of coarse-grained potentials via multistate iterative Boltzmann inversion",
      journal = "The Journal of Chemical Physics",
      year = "2014",
      volume = "140",
      number = "22",
      doi = "http://dx.doi.org/10.1063/1.4880555"
}

msibi's People

Contributors

chrisjonesbsu avatar jennyfothergill avatar tcmoore3 avatar ctk3b avatar davyyue avatar marjanalbooyeh avatar mattwthompson avatar

Stargazers

 avatar Atanu Baksi avatar  avatar  avatar  avatar

Watchers

James Cloos avatar

msibi's Issues

Fix exponential tail corrections

We may want to use exponential corrections on the tails when optimizing bonds and angles. The current implementation isn't working, and throws an error by default.

Add more unit tests, better toy system

The test cov is pretty low, need to take a look and see what is being missed in the tests.

I need to create a better toy system to perform any unit tests that involve actually running iterations. Creating a small one based on a PEKK simulation output should work.

Calculate the atomistic RDFs when passing in a trajectory file to State

It would be nice if calculating the Target RDF and saving the outputs could be handled when creating a State object by passing in a trajectory file. Also, this can help ensure that the rdf cutoff specified in MSIBI is the same one used for calculating the target RDFs.

Maybe this can be done by calling a function, or by setting up a parameter in the init function?

State.generate_target_rdf()

or generate_target_rdfs=True in the init?

Following the example in the LJ tutorial:

with gsd.hoomd.open(self.traj_file) as t:
    rdf = freud.density.RDF(bins=101, r_max=5)
    for snap in t[-50:]:
        rdf.compute(system=snap, reset=False)
    data = np.stack((rdf.bin_centers, rdf.rdf)).T
    self.target_rdf = data
    # or save 
    np.savetxt(self.state_dir, data)
)

Give error when rdf cut and potential cut do not match

On my latest runs I changed my rdf cutoff but forgot to also update the potential cutoff and it was causing an error at the potential update step. We should probably check and throw an error if they don't match. Or, maybe we juts set a single cutoff parameter that is used for both? If there is some reason why you want different cutoff distances, then we should handle truncating when necessary to deal with different sized data sets.

I personally think we should either throw an error if they don't match, or set a single cutoff parameter in the MSIBI class that gets used for both.

Add option to not scale `alpha` values.

The alpha values used in IBI/MSIBI are used to scale (i.e. dampen and weight) the potential updates at each bin of the independent variable (angle, length, distance, etc..). In the MSIBI paper, the alpha values are actually a linear function of this parameter, and scale towards zero. This is useful for pair potentials to help ensure a smooth cutoff at longer distances, but I don't think we'd want this for bond, angles and dihedrals. We need a way to turn this alpha(x) off and just use a constant alpha at all values.

Remove hoomd 1 scripts

With hoomd now at V3, I think we can remove the hoomd 1 related bits and keep support for hoomd 2 and eventually add it for hoomd 3

Add msibi to container

I removed MSIBI from the environment.yml and forgot to add it to the container build.

I'm working on this right now for planckton (cmelab/planckton#83) and once any issues are worked out I will fix the msibi container.

Clean up environment files

It looks like the .yml files have a few packages that aren't used anymore. Maybe some of them are due to the tutorial notebooks. I wonder if a better idea might be to create a separate coarse-graining tutorial repo that show show to use both GRiTS and MSIBI together?

  • mdtraj
  • foyer
  • antefoyer
  • p3Dmol
  • jupyter

Possibly some others.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.