msg-byu / enumlib

Derivative structure enumeration library
MIT License
59 stars 34 forks source link

Fortran Runtime Error in labeling_related.f90 #127

Open fadams-umd opened 3 weeks ago

fadams-umd commented 3 weeks ago

I'm using pymatgen.transformations.advanced_transformations.EnumerateStructureTransformation to order disordered structures. For some structures, I'm getting Fortran runtime errors from enumlib. Here is one of the errors I'm getting; I believe it's the same as #77.

See below for...

First, the pymatgen minimum working example (enum_error_mwe.py):

# # Windows path bodge, required on my Windows machine but unrelated to problem
# import os
# os.environ['PATHEXT'] += ';.PY'
# os.environ['PATH'] += os.pathsep + os.getcwd() + "\\..\\enumlib\\src"
# os.environ['PATH'] += os.pathsep + os.getcwd() + "\\..\\enumlib\\aux_src"

from pymatgen.core import Structure
from pymatgen.transformations.advanced_transformations import (
    EnumerateStructureTransformation,
)

disordered_structure = Structure.from_file('Sb8Ge2Te14.cif')

est = EnumerateStructureTransformation(
    min_cell_size=5,
    max_cell_size=5,
)

ordered_structure = est.apply_transformation(
    structure=disordered_structure,
)

The example structure, as found in Sb8Ge2Te14.cif:

# generated using pymatgen
data_Ge0.4Sb1.6Te2.8
_symmetry_space_group_name_H-M   'P 1'
_cell_length_a   10.74489572
_cell_length_b   10.74489572
_cell_length_c   10.74489621
_cell_angle_alpha   23.26376926
_cell_angle_beta   23.26376926
_cell_angle_gamma   23.26376624
_symmetry_Int_Tables_number   1
_chemical_formula_structural   Ge0.4Sb1.6Te2.8
_chemical_formula_sum   'Ge0.4 Sb1.6 Te2.8'
_cell_volume   169.89340677
_cell_formula_units_Z   1
loop_
 _symmetry_equiv_pos_site_id
 _symmetry_equiv_pos_as_xyz
  1  'x, y, z'
loop_
 _atom_type_symbol
 _atom_type_oxidation_number
  Ge2+  2.0
  Sb3+  3.0
  Te2-  -2.0
loop_
 _atom_site_type_symbol
 _atom_site_label
 _atom_site_symmetry_multiplicity
 _atom_site_fract_x
 _atom_site_fract_y
 _atom_site_fract_z
 _atom_site_occupancy
  Ge2+  Ge0  1  0.60327800  0.60327800  0.60327800  0.2
  Sb3+  Sb1  1  0.60327800  0.60327800  0.60327800  0.8
  Ge2+  Ge2  1  0.39672200  0.39672200  0.39672200  0.2
  Sb3+  Sb3  1  0.39672200  0.39672200  0.39672200  0.8
  Te2-  Te4  1  0.78462500  0.78462500  0.78462500
  0.9333333333333333
  Te2-  Te5  1  0.21537500  0.21537500  0.21537500
  0.9333333333333333
  Te2-  Te6  1  0.00000000  0.00000000  0.00000000
  0.9333333333333333

Error trace (with directories shortened for clarity):

At line 841 of file labeling_related.f90
Fortran runtime error: Index '1' of dimension 1 of array 'vslabels' outside of expected range (1:0)

Error termination. Backtrace:
#0  0xfc65fe37 in generate_labeling_from_index
        at C:/.../enumlib/src/labeling_related.f90:841
#1  0xfc6642bf in __labeling_related_MOD_write_labelings
        at C:/.../enumlib/src/labeling_related.f90:718
#2  0xfc6856b5 in __derivative_structure_generator_MOD_gen_multilattice_derivatives
        at C:/.../enumlib/src/derivative_structure_generator.f90:1482
#3  0xfc706d01 in driver
        at C:/.../enumlib/src/driver.f90:39
#4  0xfc706d46 in main
        at C:/.../enumlib/src/driver.f90:2

C:\...\pymatgen\transformations\advanced_transformations.py:408: UserWarning: Unable to enumerate for max_cell_size = 5
  warnings.warn(f"Unable to enumerate for {max_cell_size = }")
Traceback (most recent call last):
  File "c:\...\enum_error_mwe.py", line 19, in <module>
    ordered_structure = est.apply_transformation(
                        ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\...\pymatgen\transformations\advanced_transformations.py", line 411, in apply_transformation
    raise ValueError("Unable to enumerate")
ValueError: Unable to enumerate

A bit of extra Python to generate the struct_enum.in file:

# # Windows path bodge, unrelated to problem
# import os
# os.environ['PATHEXT'] += ';.PY'
# os.environ['PATH'] += os.pathsep + os.getcwd() + "\\..\\enumlib\\src"
# os.environ['PATH'] += os.pathsep + os.getcwd() + "\\..\\enumlib\\aux_src"

from pymatgen.core import Structure
from pymatgen.command_line.enumlib_caller import EnumlibAdaptor

disordered_structure = Structure.from_file('Sb8Ge2Te14.cif')

ea = EnumlibAdaptor(
    structure=disordered_structure,
    min_cell_size=5,
    max_cell_size=5,
)

ea._gen_input_file()

...and finally, the contents of struct_enum.in:

Ge0.4 Sb1.6 Te2.8
bulk
4.243854 0.000000 9.871296
2.032012 3.725751 9.871296
0.000000 0.000000 10.744896
4
5
3.786092 2.247664 18.392431 0/1
2.489774 1.478088 12.095057 0/1
4.924201 2.923318 23.921246 2/3
1.351665 0.802434 6.566243 2/3
0.000000 0.000000 0.000000 2/3
5 5
0.001
full
20 20 250
80 80 250
140 140 250
10 10 250

Other ternary systems with similar structures & compositions have worked fine. Thanks in advance!