Skip to content

Commit

Permalink
Merge branch 'main' of github.com:Quantum-Accelerators/quacc
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrew-S-Rosen committed Apr 23, 2024
2 parents 66276f4 + ae935eb commit 89f7c8b
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 24 deletions.
39 changes: 21 additions & 18 deletions src/quacc/recipes/common/phonons.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

from monty.dev import requires

from quacc import flow, job, subflow
from quacc import job, subflow
from quacc.atoms.phonons import get_phonopy, phonopy_atoms_to_ase_atoms
from quacc.runners.phonons import run_phonopy
from quacc.schemas.phonons import summarize_phonopy
Expand All @@ -23,11 +23,11 @@
from quacc.schemas._aliases.phonons import PhononSchema


@flow
@subflow
@requires(
has_deps, "Phonopy and seekpath must be installed. Run `pip install quacc[phonons]`"
)
def phonon_flow(
def phonon_subflow(
atoms: Atoms,
force_job: Job,
relax_job: Job | None = None,
Expand Down Expand Up @@ -80,19 +80,20 @@ def phonon_flow(
Dictionary of results from [quacc.schemas.phonons.summarize_phonopy][]
"""

phonon = get_phonopy(
atoms,
min_lengths=min_lengths,
supercell_matrix=supercell_matrix,
symprec=symprec,
displacement=displacement,
phonopy_kwargs=phonopy_kwargs,
)
supercells = [
phonopy_atoms_to_ase_atoms(s) for s in phonon.supercells_with_displacements
]

@subflow
def _get_forces_subflow(atoms: Atoms) -> list[dict]:
phonon = get_phonopy(
atoms,
min_lengths=min_lengths,
supercell_matrix=supercell_matrix,
symprec=symprec,
displacement=displacement,
phonopy_kwargs=phonopy_kwargs,
)
supercells = [
phonopy_atoms_to_ase_atoms(s) for s in phonon.supercells_with_displacements
]
def _get_forces_subflow(supercells: list[Atoms]) -> list[dict]:
return [
force_job(supercell) for supercell in supercells if supercell is not None
]
Expand All @@ -109,18 +110,20 @@ def _thermo_job(atoms: Atoms, force_job_results: list[dict]) -> PhononSchema:
)
parameters = force_job_results[-1].get("parameters")
forces = [output["results"]["forces"] for output in force_job_results]
phonon = run_phonopy(phonon, forces, t_step=t_step, t_min=t_min, t_max=t_max)
phonon_results = run_phonopy(
phonon, forces, t_step=t_step, t_min=t_min, t_max=t_max
)

return summarize_phonopy(
phonon,
atoms,
phonon.directory,
phonon_results.directory,
parameters=parameters,
additional_fields=additional_fields,
)

if relax_job is not None:
atoms = relax_job(atoms)["atoms"]

force_job_results = _get_forces_subflow(atoms)
force_job_results = _get_forces_subflow(supercells)
return _thermo_job(atoms, force_job_results)
4 changes: 2 additions & 2 deletions src/quacc/recipes/emt/phonons.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from typing import TYPE_CHECKING

from quacc import flow
from quacc.recipes.common.phonons import phonon_flow as common_phonon_flow
from quacc.recipes.common.phonons import phonon_subflow
from quacc.recipes.emt.core import relax_job, static_job
from quacc.utils.dicts import recursive_dict_merge
from quacc.wflow_tools.customizers import customize_funcs
Expand Down Expand Up @@ -93,7 +93,7 @@ def phonon_flow(
decorators=job_decorators,
)

return common_phonon_flow(
return phonon_subflow(
atoms,
static_job_,
relax_job=relax_job_ if run_relax else None,
Expand Down
4 changes: 2 additions & 2 deletions src/quacc/recipes/mlp/phonons.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from monty.dev import requires

from quacc import flow
from quacc.recipes.common.phonons import phonon_flow as common_phonon_flow
from quacc.recipes.common.phonons import phonon_subflow
from quacc.recipes.mlp.core import relax_job, static_job
from quacc.utils.dicts import recursive_dict_merge
from quacc.wflow_tools.customizers import customize_funcs
Expand Down Expand Up @@ -106,7 +106,7 @@ def phonon_flow(
decorators=job_decorators,
)

return common_phonon_flow(
return phonon_subflow(
atoms,
static_job_,
relax_job=relax_job_ if run_relax else None,
Expand Down
4 changes: 2 additions & 2 deletions src/quacc/recipes/tblite/phonons.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from monty.dev import requires

from quacc import flow
from quacc.recipes.common.phonons import phonon_flow as common_phonon_flow
from quacc.recipes.common.phonons import phonon_subflow
from quacc.recipes.tblite.core import relax_job, static_job
from quacc.utils.dicts import recursive_dict_merge
from quacc.wflow_tools.customizers import customize_funcs
Expand Down Expand Up @@ -106,7 +106,7 @@ def phonon_flow(
decorators=job_decorators,
)

return common_phonon_flow(
return phonon_subflow(
atoms,
static_job_,
relax_job=relax_job_ if run_relax else None,
Expand Down

0 comments on commit 89f7c8b

Please sign in to comment.