flashmd 0.2.2__tar.gz → 0.2.4__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {flashmd-0.2.2 → flashmd-0.2.4}/PKG-INFO +63 -3
- {flashmd-0.2.2 → flashmd-0.2.4}/README.md +62 -2
- {flashmd-0.2.2 → flashmd-0.2.4}/pyproject.toml +1 -1
- {flashmd-0.2.2 → flashmd-0.2.4}/src/flashmd/ase/langevin.py +2 -2
- {flashmd-0.2.2 → flashmd-0.2.4}/src/flashmd/ase/velocity_verlet.py +31 -0
- {flashmd-0.2.2 → flashmd-0.2.4}/src/flashmd.egg-info/PKG-INFO +63 -3
- {flashmd-0.2.2 → flashmd-0.2.4}/LICENSE +0 -0
- {flashmd-0.2.2 → flashmd-0.2.4}/setup.cfg +0 -0
- {flashmd-0.2.2 → flashmd-0.2.4}/src/flashmd/__init__.py +0 -0
- {flashmd-0.2.2 → flashmd-0.2.4}/src/flashmd/ase/__init__.py +0 -0
- {flashmd-0.2.2 → flashmd-0.2.4}/src/flashmd/ase/bussi.py +0 -0
- {flashmd-0.2.2 → flashmd-0.2.4}/src/flashmd/ase/npt.py +0 -0
- {flashmd-0.2.2 → flashmd-0.2.4}/src/flashmd/constraints.py +0 -0
- {flashmd-0.2.2 → flashmd-0.2.4}/src/flashmd/ipi.py +0 -0
- {flashmd-0.2.2 → flashmd-0.2.4}/src/flashmd/models.py +0 -0
- {flashmd-0.2.2 → flashmd-0.2.4}/src/flashmd/stepper.py +0 -0
- {flashmd-0.2.2 → flashmd-0.2.4}/src/flashmd.egg-info/SOURCES.txt +0 -0
- {flashmd-0.2.2 → flashmd-0.2.4}/src/flashmd.egg-info/dependency_links.txt +0 -0
- {flashmd-0.2.2 → flashmd-0.2.4}/src/flashmd.egg-info/requires.txt +0 -0
- {flashmd-0.2.2 → flashmd-0.2.4}/src/flashmd.egg-info/top_level.txt +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: flashmd
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.4
|
|
4
4
|
Summary: Accelerated molecular dynamics with large-time-step predictions
|
|
5
5
|
Author: flashmd developers
|
|
6
6
|
License: Apache-2.0
|
|
@@ -60,17 +60,20 @@ from flashmd.ase.langevin import Langevin
|
|
|
60
60
|
|
|
61
61
|
|
|
62
62
|
# Choose your time step (go for 10-30x what you would use in normal MD for your system)
|
|
63
|
-
time_step =
|
|
63
|
+
time_step = 64 # 64 fs; also available: 1, 2, 4, 8, 16, 32, 128 fs
|
|
64
64
|
|
|
65
65
|
# Create a structure and initialize velocities
|
|
66
66
|
atoms = ase.build.bulk("Al", "fcc", cubic=True)
|
|
67
67
|
MaxwellBoltzmannDistribution(atoms, temperature_K=300)
|
|
68
|
-
atoms.set_velocities(
|
|
68
|
+
atoms.set_velocities( # it is generally a good idea to remove any net velocity
|
|
69
|
+
atoms.get_velocities() - atoms.get_momenta().sum(axis=0) / atoms.get_masses().sum()
|
|
70
|
+
)
|
|
69
71
|
|
|
70
72
|
# Load models
|
|
71
73
|
device="cuda" if torch.cuda.is_available() else "cpu"
|
|
72
74
|
energy_model, flashmd_model = get_pretrained("pet-omatpes", time_step)
|
|
73
75
|
|
|
76
|
+
# Set the energy model (see below for more precise usage)
|
|
74
77
|
calculator = MetatomicCalculator(energy_model, device=device)
|
|
75
78
|
atoms.calc = calculator
|
|
76
79
|
|
|
@@ -96,6 +99,60 @@ Other available integrators:
|
|
|
96
99
|
from flashmd.ase.bussi import Bussi
|
|
97
100
|
```
|
|
98
101
|
|
|
102
|
+
Common pitfalls
|
|
103
|
+
---------------
|
|
104
|
+
|
|
105
|
+
Stick to 10-30x what you would use in normal MD for your system! The 64 fs example
|
|
106
|
+
above is good for metals. However,
|
|
107
|
+
- for most materials: try 32 fs (aggressive) or 16 fs (conservative)
|
|
108
|
+
- for aqueous and/or organic systems: try 16 fs (aggressive) or 8 fs (conservative)
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
Companion energy models and exact energy conservation
|
|
112
|
+
-----------------------------------------------------
|
|
113
|
+
|
|
114
|
+
You might have noticed that ``get_pretrained()`` does not only return a FlashMD model,
|
|
115
|
+
but also an energy model, which is itself just a machine-learned interatomic potential.
|
|
116
|
+
This is the energy model that the FlashMD model was trained on. You might want to use it
|
|
117
|
+
if...
|
|
118
|
+
|
|
119
|
+
Case 1: you want to run FlashMD with exact energy conservation, available through the
|
|
120
|
+
integrator's (``dyn`` above) parameter ``rescale_energy=True`` (this is enabled by
|
|
121
|
+
default only when targeting the NVE ensemble with ``VelocityVerlet``). In that case,
|
|
122
|
+
besides setting this flag, you should attach the energy calculator to the atoms before
|
|
123
|
+
running FlashMD, exactly as shown above (and below with the more precise
|
|
124
|
+
``do_gradients_with_energy=False`` which will save you memory and computation):
|
|
125
|
+
|
|
126
|
+
```
|
|
127
|
+
from metatomic.torch.ase_calculator import MetatomicCalculator
|
|
128
|
+
|
|
129
|
+
... # setting up atoms
|
|
130
|
+
calculator = MetatomicCalculator(energy_model, device=device, do_gradients_with_energy=False)
|
|
131
|
+
atoms.calc = calculator
|
|
132
|
+
... # running FlashMD
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
Case 2: you want to compute energies after running FlashMD for your own analysis. In
|
|
136
|
+
this case, you can create the calculator just like in case 1, but possibly after running
|
|
137
|
+
FlashMD and/or in a different script.
|
|
138
|
+
|
|
139
|
+
Case 3: you found something interesting during a FlashMD run and you want to confirm it
|
|
140
|
+
with traditional MD. Then, you can just use ASE's MD modules as usual after attaching
|
|
141
|
+
the energy calculator:
|
|
142
|
+
|
|
143
|
+
```
|
|
144
|
+
from metatomic.torch.ase_calculator import MetatomicCalculator
|
|
145
|
+
|
|
146
|
+
... # setting up atoms
|
|
147
|
+
calculator = MetatomicCalculator(energy_model, device=device)
|
|
148
|
+
atoms.calc = calculator
|
|
149
|
+
... # running MD
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
In general, the energy models are slower and have a larger memory footprint compared to
|
|
153
|
+
the FlashMD models. As summarized above, you should use `do_gradients_with_energy=False`
|
|
154
|
+
to save computation and memory when you don't need forces.
|
|
155
|
+
|
|
99
156
|
Disclaimer
|
|
100
157
|
----------
|
|
101
158
|
|
|
@@ -132,3 +189,6 @@ pip install flashmd==0.1.2 ase==3.24.0 pet-mad==1.4.3
|
|
|
132
189
|
|
|
133
190
|
and using the "PET-MAD" models (PBEsol) from https://huggingface.co/lab-cosmo/flashmd.
|
|
134
191
|
Note that the results were obtained through the i-PI interface.
|
|
192
|
+
|
|
193
|
+
Instructions and material to reproduce the results in the paper are available on
|
|
194
|
+
Materials Cloud at https://doi.org/10.24435/materialscloud:b7-xq.
|
|
@@ -31,17 +31,20 @@ from flashmd.ase.langevin import Langevin
|
|
|
31
31
|
|
|
32
32
|
|
|
33
33
|
# Choose your time step (go for 10-30x what you would use in normal MD for your system)
|
|
34
|
-
time_step =
|
|
34
|
+
time_step = 64 # 64 fs; also available: 1, 2, 4, 8, 16, 32, 128 fs
|
|
35
35
|
|
|
36
36
|
# Create a structure and initialize velocities
|
|
37
37
|
atoms = ase.build.bulk("Al", "fcc", cubic=True)
|
|
38
38
|
MaxwellBoltzmannDistribution(atoms, temperature_K=300)
|
|
39
|
-
atoms.set_velocities(
|
|
39
|
+
atoms.set_velocities( # it is generally a good idea to remove any net velocity
|
|
40
|
+
atoms.get_velocities() - atoms.get_momenta().sum(axis=0) / atoms.get_masses().sum()
|
|
41
|
+
)
|
|
40
42
|
|
|
41
43
|
# Load models
|
|
42
44
|
device="cuda" if torch.cuda.is_available() else "cpu"
|
|
43
45
|
energy_model, flashmd_model = get_pretrained("pet-omatpes", time_step)
|
|
44
46
|
|
|
47
|
+
# Set the energy model (see below for more precise usage)
|
|
45
48
|
calculator = MetatomicCalculator(energy_model, device=device)
|
|
46
49
|
atoms.calc = calculator
|
|
47
50
|
|
|
@@ -67,6 +70,60 @@ Other available integrators:
|
|
|
67
70
|
from flashmd.ase.bussi import Bussi
|
|
68
71
|
```
|
|
69
72
|
|
|
73
|
+
Common pitfalls
|
|
74
|
+
---------------
|
|
75
|
+
|
|
76
|
+
Stick to 10-30x what you would use in normal MD for your system! The 64 fs example
|
|
77
|
+
above is good for metals. However,
|
|
78
|
+
- for most materials: try 32 fs (aggressive) or 16 fs (conservative)
|
|
79
|
+
- for aqueous and/or organic systems: try 16 fs (aggressive) or 8 fs (conservative)
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
Companion energy models and exact energy conservation
|
|
83
|
+
-----------------------------------------------------
|
|
84
|
+
|
|
85
|
+
You might have noticed that ``get_pretrained()`` does not only return a FlashMD model,
|
|
86
|
+
but also an energy model, which is itself just a machine-learned interatomic potential.
|
|
87
|
+
This is the energy model that the FlashMD model was trained on. You might want to use it
|
|
88
|
+
if...
|
|
89
|
+
|
|
90
|
+
Case 1: you want to run FlashMD with exact energy conservation, available through the
|
|
91
|
+
integrator's (``dyn`` above) parameter ``rescale_energy=True`` (this is enabled by
|
|
92
|
+
default only when targeting the NVE ensemble with ``VelocityVerlet``). In that case,
|
|
93
|
+
besides setting this flag, you should attach the energy calculator to the atoms before
|
|
94
|
+
running FlashMD, exactly as shown above (and below with the more precise
|
|
95
|
+
``do_gradients_with_energy=False`` which will save you memory and computation):
|
|
96
|
+
|
|
97
|
+
```
|
|
98
|
+
from metatomic.torch.ase_calculator import MetatomicCalculator
|
|
99
|
+
|
|
100
|
+
... # setting up atoms
|
|
101
|
+
calculator = MetatomicCalculator(energy_model, device=device, do_gradients_with_energy=False)
|
|
102
|
+
atoms.calc = calculator
|
|
103
|
+
... # running FlashMD
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
Case 2: you want to compute energies after running FlashMD for your own analysis. In
|
|
107
|
+
this case, you can create the calculator just like in case 1, but possibly after running
|
|
108
|
+
FlashMD and/or in a different script.
|
|
109
|
+
|
|
110
|
+
Case 3: you found something interesting during a FlashMD run and you want to confirm it
|
|
111
|
+
with traditional MD. Then, you can just use ASE's MD modules as usual after attaching
|
|
112
|
+
the energy calculator:
|
|
113
|
+
|
|
114
|
+
```
|
|
115
|
+
from metatomic.torch.ase_calculator import MetatomicCalculator
|
|
116
|
+
|
|
117
|
+
... # setting up atoms
|
|
118
|
+
calculator = MetatomicCalculator(energy_model, device=device)
|
|
119
|
+
atoms.calc = calculator
|
|
120
|
+
... # running MD
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
In general, the energy models are slower and have a larger memory footprint compared to
|
|
124
|
+
the FlashMD models. As summarized above, you should use `do_gradients_with_energy=False`
|
|
125
|
+
to save computation and memory when you don't need forces.
|
|
126
|
+
|
|
70
127
|
Disclaimer
|
|
71
128
|
----------
|
|
72
129
|
|
|
@@ -103,3 +160,6 @@ pip install flashmd==0.1.2 ase==3.24.0 pet-mad==1.4.3
|
|
|
103
160
|
|
|
104
161
|
and using the "PET-MAD" models (PBEsol) from https://huggingface.co/lab-cosmo/flashmd.
|
|
105
162
|
Note that the results were obtained through the i-PI interface.
|
|
163
|
+
|
|
164
|
+
Instructions and material to reproduce the results in the paper are available on
|
|
165
|
+
Materials Cloud at https://doi.org/10.24435/materialscloud:b7-xq.
|
|
@@ -27,7 +27,7 @@ class Langevin(VelocityVerlet):
|
|
|
27
27
|
self.friction = 1.0 / time_constant
|
|
28
28
|
self.fixcm = fixcm
|
|
29
29
|
if self.fixcm:
|
|
30
|
-
self.atoms.set_velocities(self.atoms.get_velocities() - self.atoms.
|
|
30
|
+
self.atoms.set_velocities(self.atoms.get_velocities() - self.atoms.get_momenta().sum(axis=0) / self.atoms.get_masses().sum())
|
|
31
31
|
|
|
32
32
|
def step(self):
|
|
33
33
|
self.apply_langevin_half_step()
|
|
@@ -43,4 +43,4 @@ class Langevin(VelocityVerlet):
|
|
|
43
43
|
) * np.random.randn(*old_momenta.shape)
|
|
44
44
|
self.atoms.set_momenta(new_momenta)
|
|
45
45
|
if self.fixcm:
|
|
46
|
-
self.atoms.set_velocities(self.atoms.get_velocities() - self.atoms.
|
|
46
|
+
self.atoms.set_velocities(self.atoms.get_velocities() - self.atoms.get_momenta().sum(axis=0) / self.atoms.get_masses().sum())
|
|
@@ -95,6 +95,37 @@ class VelocityVerlet(MolecularDynamics):
|
|
|
95
95
|
alpha = np.sqrt(1.0 - (new_energy - old_energy) / old_kinetic_energy)
|
|
96
96
|
self.atoms.set_momenta(alpha * self.atoms.get_momenta())
|
|
97
97
|
|
|
98
|
+
def irun(self, steps=50):
|
|
99
|
+
# We have to override irun to avoid calling MolecularDynamics.irun(), which
|
|
100
|
+
# calls gradients to check convergence (optimizer-like behavior) or to log the
|
|
101
|
+
# forces, depending on the ASE version. This function is a copy of
|
|
102
|
+
# Dynamics.irun(), where the calls to the forces are commented out.
|
|
103
|
+
|
|
104
|
+
# update the maximum number of steps
|
|
105
|
+
self.max_steps = self.nsteps + steps
|
|
106
|
+
|
|
107
|
+
if self.nsteps == 0:
|
|
108
|
+
# For historical reasons we do a magical incantation
|
|
109
|
+
# here with forces, log, observers.
|
|
110
|
+
# self.atoms.get_forces()
|
|
111
|
+
self.log()
|
|
112
|
+
self.call_observers()
|
|
113
|
+
|
|
114
|
+
yield self.nsteps == self.max_steps
|
|
115
|
+
|
|
116
|
+
# run the algorithm until converged or max_steps reached
|
|
117
|
+
while self.nsteps < self.max_steps:
|
|
118
|
+
self.step()
|
|
119
|
+
self.nsteps += 1
|
|
120
|
+
# self.atoms.get_forces()
|
|
121
|
+
self.log()
|
|
122
|
+
self.call_observers()
|
|
123
|
+
yield self.nsteps == self.max_steps
|
|
124
|
+
|
|
125
|
+
def run(self, steps=50):
|
|
126
|
+
# needed for ASE <= 3.26.0; in 3.27.0 Dynamics.run() works well for us
|
|
127
|
+
for _ in self.irun(steps=steps):
|
|
128
|
+
pass
|
|
98
129
|
|
|
99
130
|
def _convert_atoms_to_system(
|
|
100
131
|
atoms: ase.Atoms, dtype: str, device: str | torch.device
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: flashmd
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.4
|
|
4
4
|
Summary: Accelerated molecular dynamics with large-time-step predictions
|
|
5
5
|
Author: flashmd developers
|
|
6
6
|
License: Apache-2.0
|
|
@@ -60,17 +60,20 @@ from flashmd.ase.langevin import Langevin
|
|
|
60
60
|
|
|
61
61
|
|
|
62
62
|
# Choose your time step (go for 10-30x what you would use in normal MD for your system)
|
|
63
|
-
time_step =
|
|
63
|
+
time_step = 64 # 64 fs; also available: 1, 2, 4, 8, 16, 32, 128 fs
|
|
64
64
|
|
|
65
65
|
# Create a structure and initialize velocities
|
|
66
66
|
atoms = ase.build.bulk("Al", "fcc", cubic=True)
|
|
67
67
|
MaxwellBoltzmannDistribution(atoms, temperature_K=300)
|
|
68
|
-
atoms.set_velocities(
|
|
68
|
+
atoms.set_velocities( # it is generally a good idea to remove any net velocity
|
|
69
|
+
atoms.get_velocities() - atoms.get_momenta().sum(axis=0) / atoms.get_masses().sum()
|
|
70
|
+
)
|
|
69
71
|
|
|
70
72
|
# Load models
|
|
71
73
|
device="cuda" if torch.cuda.is_available() else "cpu"
|
|
72
74
|
energy_model, flashmd_model = get_pretrained("pet-omatpes", time_step)
|
|
73
75
|
|
|
76
|
+
# Set the energy model (see below for more precise usage)
|
|
74
77
|
calculator = MetatomicCalculator(energy_model, device=device)
|
|
75
78
|
atoms.calc = calculator
|
|
76
79
|
|
|
@@ -96,6 +99,60 @@ Other available integrators:
|
|
|
96
99
|
from flashmd.ase.bussi import Bussi
|
|
97
100
|
```
|
|
98
101
|
|
|
102
|
+
Common pitfalls
|
|
103
|
+
---------------
|
|
104
|
+
|
|
105
|
+
Stick to 10-30x what you would use in normal MD for your system! The 64 fs example
|
|
106
|
+
above is good for metals. However,
|
|
107
|
+
- for most materials: try 32 fs (aggressive) or 16 fs (conservative)
|
|
108
|
+
- for aqueous and/or organic systems: try 16 fs (aggressive) or 8 fs (conservative)
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
Companion energy models and exact energy conservation
|
|
112
|
+
-----------------------------------------------------
|
|
113
|
+
|
|
114
|
+
You might have noticed that ``get_pretrained()`` does not only return a FlashMD model,
|
|
115
|
+
but also an energy model, which is itself just a machine-learned interatomic potential.
|
|
116
|
+
This is the energy model that the FlashMD model was trained on. You might want to use it
|
|
117
|
+
if...
|
|
118
|
+
|
|
119
|
+
Case 1: you want to run FlashMD with exact energy conservation, available through the
|
|
120
|
+
integrator's (``dyn`` above) parameter ``rescale_energy=True`` (this is enabled by
|
|
121
|
+
default only when targeting the NVE ensemble with ``VelocityVerlet``). In that case,
|
|
122
|
+
besides setting this flag, you should attach the energy calculator to the atoms before
|
|
123
|
+
running FlashMD, exactly as shown above (and below with the more precise
|
|
124
|
+
``do_gradients_with_energy=False`` which will save you memory and computation):
|
|
125
|
+
|
|
126
|
+
```
|
|
127
|
+
from metatomic.torch.ase_calculator import MetatomicCalculator
|
|
128
|
+
|
|
129
|
+
... # setting up atoms
|
|
130
|
+
calculator = MetatomicCalculator(energy_model, device=device, do_gradients_with_energy=False)
|
|
131
|
+
atoms.calc = calculator
|
|
132
|
+
... # running FlashMD
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
Case 2: you want to compute energies after running FlashMD for your own analysis. In
|
|
136
|
+
this case, you can create the calculator just like in case 1, but possibly after running
|
|
137
|
+
FlashMD and/or in a different script.
|
|
138
|
+
|
|
139
|
+
Case 3: you found something interesting during a FlashMD run and you want to confirm it
|
|
140
|
+
with traditional MD. Then, you can just use ASE's MD modules as usual after attaching
|
|
141
|
+
the energy calculator:
|
|
142
|
+
|
|
143
|
+
```
|
|
144
|
+
from metatomic.torch.ase_calculator import MetatomicCalculator
|
|
145
|
+
|
|
146
|
+
... # setting up atoms
|
|
147
|
+
calculator = MetatomicCalculator(energy_model, device=device)
|
|
148
|
+
atoms.calc = calculator
|
|
149
|
+
... # running MD
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
In general, the energy models are slower and have a larger memory footprint compared to
|
|
153
|
+
the FlashMD models. As summarized above, you should use `do_gradients_with_energy=False`
|
|
154
|
+
to save computation and memory when you don't need forces.
|
|
155
|
+
|
|
99
156
|
Disclaimer
|
|
100
157
|
----------
|
|
101
158
|
|
|
@@ -132,3 +189,6 @@ pip install flashmd==0.1.2 ase==3.24.0 pet-mad==1.4.3
|
|
|
132
189
|
|
|
133
190
|
and using the "PET-MAD" models (PBEsol) from https://huggingface.co/lab-cosmo/flashmd.
|
|
134
191
|
Note that the results were obtained through the i-PI interface.
|
|
192
|
+
|
|
193
|
+
Instructions and material to reproduce the results in the paper are available on
|
|
194
|
+
Materials Cloud at https://doi.org/10.24435/materialscloud:b7-xq.
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|