Git Product home page Git Product logo

pysages's Introduction


Documentation   GitHub Actions   GitHub Actions   Trunk

PySAGES (Python Suite for Advanced General Ensemble Simulations) is a Python implementation of SSAGES with support for GPUs.

Installation

PySAGES currently supports HOOMD-blue, LAMMPS, ASE, and OpenMM. We plan to add support for other engines that have a python API, including those supported by the original SSAGES.

Before installing PySAGES, you need to install one of the following plugins, depending on your molecular dynamics engine of choice:

You also need to install JAX, a library for high-performance numerical computing. Follow their installation guide and make sure you have it installed before using PySAGES. Depending on your local setup, you may need to install the CPU version or the CUDA compatible version.

For GPU support, JAX and any backend (HOOMD-blue, LAMMPS, or OpenMM) need to be built or installed with CUDA support.

You can follow our installation tutorial on Google Colab to see how PySAGES, HOOMD-blue, and OpenMM can be built and installed in such an environment. Colab Badge

Usage

PySAGES provides a straightforward interface to set up collective variables and enhanced sampling methods in your MD simulations. See the documentation to learn more.

We provide ready-to-go examples for common methods. Check out the examples subfolder to look at different script and notebook examples. These include pre-set simulations and a tutorial on how to install PySAGES along with the supported MD engines.

Development

We believe in good software engineering and collaboration. We welcome all contributions. To ease collaboration, we use trunk as a development tool free for open-source software. This includes version-checked linters that can be run automatically. We ship a launcher for trunk with this repo: ./trunk, no installation required. For details about how to use ./trunk fmt to format existing code into this style and ./trunk check to verify a consistent code style, check out the trunk documentation page.

pysages's People

Contributors

gustavor101 avatar innocentbug avatar maggiezimon avatar pabloferz avatar pre-commit-ci[bot] avatar ricalessandri avatar sivadasetty avatar xuyinan2 avatar yihengwukp avatar yzjin avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pysages's Issues

Not sure this is a bug

I think #163 changed how distance works if you don't use groups.

In my notebook, I used Distance((0,1)) for the distance between particle 0 and particle 1.

That doesn't work now anymore.
It doesn't throw an error, and calculates something.

Distance(([0], [1])) seems to work though.

Move /content/xxx lines to setup section of notebooks

The lines:

mkdir /content/xxx
cd /content/xxx

are meant for google colab only.
That should not be a huge deal. Having them fail should be fine.
I think the setup section uses the /content/ explicitly too.
We could move these line into the setup section. So, locally you just don’t run these anyways.

Originally posted by @InnocentBug in #170 (comment)

Forward Flux programming style

 30:46  medium  Redefining name 'T' from outer scope (line 25)     pylint/W0621
 30:51  medium  Redefining name 'dt' from outer scope (line 26)    pylint/W0621
 34:4   medium  Unused variable 'kT'                               pylint/W0612
 34:5   high    local variable 'kT' is assigned to but never used  flake8/F841 
 73:22  medium  Redefining name 'T' from outer scope (line 25)     pylint/W0621
 80:4   medium  Redefining name 'dt' from outer scope (line 26)    pylint/W0621

[docs] minor issue -- make html spell errors

Just wanted to make a note here on missing words in pysages_wordlist.txt
make html involving
sphinx-build -M html "source" "build" -W --keep-going -b spelling &&\
sphinx-build -M html "source" "build"

generating spell warnings and failed build. Missing words are:

  • reinstall
  • unweighted
  • functor
  • Tuple
  • workflow
  • covariance

Document how to implement new CV/methods

Discussed in #179

Originally posted by sivadasetty August 1, 2022
May be this is already considered but want to add it here. Wondering if we should list clearly the steps to implement a new CV or method in PySAGES user documentation. It would be nice to have a checklist especially on steps related to a) adding example systems, b) updating pysages tests, c) updating docs, and d) ci workflow.

Metad example breaks

mmw-tut02@pool1:~/git/PySAGES/examples/openmm/metad>python3 alanine-dipeptide.py 
Traceback (most recent call last):
  File "alanine-dipeptide.py", line 168, in <module>
    main(sys.argv[1:])
  File "alanine-dipeptide.py", line 115, in main
    method = Metadynamics(cvs, height, sigma, stride, ngauss, deltaT=deltaT, kB=kB, grid=grid)
  File "/data/scratch/pysages/python_packages/pysages/methods/metad.py", line 137, in __init__
    super().__init__(cvs, **kwargs)
  File "/data/scratch/pysages/python_packages/pysages/methods/core.py", line 67, in __init__
    check_dims(cvs, grid)
  File "plum/function.py", line 591, in plum.function.Function.__call__
  File "plum/function.py", line 556, in plum.function.Function.resolve_method
  File "plum/function.py", line 492, in plum.function.Function.resolve_signature
plum.function.NotFoundLookupError: For function "check_dims", signature Signature(builtins.list, builtins.NoneType) could not be resolved.

Feature to wrap difference between angle CVs

Is there a function to wrap difference between angle CVs? If not, adding something similar to GetDifference() in SSAGES for calculating difference between CVs and taking care of periodicity (if defined as periodic) might be be useful.

Something along,

def diff(xi, center):
    cvdiff = xi-center
    if cvdiff > np.pi:
        cvdiff -= 2*np.pi
    elif cvdiff < -np.pi:
        cvdiff += 2*np.pi
    return cvdiff

Restart/Extending runs

Is restart supported in pysages? I couldn't find any examples yet. If not, could you suggest some ways to work around that?

Collective Variables that need unwrap coordinates.

Here are the CVs that require unwraped coordinates.

Let's discuss if you agree.

Angle
DihedralAngle
Distance
All the shape CVs

