Mn doped SmFeO3 property prediction

I am trying to predict the magnetic order transformations in Mn doped SmFeO3 using the MagneticStructureEnumerator class. However I am getting the error [WinError 193] %1 is not a valid Win32 application. How do I resolve this issue?

Attached is the complete discription of the error

OSError Traceback (most recent call last)
in
37 from pymatgen.transformations.advanced_transformations import MagOrderingTransformation
38 mag_par = MagOrderingTransformation({“Sm3+”:5,“Fe3+”:5,“O2-”:0,“Mn3+”:4}, order_parameter=0.5)
—> 39 SmFeO3_Mn_Mag_new = mag_par.apply_transformation(SmFeO3_Mn_prop)
40 print(SmFeO3_Mn_Mag_new)

~\anaconda3\lib\site-packages\pymatgen\transformations\advanced_transformations.py in apply_transformation(self, structure, return_ranked_list)
940 t = EnumerateStructureTransformation(**enum_kwargs)
941
→ 942 alls = t.apply_transformation(structure, return_ranked_list=return_ranked_list)
943
944 # handle the fact that EnumerateStructureTransformation can either

~\anaconda3\lib\site-packages\pymatgen\transformations\advanced_transformations.py in apply_transformation(self, structure, return_ranked_list)
445 )
446 try:
→ 447 adaptor.run()
448 except EnumError:
449 warn(“Unable to enumerate for max_cell_size = {}”.format(max_cell_size))

~\anaconda3\lib\site-packages\pymatgen\command_line\enumlib_caller.py in run(self)
140 self._gen_input_file()
141 # Perform the actual enumeration
→ 142 num_structs = self._run_multienum()
143 # Read in the enumeration output as structures.
144 if num_structs > 0:

~\anaconda3\lib\site-packages\pymatgen\command_line\enumlib_caller.py in _run_multienum(self)
292 def _run_multienum(self):
293
→ 294 p = subprocess.Popen([enum_cmd],
295 stdout=subprocess.PIPE,
296 stdin=subprocess.PIPE, close_fds=True)

~\anaconda3\lib\subprocess.py in init(self, args, bufsize, executable, stdin, stdout, stderr, preexec_fn, close_fds, shell, cwd, env, universal_newlines, startupinfo, creationflags, restore_signals, start_new_session, pass_fds, encoding, errors, text)
852 encoding=encoding, errors=errors)
853
→ 854 self._execute_child(args, executable, preexec_fn, close_fds,
855 pass_fds, cwd, env,
856 startupinfo, creationflags, shell,

~\anaconda3\lib\subprocess.py in _execute_child(self, args, executable, preexec_fn, close_fds, pass_fds, cwd, env, startupinfo, creationflags, shell, p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite, unused_restore_signals, unused_start_new_session)
1305 # Start the process
1306 try:
→ 1307 hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
1308 # no special security
1309 None, None,

OSError: [WinError 193] %1 is not a valid Win32 application

In the beginning of the file enumlib_caller.py it says

This module implements an interface to enumlib, Gus Hart’s excellent Fortran code for enumerating derivative structures.
This module depends on a compiled enumlib with the executables enum.x and makestr.x available in the path. Please download the library at GitHub - msg-byu/enumlib: Derivative structure enumeration library and follow the instructions in the README to compile these two executables accordingly.

I haven’t used this myself, but the error sounds like you haven’t compiled those?

-Peter

Thanks for your response.
I have compiled enumlibcaller and have also added the required files to the path.
Not including the files associated with enumlib leads to a different error altogether.

I see. Not sure then, but have you verified that enum.x runs correctly in your command line?

No not yet.Am trying to do this now. The reason I didnt test this initially was because a different error was being displayed when there were problems pertaining to the installation of enumlib related dependencies.

When I downloaded the 32 bit version of anaconda and ran the same program ,the same error is being displayed.

Hi Peter,thanks its almost sorted I compiled enum.x and makestr.x .However I am having a bit of difficulty appending them to my path in jupyter.Do I need to add them to my anaconda directory or another directory to integrate them with jupyter?

Great! If you add the directory where enum.x is located to your PYTHONPATH variable then it should work fine, I believe. If not, there are many solutions to this if you search on Google or StackOverflow. Good luck!
-Peter

OSError Traceback (most recent call last)
in
29 from pymatgen.transformations.advanced_transformations import MagOrderingTransformation
30 mag_par = MagOrderingTransformation({“Sm3+”:5,“Fe3+”:5,“O2-”:0,“Mn3+”:4}, order_parameter=0.5)
—> 31 SmFeO3_Mn_Mag_new = mag_par.apply_transformation(SmFeO3_Mn_prop)
32 print(SmFeO3_Mn_Mag_new)

~/anaconda3/lib/python3.7/site-packages/pymatgen/transformations/advanced_transformations.py in apply_transformation(self, structure, return_ranked_list)
943 t = EnumerateStructureTransformation(**enum_kwargs)
944
→ 945 alls = t.apply_transformation(structure, return_ranked_list=return_ranked_list)
946
947 # handle the fact that EnumerateStructureTransformation can either

~/anaconda3/lib/python3.7/site-packages/pymatgen/transformations/advanced_transformations.py in apply_transformation(self, structure, return_ranked_list)
455 )
456 try:
→ 457 adaptor.run()
458 except EnumError:
459 warnings.warn(“Unable to enumerate for max_cell_size = {}”.format(max_cell_size))

