flashmd 0.2.7__tar.gz → 0.2.8__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.7 → flashmd-0.2.8}/PKG-INFO +12 -4
- {flashmd-0.2.7 → flashmd-0.2.8}/README.md +9 -1
- {flashmd-0.2.7 → flashmd-0.2.8}/pyproject.toml +5 -6
- flashmd-0.2.8/src/flashmd/__init__.py +21 -0
- flashmd-0.2.8/src/flashmd/ase/__init__.py +13 -0
- {flashmd-0.2.7 → flashmd-0.2.8}/src/flashmd/constraints.py +19 -8
- {flashmd-0.2.7 → flashmd-0.2.8}/src/flashmd/stepper.py +2 -4
- {flashmd-0.2.7 → flashmd-0.2.8}/src/flashmd.egg-info/PKG-INFO +12 -4
- {flashmd-0.2.7 → flashmd-0.2.8}/src/flashmd.egg-info/SOURCES.txt +1 -0
- {flashmd-0.2.7 → flashmd-0.2.8}/src/flashmd.egg-info/requires.txt +1 -1
- flashmd-0.2.8/tests/test_edge_cases.py +55 -0
- flashmd-0.2.7/src/flashmd/__init__.py +0 -7
- flashmd-0.2.7/src/flashmd/ase/__init__.py +0 -26
- {flashmd-0.2.7 → flashmd-0.2.8}/LICENSE +0 -0
- {flashmd-0.2.7 → flashmd-0.2.8}/setup.cfg +0 -0
- {flashmd-0.2.7 → flashmd-0.2.8}/src/flashmd/ase/bussi.py +0 -0
- {flashmd-0.2.7 → flashmd-0.2.8}/src/flashmd/ase/langevin.py +0 -0
- {flashmd-0.2.7 → flashmd-0.2.8}/src/flashmd/ase/velocity_verlet.py +0 -0
- {flashmd-0.2.7 → flashmd-0.2.8}/src/flashmd/ipi.py +0 -0
- {flashmd-0.2.7 → flashmd-0.2.8}/src/flashmd/models.py +0 -0
- {flashmd-0.2.7 → flashmd-0.2.8}/src/flashmd.egg-info/dependency_links.txt +0 -0
- {flashmd-0.2.7 → flashmd-0.2.8}/src/flashmd.egg-info/top_level.txt +0 -0
- {flashmd-0.2.7 → flashmd-0.2.8}/tests/test_energy.py +0 -0
- {flashmd-0.2.7 → flashmd-0.2.8}/tests/test_models.py +0 -0
- {flashmd-0.2.7 → flashmd-0.2.8}/tests/test_readme.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: flashmd
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.8
|
|
4
4
|
Summary: Accelerated molecular dynamics with large-time-step predictions
|
|
5
5
|
Author: flashmd developers
|
|
6
6
|
License: Apache-2.0
|
|
@@ -19,10 +19,10 @@ Classifier: Topic :: Scientific/Engineering :: Chemistry
|
|
|
19
19
|
Classifier: Topic :: Scientific/Engineering :: Physics
|
|
20
20
|
Classifier: Topic :: Software Development :: Libraries
|
|
21
21
|
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
22
|
-
Requires-Python: >=3.
|
|
22
|
+
Requires-Python: >=3.10
|
|
23
23
|
Description-Content-Type: text/markdown
|
|
24
24
|
License-File: LICENSE
|
|
25
|
-
Requires-Dist: metatrain==2026.
|
|
25
|
+
Requires-Dist: metatrain==2026.2
|
|
26
26
|
Requires-Dist: ase
|
|
27
27
|
Requires-Dist: huggingface_hub
|
|
28
28
|
Provides-Extra: dev
|
|
@@ -141,10 +141,13 @@ new to FlashMD, we recommend starting with the ``pet-omatpes-v2`` models.
|
|
|
141
141
|
Training/fine-tuning your own FlashMD models
|
|
142
142
|
--------------------------------------------
|
|
143
143
|
|
|
144
|
-
FlashMD models can be trained from the metatrain library
|
|
144
|
+
FlashMD models can be trained from the **metatrain library**. This
|
|
145
145
|
[tutorial](https://docs.metatensor.org/metatrain/latest/generated_examples/1-advanced/04-flashmd.html)
|
|
146
146
|
shows how to train your own FlashMD model, either from scratch or by fine-tuning of one of our universal models.
|
|
147
147
|
|
|
148
|
+
The trajectory datasets generated with the PET-MAD baseline MLIPs used in the paper can be found in [this
|
|
149
|
+
repository](https://zenodo.org/records/17904449).
|
|
150
|
+
|
|
148
151
|
Disclaimer
|
|
149
152
|
----------
|
|
150
153
|
|
|
@@ -156,6 +159,11 @@ parts of the simulated system. For the time being, we also recommend checking al
|
|
|
156
159
|
FlashMD-powered findings with traditional MD. The energy models that were used to train
|
|
157
160
|
FlashMD, and that we make available in this repository, can be used for this purpose.
|
|
158
161
|
|
|
162
|
+
#### More energy models
|
|
163
|
+
|
|
164
|
+
Do you want to try out different energy models (MLIPs),
|
|
165
|
+
trained on different levels of theory and/or with different accuracy-speed tradeoffs? Check
|
|
166
|
+
out the **[UPET](https://github.com/lab-cosmo/upet) repository.**
|
|
159
167
|
|
|
160
168
|
Publication
|
|
161
169
|
-----------
|
|
@@ -108,10 +108,13 @@ new to FlashMD, we recommend starting with the ``pet-omatpes-v2`` models.
|
|
|
108
108
|
Training/fine-tuning your own FlashMD models
|
|
109
109
|
--------------------------------------------
|
|
110
110
|
|
|
111
|
-
FlashMD models can be trained from the metatrain library
|
|
111
|
+
FlashMD models can be trained from the **metatrain library**. This
|
|
112
112
|
[tutorial](https://docs.metatensor.org/metatrain/latest/generated_examples/1-advanced/04-flashmd.html)
|
|
113
113
|
shows how to train your own FlashMD model, either from scratch or by fine-tuning of one of our universal models.
|
|
114
114
|
|
|
115
|
+
The trajectory datasets generated with the PET-MAD baseline MLIPs used in the paper can be found in [this
|
|
116
|
+
repository](https://zenodo.org/records/17904449).
|
|
117
|
+
|
|
115
118
|
Disclaimer
|
|
116
119
|
----------
|
|
117
120
|
|
|
@@ -123,6 +126,11 @@ parts of the simulated system. For the time being, we also recommend checking al
|
|
|
123
126
|
FlashMD-powered findings with traditional MD. The energy models that were used to train
|
|
124
127
|
FlashMD, and that we make available in this repository, can be used for this purpose.
|
|
125
128
|
|
|
129
|
+
#### More energy models
|
|
130
|
+
|
|
131
|
+
Do you want to try out different energy models (MLIPs),
|
|
132
|
+
trained on different levels of theory and/or with different accuracy-speed tradeoffs? Check
|
|
133
|
+
out the **[UPET](https://github.com/lab-cosmo/upet) repository.**
|
|
126
134
|
|
|
127
135
|
Publication
|
|
128
136
|
-----------
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "flashmd"
|
|
3
|
-
version = "0.2.
|
|
4
|
-
requires-python = ">=3.
|
|
3
|
+
version = "0.2.8"
|
|
4
|
+
requires-python = ">=3.10"
|
|
5
5
|
|
|
6
6
|
readme = "README.md"
|
|
7
7
|
license = {text = "Apache-2.0"}
|
|
@@ -9,7 +9,7 @@ description = "Accelerated molecular dynamics with large-time-step predictions"
|
|
|
9
9
|
authors = [{name = "flashmd developers"}]
|
|
10
10
|
|
|
11
11
|
dependencies = [
|
|
12
|
-
"metatrain==2026.
|
|
12
|
+
"metatrain==2026.2",
|
|
13
13
|
"ase",
|
|
14
14
|
"huggingface_hub",
|
|
15
15
|
]
|
|
@@ -74,10 +74,9 @@ ignore_missing_imports = true
|
|
|
74
74
|
disable_error_code = ["union-attr"]
|
|
75
75
|
|
|
76
76
|
[tool.pytest.ini_options]
|
|
77
|
-
markers = [
|
|
78
|
-
"slow: marks tests as slow (deselect with '-m \"not slow\"')",
|
|
79
|
-
]
|
|
80
77
|
filterwarnings = [
|
|
81
78
|
"error",
|
|
82
79
|
"ignore:custom data:UserWarning",
|
|
80
|
+
"ignore:`torch.jit.script` is deprecated:DeprecationWarning",
|
|
81
|
+
"ignore:`torch.jit.load` is deprecated:DeprecationWarning",
|
|
83
82
|
]
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import warnings
|
|
2
|
+
|
|
3
|
+
import torch
|
|
4
|
+
|
|
5
|
+
from .models import get_pretrained as get_pretrained
|
|
6
|
+
from .models import save_checkpoint as save_checkpoint
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
warnings.filterwarnings("ignore", category=UserWarning, message="custom data")
|
|
10
|
+
warnings.filterwarnings(
|
|
11
|
+
"ignore", category=DeprecationWarning, message="`torch.jit.script`"
|
|
12
|
+
)
|
|
13
|
+
warnings.filterwarnings(
|
|
14
|
+
"ignore", category=DeprecationWarning, message="`torch.jit.load`"
|
|
15
|
+
)
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
# Disable static fusion. Besides the fact that atomistic batches have variable
|
|
19
|
+
# sizes, statically fused CUDA kernels cannot allocate new tensors at runtime,
|
|
20
|
+
# causing "Global alloc not supported yet" errors (cuda 13+) at the time of writing
|
|
21
|
+
torch.jit.set_fusion_strategy([("DYNAMIC", 10)])
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
from metatomic.torch.ase_calculator import MetatomicCalculator
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
class EnergyCalculator(MetatomicCalculator):
|
|
5
|
+
"""
|
|
6
|
+
ASE calculator for energy predictions using a metatomic AtomisticModel.
|
|
7
|
+
|
|
8
|
+
Slightly modified to ensure compatibility with ase.io.Trajectory, otherwise
|
|
9
|
+
completely equivalent to `metatomic.torch.ase_calculator.MetatomicCalculator`.
|
|
10
|
+
"""
|
|
11
|
+
|
|
12
|
+
def todict(self):
|
|
13
|
+
return {"name": "flashmd.ase.EnergyCalculator"}
|
|
@@ -27,20 +27,29 @@ def enforce_physical_constraints(
|
|
|
27
27
|
total_masses = [m.sum() for m in masses]
|
|
28
28
|
momenta_before = [s.get_data("momenta").block().values for s in systems]
|
|
29
29
|
momenta_now = torch.split(prediction_tmap.block().values, system_sizes)
|
|
30
|
-
velocities_now = [
|
|
30
|
+
velocities_now = [
|
|
31
|
+
p / m[:, None] for p, m in zip(momenta_now, masses, strict=True)
|
|
32
|
+
]
|
|
31
33
|
velocities_com_before = [
|
|
32
|
-
torch.sum(p, dim=0) / M
|
|
34
|
+
torch.sum(p, dim=0) / M
|
|
35
|
+
for p, M in zip(momenta_before, total_masses, strict=True)
|
|
33
36
|
]
|
|
34
37
|
velocities_com_now = [
|
|
35
|
-
torch.sum(p, dim=0) / M
|
|
38
|
+
torch.sum(p, dim=0) / M
|
|
39
|
+
for p, M in zip(momenta_now, total_masses, strict=True)
|
|
36
40
|
]
|
|
37
41
|
velocities_now = [
|
|
38
42
|
v - v_com_now_i + v_com_before_i
|
|
39
43
|
for v, v_com_before_i, v_com_now_i in zip(
|
|
40
|
-
velocities_now,
|
|
44
|
+
velocities_now,
|
|
45
|
+
velocities_com_before,
|
|
46
|
+
velocities_com_now,
|
|
47
|
+
strict=True,
|
|
41
48
|
)
|
|
42
49
|
]
|
|
43
|
-
momenta_now = [
|
|
50
|
+
momenta_now = [
|
|
51
|
+
v * m[:, None] for v, m in zip(velocities_now, masses, strict=True)
|
|
52
|
+
]
|
|
44
53
|
new_predictions[key] = TensorMap(
|
|
45
54
|
prediction_tmap.keys,
|
|
46
55
|
[
|
|
@@ -61,15 +70,16 @@ def enforce_physical_constraints(
|
|
|
61
70
|
momenta = [s.get_data("momenta").block().values for s in systems]
|
|
62
71
|
positions_now = torch.split(prediction_tmap.block().values, system_sizes)
|
|
63
72
|
velocities_com = [
|
|
64
|
-
torch.sum(p, dim=0) / M
|
|
73
|
+
torch.sum(p, dim=0) / M
|
|
74
|
+
for p, M in zip(momenta, total_masses, strict=True)
|
|
65
75
|
]
|
|
66
76
|
positions_com_before = [
|
|
67
77
|
torch.sum(q * m[:, None], dim=0) / M
|
|
68
|
-
for q, m, M in zip(positions_before, masses, total_masses)
|
|
78
|
+
for q, m, M in zip(positions_before, masses, total_masses, strict=True)
|
|
69
79
|
]
|
|
70
80
|
positions_com_now = [
|
|
71
81
|
torch.sum(q * m[:, None], dim=0) / M
|
|
72
|
-
for q, m, M in zip(positions_now, masses, total_masses)
|
|
82
|
+
for q, m, M in zip(positions_now, masses, total_masses, strict=True)
|
|
73
83
|
]
|
|
74
84
|
positions_now = [
|
|
75
85
|
q - q_com_now_i + q_com_before_i + v_com_i * timestep
|
|
@@ -78,6 +88,7 @@ def enforce_physical_constraints(
|
|
|
78
88
|
positions_com_now,
|
|
79
89
|
positions_com_before,
|
|
80
90
|
velocities_com,
|
|
91
|
+
strict=True,
|
|
81
92
|
)
|
|
82
93
|
]
|
|
83
94
|
new_predictions[key] = TensorMap(
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
# from ..utils.pretrained import load_pretrained_models
|
|
2
2
|
import ase.units
|
|
3
3
|
import torch
|
|
4
|
+
import vesin.metatomic
|
|
4
5
|
from metatensor.torch import Labels, TensorBlock, TensorMap
|
|
5
6
|
from metatomic.torch import AtomisticModel, ModelEvaluationOptions, ModelOutput, System
|
|
6
|
-
from metatrain.utils.neighbor_lists import get_system_with_neighbor_lists
|
|
7
7
|
|
|
8
8
|
from .constraints import enforce_physical_constraints
|
|
9
9
|
|
|
@@ -35,9 +35,7 @@ class FlashMDStepper:
|
|
|
35
35
|
if system.positions.dtype != self.dtype:
|
|
36
36
|
raise ValueError("System dtype does not match stepper dtype.")
|
|
37
37
|
|
|
38
|
-
system
|
|
39
|
-
system, self.model.requested_neighbor_lists()
|
|
40
|
-
)
|
|
38
|
+
vesin.metatomic.compute_requested_neighbors([system], "angstrom", self.model)
|
|
41
39
|
|
|
42
40
|
masses = system.get_data("masses").block().values
|
|
43
41
|
model_outputs = self.model(
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: flashmd
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.8
|
|
4
4
|
Summary: Accelerated molecular dynamics with large-time-step predictions
|
|
5
5
|
Author: flashmd developers
|
|
6
6
|
License: Apache-2.0
|
|
@@ -19,10 +19,10 @@ Classifier: Topic :: Scientific/Engineering :: Chemistry
|
|
|
19
19
|
Classifier: Topic :: Scientific/Engineering :: Physics
|
|
20
20
|
Classifier: Topic :: Software Development :: Libraries
|
|
21
21
|
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
22
|
-
Requires-Python: >=3.
|
|
22
|
+
Requires-Python: >=3.10
|
|
23
23
|
Description-Content-Type: text/markdown
|
|
24
24
|
License-File: LICENSE
|
|
25
|
-
Requires-Dist: metatrain==2026.
|
|
25
|
+
Requires-Dist: metatrain==2026.2
|
|
26
26
|
Requires-Dist: ase
|
|
27
27
|
Requires-Dist: huggingface_hub
|
|
28
28
|
Provides-Extra: dev
|
|
@@ -141,10 +141,13 @@ new to FlashMD, we recommend starting with the ``pet-omatpes-v2`` models.
|
|
|
141
141
|
Training/fine-tuning your own FlashMD models
|
|
142
142
|
--------------------------------------------
|
|
143
143
|
|
|
144
|
-
FlashMD models can be trained from the metatrain library
|
|
144
|
+
FlashMD models can be trained from the **metatrain library**. This
|
|
145
145
|
[tutorial](https://docs.metatensor.org/metatrain/latest/generated_examples/1-advanced/04-flashmd.html)
|
|
146
146
|
shows how to train your own FlashMD model, either from scratch or by fine-tuning of one of our universal models.
|
|
147
147
|
|
|
148
|
+
The trajectory datasets generated with the PET-MAD baseline MLIPs used in the paper can be found in [this
|
|
149
|
+
repository](https://zenodo.org/records/17904449).
|
|
150
|
+
|
|
148
151
|
Disclaimer
|
|
149
152
|
----------
|
|
150
153
|
|
|
@@ -156,6 +159,11 @@ parts of the simulated system. For the time being, we also recommend checking al
|
|
|
156
159
|
FlashMD-powered findings with traditional MD. The energy models that were used to train
|
|
157
160
|
FlashMD, and that we make available in this repository, can be used for this purpose.
|
|
158
161
|
|
|
162
|
+
#### More energy models
|
|
163
|
+
|
|
164
|
+
Do you want to try out different energy models (MLIPs),
|
|
165
|
+
trained on different levels of theory and/or with different accuracy-speed tradeoffs? Check
|
|
166
|
+
out the **[UPET](https://github.com/lab-cosmo/upet) repository.**
|
|
159
167
|
|
|
160
168
|
Publication
|
|
161
169
|
-----------
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import ase.build
|
|
2
|
+
import ase.units
|
|
3
|
+
import torch
|
|
4
|
+
from ase.md.velocitydistribution import MaxwellBoltzmannDistribution
|
|
5
|
+
|
|
6
|
+
from flashmd import get_pretrained
|
|
7
|
+
from flashmd.ase import EnergyCalculator
|
|
8
|
+
from flashmd.ase.velocity_verlet import VelocityVerlet
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
def test_isolated_atom(monkeypatch, tmp_path):
|
|
12
|
+
"""Test that a short MD run completes without errors on an isolated atom."""
|
|
13
|
+
monkeypatch.chdir(tmp_path)
|
|
14
|
+
|
|
15
|
+
atoms = ase.Atoms("O", positions=[[0, 0, 0]])
|
|
16
|
+
MaxwellBoltzmannDistribution(atoms, temperature_K=300)
|
|
17
|
+
|
|
18
|
+
time_step = 8
|
|
19
|
+
device = "cuda" if torch.cuda.is_available() else "cpu"
|
|
20
|
+
energy_model, flashmd_model = get_pretrained("pet-omatpes-v2", time_step)
|
|
21
|
+
calculator = EnergyCalculator(energy_model, device=device)
|
|
22
|
+
atoms.calc = calculator
|
|
23
|
+
|
|
24
|
+
dyn = VelocityVerlet(
|
|
25
|
+
atoms=atoms,
|
|
26
|
+
timestep=time_step * ase.units.fs,
|
|
27
|
+
model=flashmd_model,
|
|
28
|
+
device=device,
|
|
29
|
+
)
|
|
30
|
+
dyn.run(10)
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
def test_slab_plus_isolated_atom(monkeypatch, tmp_path):
|
|
34
|
+
"""Test that a short MD run completes without errors on a slab plus an isolated atom."""
|
|
35
|
+
monkeypatch.chdir(tmp_path)
|
|
36
|
+
|
|
37
|
+
# Create a slab and an isolated atom
|
|
38
|
+
slab = ase.build.fcc111("Al", size=(2, 2, 3), vacuum=10)
|
|
39
|
+
isolated_atom = ase.Atoms("O", positions=[[0, 0, 24]])
|
|
40
|
+
atoms = slab + isolated_atom
|
|
41
|
+
MaxwellBoltzmannDistribution(atoms, temperature_K=300)
|
|
42
|
+
|
|
43
|
+
time_step = 8
|
|
44
|
+
device = "cuda" if torch.cuda.is_available() else "cpu"
|
|
45
|
+
energy_model, flashmd_model = get_pretrained("pet-omatpes-v2", time_step)
|
|
46
|
+
calculator = EnergyCalculator(energy_model, device=device)
|
|
47
|
+
atoms.calc = calculator
|
|
48
|
+
|
|
49
|
+
dyn = VelocityVerlet(
|
|
50
|
+
atoms=atoms,
|
|
51
|
+
timestep=time_step * ase.units.fs,
|
|
52
|
+
model=flashmd_model,
|
|
53
|
+
device=device,
|
|
54
|
+
)
|
|
55
|
+
dyn.run(10)
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import tempfile
|
|
2
|
-
|
|
3
|
-
from metatomic.torch import AtomisticModel
|
|
4
|
-
from metatomic.torch.ase_calculator import MetatomicCalculator
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
class EnergyCalculator(MetatomicCalculator):
|
|
8
|
-
"""
|
|
9
|
-
ASE calculator for energy predictions using a metatomic AtomisticModel.
|
|
10
|
-
|
|
11
|
-
Slightly modified to save the model to a temporary file to ensure compatibility
|
|
12
|
-
with ase.io.Trajectory.
|
|
13
|
-
"""
|
|
14
|
-
|
|
15
|
-
def __init__(self, model, *args, **kwargs):
|
|
16
|
-
# save the model to a path otherwise it won't work with ase.io.Trajectory
|
|
17
|
-
# which calls todict on the calculator
|
|
18
|
-
|
|
19
|
-
if isinstance(model, AtomisticModel):
|
|
20
|
-
with tempfile.NamedTemporaryFile(delete=False, suffix=".pt") as f:
|
|
21
|
-
path = f.name
|
|
22
|
-
model.save(path)
|
|
23
|
-
else:
|
|
24
|
-
path = model
|
|
25
|
-
|
|
26
|
-
super().__init__(path, *args, **kwargs)
|
|
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
|