Basically every one of the CVs we have so far.
Maybe we should make that the default behavior and just disable it where it isn't necessary.

Inconsistencies in ffs branch

There are some small issues with the recent commit a6844c8.

  • pysages/methods/__init__.py is missing from .ffs import FFS
  • utils.py from main branch is not merged with utils.py from ffs branch. The following function is missing: try_import and needs to be copied in.
  • provided example for ffs has a bad initial configuration; choosing different atom ids solves the problem.

Example using JAX-MD

Hi PySAGES developers, first thank you again for the nice code!
I've seen some codes regarding JAX-MD as backend simulator, but have not yet figured out how I could use it for metadynamics. Does PySAGES currently support JAX-MD? if so, is it possible to provide a simple example about the usage? Thank you!

FFS support for hoomd-blue

Hoomd backend still present issues with handling snapshots, it throws this error:
reference_snapshot = copy(sampler.snapshot)
AttributeError: 'Sampler' object has no attribute 'snapshot'

Error in the example of alanine dipeptide using colab

I am trying to test the example of alanine dipeptide in colab but met the following error:

it happens when I tried to import pysages:

from pysages.grids import Grid
from pysages.colvars import DihedralAngle
from pysages.methods import Metadynamics

import pysages


AttributeError Traceback (most recent call last)
in
2 from pysages.colvars import DihedralAngle
3 from pysages.methods import Metadynamics
----> 4 import pysages

/usr/local/lib/python3.9/dist-packages/pysages/init.py in
72 from .utils import dispatch # noqa: E402, F401
73
---> 74 run = dispatch._functions["run"]
75 analyze = dispatch._functions["analyze"]
76

AttributeError: 'Dispatcher' object has no attribute '_functions'

Thank you very much if any suggestion can be provided!

Umbrella Sampling with OpenMM: Excessive Runtime?

Hello!
Thanks so much for the answers in issue #99, gonna go ahead and close that issue for the time being (I ended up using daiquiri with the OpenMM example, happy to share if that'd be helpful to you all). I also took @InnocentBug's suggestion to try umbrella sampling with the ADP example in OpenMM. I wrote the code shown below. My understanding is that this should run five umbrellas in OpenMM over 1e5 time steps (after an initial burn-in), then use WHAM to stitch these together to provide the A matrix. Looking at some other examples, the constants I set below in terms of the torsional angles and the umbrella k constant all seem reasonable. If I run just a single umbrella in OpenMM without using pysages (by adding, for eg, bias_torsion_phi = CustomTorsionForce("0.5*k_phi*dtheta^2; dtheta = min(tmp, 2*pi-tmp); tmp = abs(theta - phi)") ), and all the exact same code as below but without pysages, then the simulation completes in, like, 4 seconds.

I started the script below running on a single core yesterday morning, and it finished this morning. I'm confused as to what is taking such a high computational overhead. I have tried changing the k values, start/end locations of (psi,phi), num_umbrellas, etc., then I run for an hour before killing it. It really shouldn't take an hour, right? It should take, what, ~30 sec?

