Skip to content

Commit

Permalink
Merge pull request #90 from gpetretto/abinit2
Browse files Browse the repository at this point in the history
Abinit workflows
  • Loading branch information
davidwaroquiers authored May 5, 2023
2 parents cd536cb + 676432a commit ed25422
Show file tree
Hide file tree
Showing 459 changed files with 1,565 additions and 23,643 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ default_language_version:
exclude: ^(src/atomate2/vasp/schemas/calc_types/|tests/test_data/abinit/)
repos:
- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: v0.0.256
rev: v0.0.259
hooks:
- id: ruff
args: [--fix]
Expand Down
34 changes: 34 additions & 0 deletions docs/user/codes/vasp.md
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,41 @@ VASP_CMD: <<VASP_CMD>>
LOBSTER_CMD: <<LOBSTER_CMD>>
```
Outputs from the automatic analysis with LobsterPy can easily be extracted from the database and also plotted:
```python
from jobflow import SETTINGS
from pymatgen.electronic_structure.cohp import Cohp
from pymatgen.electronic_structure.plotter import CohpPlotter

store = SETTINGS.JOB_STORE
store.connect()

result = store.query_one(
{"name": "lobster_run_0"},
properties=[
"output.lobsterpy_data.cohp_plot_data",
"output.lobsterpy_data_cation_anion.cohp_plot_data",
],
load=True,
)

for number, (key, cohp) in enumerate(
result["output"]["lobsterpy_data"]["cohp_plot_data"].items()
):
plotter = CohpPlotter()
cohp = Cohp.from_dict(cohp)
plotter.add_cohp(key, cohp)
plotter.save_plot("plots_all_bonds" + str(number) + ".pdf")

