Skip to content

Commit 4bcf127

Browse files
naik-aakashJaGeo
andauthored
Fix bump phonopy (#1006)
* bump phonopy version * Update pyproject.toml * replace bs plotter with pymatgen implementation > reduce code repetition * replace bs plotter with pymatgen implementation > reduce code repetition * switch off grunesien computation at gamma (unstable) * fix assertions to correct expected derived properties * fix failing test (use correct reference data) * remove non used test_data, rename Si_phonons_4 > Si_phonons_3 * point to renamed ref test_data --------- Co-authored-by: J. George <[email protected]>
1 parent 6349766 commit 4bcf127

File tree

94 files changed

+42
-146
lines changed

Some content is hidden

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

94 files changed

+42
-146
lines changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ strict = [
108108
"numpy",
109109
"openmm-mdanalysis-reporter==0.1.0",
110110
"openmm==8.1.1",
111-
"phonopy==2.27.0",
111+
"phonopy==2.30.1",
112112
"pydantic-settings==2.6.1",
113113
"pydantic==2.9.2",
114114
"pymatgen-analysis-defects==2024.10.22",

src/atomate2/common/schemas/gruneisen.py

Lines changed: 11 additions & 94 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,8 @@
44
from pathlib import Path
55
from typing import Optional, Union
66

7-
import matplotlib.pyplot as plt
8-
import numpy as np
97
import phonopy
108
from emmet.core.structure import StructureMetadata
11-
from matplotlib import colors
12-
from matplotlib.colors import LinearSegmentedColormap
139
from phonopy.api_gruneisen import PhonopyGruneisen
1410
from phonopy.phonon.band_structure import get_band_qpoints_and_path_connections
1511
from pydantic import BaseModel, Field
@@ -24,12 +20,7 @@
2420
GruneisenParameter,
2521
GruneisenPhononBandStructureSymmLine,
2622
)
27-
from pymatgen.phonon.plotter import (
28-
GruneisenPhononBSPlotter,
29-
GruneisenPlotter,
30-
freq_units,
31-
)
32-
from pymatgen.util.plotting import pretty_plot
23+
from pymatgen.phonon.plotter import GruneisenPhononBSPlotter, GruneisenPlotter
3324
from typing_extensions import Self
3425

3526
from atomate2.common.schemas.phonons import PhononBSDOSDoc
@@ -164,7 +155,7 @@ def from_phonon_yamls(
164155
mesh=mesh,
165156
shift=compute_gruneisen_param_kwargs.get("shift"),
166157
is_gamma_center=compute_gruneisen_param_kwargs.get(
167-
"is_gamma_center", True
158+
"is_gamma_center", False
168159
),
169160
is_time_reversal=compute_gruneisen_param_kwargs.get(
170161
"is_time_reversal", True
@@ -184,7 +175,7 @@ def from_phonon_yamls(
184175
mesh=kpoint.kpts[0],
185176
shift=compute_gruneisen_param_kwargs.get("shift"),
186177
is_gamma_center=compute_gruneisen_param_kwargs.get(
187-
"is_gamma_center", True
178+
"is_gamma_center", False
188179
),
189180
is_time_reversal=compute_gruneisen_param_kwargs.get(
190181
"is_time_reversal", True
@@ -228,9 +219,14 @@ def from_phonon_yamls(
228219
labels_dict=kpath_dict,
229220
)
230221
gp_bs_plot = GruneisenPhononBSPlotter(bs=gruneisen_band_structure)
231-
GruneisenParameterDocument.get_gruneisen_weighted_bandstructure(
232-
gruneisen_band_symline_plotter=gp_bs_plot,
233-
save_fig=True,
222+
223+
gruneisen_bs_plot = compute_gruneisen_param_kwargs.get(
224+
"gruneisen_bs", "gruneisen_band.pdf"
225+
)
226+
gp_bs_plot.save_plot_gs(
227+
filename=gruneisen_bs_plot,
228+
plot_ph_bs_with_gruneisen=True,
229+
img_format=compute_gruneisen_param_kwargs.get("img_format", "pdf"),
234230
**compute_gruneisen_param_kwargs,
235231
)
236232
gruneisen_parameter_inputs = {
@@ -261,82 +257,3 @@ def from_phonon_yamls(
261257
gruneisen_band_structure=gruneisen_band_structure,
262258
derived_properties=derived_properties,
263259
)
264-
265-
@staticmethod
266-
def get_gruneisen_weighted_bandstructure(
267-
gruneisen_band_symline_plotter: GruneisenPhononBSPlotter,
268-
save_fig: bool = True,
269-
**kwargs,
270-
) -> None:
271-
"""Save a phonon band structure weighted with Grueneisen parameters.
272-
273-
Parameters
274-
----------
275-
gruneisen_band_symline_plotter: GruneisenPhononBSPlotter
276-
pymatgen GruneisenPhononBSPlotter obj
277-
save_fig: bool
278-
bool to save plots
279-
kwargs: dict
280-
keyword arguments to adjust plotter
281-
282-
Returns
283-
-------
284-
None
285-
"""
286-
u = freq_units(kwargs.get("units", "THz"))
287-
ax = pretty_plot(12, 8)
288-
gruneisen_band_symline_plotter._make_ticks(ax) # noqa: SLF001
289-
290-
# plot y=0 line
291-
ax.axhline(0, linewidth=1, color="black")
292-
293-
# Create custom colormap (default is red to blue)
294-
cmap = LinearSegmentedColormap.from_list(
295-
"mycmap", kwargs.get("mycmap", ["red", "blue"])
296-
)
297-
298-
data = gruneisen_band_symline_plotter.bs_plot_data()
299-
300-
# extract min and max Grüneisen parameter values
301-
max_gruneisen = np.array(data["gruneisen"]).max()
302-
min_gruneisen = np.array(data["gruneisen"]).min()
303-
304-
# LogNormalize colormap based on the min and max Grüneisen parameter values
305-
norm = colors.SymLogNorm(
306-
vmin=min_gruneisen,
307-
vmax=max_gruneisen,
308-
linthresh=1e-2,
309-
linscale=1,
310-
)
311-
312-
for (dists_inx, dists), (_, freqs) in zip(
313-
enumerate(data["distances"]), enumerate(data["frequency"]), strict=True
314-
):
315-
for band_idx in range(gruneisen_band_symline_plotter.n_bands):
316-
ys = [freqs[band_idx][j] * u.factor for j in range(len(dists))]
317-
ys_gru = [
318-
data["gruneisen"][dists_inx][band_idx][idx]
319-
for idx in range(len(data["distances"][dists_inx]))
320-
]
321-
sc = ax.scatter(
322-
dists, ys, c=ys_gru, cmap=cmap, norm=norm, marker="o", s=1
323-
)
324-
325-
# Main X and Y Labels
326-
ax.set_xlabel(r"$\mathrm{Wave\ Vector}$", fontsize=30)
327-
units = kwargs.get("units", "THz")
328-
ax.set_ylabel(f"Frequencies ({units})", fontsize=30)
329-
# X range (K)
330-
# last distance point
331-
x_max = data["distances"][-1][-1]
332-
ax.set_xlim(0, x_max)
333-
334-
cbar = plt.colorbar(sc, ax=ax)
335-
cbar.set_label(r"$\gamma \ \mathrm{(logarithmized)}$", fontsize=30)
336-
plt.tight_layout()
337-
gruneisen_band_plot = kwargs.get("gruneisen_bs", "gruneisen_band.pdf")
338-
if save_fig:
339-
plt.savefig(fname=gruneisen_band_plot)
340-
plt.close()
341-
else:
342-
plt.close()

tests/common/jobs/test_gruneisen.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@ def test_compute_gruneisen_param(tmp_dir, test_dir):
5353
"minus": False,
5454
}
5555
assert gp_doc.derived_properties.average_gruneisen == pytest.approx(
56-
1.1882292157682082
56+
1.1203420586842452, abs=1e-2
5757
)
5858
assert gp_doc.derived_properties.thermal_conductivity_slack == pytest.approx(
59-
38.861289530152796
59+
44.078885068152346, abs=1e-2
6060
)

tests/test_data/vasp/Si_phonons_4/dielectric/inputs/INCAR.gz renamed to tests/test_data/vasp/Si_phonons_3/dielectric/inputs/INCAR.gz

File renamed without changes.

tests/test_data/vasp/Si_phonons_4/dielectric/inputs/KPOINTS.gz renamed to tests/test_data/vasp/Si_phonons_3/dielectric/inputs/KPOINTS.gz

File renamed without changes.

tests/test_data/vasp/Si_phonons_4/dielectric/inputs/POSCAR.gz renamed to tests/test_data/vasp/Si_phonons_3/dielectric/inputs/POSCAR.gz

File renamed without changes.

tests/test_data/vasp/Si_phonons_4/dielectric/inputs/POTCAR.spec.gz renamed to tests/test_data/vasp/Si_phonons_3/dielectric/inputs/POTCAR.spec.gz

File renamed without changes.

tests/test_data/vasp/Si_phonons_4/dielectric/outputs/CONTCAR.gz renamed to tests/test_data/vasp/Si_phonons_3/dielectric/outputs/CONTCAR.gz

File renamed without changes.

tests/test_data/vasp/Si_phonons_4/dielectric/outputs/INCAR.gz renamed to tests/test_data/vasp/Si_phonons_3/dielectric/outputs/INCAR.gz

File renamed without changes.

tests/test_data/vasp/Si_phonons_4/dielectric/outputs/INCAR.orig.gz renamed to tests/test_data/vasp/Si_phonons_3/dielectric/outputs/INCAR.orig.gz

File renamed without changes.

0 commit comments

Comments
 (0)