On the implementation side of things (and I'd be happy to help with this), I think it would be really nice to have one or some of the following:

  • TQDM on the for loop for the set of umbrellas to give an estimate of how long it will run for (see
    for rep in range(Nreplica):
    )
  • A cutoff flag for time running if not converged, or...
  • Based on the motion of the system, some kind of feedback to say "you should decrease your time step" or "you should increase/decrease K"
  • A warning when running WHAM along the lines of "umbrellas don't overlap much at all, so WHAM (or MBAR?) isn't going to give good results on the FES"

Thanks so much! 😄

from pysages.collective_variables import DihedralAngle
from pysages.methods import ABF, UmbrellaIntegration
import numpy as np
from pysages.utils import try_import
from openmm import *
from openmm.app import *

import numpy
import pysages

openmm = try_import("openmm", "simtk.openmm")
unit = try_import("openmm.unit", "simtk.unit")
app = try_import("openmm.app", "simtk.openmm.app")

pi = numpy.pi

def generate_simulation(**kwargs):
    pdb_filename = "alanine-dipeptide-explicit.pdb"
    T = 298.15 * unit.kelvin
    dt = 2.0 * unit.femtoseconds
    pdb = app.PDBFile(pdb_filename)

    ff = app.ForceField("amber99sb.xml", "tip3p.xml")
    cutoff_distance = 1.0 * unit.nanometer
    topology = pdb.topology
    system = ff.createSystem(
        topology, constraints = app.HBonds, nonbondedMethod = app.NoCutoff,
        nonbondedCutoff = cutoff_distance
    )
    
    positions = pdb.getPositions(asNumpy = True)

    integrator = openmm.LangevinIntegrator(T, 1 / unit.picosecond, dt)

    platform = Platform.getPlatformByName('CPU')
    simulation = app.Simulation(topology, system, integrator, platform)
    simulation.context.setPositions(positions)
    simulation.minimizeEnergy()

    return simulation

cvs = (
    DihedralAngle((4, 6, 8, 14)),
    DihedralAngle((6, 8, 14, 16))
)

num_umbrellas = 5
start_phi = -pi/2
end_phi = -pi/4
start_psi = -pi/2
end_psi = -pi/4

centers = np.array(list(zip(np.linspace(start_phi,end_phi,num_umbrellas).tolist(),\
                   np.linspace(start_psi,end_psi,num_umbrellas).tolist())))

method = UmbrellaIntegration(cvs)
result = method.run(generate_simulation,timesteps=1e5,centers=centers,\
                    ksprings=100,hist_periods=50)

Completed OpenMM Simulation FES

Hello!
Another question for you all. I noticed from the umbrella integration example with HOOMD, I can take results = method.run(...) and use this for getting at the final free energy surface (FES):

result = method.run(generate_context, args.time_steps, centers, args.k_spring, args.log_period, args.discard_equi)

I got the alanine dipeptide ABF working from the example, however in this case I just run the simulation:
method.run(generate_simulation, 50)

however if I set results = method.run(...), then I find that the new variable results is a NoneType. Is there a reason that I can set results= for a HOOMD simulation, and not results= for an OpenMM simulation to get at the FES? How should I get to the FES using the OpenMM alanine dipeptide example?

Thanks so much!

Pysages-ASE Nose-Hoover NVT error in forces

If the Nose-Hoover dynamics is chosen in ASE (ase.md.npt.NPT), there is an error with the calculated bias forces:
File "/pysages/backends/ase.py", line 105, in wrapped_step
simulation._step(forces=forces)
TypeError: step() got an unexpected keyword argument 'forces'

[Methods] Umbrella Integration

Now that we have a base implementation for Umbrella Sampling, we should implement Umbrella Integration.

This requires the run wrappers ready and some efforts on parallelization in.

Support for NPT simulations with jax_md

When working with NPT simulations and jax_md, fractional coordinates needs to be used for the neighborlist. PySAGES should extract the box size (box = simulate.npt_box(state)) and rescale the positions to correctly update the neighborlist.

Repeated histogram counts if add a openmm log reporter

Brief Description

I found that if I add a log reporter to unbiased alanine-dipeptide simulation, the histogram logger would record one time more xi values than the time steps.

Environment

I followed the set up in installation note in midway3. I ran my job in sinteractive mode in gpu partition.

Code to reproduce

(this code is adapted from example for spectral abf)

#!/usr/bin/env python3

"""
SpectralABF simulation of Alanine Dipeptide in vacuum with OpenMM and PySAGES.
Example command to run the simulation `python3 alanine-dipeptide.py --time-steps 1000`
For other supported commandline parameters, check `python3 alanine-dipeptide.py --help`
"""


# %%
import argparse
import sys
import time

import matplotlib.pyplot as plt
import numpy

import pysages
from pysages.approxfun import compute_mesh
from pysages.colvars import DihedralAngle
from pysages.methods import Unbiased, HistogramLogger
from pysages.utils import try_import

openmm = try_import("openmm", "simtk.openmm")
unit = try_import("openmm.unit", "simtk.unit")
app = try_import("openmm.app", "simtk.openmm.app")


# %%
pi = numpy.pi
kB = unit.BOLTZMANN_CONSTANT_kB * unit.AVOGADRO_CONSTANT_NA
kB = kB.value_in_unit(unit.kilojoules_per_mole / unit.kelvin)

T = 298.15 * unit.kelvin
dt = 2.0 * unit.femtoseconds
adp_pdb = "adp-vacuum.pdb"


# %%
def generate_simulation(pdb_filename=adp_pdb, T=T, dt=dt):
    pdb = app.PDBFile(pdb_filename)

    ff = app.ForceField("amber99sb.xml")
    cutoff_distance = 1.0 * unit.nanometer
    topology = pdb.topology

    system = ff.createSystem(
        topology, constraints=app.HBonds, nonbondedMethod=app.PME, nonbondedCutoff=cutoff_distance
    )

    # Set dispersion correction use.
    forces = {}
    for i in range(system.getNumForces()):
        force = system.getForce(i)
        forces[force.__class__.__name__] = force

    forces["NonbondedForce"].setUseDispersionCorrection(True)
    forces["NonbondedForce"].setEwaldErrorTolerance(1.0e-5)

    positions = pdb.getPositions(asNumpy=True)

    integrator = openmm.LangevinIntegrator(T, 1 / unit.picosecond, dt)
    integrator.setRandomNumberSeed(42)

    # platform = openmm.Platform.getPlatformByName(platform)
    # simulation = app.Simulation(topology, system, integrator, platform)
    simulation = app.Simulation(topology, system, integrator)
    simulation.context.setPositions(positions)
    simulation.minimizeEnergy()
    simulation.reporters.append(
                        app.StateDataReporter('log',
                                            1,
                                            step=True,
                                            time=True,
                                            potentialEnergy=True,
                                            kineticEnergy=True,
                                            totalEnergy=True,
                                            temperature=True))


    return simulation


# %%
def get_args(argv):
    available_args = [
        ("time-steps", "t", int, 5e5, "Number of simulation steps"),
    ]
    parser = argparse.ArgumentParser(description="Example script to run Spectral ABF")
    for (name, short, T, val, doc) in available_args:
        parser.add_argument("--" + name, "-" + short, type=T, default=T(val), help=doc)
    return parser.parse_args(argv)


# %%
def main(argv=[]):
    args = get_args(argv)

    cvs = [DihedralAngle([4, 6, 8, 14])]

    # Method
    method = Unbiased(cvs)

    tic = time.perf_counter()
    callback = HistogramLogger(1)
    run_result = pysages.run(method, generate_simulation, args.time_steps, callback)
    toc = time.perf_counter()
    print(f"Completed the simulation in {toc - tic:0.4f} seconds.")

    np.savetxt("dihedral.txt", run_result.callbacks[0].data)

# %%
if __name__ == "__main__":
    main(sys.argv[1:])

I changed phi-psi to one dihedral, changed abf to unbiased, and added a histogramLogger and a openmm log reporter.

And I execute

python alanine-dipeptide.py --time-steps 10

this would lead to a dihedral.txt file with 20 lines, and a log file with 11 lines (the first line is the head).
dihedral.txt:

-1.356931805610656738e+00
-1.358228564262390137e+00
-1.358228564262390137e+00
-1.360592961311340332e+00
-1.360592961311340332e+00
-1.361593604087829590e+00
-1.361593604087829590e+00
-1.363622307777404785e+00
-1.363622307777404785e+00
-1.365397930145263672e+00
-1.365397930145263672e+00
-1.365929484367370605e+00
-1.365929484367370605e+00
-1.368099331855773926e+00
-1.368099331855773926e+00
-1.369502067565917969e+00
-1.369502067565917969e+00
-1.370507478713989258e+00
-1.370507478713989258e+00
-1.371272802352905273e+00

log:

#"Step","Time (ps)","Potential Energy (kJ/mole)","Kinetic Energy (kJ/mole)","Total Energy (kJ/mole)","Temperature (K)"
1,0.002,-90.7515703562076,0.14926064088649582,-90.6023097153211,0.7039972076315866
2,0.004,-90.66084159644197,0.31577375944470987,-90.34506783699726,1.489366812121981
3,0.006,-90.52912772925447,0.4592449535266496,-90.06988277572782,2.166057729495585
4,0.008,-90.40165580542634,0.5241025778814219,-89.87755322754492,2.4719627970887195
5,0.01,-90.16859306128572,0.8659084612736478,-89.30268460001207,4.0841117603452854
6,0.012,-89.96650565894197,1.1798341972753406,-88.78667146166663,5.56476225357841
7,0.014,-89.90150321753572,1.4788492678198963,-88.42265394971582,6.975085654663139
8,0.016,-89.8797441843326,1.8018517950549722,-88.07789238927762,8.498547405067642
9,0.018000000000000002,-89.8254228952701,2.0839733593165874,-87.7414495359535,9.829191520443416
10,0.020000000000000004,-89.55366386206697,1.9868355998769403,-87.56682826219003,9.371035163918704

you can see that many consecutive lines are repeated in the dihedral.txt. If I print out the counter at the end:
print(run_result.callbacks[0].counter), this would print 20, but the total nsteps is only 10.

If I comment out the openmm log reporter, everything would behave normally.
dihedral.txt:

-1.356931805610656738e+00
-1.358228564262390137e+00
-1.360592961311340332e+00
-1.361593604087829590e+00
-1.363622307777404785e+00
-1.365397930145263672e+00
-1.365929484367370605e+00
-1.368099331855773926e+00
-1.369502067565917969e+00
-1.370507478713989258e+00

log:

#"Step","Time (ps)","Potential Energy (kJ/mole)","Kinetic Energy (kJ/mole)","Total Energy (kJ/mole)","Temperature (K)"
1,0.002,-90.7515703562076,0.14926064088649582,-90.6023097153211,0.7039972076315866
2,0.004,-90.66084159644197,0.31577375944470987,-90.34506783699726,1.489366812121981
3,0.006,-90.52912772925447,0.4592449535266496,-90.06988277572782,2.166057729495585
4,0.008,-90.40165580542634,0.5241025778814219,-89.87755322754492,2.4719627970887195
5,0.01,-90.16859306128572,0.8659084612736478,-89.30268460001207,4.0841117603452854
6,0.012,-89.96650565894197,1.1798341972753406,-88.78667146166663,5.56476225357841
7,0.014,-89.90150321753572,1.4788492678198963,-88.42265394971582,6.975085654663139
8,0.016,-89.8797441843326,1.8018517950549722,-88.07789238927762,8.498547405067642
9,0.018000000000000002,-89.8254228952701,2.0839733593165874,-87.7414495359535,9.829191520443416
10,0.020000000000000004,-89.55366386206697,1.9868355998769403,-87.56682826219003,9.371035163918704

Failing to open pickle file from an umbrella run

This is the stack trace:

File [~/miniforge3/envs/hoomdtest/lib/python3.8/site-packages/pysages/methods/core.py:81](~/miniforge3/envs/hoomdtest/lib/python3.8/site-packages/pysages/methods/core.py:81), in SamplingMethod.__setstate__(self, state)
     80 def __setstate__(self, state):
---> 81     default_setstate(self, state)

File [~/miniforge3/envs/hoomdtest/lib/python3.8/site-packages/pysages/methods/core.py:282](~/miniforge3/envs/hoomdtest/lib/python3.8/site-packages/pysages/methods/core.py:282), in default_setstate(method, state)
    280 def default_setstate(method, state):
    281     args, kwargs = state
--> 282     method.__init__(**args, **kwargs)

File [~/miniforge3/envs/hoomdtest/lib/python3.8/site-packages/plum/function.py:642](~/miniforge3/envs/hoomdtest/lib/python3.8/site-packages/plum/function.py:642), in _BoundFunction.__call__(self, *args, **kw_args)
    641 def __call__(self, *args, **kw_args):
--> 642     return self.f(self.instance, *args, **kw_args)

File [~/miniforge3/envs/hoomdtest/lib/python3.8/site-packages/plum/function.py:592](~/miniforge3/envs/hoomdtest/lib/python3.8/site-packages/plum/function.py:592), in Function.__call__(self, *args, **kw_args)
    590 # Cache failed. Get method and return type, and perform call.
    591 method, return_type = self.resolve_method(*sig_types)
--> 592 return _convert(method(*args, **kw_args), return_type)

TypeError: __init__() missing 1 required positional argument: 'cvs'

CFF and ANN failing for the alaninedipeptide example

When adapting examples of CFF and ANN from butane to alanine dipeptide, I encountered the error below. To note:

The error:

  data, structure = tree_flatten(params)
Traceback (most recent call last):
  File "adp_CFF.py", line 132, in <module>
    main(sys.argv[1:])
  File "adp_CFF.py", line 99, in main
    run_result = pysages.run(method, generate_simulation, timesteps)
  File "plum/function.py", line 537, in plum.function.Function.__call__
  File "/project/depablo/riccardo/PySG/PySAGES/pysages/methods/core.py", line 180, in run
    futures = [submit_work(ex, method, callback) for _ in range(config.copies)]
  File "/project/depablo/riccardo/PySG/PySAGES/pysages/methods/core.py", line 180, in <listcomp>
    futures = [submit_work(ex, method, callback) for _ in range(config.copies)]
  File "/project/depablo/riccardo/PySG/PySAGES/pysages/methods/core.py", line 168, in submit_work
    return executor.submit(
  File "/project/depablo/riccardo/PySG/PySAGES/pysages/methods/utils.py", line 34, in submit
    future.set_result(fn(*args, **kwargs))
  File "/project/depablo/riccardo/PySG/PySAGES/pysages/methods/core.py", line 190, in _run
    return run(method, *args, **kwargs)
  File "plum/function.py", line 537, in plum.function.Function.__call__
  File "/project/depablo/riccardo/PySG/PySAGES/pysages/methods/core.py", line 245, in run
    wrapped_context.run(timesteps, **kwargs)
  File "/project/depablo/riccardo/conda_envs/mypysages4/lib/python3.8/site-packages/openmm/app/simulation.py", line 134, in step
    self._simulate(endStep=self.currentStep+steps)
  File "/project/depablo/riccardo/conda_envs/mypysages4/lib/python3.8/site-packages/openmm/app/simulation.py", line 199, in _simulate
    self.integrator.step(10) # Only take 10 steps at a time, to give Python more chances to respond to a control-c.
  File "/project/depablo/riccardo/conda_envs/mypysages4/lib/python3.8/site-packages/openmm/openmm.py", line 8405, in step
    return _openmm.LangevinIntegrator_step(self, steps)
openmm.OpenMMException: ConcretizationTypeError: Abstract tracer value encountered where concrete value is expected: Traced<ShapedArray(bool[50,50])>with<DynamicJaxprTrace(level=1/2)>
The problem arose with the `bool` function.
The error occurred while tracing the function learn_free_energy at /project/depablo/riccardo/PySG/PySAGES/pysages/methods/cff.py:285 for cond. This concrete value was not available in Python because it depends on the value of the argument 'state'.

See https://jax.readthedocs.io/en/latest/errors.html#jax.errors.ConcretizationTypeError

At:
  /project/depablo/riccardo/conda_envs/mypysages4/lib/python3.8/site-packages/openmm/unit/quantity.py(670): _change_units_with_factor
  /project/depablo/riccardo/conda_envs/mypysages4/lib/python3.8/site-packages/openmm/unit/quantity.py(391): __rmul__
  /project/depablo/riccardo/conda_envs/mypysages4/lib/python3.8/site-packages/openmm/unit/quantity.py(428): __rtruediv__
  /project/depablo/riccardo/PySG/PySAGES/pysages/methods/cff.py(286): learn_free_energy
  /project/depablo/riccardo/conda_envs/mypysages4/lib/python3.8/site-packages/jax/linear_util.py(177): call_wrapped
  /project/depablo/riccardo/conda_envs/mypysages4/lib/python3.8/site-packages/jax/interpreters/partial_eval.py(2004): trace_to_subjaxpr_dynamic
  /project/depablo/riccardo/conda_envs/mypysages4/lib/python3.8/site-packages/jax/interpreters/partial_eval.py(1986): trace_to_jaxpr_dynamic
  /project/depablo/riccardo/conda_envs/mypysages4/lib/python3.8/site-packages/jax/_src/profiler.py(313): wrapper
  /project/depablo/riccardo/conda_envs/mypysages4/lib/python3.8/site-packages/jax/_src/lax/control_flow/common.py(54): _initial_style_open_jaxpr
  /project/depablo/riccardo/conda_envs/mypysages4/lib/python3.8/site-packages/jax/_src/lax/control_flow/common.py(76): <genexpr>

No GPU/TPU found, falling back to CPU

On midway3, I've been trying to run the ABF alanine dipeptide on GPU but I always get:

2022-01-12 11:12:21.762567: E external/org_tensorflow/tensorflow/stream_executor/cuda/cuda_driver.cc:271] failed call to cuInit: CUDA_ERROR_SYSTEM_DRIVER_MISMATCH: system has unsupported display driver / cuda driver combination
WARNING:absl:No GPU/TPU found, falling back to CPU. (Set TF_CPP_MIN_LOG_LEVEL=0 and rerun for more info.)

What I load (as recommended by @pabloferz some time ago):

source activate pysages
module load python/anaconda-2020.11
module load mvapich-gdr
module load nvhpc

which shows:

Currently Loaded Modulefiles:
 1) slurm/current   2) rcc/default   3) python/anaconda-2020.11(default)   4) cuda/11.2   5) mvapich-gdr/2.3.5(default)   6) nvhpc/20.11(default)