for number, (key, cohp) in enumerate(
result["output"]["lobsterpy_data_cation_anion"]["cohp_plot_data"].items()
):
plotter = CohpPlotter()
cohp = Cohp.from_dict(cohp)
plotter.add_cohp(key, cohp)
plotter.save_plot("plots_cation_anion_bonds" + str(number) + ".pdf")
```
(modifying_input_sets)=
Modifying input sets
Expand Down
18 changes: 9 additions & 9 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ dependencies = [
]

[project.optional-dependencies]
abinit = ["abipy @ git+https://github.com/abinit/abipy.git@develop"]
abinit = ["abipy>=0.9.3"]
amset = ["amset>=0.4.15", "pydash"]
cclib = ["cclib"]
mp = ["mp-api>=0.27.5"]
Expand All @@ -46,31 +46,31 @@ lobster = ["lobsterpy"]
defects = ["pymatgen-analysis-defects>=2022.11.30", "dscribe>=1.2.0"]
docs = [
"numpydoc==1.5.0",
"ipython==8.11.0",
"ipython==8.12.0",
"FireWorks==2.0.3",
"autodoc_pydantic==1.8.0",
"jupyter-book==0.14.0",
"jsonschema[format]",
]
dev = ["pre-commit>=2.12.1"]
tests = ["pytest==7.2.2", "pytest-cov==4.0.0", "FireWorks==2.0.3", "pytest-mock==3.6.1"]
tests = ["pytest==7.3.0", "pytest-cov==4.0.0", "FireWorks==2.0.3", "pytest-mock==3.10.0"]
strict = [
"pydantic==1.10.6",
"pymatgen==2023.3.10",
"pydantic==1.10.7",
"pymatgen==2023.3.23",
"custodian==2023.3.10",
"monty==2022.9.9",
"jobflow==0.1.11",
"click==8.1.3",
"PyYAML==6.0",
"cclib==1.7.2",
"phonopy==2.17.2",
"phonopy==2.18.0",
"seekpath==2.0.1",
"numpy",
"mp-api==0.30.10",
"dscribe==1.2.2",
"pymatgen-analysis-defects==2023.3.3",
"lobsterpy==0.2.8",
"emmet-core==0.51.0"
"pymatgen-analysis-defects==2023.4.5",
"lobsterpy==0.2.9",
"emmet-core==0.51.6"
]

[project.scripts]
Expand Down
92 changes: 18 additions & 74 deletions src/atomate2/abinit/flows/core.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
"""Core abinit flow makers."""
from __future__ import annotations

from dataclasses import dataclass, field
from pathlib import Path
from typing import List, Optional, Union

from jobflow import Flow, Maker
from pymatgen.core.structure import Structure

from atomate2.abinit.jobs.base import BaseAbinitMaker
from atomate2.abinit.jobs.core import NonSCFMaker, RelaxMaker, StaticMaker
from atomate2.abinit.jobs.core import (
LineNonSCFMaker,
RelaxMaker,
StaticMaker,
UniformNonSCFMaker,
)


@dataclass
Expand All @@ -29,15 +34,15 @@ class BandStructureMaker(Maker):
The maker to use for the non-self-consistent field calculations.
"""

name: str = "band structure"
bandstructure_type: str = "both"
name: str = "band structure - dos"
static_maker: BaseAbinitMaker = field(default_factory=StaticMaker)
bs_maker: BaseAbinitMaker = field(default_factory=NonSCFMaker)
bs_maker: BaseAbinitMaker | None = field(default_factory=LineNonSCFMaker)
dos_maker: BaseAbinitMaker | None = field(default_factory=UniformNonSCFMaker)

def make(
self,
structure: Structure,
restart_from: Optional[Union[str, Path]] = None,
restart_from: str | Path | None = None,
):
"""
Create a band structure flow.
Expand All @@ -54,85 +59,24 @@ def make(
Flow
A band structure flow.
"""
if self.bandstructure_type not in ("both", "line", "uniform"):
raise ValueError(
f"Unrecognised bandstructure type {self.bandstructure_type}"
)

static_job = self.static_maker.make(structure, restart_from=restart_from)
jobs = [static_job]

if self.bandstructure_type in ("both", "uniform"):
uniform_job = self.bs_maker.make(
if self.dos_maker:
uniform_job = self.dos_maker.make(
prev_outputs=static_job.output.dir_name,
mode="uniform",
)
uniform_job.name += " uniform"
jobs.append(uniform_job)

if self.bandstructure_type in ("both", "line"):
if self.bs_maker:
line_job = self.bs_maker.make(
prev_outputs=static_job.output.dir_name,
mode="line",
)
line_job.name += " line"
jobs.append(line_job)

return Flow(jobs, name=self.name)


@dataclass
class LineBandStructureMaker(Maker):
# TODO: make this more similar to Vasp
"""
Maker to generate line abinit band structure.
This is a static calculation followed by a non-self-consistent field
calculations.
Parameters
----------
name : str
Name of the flows produced by this maker.
scf_maker : .BaseAbinitMaker
The maker to use for the static calculation.
bs_maker : .BaseAbinitMaker
The maker to use for the non-self-consistent field calculations.
"""

name: str = "line band structure"
scf_maker: BaseAbinitMaker = field(default_factory=StaticMaker)
bs_maker: BaseAbinitMaker = field(default_factory=NonSCFMaker)

def make(
self,
structure: Structure,
restart_from: Optional[Union[str, Path]] = None,
):
"""
Create a line mode band structure flow.
Parameters
----------
structure : Structure
A pymatgen structure object.
restart_from : str or Path or None
One previous directory to restart from.
Returns
-------
Flow
A line mode band structure flow.
"""
scf_job = self.scf_maker.make(structure, restart_from=restart_from)
line_job = self.bs_maker.make(
prev_outputs=scf_job.output.dir_name,
mode="line",
)
jobs = [scf_job, line_job]
return Flow(jobs, line_job.output, name=self.name)


@dataclass
class RelaxFlowMaker(Maker):
"""
Expand All @@ -147,7 +91,7 @@ class RelaxFlowMaker(Maker):
"""

name: str = "relaxation"
relaxation_makers: List[Maker] = field(
relaxation_makers: list[Maker] = field(
default_factory=lambda: [
RelaxMaker.ionic_relaxation(),
RelaxMaker.full_relaxation(),
Expand All @@ -156,8 +100,8 @@ class RelaxFlowMaker(Maker):

def make(
self,
structure: Optional[Structure] = None,
restart_from: Optional[Union[str, Path]] = None,
structure: Structure | None = None,
restart_from: str | Path | None = None,
):
"""
Create a relaxation flow.
Expand Down Expand Up @@ -190,5 +134,5 @@ def make(
def ion_ioncell_relaxation(cls, *args, **kwargs):
"""Create a double relaxation (ionic relaxation + full relaxation)."""
ion_rlx_maker = RelaxMaker.ionic_relaxation(*args, **kwargs)
ioncell_rlx_maker = RelaxMaker.from_prev_maker(ion_rlx_maker, relax_cell=True)
ioncell_rlx_maker = RelaxMaker.full_relaxation(*args, **kwargs)
return cls(relaxation_makers=[ion_rlx_maker, ioncell_rlx_maker])
Loading

0 comments on commit ed25422

Please sign in to comment.