Skip to content

Commit b01b885

Browse files
Merge branch 'main' into main
2 parents 44e6c33 + 073eac1 commit b01b885

File tree

94 files changed

+48
-152
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

+48
-152
lines changed

pyproject.toml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ defects = [
5151
]
5252
forcefields = [
5353
"ase>=3.23.0",
54-
"calorine<=2.2.1",
54+
"calorine>=3.0",
5555
"chgnet>=0.2.2",
5656
"mace-torch>=0.3.3",
5757
"matgl>=1.1.3",
@@ -74,7 +74,7 @@ docs = [
7474
"FireWorks==2.0.3",
7575
"autodoc_pydantic==2.2.0",
7676
"furo==2024.8.6",
77-
"ipython==8.29.0",
77+
"ipython==8.30.0",
7878
"jsonschema[format]",
7979
"myst_parser==4.0.0",
8080
"numpydoc==1.8.0",
@@ -89,7 +89,7 @@ tests = [
8989
"pytest-cov==6.0.0",
9090
"pytest-mock==3.14.0",
9191
"pytest-split==0.10.0",
92-
"pytest==8.3.3",
92+
"pytest==8.3.4",
9393
]
9494
strict = [
9595
"PyYAML==6.0.2",
@@ -98,17 +98,17 @@ strict = [
9898
"click==8.1.7",
9999
"custodian==2024.10.16",
100100
"dscribe==2.1.1",
101-
"emmet-core==0.84.3rc4",
101+
"emmet-core==0.84.3rc6",
102102
"ijson==3.3.0",
103103
"jobflow==0.1.19",
104104
"lobsterpy==0.4.9",
105105
"mdanalysis==2.7.0",
106106
"monty==2024.10.21",
107-
"mp-api==0.42.2",
107+
"mp-api==0.43.0",
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",
@@ -124,7 +124,7 @@ strict-forcefields = [
124124
"mace-torch>=0.3.6",
125125
"matgl==1.1.3",
126126
"quippy-ase==0.9.14; python_version < '3.12'",
127-
"sevenn==0.10.1",
127+
"sevenn==0.10.2",
128128
"torch==2.5.1",
129129
"torchdata==0.7.1", # TODO: remove when issue fixed
130130
]

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
)
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

tests/vasp/flows/test_phonons.py

Lines changed: 28 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,8 @@ def test_phonon_wf_vasp_only_displacements_no_structural_transformation(
123123
):
124124
# mapping from job name to directory containing test files
125125
ref_paths = {
126-
"phonon static 1/1": "Si_phonons_3/phonon_static_1_1",
127-
"static": "Si_phonons_3/static",
126+
"phonon static 1/1": "Si_phonons_2/phonon_static_1_1",
127+
"static": "Si_phonons_2/static",
128128
}
129129

130130
# settings passed to fake_run_vasp; adjust these to check for certain INCAR settings
@@ -145,33 +145,27 @@ def test_phonon_wf_vasp_only_displacements_no_structural_transformation(
145145
store_force_constants=False,
146146
prefer_90_degrees=False,
147147
generate_frequencies_eigenvectors_kwargs={"tstep": 100},
148-
).make(si_structure)
148+
).make(si_structure.to_conventional())
149149

150150
# run the flow or job and ensure that it finished running successfully
151151
responses = run_locally(job, create_folders=True, ensure_success=True)
152152

153-
# validate the outputs
154-
assert isinstance(responses[job.jobs[-1].uuid][1].output, PhononBSDOSDoc)
155-
156-
assert_allclose(
157-
responses[job.jobs[-1].uuid][1].output.free_energies,
158-
[5927.157337, 5905.309813, 5439.530414, 4207.379685, 2297.576147],
159-
)
160-
assert_allclose(
161-
responses[job.jobs[-1].uuid][1].output.entropies,
162-
[0.0, 1.256496, 8.511348, 15.928285, 22.063785],
163-
atol=1e-6,
164-
)
165-
assert_allclose(
166-
responses[job.jobs[-1].uuid][1].output.heat_capacities,
167-
[0.0, 4.958763, 15.893881, 20.311967, 22.196143],
153+
# validate settings
154+
assert responses[job.jobs[-1].uuid][1].output.code == "vasp"
155+
assert isinstance(
156+
responses[job.jobs[-1].uuid][1].output.phonopy_settings,
157+
PhononComputationalSettings,
168158
)
169-
170-
assert_allclose(
171-
responses[job.jobs[-1].uuid][1].output.internal_energies,
172-
[5927.157337, 6030.959432, 7141.800004, 8985.865319, 11123.090225],
159+
assert responses[job.jobs[-1].uuid][1].output.phonopy_settings.npoints_band == 101
160+
assert (
161+
responses[job.jobs[-1].uuid][1].output.phonopy_settings.kpath_scheme
162+
== "seekpath"
173163
)
164+
phonopy_settings = responses[job.jobs[-1].uuid][1].output.phonopy_settings
165+
assert phonopy_settings.kpoint_density_dos == 7_000
174166

167+
# validate the outputs
168+
assert isinstance(responses[job.jobs[-1].uuid][1].output, PhononBSDOSDoc)
175169
assert isinstance(
176170
responses[job.jobs[-1].uuid][1].output.phonon_bandstructure,
177171
PhononBandStructureSymmLine,
@@ -187,7 +181,7 @@ def test_phonon_wf_vasp_only_displacements_no_structural_transformation(
187181
assert isinstance(responses[job.jobs[-1].uuid][1].output.jobdirs, PhononJobDirs)
188182
assert isinstance(responses[job.jobs[-1].uuid][1].output.uuids, PhononUUIDs)
189183
assert_allclose(
190-
responses[job.jobs[-1].uuid][1].output.total_dft_energy, -5.74525804
184+
responses[job.jobs[-1].uuid][1].output.total_dft_energy, -5.74555232
191185
)
192186
assert responses[job.jobs[-1].uuid][1].output.born is None
193187
assert responses[job.jobs[-1].uuid][1].output.epsilon_static is None
@@ -196,40 +190,25 @@ def test_phonon_wf_vasp_only_displacements_no_structural_transformation(
196190
)
197191
assert_allclose(
198192
responses[job.jobs[-1].uuid][1].output.primitive_matrix,
199-
((0, 1, 0), (0, 0, 1), (1, 0, 0)),
193+
((0, 0.5, 0.5), (0.5, 0, 0.5), (0.5, 0.5, 0)),
200194
atol=1e-8,
201195
)
202196
assert_allclose(
203-
responses[job.jobs[-1].uuid][1].output.primitive_matrix,
204-
((0, 1, 0), (0, 0, 1), (1, 0, 0)),
205-
)
206-
assert responses[job.jobs[-1].uuid][1].output.code == "vasp"
207-
assert isinstance(
208-
responses[job.jobs[-1].uuid][1].output.phonopy_settings,
209-
PhononComputationalSettings,
210-
)
211-
assert responses[job.jobs[-1].uuid][1].output.phonopy_settings.npoints_band == 101
212-
assert (
213-
responses[job.jobs[-1].uuid][1].output.phonopy_settings.kpath_scheme
214-
== "seekpath"
197+
responses[job.jobs[-1].uuid][1].output.free_energies,
198+
[6115.980051, 6059.749756, 5490.929122, 4173.234384, 2194.164562],
215199
)
216-
phonopy_settings = responses[job.jobs[-1].uuid][1].output.phonopy_settings
217-
assert phonopy_settings.kpoint_density_dos == 7_000
218200
assert_allclose(
219201
responses[job.jobs[-1].uuid][1].output.entropies,
220-
[0.0, 1.256496, 8.511348, 15.928285, 22.063785],
202+
[0.0, 2.194216, 9.478603, 16.687079, 22.702177],
221203
atol=1e-6,
222204
)
223205
assert_allclose(
224206
responses[job.jobs[-1].uuid][1].output.heat_capacities,
225-
[0.0, 4.958763, 15.893881, 20.311967, 22.196143],
226-
atol=1e-6,
207+
[0.0, 5.750113, 15.408866, 19.832123, 21.842104],
227208
)
228-
229209
assert_allclose(
230210
responses[job.jobs[-1].uuid][1].output.internal_energies,
231-
[5927.157337, 6030.959432, 7141.800004, 8985.865319, 11123.090225],
232-
atol=1e-6,
211+
[6115.980051, 6279.17132, 7386.649622, 9179.358187, 11275.035523],
233212
)
234213

235214

@@ -542,11 +521,11 @@ def test_phonon_wf_vasp_only_displacements_optional_settings(
542521
def test_phonon_wf_vasp_all_steps(mock_vasp, clean_dir, si_structure: Structure):
543522
# mapping from job name to directory containing test files
544523
ref_paths = {
545-
"phonon static 1/1": "Si_phonons_4/phonon_static_1_1",
546-
"static": "Si_phonons_4/static",
547-
"tight relax 1": "Si_phonons_4/tight_relax_1",
548-
"tight relax 2": "Si_phonons_4/tight_relax_2",
549-
"dielectric": "Si_phonons_4/dielectric",
524+
"phonon static 1/1": "Si_phonons_3/phonon_static_1_1",
525+
"static": "Si_phonons_3/static",
526+
"tight relax 1": "Si_phonons_3/tight_relax_1",
527+
"tight relax 2": "Si_phonons_3/tight_relax_2",
528+
"dielectric": "Si_phonons_3/dielectric",
550529
}
551530

552531
# settings passed to fake_run_vasp; adjust these to check for certain INCAR settings

0 commit comments

Comments
 (0)