Giter VIP home page Giter VIP logo

Comments (2)

WangXinyan940 avatar WangXinyan940 commented on July 20, 2024 1

Hello. Maybe you would like to switch to branch wangxy/v1.0.0-devel and try this test code:

import sys
import time
import jax
import jax.numpy as jnp
import numpy as np
import openmm.app as app
import openmm.unit as unit
import openmm as mm
from dmff import Hamiltonian, NeighborListFreud

from jax.config import config
config.update("jax_enable_x64", True)

prmtop = app.AmberPrmtopFile("RAMP1_gas.prmtop")
inpcrd = app.AmberInpcrdFile("RAMP1_gas.inpcrd")
ff = Hamiltonian("amber14/protein.ff14SB.xml", "amber14/tip3p.xml")

potentials = ff.createPotential(prmtop.topology, nonbondedMethod=app.NoCutoff, useDispersionCorrection=False)
params = ff.getParameters()
positions = jnp.array(inpcrd.getPositions(asNumpy=True).value_in_unit(unit.nanometer))

box = jnp.array([[100.0, 0.0, 0.0], [0.0, 100.0, 0.0], [0.0, 0.0, 100.0]])

nbList = NeighborListFreud(box, 20.0, potentials.meta["cov_map"])
nbList.allocate(positions)
pairs = nbList.pairs
efunc = potentials.getPotentialFunc()
dmff_e = efunc(positions, box, pairs, ff.paramset)
print("DMFF Pot E: ", dmff_e)

system = prmtop.createSystem(nonbondedMethod=app.NoCutoff, constraints=None)
integrator = mm.VerletIntegrator(0.001*unit.picoseconds)
platform = mm.Platform.getPlatformByName('Reference')
simulation = app.Simulation(prmtop.topology, system, integrator, platform)
simulation.context.setPositions(inpcrd.positions)

state = simulation.context.getState(getEnergy=True, getVelocities=True, getForces=True, getPositions=True)
energy = state.getPotentialEnergy()
print("OpenMM Pot E: ", energy)

The output on my laptop is:

DMFF Pot E:  -6487.265980775686
Initial Pot E:  -6487.229977725502 kJ/mol

Our neighbor list is a (N, 3) matrix with the third element saving covalant distance (1-2, 1-3, 1-4, etc). Directly using neighborlist in jax_md would cause unexpected error.

from dmff.

WangXinyan940 avatar WangXinyan940 commented on July 20, 2024

The devel branch has been merged to the master branch and our 1.0.0 version is released. I believe this problem is solved and would close this issue.

from dmff.

Related Issues (20)

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.