Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add assign_magmoms=True keyword to StructOptimizer.relax() #124

Merged
merged 4 commits into from
Feb 18, 2024

Conversation

janosh
Copy link
Collaborator

@janosh janosh commented Feb 18, 2024

f347536 update pre-commit and site/package.json deps
9c0b453 swap metrics table of full WBM test set for one restricted to unique+novel WBM prototypes
7409cf8 add assign_magmoms=True keyword to StructOptimizer.relax()
1d59310 cover assign_magmoms: True | False in test_relaxation()

Reason

magmoms and phonopy don't go great together. Makes using chgnet with phonopy more difficult.
phonopy just bails when trying to determine symmetry on structures with magmoms (even though afaik spglib, which phonopy uses, handles magmoms just fine). symmetry is needed to generate efficient structure deformations.

2024-02-18 17:32:08,008 INFO generate_phonon_displacements failed with exception:
Traceback (most recent call last):
  File "jobflow/managers/local.py", line 114, in _run_job
    response = job.run(store=store)
               ^^^^^^^^^^^^^^^^^^^^
  File "jobflow/core/job.py", line 583, in run
    response = function(*self.function_args, **self.function_kwargs)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "atomate2/src/atomate2/common/jobs/phonons.py", line 162, in generate_phonon_displacements
    phonon = Phonopy(
             ^^^^^^^^
  File "phonopy/api_phonopy.py", line 171, in __init__
    self._primitive_matrix = self._set_primitive_matrix(primitive_matrix)
                             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "phonopy/api_phonopy.py", line 3794, in _set_primitive_matrix
    return guess_primitive_matrix(self._unitcell, symprec=self._symprec)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "phonopy/structure/cells.py", line 1693, in guess_primitive_matrix
    raise RuntimeError(msg)
RuntimeError: Can not be used with the unit cell having magnetic moments.

@janosh janosh added api Application programming interface relax Structure optimization magmom Magnetism related labels Feb 18, 2024
@@ -216,6 +216,7 @@ def relax(
loginterval: int | None = 1,
crystal_feas_save_path: str | None = None,
verbose: bool = True,
assign_magmoms: bool = True,
Copy link
Collaborator Author

@janosh janosh Feb 18, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@BowenD-UCB let me know if assign_magmoms makes sense or you'd like a different name or API here

@janosh janosh merged commit 6dbd335 into main Feb 18, 2024
10 checks passed
@janosh janosh deleted the relax-assign-magmom-kwarg branch February 18, 2024 17:45
@janosh janosh added the enhancement New feature or request label Mar 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api Application programming interface enhancement New feature or request magmom Magnetism related relax Structure optimization
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant