Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Running metadynamics with PLUMED and metatensor-defined collective variables #88

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions examples/metatensor-plumed/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
extensions/
custom-cv.pt
HILLS
4 changes: 4 additions & 0 deletions examples/metatensor-plumed/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Using machine learning collective variables in PLUMED with metatensor
=====================================================================

TODO
39 changes: 39 additions & 0 deletions examples/metatensor-plumed/data/input-md.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<simulation safe_stride='10' verbosity='medium'>
<ffsocket mode='unix' name='driver'>
<latency> 1.00000000e-04</latency> <address>lj-driver</address>
</ffsocket>
<total_steps>5000</total_steps>
<output prefix="base-md">
<trajectory stride="10" filename="pos" cell_units="atomic_unit">positions{atomic_unit}</trajectory>
<properties stride="10">
[ step, time, conserved, temperature, kinetic_md, potential, ensemble_bias ]
</properties>
</output>
<prng>
<seed>18885</seed>
</prng>
<system>
<forces>
<force forcefield="driver"></force>
</forces>
<initialize nbeads="1">
<file mode="xyz">data/lj38.xyz</file>
<masses mode="manual"> [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]</masses>
<cell>
[ 100, 0, 0, 0, 100, 0, 0, 0, 100 ]
</cell>
</initialize>
<ensemble>
<temperature units="atomic_unit"> 0.30 </temperature>
</ensemble>
<motion mode="dynamics">
<fixcom> False </fixcom>
<dynamics mode="nvt">
<timestep units="atomic_unit"> 0.02 </timestep>
<thermostat mode="langevin">
<tau units="atomic_unit"> 10 </tau>
</thermostat>
</dynamics>
</motion>
</system>
</simulation>
51 changes: 51 additions & 0 deletions examples/metatensor-plumed/data/input-meta.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<simulation safe_stride='10' verbosity='medium'>
<ffsocket mode='unix' name='driver'>
<latency> 1.00000000e-04</latency> <address>lj-driver</address>
</ffsocket>
<ffplumed name="plumed">
<file mode="xyz">data/lj38.xyz</file>
<plumeddat> data/plumed.dat </plumeddat>
<plumed_extras> [cv1, cv2, mtd.bias ] </plumed_extras>
</ffplumed>
<total_steps>5000</total_steps>
<output prefix="meta-md">
<trajectory stride="10" filename="pos" cell_units="atomic_unit">positions{atomic_unit}</trajectory>
<trajectory stride="10" filename="colvar" bead="0" extra_type="cv1,cv2,mtd.bias"> extras_bias </trajectory>
<properties stride="10">
[ step, time, conserved, temperature, kinetic_md, potential, ensemble_bias ]
</properties>
</output>
<prng>
<seed>18885</seed>
</prng>
<system>
<forces>
<force forcefield="driver"></force>
</forces>
<initialize nbeads="1">
<file mode="xyz">data/lj38.xyz</file>
<masses mode="manual"> [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]</masses>
<cell>
[ 100, 0, 0, 0, 100, 0, 0, 0, 100 ]
</cell>
</initialize>
<ensemble>
<temperature units="atomic_unit"> 0.30 </temperature>
<bias>
<force forcefield="plumed"/>
</bias>
</ensemble>
<motion mode="dynamics">
<fixcom> False </fixcom>
<dynamics mode="nvt">
<timestep units="atomic_unit"> 0.02 </timestep>
<thermostat mode="langevin">
<tau units="atomic_unit"> 10 </tau>
</thermostat>
</dynamics>
</motion>
</system>
<smotion mode="metad">
<metad> <metaff> [ plumed ] </metaff> </metad>
</smotion>
</simulation>
40 changes: 40 additions & 0 deletions examples/metatensor-plumed/data/lj38.xyz
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
38
# Step 100000000
Ar 1.4267876E+000 2.9212078E+000 1.0701605E+000
Ar -6.1336159E-001 1.3366171E+000 9.8967797E-001
Ar -7.1959392E-002 1.9963731E+000 2.9199481E-001
Ar 1.4336444E+000 1.1270242E+000 1.0450441E+000
Ar 2.2149714E+000 1.7976783E+000 2.1410531E+000
Ar 1.3734694E+000 2.6020966E+000 2.6952938E+000
Ar 9.1665725E-001 1.3886509E-001 1.2365719E+000
Ar 3.1414994E-001 3.7667848E+000 2.3424693E+000
Ar 9.8263797E-001 2.0201570E+000 6.6390178E-001
Ar 4.1439813E-001 1.0970310E+000 7.5153475E-001
Ar -1.0887056E+000 5.8302904E-001 1.8687178E+000
Ar 2.8615674E-001 2.9154779E+000 7.1026823E-001
Ar -3.3917867E-001 3.4038120E+000 1.4536682E+000
Ar -3.8905351E-001 1.9077154E+000 3.1118603E+000
Ar -6.7077782E-001 3.3591081E+000 2.6207557E+000
Ar -1.1449957E-001 5.0378829E-001 1.5028689E+000
Ar -5.4573740E-001 3.8732958E-001 2.8483650E+000
Ar 1.6481073E-001 1.9170175E+000 1.3753046E+000
Ar 5.1444560E-001 1.9761151E+000 2.4004309E+000
Ar -6.9012030E-001 2.4364761E+000 1.0438342E+000
Ar -1.3149162E+000 3.0291069E+000 1.8041757E+000
Ar 2.1566535E+000 2.0243254E+000 9.8121294E-001
Ar 1.3838741E+000 3.6177568E+000 2.0154838E+000
Ar 2.1685344E+000 2.8098050E+000 1.8275828E+000
Ar -1.3254347E+000 1.2746350E+000 2.7507219E+000
Ar 1.3956249E+000 1.3881537E+000 2.6916380E+000
Ar -1.3201815E+000 2.4262575E+000 2.6909376E+000
Ar 3.4406330E-001 1.0391058E+000 2.9605370E+000
Ar 3.0221745E-001 2.8678386E+000 2.9556254E+000
Ar 5.7627097E-001 2.8893057E+000 1.8005862E+000
Ar 7.7447852E-001 2.0078518E+000 3.4195584E+000
Ar 6.2013735E-001 4.8378593E-002 2.3725838E+000
Ar 1.2838145E+000 2.0173886E+000 1.6958543E+000
Ar -1.2221551E+000 1.8286569E+000 1.7668366E+000
Ar 7.0190189E-001 3.8124480E+000 1.2117366E+000
Ar -3.5844585E-001 1.3234871E+000 2.1555337E+000
Ar 7.0158765E-001 1.0394241E+000 1.8553935E+000
Ar -4.3723088E-001 2.3968664E+000 2.1187988E+000
12 changes: 12 additions & 0 deletions examples/metatensor-plumed/data/plumed.dat
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# default (nm, kJ/mol) to atomic
UNITS LENGTH=0.052917721 ENERGY=0.00038087988
cv: METATENSOR MODEL=custom-cv.pt EXTENSIONS_DIRECTORY=./extensions/ SPECIES1=1-38 SPECIES_TO_TYPES=18
# extract the different components from METATENSOR output into scalar
# (METAD only accepts scalars, and METATENSOR output is a vector here)
cv1: SELECT_COMPONENTS ARG=cv COMPONENTS=1
cv2: SELECT_COMPONENTS ARG=cv COMPONENTS=2
# run metadynamics with this collective variable
mtd: METAD ARG=cv1,cv2 HEIGHT=0.05 PACE=50 SIGMA=1,2.5 GRID_MIN=-20,-40 GRID_MAX=20,40 GRID_BIN=500,500 BIASFACTOR=5 FILE=HILLS TEMP=0.18
# prints out trajectory
PRINT ARG=cv1,cv2,mtd.* STRIDE=10 FILE=COLVAR
FLUSH STRIDE=1
15 changes: 15 additions & 0 deletions examples/metatensor-plumed/environment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
channels:
- conda-forge
dependencies:
- python=3.12
- pip
- plumed
- py-plumed
- pip:
- ase
- numpy
- chemiscope
- metatensor[torch]
- rascaline-torch @ git+https://github.com/Luthaf/rascaline@b14477f#subdirectory=python/rascaline-torch
variables:
PLUMED_KERNEL:
Loading
Loading