Then run my sbatch script:

#!/bin/bash
#SBATCH --nodes=1
#SBATCH --account=pi-depablo
#SBATCH --job-name=test
#SBATCH --time=0-01:00:00
#SBATCH --ntasks=1
#SBATCH --gres=gpu:1
#SBATCH --partition=depablo-gpu
python alanine-dipeptide_openmm.py

(or --partition=gpu).

What am I doing wrong?

External Fields support

PySAGES should support a way to support external fields into the simulation.

We are envisioning a separate API that supports this.
The external field should be passed separately to the pysages.run function to allow external field in tandem with each method.
The external field gets an API that allows the definition of potentials via functions and tabulated fields.

Optimally, we are thinking about time dependent potentials as well.

jaxlib issue on midway3

Hi all,

I have been trying to keep the pysages module up to date on midway2 and midway3; following the steps described in https://hackmd.io/Jbpc1E2kRbKPLUnmLKwINA

While the abf example script with openmm runs normally, I got the following errors with the example scripts under examples/hoomd-blue:

jaxlib.xla_extension.XlaRuntimeError: No matching device found for local hardware

To reproduce this error, on a GPU compute node on midway3 (midway3-0279 in this case) I did

module load python/anaconda-2021.05 cuda/11.2 openmpi/4.1.2+gcc-7.4.0 source activate pysages3
and then goes to examples/hoomd-blue/unbiased, run

python3 gen_gsd.py

to get start.gsd. Then run

python3 unbiased.py

(screenshot attached)

Screenshot from 2022-08-30 16-17-46

Maybe I missed something important here. Any suggestion will be appreciated.

(hoomd v2.9.7 installed in this pysages3 environment runs normally.)

Thanks,
-Trung

Sphinix doc build failed: `[Makefile:20: html] Error 1`

Description

I found that using current git repo main branch, the sphinx doc build would throw this error: [Makefile:20: html] Error 1

Reproduce the bug

I followed the set up in installation note in midway3. I ran the doc build in the login node.
Also, I followed the README.md in docs:

pip install -r docs/requirements.txt
make html 

And these lines give a stdout like this:

sphinx-build -M html "source" "build" -W --keep-going -b spelling &&\                                                                                                                                                                                                                    
sphinx-build -M html "source" "build" -W                                                                                                                                                                                                                                                 
Running Sphinx v5.2.3                                                                                                                                                                                                                                                                    
Initializing Spelling Checker 7.6.1                                                                                                                                                                                                                                                      
loading pickled environment... done                                                                                                                                                                                                                                                      
Ignoring wiki words                                                                                                                                                                                                                                                                      
Ignoring acronyms                                                                                                                                                                                                                                                                        
Ignoring Python builtins                                                                                                                                                                                                                                                                 
Ignoring importable module names                                                                                                                                                                                                                                                         
Ignoring contributor names                                                                                                                                                                                                                                                               
Looking for custom word list in /home/yihengwu917/source_code/PySAGES/docs/source/pysages_wordlist.txt                                                                                                                                                                                   
Scanning contributors                                                                                                                                                                                                                                                                    
[autosummary] generating autosummary for: getting-started.rst, index.rst, installation.rst, module-pysages-colvars-angles.rst, module-pysages-colvars-coordinates.rst, module-pysages-colvars-core.rst, module-pysages-colvars-shape.rst, module-pysages-colvars.rst, module-pysages-meth
ods-abf.rst, module-pysages-methods-ann.rst, ..., module-pysages-methods-funn.rst, module-pysages-methods-harmonic_bias.rst, module-pysages-methods-metad.rst, module-pysages-methods-string.rst, module-pysages-methods-umbrella.rst, module-pysages-methods-utils.rst, module-pysages-m
ethods.rst, mpi.rst, package-pysages.rst, trouble-shooting.rst                                                                                                                                                                                                                           
2022-10-14 11:05:25.327818: W external/org_tensorflow/tensorflow/compiler/xla/stream_executor/platform/default/dso_loader.cc:64] Could not load dynamic library 'libcuda.so.1'; dlerror: libcuda.so.1: cannot open shared object file: No such file or directory; LD_LIBRARY_PATH: /softw
are/openmpi-3.1.4-el8-x86_64/lib:/software/python-anaconda-2021.05-el8-x86_64/lib:/software/cudnn-11.2-el8-x86_64/lib64:/software/cuda-11.2-el8-x86_64/extras/CUPTI/lib64:/software/cuda-11.2-el8-x86_64/lib64:/software/gcc-10.2.0-el8-x86_64/lib64:/software/gcc-10.2.0-el8-x86_64/lib:
/software/R-4.0.3-el8-x86_64/lib64/R/lib:/software/R-4.0.3-el8-x86_64/lib64:/software/java-15.0.2-el8-x86_64/lib:/software/openblas-0.3.13-el8-x86_64/lib:/software/fftw3-3.3.9-el8-x86_64/lib:/software/slurm-current-el8-x86_64/lib:/home/yihengwu917/openmm/lib:/usr/local/lib:/usr/li
b:/home/yihengwu917/lib                                                                                                                                                                                                                                                                  
2022-10-14 11:05:25.327875: W external/org_tensorflow/tensorflow/compiler/xla/stream_executor/cuda/cuda_driver.cc:265] failed call to cuInit: UNKNOWN ERROR (303)                                                                                                                        
WARNING:absl:No GPU/TPU found, falling back to CPU. (Set TF_CPP_MIN_LOG_LEVEL=0 and rerun for more info.)                                                                                                                                                                                
building [mo]: targets for 0 po files that are out of date                                                                                                                                                                                                                               
building [spelling]: all documents                                                                                                                                                                                                                                                       
updating environment: 0 added, 6 changed, 0 removed                                                                                                                                                                                                                                      
reading sources... [ 16%] module-pysages-colvars-core                                                                                                                                                                                                                                    
reading sources... [ 33%] module-pysages-methods-abf                                                                                                                                                                                                                                     
reading sources... [ 50%] module-pysages-methods-ann
reading sources... [ 66%] module-pysages-methods-core
reading sources... [ 83%] module-pysages-methods-funn
reading sources... [100%] module-pysages-methods-metad

