Skip to content

Commit

Permalink
Merge branch 'develop' into dopey_fermi
Browse files Browse the repository at this point in the history
  • Loading branch information
kavanase committed Aug 20, 2024
2 parents 9935e0f + 5cd9958 commit e5128ec
Show file tree
Hide file tree
Showing 25 changed files with 692 additions and 257 deletions.
1 change: 1 addition & 0 deletions docs/Dev_ToDo.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@
- Should flick through other defect codes (see
https://shakenbreak.readthedocs.io/en/latest/Code_Compatibility.html, also `AiiDA-defects`) and see if
there's any useful functionality we want to add!
- Add short example notebook showing how to generate a defect PES for carrier capture or NEB calculations (don't use `IBRION = 2` for NEB).

## SK To-Do for next update:
- `doped` repo/docs cleanup `TODO`s above
Expand Down
7 changes: 7 additions & 0 deletions docs/Tips.rst
Original file line number Diff line number Diff line change
Expand Up @@ -461,6 +461,13 @@ etc.).
defect supercell, directly from just the relaxed structures, regardless of whether these defects were
generated/parsed with ``doped``.

.. note::

Wyckoff letters for lattice sites can depend on the ordering of elements in the conventional standard
structure, for which doped uses the ``spglib`` convention (e.g. in the ``DefectsGenerator`` info
output).


Serialization & Data Provenance (``JSON``/``csv``)
--------------------------------------------------
To aid calculation reproducibility, data provenance and easy sharing/comparison of pre- and post-processing
Expand Down
2 changes: 1 addition & 1 deletion doped/analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ def check_and_set_defect_entry_name(
) -> None:
"""
Check that ``possible_defect_name`` is a recognised format by doped (i.e.
in the format "{defect_name}_{optional_site_info}_{charge_state}").
in the format ``"{defect_name}_{optional_site_info}_{charge_state}"``).
If the DefectEntry.name attribute is not defined or does not end with the
charge state, then the entry will be renamed with the doped default name
Expand Down
407 changes: 392 additions & 15 deletions doped/chemical_potentials.py

Large diffs are not rendered by default.

9 changes: 7 additions & 2 deletions doped/generation.py
Original file line number Diff line number Diff line change
Expand Up @@ -1124,6 +1124,9 @@ def __init__(
``DefectEntry.charge_state_guessing_log`` attributes. See docs for examples of
modifying the generated charge states.
Note that Wyckoff letters can depend on the ordering of elements in the conventional
standard structure, for which doped uses the ``spglib`` convention.
Args:
structure (Structure):
Structure of the host material (as a pymatgen Structure object).
Expand Down Expand Up @@ -1836,8 +1839,6 @@ def _defect_generator_info(self):
info_string += (
"The number in the Wyckoff label is the site multiplicity/degeneracy of that defect in the "
f"conventional ('conv.') unit cell, which comprises {fu} formula unit(s) of {formula}.\n"
"Note that Wyckoff letters can depend on the ordering of elements in the conventional "
"standard structure, for which doped uses the spglib convention."
)

return info_string
Expand Down Expand Up @@ -2172,6 +2173,10 @@ def __repr__(self):
"""
Returns a string representation of the DefectsGenerator object, and
prints the DefectsGenerator info.
Note that Wyckoff letters can depend on the ordering of elements in
the conventional standard structure, for which doped uses the ``spglib``
convention.
"""
return (
self.__str__()
Expand Down
Empty file added doped/py.typed
Empty file.
2 changes: 1 addition & 1 deletion doped/thermodynamics.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ def raw_energy_from_chempots(composition: Union[str, dict, Composition], chempot
raw_energies_dict = dict(next(iter(chempots["limits"].values())))

if any(el.symbol not in raw_energies_dict for el in composition.elements):
raise ValueError(
warnings.warn(
f"The chemical potentials dictionary (with elements {list(raw_energies_dict.keys())} does not "
f"contain all the elements in the host composition "
f"({[el.symbol for el in composition.elements]})!"
Expand Down
22 changes: 10 additions & 12 deletions doped/utils/symmetry.py
Original file line number Diff line number Diff line change
Expand Up @@ -398,9 +398,9 @@ def get_wyckoff(frac_coords, struct, symm_ops: Optional[list] = None, equiv_site
symm_dataset, unique_sites = _get_symm_dataset_of_struc_with_all_equiv_sites(
frac_coords, struct, symm_ops, symprec=symprec
)
conv_cell_factor = len(symm_dataset["std_positions"]) / len(symm_dataset["wyckoffs"])
conv_cell_factor = len(symm_dataset.std_positions) / len(symm_dataset.wyckoffs)
multiplicity = int(conv_cell_factor * len(unique_sites))
wyckoff_label = f"{multiplicity}{symm_dataset['wyckoffs'][-1]}"
wyckoff_label = f"{multiplicity}{symm_dataset.wyckoffs[-1]}"

return (wyckoff_label, unique_sites) if equiv_sites else wyckoff_label

Expand Down Expand Up @@ -1126,7 +1126,7 @@ def point_symmetry_from_defect(defect, symm_ops=None, symprec=0.01):
symm_dataset, _unique_sites = _get_symm_dataset_of_struc_with_all_equiv_sites(
defect.site.frac_coords, defect.structure, symm_ops=symm_ops, symprec=symprec
)
spglib_point_group_symbol = schoenflies_from_hermann(symm_dataset["site_symmetry_symbols"][-1])
spglib_point_group_symbol = schoenflies_from_hermann(symm_dataset.site_symmetry_symbols[-1])
if spglib_point_group_symbol is not None:
return spglib_point_group_symbol

Expand Down Expand Up @@ -1240,7 +1240,7 @@ def point_symmetry_from_defect_entry(
# then easy, can just be taken from symmetry dataset of defect structure
symm_dataset = _get_sga(defect_entry.defect.structure, symprec=symprec).get_symmetry_dataset()
return schoenflies_from_hermann(
symm_dataset["site_symmetry_symbols"][defect_entry.defect.defect_site_index]
symm_dataset.site_symmetry_symbols[defect_entry.defect.defect_site_index]
)

supercell = _get_defect_supercell(defect_entry) if relaxed else _get_bulk_supercell(defect_entry)
Expand Down Expand Up @@ -1344,15 +1344,15 @@ def point_symmetry_from_defect_entry(
# This issue is avoided for relaxed defect supercells as we take the symm_ops of our reduced
# symmetry cell rather than that of the bulk (so no chance of spurious symmetry upgrade from
# equivalent sites), and hence the max point symmetry is the point symmetry of the defect
spglib_point_group_symbol = schoenflies_from_hermann(symm_dataset["site_symmetry_symbols"][-1])
spglib_point_group_symbol = schoenflies_from_hermann(symm_dataset.site_symmetry_symbols[-1])

# Note that, if the supercell is non-periodicity-breaking, then the site symmetry can be simply
# determined using the point group of the unrelaxed defect structure:
# unrelaxed_defect_supercell = defect_entry.calculation_metadata.get(
# "unrelaxed_defect_structure", defect_supercell
# )
# return schoenflies_from_hermann(
# _get_sga(unrelaxed_defect_supercell, symprec).get_symmetry_dataset()["pointgroup"],
# _get_sga(unrelaxed_defect_supercell, symprec).get_symmetry_dataset().pointgroup,
# )
# But current approach works for all cases with unrelaxed defect structures

Expand All @@ -1361,15 +1361,15 @@ def point_symmetry_from_defect_entry(
# the defect (e.g. for split-interstitials, split-vacancies, swapped vacancies etc),
# so use 'pointgroup' output (in this case the reduced symmetry avoids the symmetry-upgrade
# possibility with the equivalent sites, as when relaxed=False)
spglib_point_group_symbol = schoenflies_from_hermann(symm_dataset["pointgroup"])
spglib_point_group_symbol = schoenflies_from_hermann(symm_dataset.pointgroup)

# This also works (at least for non-periodicity-breaking supercells) for relaxed defects in
# most cases, but is slightly less robust (more sensitive to ``symprec`` choice) than the
# approach above:
# schoenflies_from_hermann(
# _get_sga(
# defect_supercell, symprec=symprec
# ).get_symmetry_dataset()["pointgroup"]
# ).get_symmetry_dataset().pointgroup
# )

if spglib_point_group_symbol is not None:
Expand Down Expand Up @@ -1416,7 +1416,7 @@ def _check_relaxed_defect_symmetry_determination(

if unrelaxed_defect_structure is not None:
unrelaxed_spglib_point_group_symbol = schoenflies_from_hermann(
_get_sga(unrelaxed_defect_structure, symprec=symprec).get_symmetry_dataset()["pointgroup"],
_get_sga(unrelaxed_defect_structure, symprec=symprec).get_symmetry_dataset().pointgroup,
)

bulk_supercell = _get_bulk_supercell(defect_entry)
Expand All @@ -1428,9 +1428,7 @@ def _check_relaxed_defect_symmetry_determination(
symprec=symprec,
dist_tol=symprec,
)
bulk_spglib_point_group_symbol = schoenflies_from_hermann(
symm_dataset["site_symmetry_symbols"][-1]
)
bulk_spglib_point_group_symbol = schoenflies_from_hermann(symm_dataset.site_symmetry_symbols[-1])

if bulk_spglib_point_group_symbol != unrelaxed_spglib_point_group_symbol:
if verbose:
Expand Down
Loading

0 comments on commit e5128ec

Please sign in to comment.