Skip to content

Commit

Permalink
CP2K allow specifying default initial element magmoms (#4170)
Browse files Browse the repository at this point in the history
* simplify DftSet.create_subsys

* DftSet.create_subsys write element-specific initial magmoms to KIND sections if found in DftSet.element_defaults

* add TestDftSet.test_kind_magnetization for checking different ways of setting element-specific initial magnetization

* fix Section.check failing on missing subsections

AttributeError: 'dict' object has no attribute 'subsections'

* add support for env vars CP2K_DATA_DIR, DEFAULT_CP2K_FUNCTIONAL, DEFAULT_CP2K_BASIS_TYPE, DEFAULT_CP2K_AUX_BASIS_TYPE in addition to PMG_CP2K_DATA_DIR, PMG_DEFAULT_CP2K_FUNCTIONAL, ... config keys

* DftSet add keyword cell: dict[str, Any] | None = None to e.g. specify symmetry

this is useful when running disordered systems with CP2K where enforcing cubic cells minimizes finite size effects

* refactor section keywords merging with section defaults

* readable var names

* remove redundant keywords/subsections or {}

* new DftSet unit test test_cell_parameters

plus type hints

---------

Co-authored-by: Matthew Horton <[email protected]>
  • Loading branch information
janosh and mkhorton authored Nov 17, 2024
1 parent c72c9e9 commit 424672f
Show file tree
Hide file tree
Showing 5 changed files with 284 additions and 276 deletions.
3 changes: 1 addition & 2 deletions src/pymatgen/analysis/magnetism/analyzer.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,7 @@ def __init__(
has_spin = False
for comp in structure.species_and_occu:
for sp in comp:
if getattr(sp, "spin", False):
has_spin = True
has_spin |= bool(getattr(sp, "spin", False))

# perform input sanitation ...
# rest of class will assume magnetic moments are stored on site properties:
Expand Down
Loading

0 comments on commit 424672f

Please sign in to comment.