About the use of MagneticStructureEnumerator class

Can anyone provide a specific script example using MagneticStructureEnumerator class? Thank you very much.

Hi @obaica,

I don’t think I have an example notebook available right now, but a good place to look for examples of usage are actually the test cases. Take a look here:

Hope this helps! Let me know if you have follow-up questions.

Matt

1 Like

Thank you very much!

No worries, let me know if you’re still having issues however and I can paste a more specific example – maybe if you share what input structure you’re using, or what you’re hoping to achieve with the class?

hi, I am using the powerful magnetic configuration generator “MagneticStructureEnumerator”, and I want to know the theory behind this class, is there any related paper that I could read about?

POSCAR file

0.5(Cl24 Cs8 Cu2 Sb4)
1.0
       13.0256996155         0.0000000000         0.0000000000
        0.0000000000         7.3267002106         0.0000000000
       -4.8683449943         0.0000000000        12.0604826481
   Cs   Sb   Fe   Cl
    8    4    2   24
Direct
     0.624059975         0.000000000         0.870050013
     0.375940025         0.000000000         0.129949987
     0.124059975         0.500000000         0.870050013
     0.875940025         0.500000000         0.129949987
     0.374430001         0.500000000         0.620209992
     0.625569999         0.500000000         0.379790008
     0.874430001         0.000000000         0.620209992
     0.125569999         0.000000000         0.379790008
     0.251980007         0.000000000         0.759029984
     0.748019993         0.000000000         0.240970016
     0.751980007         0.500000000         0.759029984
     0.248019993         0.500000000         0.240970016
     0.500000000         0.000000000         0.500000000
     0.000000000         0.500000000         0.500000000
     0.612399995         0.221660003         0.611060023
     0.387600005         0.778339982         0.388939977
     0.387600005         0.221660003         0.388939977
     0.612399995         0.778339982         0.611060023
     0.112399995         0.721660018         0.611060023
     0.887600005         0.278339982         0.388939977
     0.887600005         0.721660018         0.388939977
     0.112399995         0.278339982         0.611060023
     0.374639988         0.000000000         0.634840012
     0.625360012         0.000000000         0.365159988
     0.874639988         0.500000000         0.634840012
     0.125360012         0.500000000         0.365159988
     0.370020002         0.238380000         0.873459995
     0.629979968         0.761619985         0.126540005
     0.629979968         0.238380000         0.126540005
     0.370020002         0.761619985         0.873459995
     0.870020032         0.738380015         0.873459995
     0.129979998         0.261619985         0.126540005
     0.129979998         0.738380015         0.126540005
     0.870020032         0.261619985         0.873459995
     0.133729994         0.000000000         0.877950013
     0.866270006         0.000000000         0.122049987
     0.633729994         0.500000000         0.877950013
     0.366270006         0.500000000         0.122049987

script

from pymatgen.core.structure import Structure
from pymatgen.analysis.magnetism.analyzer import MagneticStructureEnumerator
from pymatgen.analysis.magnetism.analyzer import CollinearMagneticStructureAnalyzer

# 定义初始磁矩
mag_species = {"Cu": 1}

# 
structure = Structure.from_file("POSCAR")

# 
mag_struct_enum = MagneticStructureEnumerator(structure, default_magmoms=mag_species, strategies=["antiferromagnetic", "antiferromagnetic_by_motif", "ferrimagnetic_by_motif", "ferrimagnetic_by_species"])

# 
for i, mag_struct in enumerate(mag_struct_enum.structures):
    # 
    mag_analyzer = CollinearMagneticStructureAnalyzer(mag_struct)
    ifmag_analyzer.is_magnetic:
        # 
        mag_poscar_name = "POSCAR_mag_" + str(i+1)

        # 
        mag_struct.to(fmt="poscar", filename=mag_poscar_name)

I would like to know if it is correct to use the above script to generate various antiferromagnetic structures.