Enumerate Structure Transformation Error

Hi, I tried to generate potential vacancy ordering for Li0.5CoO2. Here is my code:

from pymatgen.core.structure import Structure
from pymatgen.transformations.advanced_transformations import EnumerateStructureTransformation
from pymatgen.io.vasp.inputs import Poscar
from pymatgen.alchemy.transmuters import StandardTransmuter

Li12 = Structure.from_file("Li1-2CoO2.cif")
Li12.add_oxidation_state_by_element({"Co": 3, "Li": 1, "O": -2})

order = EnumerateStructureTransformation(max_cell_size=2)
stm = StandardTransmuter.from_structures(Li12, order, extend_collection=10)
structures = stm.transformed_structures
for s in structures:

However, it shows the following error. I would appreciate if someone can help me out.

TypeError: 'EnumerateStructureTransformation' object is not iterable

Here is the cif file:

# generated using pymatgen
_symmetry_space_group_name_H-M   R-3m
_cell_length_a   2.84289827
_cell_length_b   2.84289827
_cell_length_c   14.14561550
_cell_angle_alpha   90.00000000
_cell_angle_beta   90.00000000
_cell_angle_gamma   120.00000000
_symmetry_Int_Tables_number   166
_chemical_formula_structural   LiCoO2
_chemical_formula_sum   'Li3 Co3 O6'
_cell_volume   99.00910176
_cell_formula_units_Z   3
  1  'x, y, z'
  2  '-x, -y, -z'
  3  '-y, x-y, z'
  4  'y, -x+y, -z'
  5  '-x+y, -x, z'
  6  'x-y, x, -z'
  7  'y, x, -z'
  8  '-y, -x, z'
  9  'x-y, -y, -z'
  10  '-x+y, y, z'
  11  '-x, -x+y, -z'
  12  'x, x-y, z'
  13  'x+2/3, y+1/3, z+1/3'
  14  '-x+2/3, -y+1/3, -z+1/3'
  15  '-y+2/3, x-y+1/3, z+1/3'
  16  'y+2/3, -x+y+1/3, -z+1/3'
  17  '-x+y+2/3, -x+1/3, z+1/3'
  18  'x-y+2/3, x+1/3, -z+1/3'
  19  'y+2/3, x+1/3, -z+1/3'
  20  '-y+2/3, -x+1/3, z+1/3'
  21  'x-y+2/3, -y+1/3, -z+1/3'
  22  '-x+y+2/3, y+1/3, z+1/3'
  23  '-x+2/3, -x+y+1/3, -z+1/3'
  24  'x+2/3, x-y+1/3, z+1/3'
  25  'x+1/3, y+2/3, z+2/3'
  26  '-x+1/3, -y+2/3, -z+2/3'
  27  '-y+1/3, x-y+2/3, z+2/3'
  28  'y+1/3, -x+y+2/3, -z+2/3'
  29  '-x+y+1/3, -x+2/3, z+2/3'
  30  'x-y+1/3, x+2/3, -z+2/3'
  31  'y+1/3, x+2/3, -z+2/3'
  32  '-y+1/3, -x+2/3, z+2/3'
  33  'x-y+1/3, -y+2/3, -z+2/3'
  34  '-x+y+1/3, y+2/3, z+2/3'
  35  '-x+1/3, -x+y+2/3, -z+2/3'
  36  'x+1/3, x-y+2/3, z+2/3'
  Li  Li0  3  0.00000000  0.00000000  0.00000000  0.5
  Co  Co1  3  -0.00000000  -0.00000000  0.50000000  1
  O  O2  6  0.00000000  0.00000000  0.23958700  1
1 Like

Looking at the docs (pymatgen.alchemy.transmuters module — pymatgen 2022.0.15 documentation), the from_structures() method of StandardTransmuter takes one positional argument, which should be a list of structures. Currently you are passing a single structure Li12, and also trying to pass a transformation as a second positional argument instead of as the optional keyword argument. I recommend trying

stm = StandardTransmuter.from_structures([Li12], transformations=[order], extend_collection=10)

to make sure that every argument which should be iterable, is iterable.

Thank you. I tried several times, but another error appeared. I installed gfortran via brew and I could find libgfortran.5.dylib only.

unfile('/Users/thienbinh/Documents/pymatgen/convex-hull/Li1-2CoO2.py', wdir='/Users/thienbinh/Documents/pymatgen/convex-hull')
dyld[45143]: Library not loaded: /usr/local/opt/gcc/lib/gcc/6/libgfortran.3.dylib
  Referenced from: /Users/thienbinh/opt/miniconda3/bin/enum.x
  Reason: tried: '/usr/local/opt/gcc/lib/gcc/6/libgfortran.3.dylib' (no such file), '/usr/local/lib/libgfortran.3.dylib' (no such file), '/usr/lib/libgfortran.3.dylib' (no such file)
/Users/thienbinh/opt/miniconda3/lib/python3.7/site-packages/pymatgen/transformations/advanced_transformations.py:430: UserWarning: Unable to enumerate for max_cell_size = 2
  warnings.warn("Unable to enumerate for max_cell_size = {}".format(max_cell_size))
Traceback (most recent call last):

  File "/var/folders/13/76vrjtyn2kgckfh7v76ndv900000gn/T/ipykernel_45118/399155039.py", line 1, in <module>
    runfile('/Users/thienbinh/Documents/pymatgen/convex-hull/Li1-2CoO2.py', wdir='/Users/thienbinh/Documents/pymatgen/convex-hull')

  File "/Users/thienbinh/opt/miniconda3/lib/python3.7/site-packages/debugpy/_vendored/pydevd/_pydev_bundle/pydev_umd.py", line 167, in runfile
    execfile(filename, namespace)

  File "/Users/thienbinh/opt/miniconda3/lib/python3.7/site-packages/debugpy/_vendored/pydevd/_pydev_imps/_pydev_execfile.py", line 25, in execfile
    exec(compile(contents + "\n", file, 'exec'), glob, loc)

  File "/Users/thienbinh/Documents/pymatgen/convex-hull/Li1-2CoO2.py", line 20, in <module>
    stm = StandardTransmuter.from_structures([Li12], transformations=[order], extend_collection=10)

  File "/Users/thienbinh/opt/miniconda3/lib/python3.7/site-packages/pymatgen/alchemy/transmuters.py", line 241, in from_structures
    return StandardTransmuter(tstruct, transformations, extend_collection)

  File "/Users/thienbinh/opt/miniconda3/lib/python3.7/site-packages/pymatgen/alchemy/transmuters.py", line 70, in __init__
    self.append_transformation(trans, extend_collection=extend_collection)

  File "/Users/thienbinh/opt/miniconda3/lib/python3.7/site-packages/pymatgen/alchemy/transmuters.py", line 136, in append_transformation
    new = x.append_transformation(transformation, extend_collection, clear_redo=clear_redo)

  File "/Users/thienbinh/opt/miniconda3/lib/python3.7/site-packages/pymatgen/alchemy/materials.py", line 115, in append_transformation
    self.final_structure, return_ranked_list=return_alternatives

  File "/Users/thienbinh/opt/miniconda3/lib/python3.7/site-packages/pymatgen/transformations/advanced_transformations.py", line 433, in apply_transformation
    raise ValueError("Unable to enumerate")

ValueError: Unable to enumerate