8
$\begingroup$

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?

$\endgroup$
3
  • 1
    $\begingroup$ 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! $\endgroup$ – Tristan Maxson Jul 15 at 17:12
  • 1
    $\begingroup$ I added your comments to Tristan into the question. In the future, you can edit your question add additional information rather than using comments. This makes it easier to find and can have improved formatting. $\endgroup$ – Tyberius Jul 15 at 21:14
  • 1
    $\begingroup$ @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. $\endgroup$ – Nike Dattani Jul 16 at 2:28
6
$\begingroup$

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).

$\endgroup$
2
  • 2
    $\begingroup$ 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. $\endgroup$ – Tristan Maxson Jul 15 at 20:04
  • 1
    $\begingroup$ @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. $\endgroup$ – Tyberius Jul 15 at 20:11
5
$\begingroup$

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))
$\endgroup$
2
  • 1
    $\begingroup$ Thanks a lot for your response ,however on doing so I am getting the error 'MagneticStructureEnumerator' object is not iterable $\endgroup$ – k2_2009 Jul 15 at 19:25
  • 1
    $\begingroup$ @k2_2009 Can you provide an example input? $\endgroup$ – Tristan Maxson Jul 15 at 20:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.