Skip to content

Commit fe657b4

Browse files
authored
Merge pull request #170 from JaGeo/fix_order_forces_error
Fix born error in phonon workflow
2 parents 4bde8c3 + 6f72247 commit fe657b4

File tree

176 files changed

+687
-12
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

176 files changed

+687
-12
lines changed

src/atomate2/vasp/flows/phonons.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -167,9 +167,6 @@ def make(
167167
these values can also be provided manually.
168168
if born, epsilon_static are provided, the born
169169
run will be skipped
170-
this matrix can be provided in the phonopy convention
171-
with born charges for symmetrically
172-
inequivalent atoms only or
173170
it can be provided in the VASP convention with information for
174171
every atom in unit cell. Please be careful when converting
175172
structures within in this workflow as this could lead to errors

src/atomate2/vasp/jobs/phonons.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,7 @@ def run_phonon_displacements(
287287
"forces": [],
288288
"uuids": [],
289289
"dirs": [],
290+
"displaced_structures": [],
290291
}
291292

292293
for i, displacement in enumerate(displacements):
@@ -298,6 +299,7 @@ def run_phonon_displacements(
298299
"displacement_number": i,
299300
"original_structure": structure,
300301
"supercell_matrix": supercell_matrix,
302+
"displaced_structure": displacement,
301303
}
302304
phonon_job.update_maker_kwargs(
303305
{"_set": {"write_additional_data->phonon_info:json": info}}, dict_mod=True
@@ -307,6 +309,7 @@ def run_phonon_displacements(
307309
outputs["uuids"].append(phonon_job.output.uuid)
308310
outputs["dirs"].append(phonon_job.output.dir_name)
309311
outputs["forces"].append(phonon_job.output.output.forces)
312+
outputs["displaced_structures"].append(displacement)
310313

311314
displacement_flow = Flow(phonon_jobs, outputs)
312315
return Response(replace=displacement_flow)

src/atomate2/vasp/schemas/phonons.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import numpy as np
66
from phonopy import Phonopy
77
from phonopy.phonon.band_structure import get_band_qpoints_and_path_connections
8-
from phonopy.structure.symmetry import elaborate_borns_and_epsilon
8+
from phonopy.structure.symmetry import symmetrize_borns_and_epsilon
99
from phonopy.units import VaspToTHz
1010
from pydantic import BaseModel, Field
1111
from pymatgen.core import Structure
@@ -258,17 +258,19 @@ def from_forces_born(
258258

259259
if born is not None and epsilon_static is not None:
260260
if len(structure) == len(born):
261-
borns, epsilon, atom_indices = elaborate_borns_and_epsilon(
262-
ucell=get_phonopy_structure(structure),
261+
borns, epsilon = symmetrize_borns_and_epsilon(
262+
ucell=phonon.unitcell,
263263
borns=np.array(born),
264264
epsilon=np.array(epsilon_static),
265265
symprec=symprec,
266266
primitive_matrix=phonon.primitive_matrix,
267267
supercell_matrix=phonon.supercell_matrix,
268+
is_symmetry=kwargs.get("symmetrize_born", True),
268269
)
269270
else:
270-
borns = np.array(born)
271-
epsilon = np.array(epsilon_static)
271+
raise ValueError(
272+
"Number of born charges does not agree with number of atoms"
273+
)
272274
if code == "vasp":
273275
if not np.all(np.isclose(borns, 0.0)):
274276
phonon.nac_params = {
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
ALGO = Fast
2+
EDIFF = 1e-05
3+
EDIFFG = -0.02
4+
ENAUG = 1360
5+
ENCUT = 680
6+
GGA = Ps
7+
IBRION = 8
8+
ISIF = 3
9+
ISMEAR = -5
10+
ISPIN = 2
11+
KSPACING = 0.22
12+
LAECHG = True
13+
LASPH = True
14+
LCHARG = True
15+
LELF = False
16+
LEPSILON = True
17+
LMAXMIX = 4
18+
LMIXTAU = True
19+
LORBIT = 11
20+
LPEAD = True
21+
LREAL = False
22+
LVTOT = True
23+
LWAVE = False
24+
MAGMOM = 5*0.6
25+
NELM = 200
26+
NSW = 1
27+
PREC = Accurate
28+
SIGMA = 0.2
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
Mg3 Sb2
2+
1.0
3+
2.3003714889113014 -3.9843602950772401 0.0000000000000000
4+
2.3003714889113014 3.9843602950772401 0.0000000000000000
5+
0.0000000000000000 0.0000000000000000 7.2813299999999996
6+
Mg Sb
7+
3 2
8+
direct
9+
0.0000000000000000 0.0000000000000000 0.0000000000000000 Mg
10+
0.3333333333333333 0.6666666666666666 0.3683249999999999 Mg
11+
0.6666666666666667 0.3333333333333334 0.6316750000000001 Mg
12+
0.3333333333333333 0.6666666666666666 0.7747489999999999 Sb
13+
0.6666666666666667 0.3333333333333334 0.2252510000000001 Sb
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Mg
2+
Sb
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

0 commit comments

Comments
 (0)