diff --git a/src/atomate2/common/schemas/phonons.py b/src/atomate2/common/schemas/phonons.py index d8ab569ee8..30d4a645d0 100644 --- a/src/atomate2/common/schemas/phonons.py +++ b/src/atomate2/common/schemas/phonons.py @@ -503,9 +503,11 @@ def from_forces_born( ) # compute vibrational part of free energies per formula unit - temperature_range = np.arange( - kwargs.get("tmin", 0), kwargs.get("tmax", 500), kwargs.get("tstep", 10) - ) + # the grid includes tmax and defaults to 0-1000 K, as in phonopy + tmin = kwargs.get("tmin", 0) + tmax = kwargs.get("tmax", 1000) + tstep = kwargs.get("tstep", 10) + temperature_range = np.arange(tmin, tmax + tstep / 2, tstep) free_energies = [ dos.helmholtz_free_energy( diff --git a/tests/torchsim/flows/test_phonons.py b/tests/torchsim/flows/test_phonons.py index 6163f1f8db..1b3f0c6330 100644 --- a/tests/torchsim/flows/test_phonons.py +++ b/tests/torchsim/flows/test_phonons.py @@ -178,7 +178,7 @@ def test_torchsim_phonon_maker_integration( phonon_displacement_maker=static_maker, create_thermal_displacements=False, store_force_constants=False, - generate_frequencies_eigenvectors_kwargs={"tstep": 100}, + generate_frequencies_eigenvectors_kwargs={"tstep": 100, "tmax": 400}, socket=socket, ) diff --git a/tests/vasp/flows/test_phonons.py b/tests/vasp/flows/test_phonons.py index ebdecd484f..73703de73e 100644 --- a/tests/vasp/flows/test_phonons.py +++ b/tests/vasp/flows/test_phonons.py @@ -115,6 +115,46 @@ def test_phonon_wf_vasp_only_displacements3( # structure will be kept in the format that was transferred +@pytest.mark.parametrize( + ("kwargs", "expected_temperatures"), + [ + ({}, np.arange(0, 1001, 10)), # default grid is 0-1000 K, as in phonopy + ({"tmax": 500, "tstep": 100}, [0, 100, 200, 300, 400, 500]), # tmax included + ], +) +def test_phonon_wf_vasp_temperature_grid( + mock_vasp, clean_dir, si_structure: Structure, kwargs, expected_temperatures +): + ref_paths = { + "phonon static 1/1": "Si_phonons_2/phonon_static_1_1", + "static": "Si_phonons_2/static", + } + mock_vasp( + ref_paths, + { + "phonon static 1/1": {"incar_settings": ["NSW", "ISMEAR"]}, + "static": {"incar_settings": ["NSW", "ISMEAR"]}, + }, + ) + + job = PhononMaker( + min_length=3.0, + bulk_relax_maker=None, + born_maker=None, + use_symmetrized_structure="conventional", + create_thermal_displacements=False, + store_force_constants=False, + prefer_90_degrees=False, + generate_frequencies_eigenvectors_kwargs=kwargs, + ).make(si_structure) + responses = run_locally(job, create_folders=True, ensure_success=True) + + ph_doc = responses[job.jobs[-1].uuid][1].output + assert_allclose(ph_doc.temperatures, expected_temperatures) + assert len(ph_doc.free_energies) == len(expected_temperatures) + assert len(ph_doc.heat_capacities) == len(expected_temperatures) + + def test_phonon_wf_vasp_only_displacements_no_structural_transformation( mock_vasp, clean_dir, si_structure: Structure ):