Skip to content

Commit 0debc49

Browse files
Add NEB (#393)
* Refactor setting minimize_kwargs * Add NEB calculation * Add interpolation options * Add NEB CLI * Write NEB results * Fix reading NEB band * Fix NEB band structures input * Fix NEB band structures input * Fix NEB CLI * Catch pymatgen error * Update docs * Add steps option for NEB * Fix docstrings * Update docs for NEB * Log choice of interpolator * Rename parameter for wrting band * Add tests for NEB * Add NEB CLI command to README * Use default neb_kwargs * Tidy setting interpolator and docstrings * Fix read_kwargs docstrings
1 parent 485084e commit 0debc49

File tree

20 files changed

+2747
-24
lines changed

20 files changed

+2747
-24
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ Current and planned features include:
104104
- NVE
105105
- NVT (Langevin(Eijnden/Ciccotti flavour) and Nosé-Hoover (Melchionna flavour))
106106
- NPT (Nosé-Hoover (Melchiona flavour))
107-
- [ ] Nudge Elastic Band
107+
- [x] Nudge Elastic Band
108108
- [x] Phonons
109109
- Phonopy
110110
- [x] Equation of State
@@ -210,6 +210,7 @@ janus geomopt
210210
janus md
211211
janus phonons
212212
janus eos
213+
janus neb
213214
janus train
214215
janus descriptors
215216
janus preprocess

docs/source/apidoc/janus_core.rst

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,17 @@ janus\_core.calculations.md module
6565
:undoc-members:
6666
:show-inheritance:
6767

68+
janus\_core.calculations.neb module
69+
-----------------------------------
70+
71+
.. automodule:: janus_core.calculations.neb
72+
:members:
73+
:special-members:
74+
:private-members:
75+
:inherited-members:
76+
:undoc-members:
77+
:show-inheritance:
78+
6879
janus\_core.calculations.phonons module
6980
---------------------------------------
7081

@@ -136,6 +147,16 @@ janus\_core.cli.md module
136147
:undoc-members:
137148
:show-inheritance:
138149

150+
janus\_core.cli.neb module
151+
--------------------------
152+
153+
.. automodule:: janus_core.cli.neb
154+
:members:
155+
:special-members:
156+
:private-members:
157+
:undoc-members:
158+
:show-inheritance:
159+
139160
janus\_core.cli.phonons module
140161
------------------------------
141162

docs/source/conf.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454
"phonopy": ("https://phonopy.github.io/phonopy/", None),
5555
"codecarbon": ("https://mlco2.github.io/codecarbon/", None),
5656
"torch": ("https://pytorch.org/docs/stable", None),
57+
"matplotlib": ("https://matplotlib.org/stable/", None,)
5758
}
5859

5960
# Add any paths that contain templates here, relative to this directory.
@@ -225,4 +226,5 @@
225226
("py:class", "Calculator"),
226227
("py:class", "Context"),
227228
("py:class", "Path"),
229+
("py:class", "Figure"),
228230
]

docs/source/user_guide/command_line.rst

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ This should return something similar to:
3131
eos Calculate equation of state.
3232
geomopt Perform geometry optimization and save optimized structure...
3333
md Run molecular dynamics simulation, and save trajectory and...
34+
neb Run Nudged Elastic Band method.
3435
phonons Calculate phonons and save results.
3536
singlepoint Perform single point calculations and save to file.
3637
train Running training for an MLIP.
@@ -483,6 +484,36 @@ with 101 sampling points for each path segment.
483484
:align: center
484485

485486

487+
Nudged Elastic Band
488+
-------------------
489+
490+
Run the Nudged Elastic Band method (using the `MACE-MP <https://github.com/ACEsuit/mace-mp>`_ "small" force-field):
491+
492+
.. code-block:: bash
493+
494+
janus neb --init-struct tests/data/N2.xyz --final-struct tests/data/2N.xyz --minimize
495+
496+
497+
This will use ASE's built-in `interpolation <https://wiki.fysik.dtu.dk/ase/ase/neb.html#interpolation>`_
498+
between the minimized initial and final structures, before applying ASE's ``NEBOptimizer``, an adaptive ODE solver,
499+
to the NEB.
500+
501+
This will save the energy barrier, delta E of the elementary reaction, and maximum force, to a results file, ``N2-neb-results.dat``,
502+
in addition to generating a log file, ``N2-neb-log.yml``, and summary of inputs, ``N2-neb-summary.yml``.
503+
504+
If a band has already been generated, such as by adding the ``--write-images`` option to the above command,
505+
this can be passed instead of the initial and final structures:
506+
507+
.. code-block:: bash
508+
509+
janus neb --band-structs tests/data/N2-neb-images.xyz
510+
511+
512+
Additional options include using `pymatgen to interpolate <https://pymatgen.org/pymatgen.core.html#pymatgen.core.structure.IStructure.interpolate>`_,
513+
with the ``--interpolator`` option, using `DyNEB <https://wiki.fysik.dtu.dk/ase/ase/neb.html#ase.mep.dyneb.DyNEB>`_ for scaled and dynamic
514+
optimizations of images through the ``--neb-method`` option, and changing the optimizer using the ``--neb-optimizer`` option.
515+
516+
486517
Training and fine-tuning MLIPs
487518
------------------------------
488519

janus_core/calculations/eos.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
PathLike,
2323
)
2424
from janus_core.helpers.struct_io import output_structs
25-
from janus_core.helpers.utils import none_to_dict
25+
from janus_core.helpers.utils import none_to_dict, set_minimize_logging
2626

2727

2828
class EoS(BaseCalculation):
@@ -257,12 +257,9 @@ def __init__(
257257
raise ValueError("Please attach a calculator to `struct`.")
258258

259259
if self.minimize and self.logger:
260-
self.minimize_kwargs["log_kwargs"] = {
261-
"filename": self.log_kwargs["filename"],
262-
"name": self.logger.name,
263-
"filemode": "a",
264-
}
265-
self.minimize_kwargs["track_carbon"] = self.track_carbon
260+
set_minimize_logging(
261+
self.logger, self.minimize_kwargs, self.log_kwargs, track_carbon
262+
)
266263

267264
# Set output files
268265
self.write_kwargs.setdefault("filename", None)

janus_core/calculations/md.py

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
PostProcessKwargs,
4444
)
4545
from janus_core.helpers.struct_io import input_structs, output_structs
46-
from janus_core.helpers.utils import none_to_dict, write_table
46+
from janus_core.helpers.utils import none_to_dict, set_minimize_logging, write_table
4747
from janus_core.processing.correlator import Correlation
4848
from janus_core.processing.post_process import compute_rdf, compute_vaf
4949

@@ -493,13 +493,9 @@ def __init__(
493493
self.minimize_kwargs["write_kwargs"] = {"filename": opt_file}
494494

495495
# Use MD logger for geometry optimization
496-
if self.logger:
497-
self.minimize_kwargs["log_kwargs"] = {
498-
"filename": self.log_kwargs["filename"],
499-
"name": self.logger.name,
500-
"filemode": "a",
501-
}
502-
self.minimize_kwargs["track_carbon"] = self.track_carbon
496+
set_minimize_logging(
497+
self.logger, self.minimize_kwargs, self.log_kwargs, track_carbon
498+
)
503499

504500
self.dyn: Langevin | VelocityVerlet | ASE_NPT
505501
self.n_atoms = len(self.struct)

0 commit comments

Comments
 (0)