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
Molecular dynamics job #134
Changes from 3 commits
bbe9b26
a44480d
4a677f5
ff79d52
b4352a4
b552ca3
37e469c
d5b7a1f
6edfdaa
47a2101
cf6ece7
7b02f67
6883d97
57e164e
e9fa8ab
e87b1b5
62abb2b
31ee4df
1e5d5ef
53da989
675034f
d32fe25
7538108
6467e6c
ac2a0dc
5bd060c
0e0308e
ff083e8
48686be
c42cf11
137af78
b7f4e89
84fa505
00d7dbd
6bc888d
b9709c0
b2a6c5d
0288471
8adf37c
02accd2
07df203
bde7f1c
b9b8754
37becfb
5c3d39c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -6,6 +6,7 @@ | |||||
|
||||||
import numpy as np | ||||||
from pymatgen.core import Structure | ||||||
from pymatgen.core.periodic_table import Element | ||||||
from pymatgen.io.vasp import Outcar, Vasprun | ||||||
|
||||||
from atomate2.common.schemas.math import Vector3D | ||||||
|
@@ -21,6 +22,7 @@ | |||||
"HSEBSSetGenerator", | ||||||
"HSETightRelaxSetGenerator", | ||||||
"ElectronPhononSetGenerator", | ||||||
"MDSetGenerator", | ||||||
] | ||||||
|
||||||
|
||||||
|
@@ -775,6 +777,86 @@ def get_kpoints_updates( | |||||
return {"reciprocal_density": self.reciprocal_density} | ||||||
|
||||||
|
||||||
@dataclass | ||||||
class MDSetGenerator(VaspInputSetGenerator): | ||||||
"""Class to generate VASP molecular dynamics input sets.""" | ||||||
|
||||||
def get_incar_updates( | ||||||
self, | ||||||
structure: Structure, | ||||||
prev_incar: dict = None, | ||||||
bandgap: float = 0, | ||||||
vasprun: Vasprun = None, | ||||||
outcar: Outcar = None, | ||||||
) -> dict: | ||||||
""" | ||||||
Get updates to the INCAR for a molecular dynamics job. | ||||||
|
||||||
Parameters | ||||||
---------- | ||||||
structure | ||||||
A structure. | ||||||
prev_incar | ||||||
An incar from a previous calculation. | ||||||
bandgap | ||||||
The band gap. | ||||||
vasprun | ||||||
A vasprun from a previous calculation. | ||||||
outcar | ||||||
An outcar from a previous calculation. | ||||||
|
||||||
Returns | ||||||
------- | ||||||
dict | ||||||
A dictionary of updates to apply. | ||||||
""" | ||||||
# TODO is is copied and changed based on pymatgen.io.vasp.sets.MPMDSet, | ||||||
# dobule check and discuss with others | ||||||
updates = { | ||||||
# expect to be changed by user | ||||||
"NSW": 1000, | ||||||
"ISIF": 0, | ||||||
"MDALGO": 0, | ||||||
"SMASS": 0, | ||||||
"TEBEG": 300, | ||||||
"TEEND": 300, | ||||||
"POTIM": 2, | ||||||
# exepct to be fixed | ||||||
"PREC": "Normal", | ||||||
"IBRION": 0, | ||||||
"LREAL": "Auto", | ||||||
"NELM": 500, | ||||||
"NELMIN": 4, | ||||||
"ISYM": 0, | ||||||
"NBLOCK": 1, | ||||||
"KBLOCK": 100, | ||||||
"LSCALU": False, | ||||||
"LCHARG": False, | ||||||
"LPLANE": False, | ||||||
"LWAVE": True, | ||||||
"LDAU": False, | ||||||
# "ISMEAR": 0, | ||||||
# "EDIFF_PER_ATOM": 0.00001, # TODO deprecated? | ||||||
# "MAXMIX": 20, | ||||||
# "BMIX": 1, | ||||||
# "NSIM": 4, | ||||||
# "ADDGRID": True, | ||||||
} | ||||||
|
||||||
# use VASP default ENCUT | ||||||
update["ENCUT"] = None | ||||||
|
||||||
if defaults["ISPIN"] == 1: | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not sure what defaults is here? Instead of this, you might want to set atomate2/src/atomate2/vasp/sets/base.py Line 257 in 6445c2b
And this is an example of where I've turned it on: atomate2/src/atomate2/vasp/sets/core.py Line 528 in 6445c2b
|
||||||
update["MAGMOM"] = None | ||||||
|
||||||
# smaller steps for H containing structrue | ||||||
if Element("H") in structure.species: | ||||||
updates["POTIM"] = 0.5 | ||||||
# updates["NSW"] = defaults["NSW"] * 4 # TODO not a big deal | ||||||
|
||||||
return updates | ||||||
|
||||||
|
||||||
def _get_nedos(vasprun: Optional[Vasprun], dedos: float): | ||||||
"""Automatic setting of nedos using the energy range and the energy step.""" | ||||||
if vasprun is None: | ||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
ALGO = Normal | ||
EDIFF = 1e-07 | ||
EDIFFG = -0.001 | ||
ENAUG = 1360.0 | ||
IBRION = 0 | ||
ISIF = 2 | ||
ISMEAR = -5 | ||
ISPIN = 2 | ||
KSPACING = 0.2925287784072645 | ||
LAECHG = False | ||
LASPH = True | ||
LCHARG = True | ||
LELF = True | ||
LMIXTAU = True | ||
LORBIT = 11 | ||
LREAL = False | ||
LVTOT = True | ||
LWAVE = False | ||
MAGMOM = 2*-0.0 | ||
NELM = 200 | ||
NSW = 99 | ||
PREC = Normal | ||
SIGMA = 0.05 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
pymatgen with grid density = 100 / number of atoms | ||
0 | ||
Gamma | ||
3 3 3 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
Si2 | ||
1.0 | ||
0.000000 2.752777 2.752777 | ||
2.725110 0.000000 2.752777 | ||
2.725110 2.752777 0.000000 | ||
Si | ||
2 | ||
direct | ||
0.750000 0.750000 0.750000 Si | ||
0.500000 0.500000 0.500000 Si |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Si |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -193,3 +193,29 @@ def test_transmuter(mock_vasp, clean_dir, si_structure): | |
np.testing.assert_allclose( | ||
output1.structure.lattice.abc, [3.866974, 3.866975, 7.733949] | ||
) | ||
|
||
|
||
def test_md(mock_vasp, clean_dir, si_structure): | ||
from jobflow import run_locally | ||
|
||
from atomate2.vasp.jobs.core import MDMaker | ||
from atomate2.vasp.schemas.task import TaskDocument | ||
|
||
# mapping from job name to directory containing test files | ||
ref_paths = {"molecular dynamics": "Si_md"} | ||
|
||
# settings passed to fake_run_vasp; adjust these to check for certain INCAR settings | ||
fake_run_vasp_kwargs = {"transmuter": {"incar_settings": ["ISMEAR", "NSW"]}} | ||
|
||
# automatically use fake VASP and write POTCAR.spec during the test | ||
mock_vasp(ref_paths, fake_run_vasp_kwargs) | ||
|
||
# generate transmuter job | ||
job = MDMaker( | ||
transformations=["SupercellTransformation"], | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I guess you don't need these options? |
||
transformation_params=[{"scaling_matrix": ((1, 0, 0), (0, 1, 0), (0, 0, 2))}], | ||
).make(si_structure) | ||
job.maker.input_set_generator.user_incar_settings["KSPACING"] = 0.5 | ||
|
||
# run the job and ensure that it finished running successfully | ||
responses = run_locally(job, create_folders=True, ensure_success=True) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please don't put these controls in the job maker, instead put them in the input set generator to be consistent with the other input sets.
Also, I'd advise against exposing the basic incar settings as those are easily overriden using
user_incar_settings
. Instead you could add a several "presets", specified by a string, e.g., "nvt", "npt", "long" or whatever you think is useful