# Magnetic Transition Pymatgen Error

I am trying to simulate the change in magnetic moments during a ferromagnetic to antiferromagnetic transition.

MagneticStructureEnumerator(SmFeO3_Mn_prop,
default_magmoms={"Sm3+":0.009 ,"Fe3+":4.36 ,"Mn3+":5.0 ,"O2-":0.173},
strategies=('ferromagnetic', 'antiferromagnetic'))


where SmFeO3_Mn_prop is $$\ce{SmFeO3}$$ (mp-20243 in the Materials Project database) doped with $$\ce{Mn}$$ replacing $$2$$ $$\ce{Fe}$$ atoms.

However when I apply the MagneticStructureEnumerator class it returns the message: <pymatgen.analysis.magnetism.analyzer.MagneticStructureEnumerator object at 0x7ff411d6da10>

How may I print the generated enumerator?

• I have made some edits to your question to remove/clarify some things, keep in mind stack exchange tends to be more direct than an informal email to someone. There is no need to be too formal, but questions that get right to the point tend to get better answers. Good first question though! Jul 15 at 17:12
– Tyberius
Jul 15 at 21:14
• @TristanMaxson Thanks for helping out here. I noticed the original version needed a bit of polishing, so I asked Tyberius to make some edits, since I was on a phone (not keyboard) while waiting at the cardiologist's office. It seems you got to it before he did, which is great. Jul 16 at 2:28

Oddly, despite the name, the class doesn't specifically implement any methods to do iteration directly on the object to access the structures. You can see in the source code, you can see the class doesn't have an __iter__ or __getitem__ method.

However, it does have attributes ordered_structures and ordered_structures_origin, which are lists of structures and the transformations used to create them respectively.

So with your enumerator, you should be able to print them with: print(your_enum.ordered_structures) or

for struct in your_enum.ordered_structures:
print(struct)


I wasn't able to find the attributes of the MagneticStructureEnumerator object in the pymatgen documentation, so figuring out certain features may require looking at the source code until the documentation for some of these objects is more fleshed out (or I may have just missed where these attributes were described).

• This should be the accepted answer. However, this should really be fixed given the name. I will bring this question up to the pymatgen people. Jul 15 at 20:04
• @TristanMaxson Yeah I had assumed your answer would work based on the name. It would presumably be a pretty simple "quality of life" addition to the code.
– Tyberius
Jul 15 at 20:11

I suspect this is not an error, but just an issue with how you are trying to print it. The enumerator object is an object, so when you print it attempts to give you information about the enumerator and not the actually enumeration. You can try to convert it to a list first, then print the enumeration.

This still might be difficult however to read, so you might try printing each magnetic structure independently and not all at once.

print(list(EnumeratorOfSomeData))

• Thanks a lot for your response ,however on doing so I am getting the error 'MagneticStructureEnumerator' object is not iterable Jul 15 at 19:25
• @k2_2009 Can you provide an example input? Jul 15 at 20:02