~/anaconda3/lib/python3.7/site-packages/pymatgen/command_line/enumlib_caller.py in run(self)
136 # Read in the enumeration output as structures.
137 if num_structs > 0:
→ 138 self.structures = self._get_structures(num_structs)
139 else:
140 raise EnumError(“Unable to enumerate structure.”)

~/anaconda3/lib/python3.7/site-packages/pymatgen/command_line/enumlib_caller.py in _get_structures(self, num_structs)
331 rs = subprocess.Popen([makestr_cmd] + options,
332 stdout=subprocess.PIPE,
→ 333 stdin=subprocess.PIPE, close_fds=True)
334 stdout, stderr = rs.communicate()
335 if stderr:

~/anaconda3/lib/python3.7/subprocess.py in init(self, args, bufsize, executable, stdin, stdout, stderr, preexec_fn, close_fds, shell, cwd, env, universal_newlines, startupinfo, creationflags, restore_signals, start_new_session, pass_fds, encoding, errors, text)
798 c2pread, c2pwrite,
799 errread, errwrite,
→ 800 restore_signals, start_new_session)
801 except:
802 # Cleanup if the child failed starting.

~/anaconda3/lib/python3.7/subprocess.py in _execute_child(self, args, executable, preexec_fn, close_fds, pass_fds, cwd, env, startupinfo, creationflags, shell, p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite, restore_signals, start_new_session)
1549 if errno_num == errno.ENOENT:
1550 err_msg += ': ’ + repr(err_filename)
→ 1551 raise child_exception_type(errno_num, err_msg, err_filename)
1552 raise child_exception_type(err_msg)
1553

OSError: [Errno 8] Exec format error: ‘/mnt/c/Users/k2/anaconda3/makeStr.py’

how might I resolve this?

Hi , I managed to get the code to work ,however there is a problem in the output ,It is returning a hexadecimal memory location instead of a list :-

<pymatgen.analysis.magnetism.analyzer.MagneticStructureEnumerator object at 0x7f179de1cc90>

how do I resolve this?

Congrats on solving the previous issue! Could you share what you have done to solve the issue, in case someone else has a similar issue?

Regarding the new problem: Can you share your code? Which output do you want? It seems like you are printing out the Python object itself.

will share my solution after I successfully get the output .Its better to have everything in one post

I wish to print the output of the MagneticStructureEnumerator class i.e the proposed orderings in different strategies such as ferromagnetic ,paramagnetic etc.
My code is :-
import requests
response = requests.get(“https://www.materialsproject.org/rest/v2/materials/mp-1234/vasp”,
{“API_KEY”: “CLASSIFIED”})
from pymatgen.ext.matproj import MPRester
with MPRester(“CLASSIFIED”) as mpr:
SmFeO3 = mpr.get_structure_by_material_id(“mp-20243”)

from pymatgen.transformations.standard_transformations import AutoOxiStateDecorationTransformation
ox_trans = AutoOxiStateDecorationTransformation()
SmFeO3_ox = ox_trans.apply_transformation(SmFeO3)

from pymatgen.transformations.site_transformations import PartialRemoveSitesTransformation
part_mat = PartialRemoveSitesTransformation([[4], [7]],[1.0, 1.0],algo=0)
SmFeO3_part_mat = part_mat.apply_transformation(SmFeO3_ox)

from pymatgen.transformations.site_transformations import InsertSitesTransformation
Mn_dope = InsertSitesTransformation([“Mn3+”, “Mn3+”],[[0.5, 0.0, 0.0],[0.0, 0.5, 0.0]], coords_are_cartesian=False, validate_proximity=True)
SmFeO3_Mn_doped = Mn_dope.apply_transformation(SmFeO3_part_mat)

from pymatgen.transformations.site_transformations import AddSitePropertyTransformation
Mn_prop = AddSitePropertyTransformation({“magmom”: [0.009,0.009,0.009,0.009,5.0,5.0,4.361,4.36,0.174,0.173,0.174,0.173,0.174,0.184,0.174,0.185,0.174,0.184,0.174,0.185]})
SmFeO3_Mn_prop = Mn_prop.apply_transformation(SmFeO3_Mn_doped)

import pymatgen.command_line.enumlib_caller
from pymatgen.analysis.magnetism.analyzer import MagneticStructureEnumerator
mag = MagneticStructureEnumerator(SmFeO3_Mn_prop,default_magmoms={“Sm3+”:0.009 ,“Fe3+”:4.36 ,“Mn3+”:5.0 ,“O2-”:0.173},strategies=(‘ferromagnetic’, ‘antiferromagnetic’))
print(list(mag))

The output i am getting is ‘MagneticStructureEnumerator’ object is not iterable

I looked into the MagneticStructureEnumerator class and it’s indeed a bit confusing/misleading as it says it returns a list of structures, but it actually doesn’t. To get the structures, you need to instead replace the last line with

print(mag.ordered_structures)

There is also an ordered_structures_origins property in case you need that as well.

-Peter

Thanks a lot