Handling Magnetic Moments in Phonon Calculations Workflow

Dear Atomate Community,

I am currently working on calculating the harmonic phonons of a material using the Atomate2 framework. I have encountered the following warning relevant to the implementation in the workflow:

Warning

The current implementation of the workflow does not consider the initial magnetic moments for the determination of the symmetry of the structure; therefore, they are removed from the structure.

As outlined in the documentation, the current implementation of the phonon calculation workflow does not consider the initial magnetic moments for the determination of the structure’s symmetry. Consequently, the magnetic moments are removed from the structure. This presents a challenge for my project, as maintaining accurate magnetic moments is crucial for my calculations.

I would like to ask for advice on the following points:

  1. Incorporating Magnetic Moments:

How can I modify the current workflow to ensure that initial magnetic moments are properly set and maintained throughout the structural relaxation and subsequent calculations?

  1. Symmetrizing Structures:

What are the best practices for symmetrizing the structure before passing it to the workflow to avoid unnecessary displacement calculations? Are there specific tools or methods within Atomate2 or Pymatgen that you would recommend?

  1. Adjusting Convergence Parameters:

Are there recommended convergence parameters for phonon calculations that I should consider adjusting? How can I integrate these adjustments into the existing workflow?

Here is a brief outline of my current approach along with potential implementation code:

Setting Initial Magnetic Moments:

from pymatgen.core import Structure

def set_initial_magnetic_moments(structure: Structure, magmom: float):
    for site in structure:
        site.properties['magmom'] = magmom
    return structure

Symmetrizing Structure:

from pymatgen.symmetry.analyzer import SpacegroupAnalyzer

def symmetrize_structure(structure: Structure):
    sga = SpacegroupAnalyzer(structure)
    return sga.get_refined_structure()

Modifying the Workflow:

from atomate2.vasp.workflows.base import get_wf

def get_custom_phonon_workflow(structure: Structure, magmom: float, user_params: dict):
    # Set initial magnetic moments
    structure = set_initial_magnetic_moments(structure, magmom)

    # Symmetrize the structure
    structure = symmetrize_structure(structure)

    # Get the default workflow
    wf = get_wf(structure, 'phonon')

    # Update workflow parameters
    wf.update(user_params)

    # Adjust convergence parameters
    for task in wf['tasks']:
        if 'INCAR' in task:
            task['INCAR'].update({
                'EDIFF': 1e-8,
                'EDIFFG': -1e-4,
                'NSW': 100,
                'IBRION': 2
            })

    return wf

I would greatly appreciate any insights, examples, or references to relevant documentation that could assist me in addressing these issues.

Thank you for your time and support.

Best regards,
Zhao

I can comment on the magnetic moments.
I was working on an implementation but didn’t have the time to finish and test it again GitHub - JonathanSchmidt1/atomate2_other_forcefields at magnetic_phonons so at best use this for inspiration. The problem is that the pymatgen SpacegroupAnalyzer does not deal well with magnetic moments so you will have to disable the to primitive/conventional routines from the workflow and of course the lines of code that remove the magnetic moments. I would also enter an explicit supercell size. Then I would test it with e.g. the Cr example from phonopy phonopy/example/Cr at 3ffe35386fe4d668d4294982b2a0814e39ebac68 · phonopy/phonopy · GitHub and maybe another more complicated magnetic system where you know the outcome. Make sure that you give the workflow a primitive cell as input. Also check that the magnetic moments of the resulting supercells are as you would expect them. Best of luck!