looking for now-outdated files... none found
pickling environment... done
checking consistency... done
preparing documents... done
writing output... [  4%] getting-started
writing output... [  9%] index
writing output... [ 13%] installation
Writing /home/yihengwu917/source_code/PySAGES/docs/build/html/installation.spelling
writing output... [ 18%] module-pysages-colvars
Writing /home/yihengwu917/source_code/PySAGES/docs/build/html/module-pysages-colvars.spelling
writing output... [ 22%] module-pysages-colvars-angles
writing output... [ 27%] module-pysages-colvars-coordinates
writing output... [ 31%] module-pysages-colvars-core
Writing /home/yihengwu917/source_code/PySAGES/docs/build/html/module-pysages-colvars-core.spelling
writing output... [ 36%] module-pysages-colvars-shape
Writing /home/yihengwu917/source_code/PySAGES/docs/build/html/module-pysages-colvars-shape.spelling
writing output... [ 40%] module-pysages-methods
Writing /home/yihengwu917/source_code/PySAGES/docs/build/html/module-pysages-methods.spelling
writing output... [ 45%] module-pysages-methods-abf
Writing /home/yihengwu917/source_code/PySAGES/docs/build/html/module-pysages-methods-abf.spelling
writing output... [ 50%] module-pysages-methods-ann
writing output... [ 54%] module-pysages-methods-core
Writing /home/yihengwu917/source_code/PySAGES/docs/build/html/module-pysages-methods-core.spelling
writing output... [ 59%] module-pysages-methods-ffs
writing output... [ 63%] module-pysages-methods-funn
writing output... [ 68%] module-pysages-methods-harmonic_bias
writing output... [ 72%] module-pysages-methods-metad
writing output... [ 77%] module-pysages-methods-string
writing output... [ 81%] module-pysages-methods-umbrella
writing output... [ 86%] module-pysages-methods-utils
Writing /home/yihengwu917/source_code/PySAGES/docs/build/html/module-pysages-methods-utils.spelling
writing output... [ 90%] mpi
writing output... [ 95%] package-pysages
writing output... [100%] trouble-shooting

WARNING: source/installation.rst:5: : Spell check: reinstall: ["re install", "re-install", "rein stall", "rein-stall", "reins tall", "reins-tall", "reinstate", "installer"]: Depending on your system setup, it may be necessary to reinstall the simulation backend, especially if you
do not have write permission for your current installation..
WARNING: source/module-pysages-colvars.rst:21:<autosummary>:1: : Spell check: unweighted: ["weighted", "underweight", "unlighted", "hundredweight"]: Collective Variable that calculates the unweighted radius of gyration as CV..                                                      
WARNING: ../pysages/colvars/core.py:docstring of pysages.colvars.core.multicomponent:1: : Spell check: multi: ["mulch", "mufti"]: Class decorator for multi-component (tensor-valued) collective variables..                                                                            
WARNING: ../pysages/colvars/core.py:docstring of pysages.colvars.core.multicomponent:2: : Spell check: multi: ["mulch", "mufti"]: By default CVs are assumed to be scalar-valued functions, so multi-component.                                                                         
WARNING: source/module-pysages-colvars-shape.rst:13:<autosummary>:1: : Spell check: unweighted: ["weighted", "underweight", "unlighted", "hundredweight"]: Collective Variable that calculates the unweighted radius of gyration as CV..                                                
WARNING: ../pysages/colvars/shape.py:docstring of pysages.colvars.shape.RadiusOfGyration:1: : Spell check: unweighted: ["weighted", "underweight", "unlighted", "hundredweight"]: Collective Variable that calculates the unweighted radius of gyration as CV..                         
WARNING: source/module-pysages-methods.rst:25:<autosummary>:1: : Spell check: functor: ["function"]: Implements a Callback functor for methods..                                                                                                                                        
WARNING: ../pysages/methods/abf.py:docstring of pysages.methods.abf.ABF.build:1: : Spell check: Tuple: ["Duple", "Tulle", "Letup", "Rtype"]: Tuple .                                                                                                                                    
WARNING: ../pysages/methods/core.py:docstring of pysages.methods.core.run:1: : Spell check: workflow: ["work flow", "work-flow", "workforce"]: Allows for user defined actions into the simulation workflow of the method..                                                             
WARNING: source/module-pysages-methods-utils.rst:10:<autosummary>:1: : Spell check: functor: ["function"]: Implements a Callback functor for methods..                                                                                                                                  
WARNING: ../pysages/methods/utils.py:docstring of pysages.methods.utils:3: : Spell check: functor: ["function"]: This includes callback functor objects (callable classes)..                                                                                                            
WARNING: ../pysages/methods/utils.py:docstring of pysages.methods.utils.HistogramLogger:1: : Spell check: functor: ["function"]: Implements a Callback functor for methods..                                                                                                            
WARNING: ../pysages/methods/utils.py:docstring of pysages.methods.utils.HistogramLogger.get_cov:1: : Spell check: covariance: ["co variance", "co-variance", "variance", "contrivance", "connivance"]: Returns covariance matrix of the histogram data..                                
WARNING: Found 13 misspelled words

====================== slowest reading durations =======================
0.397 module-pysages-methods-abf
0.183 module-pysages-colvars-core
0.117 module-pysages-methods-ann
0.112 module-pysages-methods-metad
0.105 module-pysages-methods-funn
build finished with problems, 14 warnings.
make: *** [Makefile:20: html] Error 1

And tree ./ in docs gives:

.                                                                                                                                                                                                                                                                                        
├── assets                                                                                                                                                                                                                                                                               
│   ├── pysages-bottom.svg                                                                                                                                                                                                                                                               
│   ├── pysages.png                                                                                                                                                                                                                                                                      
│   ├── pysages-right.svg
│   ├── pysages.svg
│   └── usage.png
├── build
│   ├── doctrees
│   │   ├── environment.pickle
│   │   ├── getting-started.doctree
│   │   ├── index.doctree
│   │   ├── installation.doctree
│   │   ├── module-pysages-colvars-angles.doctree
│   │   ├── module-pysages-colvars-coordinates.doctree
│   │   ├── module-pysages-colvars-core.doctree
│   │   ├── module-pysages-colvars.doctree
│   │   ├── module-pysages-colvars-shape.doctree
│   │   ├── module-pysages-methods-abf.doctree
│   │   ├── module-pysages-methods-ann.doctree
│   │   ├── module-pysages-methods-core.doctree
│   │   ├── module-pysages-methods.doctree
│   │   ├── module-pysages-methods-ffs.doctree
│   │   ├── module-pysages-methods-funn.doctree
│   │   ├── module-pysages-methods-harmonic_bias.doctree
│   │   ├── module-pysages-methods-metad.doctree
│   │   ├── module-pysages-methods-string.doctree
│   │   ├── module-pysages-methods-umbrella.doctree
│   │   ├── module-pysages-methods-utils.doctree
│   │   ├── mpi.doctree
│   │   ├── package-pysages.doctree
│   │   └── trouble-shooting.doctree
│   └── html
│       ├── installation.spelling
│       ├── module-pysages-colvars-core.spelling
│       ├── module-pysages-colvars-shape.spelling
│       ├── module-pysages-colvars.spelling
│       ├── module-pysages-methods-abf.spelling
│       ├── module-pysages-methods-core.spelling
│       ├── module-pysages-methods.spelling
│       └── module-pysages-methods-utils.spelling
├── make.bat
├── Makefile
├── README.md
├── requirements.txt
└── source
    ├── conf.py
    ├── getting-started.rst
    ├── index.rst
    ├── installation.rst
    ├── module-pysages-colvars-angles.rst
    ├── module-pysages-colvars-coordinates.rst
    ├── module-pysages-colvars-core.rst
    ├── module-pysages-colvars.rst
    ├── module-pysages-colvars-shape.rst
    ├── module-pysages-methods-abf.rst
    ├── module-pysages-methods-ann.rst
    ├── module-pysages-methods-core.rst
    ├── module-pysages-methods-ffs.rst
    ├── module-pysages-methods-funn.rst
    ├── module-pysages-methods-harmonic_bias.rst
    ├── module-pysages-methods-metad.rst
    ├── module-pysages-methods.rst
    ├── module-pysages-methods-string.rst
    ├── module-pysages-methods-umbrella.rst
    ├── module-pysages-methods-utils.rst
    ├── mpi.rst
    ├── package-pysages.rst
    ├── pysages_wordlist.txt
    └── trouble-shooting.rst

5 directories, 64 files

without the build/index.html.

Wrapping coordinates

Decide if coordinates should be delivered in the snapshots wrapped or unwrapped.
Or make it a user option.

At the moment, results between different backends might differ.

New Example: OpenMM+Umbrella Sampling

Hello!
I am trying to run OpenMM with umbrella sampling on just a very simple system, then move up to classical alanine dipeptide methods (both via umbrella sampling). I am fairly used to using OpenMM, although I am learning hoomd as well. Below is the system I am trying to run with (originally from Laio 2004):

import pysages
from pysages.collective_variables import Component
from pysages.methods import UmbrellaIntegration, ABF
import numpy as np
from openmm import *
from openmm.app import *
from openmm.unit import *

GLOB_TEMP = 0.12028 #Set such that $\beta = 1$
system = System()
system.addParticle(1)
force = CustomExternalForce('-5*e^(-(x/1.75)^2)')
force.addGlobalParameter("e", math.e)
integrator = LangevinIntegrator(GLOB_TEMP,0.0005,0.1)

force.addParticle(0,[])
system.addForce(force)
topology = Topology()
chain = topology.addChain()
residue = topology.addResidue('BAH',chain)
topology.addAtom('C',element.carbon,residue)
simulation = Simulation(topology,system,integrator)

cv1 = CustomExternalForce('x')
cv1.addParticle(0,[])
x = BiasVariable(cv1,-4,4,biasWidth=0.2,periodic=True,gridWidth=100)

cvs = np.array([Component([0], 0)])
method = UmbrellaIntegration(cvs)

centers = list(np.linspace(-4,4,10))
result = method.run(simulation, int(1e5), centers, \
                    50., int(50), int(1e-4))

Right now, if I try running this I get:
TypeError: 'Simulation' object is not callable
I am by no means an expert in OpenMM, but upon reviewing the ABF+OpenMM example, I thought that this should work with calling the Simulation object. Should I not be introducing a BiasVariable via OpenMM for the potential?
Thanks so much,
Marcus Schwarting

Some analysis techniques

Dear Developers,

I wonder if you can:

  1. give a little guide on how to implement a per-atom collective variable. Some things are similar to MultiColvar in PLUMED.

  2. Add some analysis techniques, such as contact matrix, clustering analysis,...

  3. Implement an Enhanced Sampling technique called LogMFD

It will be very helpful if you have example docs for a case implementation

Thank you so much

Memory allocation with multiple JAX/Simulation contexts

The preallocation of JAX causes issues when we run multiple JAX and/or simulation contexts.
We run into this situation as soon as we run multiple replica on a single GPU. (As for example with #68 )
The documentation of JAX says to either set manual amounts for JAX, or disable the preallocation alltogether.

At the moment, I see disabling the preallocation as the only practical solution for us.
It might be a bit slower, but it should also prevent interference between GPU allocation of JAX and the simulations.
We could set this behavior in the init.py of PySAGES, to avoid having users run into this issue.
Not the most elegant solution, but probably better than frustrated users.
What do you think @pabloferz

Two files are almost the same.

examples/openmm/metad/nacl/nacl.py
and
examples/openmm/metad/nacl/nacl-displacement.py
are almost the same file.

Can maybe one of them import stuff from the other one.
Maintance seems hard here.

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.