Interfaces to online databases and random crystal generation

The StructureImporter class has the purpose to produce structure pools which can be further analysed or used as input for high-throughput workflows straightaway. As such the class offers interfaces to several online databases as well as to the PyXtaL python package to randomly generate crystal structures.

[1]:
from aim2dat.strct import StructureImporter

strct_imp = StructureImporter()

Interfaces to the following databases are currently supported:

Crystals can be imported by using the implemented import_* or append_* functions and giving the chemical formula for a specific stoichiometry or an element set as input parameter:

[2]:
Cs2Te_structures = strct_imp.import_from_oqmd("Cs2Te")
NaSb_structures = strct_imp.import_from_oqmd("Cs-Sb")

The imported structures of the query are returned as a StructureCollection object but also added to an internal StructureCollection object within the StructureImporter class that can accessed via the structures property:

[3]:
print(strct_imp.structures)
----------------------------------------------------------------------
------------------------ Structure Collection ------------------------
----------------------------------------------------------------------

 - Number of structures: 116
 - Elements: Cs-Sb-Te

                              Structures
  - OQMD_6763           Cs8Te4              [True  True  True ]
  - OQMD_1239241        Cs4Te2              [True  True  True ]
  - OQMD_1343671        Cs2Te               [True  True  True ]
  - OQMD_1343380        Cs4Te2              [True  True  True ]
  - OQMD_1473530        Cs2Te               [True  True  True ]
  ...
  - OQMD_1343518        Cs18Sb6             [True  True  True ]
  - OQMD_1339303        Cs12Sb4             [True  True  True ]
  - OQMD_1521868        Cs6Sb2              [True  True  True ]
  - OQMD_1376097        Cs5Sb4              [True  True  True ]
  - OQMD_650085         Cs20Sb32            [True  True  True ]
----------------------------------------------------------------------

An overview of all imported structures is given by the string representation of the class:

[4]:
print(strct_imp)
----------------------------------------------------------------------
------------------------ Structure Collection ------------------------
----------------------------------------------------------------------

                         Imported from: oqmd
   - Number of structures: 116
   - Elements: Cs-Sb-Te

----------------------------------------------------------------------

                     Chemical element constraints
   Neglecting elemental structures: False

                     Chemical formula constraints
   Not set.

                        Attribute constraints
   Not set.

----------------------------------------------------------------------

Adding constraints

As you may have noticed in the string representation of the object, one can apply constraintsto the structures that are imported. Before a new structure is imported all of the set constraints are checked and only structures that abide all constraints are added.

New constraints can be set via the functions:

Additionally, the neglect_elemental_structures property can be set to prevent importing structures merely consisting of one element.

As an example, we set a constraint on the chemical formula:

[5]:
strct_imp.add_chem_formula_constraint("Na3Sb")

Looking at the string representation, we find the new constraint listed with the additional information that the formula is ‘reduced’. This means that also multiple of the formula, e.g. structures with the formula ‘Na6Sb2’ are allowed as well.

[6]:
print(strct_imp)
----------------------------------------------------------------------
------------------------ Structure Collection ------------------------
----------------------------------------------------------------------

                         Imported from: oqmd
   - Number of structures: 116
   - Elements: Cs-Sb-Te

----------------------------------------------------------------------

                     Chemical element constraints
   Neglecting elemental structures: False

                     Chemical formula constraints
   - Na3Sb (reduced)

                        Attribute constraints
   Not set.

----------------------------------------------------------------------

In order to only allow structures with a specific composition, we can set the keyword argument reduced_formula to False:

[7]:
strct_imp.add_chem_formula_constraint("Na2Sb2", reduced_formula=False)
print(strct_imp)
----------------------------------------------------------------------
------------------------ Structure Collection ------------------------
----------------------------------------------------------------------

                         Imported from: oqmd
   - Number of structures: 116
   - Elements: Cs-Sb-Te

----------------------------------------------------------------------

                     Chemical element constraints
   Neglecting elemental structures: False

                     Chemical formula constraints
   - Na3Sb (reduced)
   - Na2Sb2

                        Attribute constraints
   Not set.

----------------------------------------------------------------------

If we now import the binary system ‘Na-Sb’ from the open quantum materials database, we will only receive crystals with the composition ‘Na2Sb2’ or with a Na:Sb ratio of 3:1:

[8]:
structures_NaSb = strct_imp.import_from_oqmd("Na-Sb")
print(structures_NaSb)
OQMD_8534 - Chem. formula constraint: Na doesn't match with Na3Sb, Na2Sb2.
OQMD_8535 - Chem. formula constraint: Na2 doesn't match with Na3Sb, Na2Sb2.
OQMD_30779 - Chem. formula constraint: Na3 doesn't match with Na3Sb, Na2Sb2.
OQMD_1214546 - Chem. formula constraint: Na doesn't match with Na3Sb, Na2Sb2.
OQMD_1214635 - Chem. formula constraint: Na doesn't match with Na3Sb, Na2Sb2.
OQMD_1214724 - Chem. formula constraint: Na4 doesn't match with Na3Sb, Na2Sb2.
OQMD_1214813 - Chem. formula constraint: Na29 doesn't match with Na3Sb, Na2Sb2.
OQMD_1214902 - Chem. formula constraint: Na20 doesn't match with Na3Sb, Na2Sb2.
OQMD_1214991 - Chem. formula constraint: Na8 doesn't match with Na3Sb, Na2Sb2.
OQMD_1215080 - Chem. formula constraint: Na4 doesn't match with Na3Sb, Na2Sb2.
OQMD_1215169 - Chem. formula constraint: Na doesn't match with Na3Sb, Na2Sb2.
OQMD_1215258 - Chem. formula constraint: Na2 doesn't match with Na3Sb, Na2Sb2.
OQMD_1215347 - Chem. formula constraint: Na2 doesn't match with Na3Sb, Na2Sb2.
OQMD_1215437 - Chem. formula constraint: Na4 doesn't match with Na3Sb, Na2Sb2.
OQMD_1215526 - Chem. formula constraint: Na2 doesn't match with Na3Sb, Na2Sb2.
OQMD_1215615 - Chem. formula constraint: Na2 doesn't match with Na3Sb, Na2Sb2.
OQMD_1215704 - Chem. formula constraint: Na doesn't match with Na3Sb, Na2Sb2.
OQMD_1215793 - Chem. formula constraint: Na2 doesn't match with Na3Sb, Na2Sb2.
OQMD_1215882 - Chem. formula constraint: Na3 doesn't match with Na3Sb, Na2Sb2.
OQMD_1215971 - Chem. formula constraint: Na4 doesn't match with Na3Sb, Na2Sb2.
OQMD_1216063 - Chem. formula constraint: Na3 doesn't match with Na3Sb, Na2Sb2.
OQMD_1277928 - Chem. formula constraint: Na28 doesn't match with Na3Sb, Na2Sb2.
OQMD_2030325 - Chem. formula constraint: Na doesn't match with Na3Sb, Na2Sb2.
OQMD_2030329 - Chem. formula constraint: Na4 doesn't match with Na3Sb, Na2Sb2.
OQMD_2015716 - Chem. formula constraint: Na8 doesn't match with Na3Sb, Na2Sb2.
OQMD_2030326 - Chem. formula constraint: Na8 doesn't match with Na3Sb, Na2Sb2.
OQMD_2054101 - Chem. formula constraint: Na48 doesn't match with Na3Sb, Na2Sb2.
Entry for OQMD_31044 already imported.
Entry for OQMD_9214 already imported.
Entry for OQMD_18780 already imported.
Entry for OQMD_9672 already imported.
Entry for OQMD_9221 already imported.
Entry for OQMD_18986 already imported.
Entry for OQMD_51014 already imported.
Entry for OQMD_92588 already imported.
Entry for OQMD_670516 already imported.
Entry for OQMD_1215725 already imported.
Entry for OQMD_676194 already imported.
Entry for OQMD_1214567 already imported.
Entry for OQMD_1214656 already imported.
Entry for OQMD_1214745 already imported.
Entry for OQMD_1214834 already imported.
Entry for OQMD_1214923 already imported.
Entry for OQMD_1215012 already imported.
Entry for OQMD_1215101 already imported.
Entry for OQMD_1215190 already imported.
Entry for OQMD_1215279 already imported.
Entry for OQMD_1215368 already imported.
Entry for OQMD_1215458 already imported.
Entry for OQMD_1215547 already imported.
Entry for OQMD_1215636 already imported.
Entry for OQMD_1215814 already imported.
Entry for OQMD_1215903 already imported.
Entry for OQMD_1215992 already imported.
Entry for OQMD_1216084 already imported.
Entry for OQMD_676462 already imported.
Entry for OQMD_1277930 already imported.
Entry for OQMD_1280366 already imported.
Entry for OQMD_1522240 already imported.
Entry for OQMD_1787572 already imported.
OQMD_306088 - Chem. formula constraint: NaSb doesn't match with Na3Sb, Na2Sb2.
OQMD_327172 - Chem. formula constraint: NaSb doesn't match with Na3Sb, Na2Sb2.
OQMD_337630 - Chem. formula constraint: NaSb doesn't match with Na3Sb, Na2Sb2.
OQMD_5018 - Chem. formula constraint: Na8Sb8 doesn't match with Na3Sb, Na2Sb2.
OQMD_1105273 - Chem. formula constraint: NaSb doesn't match with Na3Sb, Na2Sb2.
OQMD_1108400 - Chem. formula constraint: Na4Sb4 doesn't match with Na3Sb, Na2Sb2.
OQMD_1223474 - Chem. formula constraint: NaSb doesn't match with Na3Sb, Na2Sb2.
OQMD_1230445 - Chem. formula constraint: NaSb doesn't match with Na3Sb, Na2Sb2.
OQMD_1798866 - Chem. formula constraint: Na8Sb8 doesn't match with Na3Sb, Na2Sb2.
OQMD_1240145 - Chem. formula constraint: Na2Sb4 doesn't match with Na3Sb, Na2Sb2.
OQMD_1280912 - Chem. formula constraint: Na4Sb8 doesn't match with Na3Sb, Na2Sb2.
OQMD_1435987 - Chem. formula constraint: Na2Sb4 doesn't match with Na3Sb, Na2Sb2.
OQMD_1592744 - Chem. formula constraint: Na2Sb4 doesn't match with Na3Sb, Na2Sb2.
OQMD_302790 - Chem. formula constraint: NaSb3 doesn't match with Na3Sb, Na2Sb2.
OQMD_313332 - Chem. formula constraint: NaSb3 doesn't match with Na3Sb, Na2Sb2.
OQMD_321867 - Chem. formula constraint: Na2Sb6 doesn't match with Na3Sb, Na2Sb2.
OQMD_346353 - Chem. formula constraint: NaSb3 doesn't match with Na3Sb, Na2Sb2.
OQMD_1277608 - Chem. formula constraint: Na2Sb6 doesn't match with Na3Sb, Na2Sb2.
OQMD_1798772 - Chem. formula constraint: NaSb3 doesn't match with Na3Sb, Na2Sb2.
OQMD_1438117 - Chem. formula constraint: Na4Sb20 doesn't match with Na3Sb, Na2Sb2.
OQMD_1603356 - Chem. formula constraint: NaSb5 doesn't match with Na3Sb, Na2Sb2.
OQMD_1240146 - Chem. formula constraint: Na4Sb2 doesn't match with Na3Sb, Na2Sb2.
OQMD_1589918 - Chem. formula constraint: Na4Sb2 doesn't match with Na3Sb, Na2Sb2.
OQMD_1340253 - Chem. formula constraint: Na6Sb4 doesn't match with Na3Sb, Na2Sb2.
OQMD_1340156 - Chem. formula constraint: Na8Sb6 doesn't match with Na3Sb, Na2Sb2.
OQMD_1339841 - Chem. formula constraint: Na5Sb4 doesn't match with Na3Sb, Na2Sb2.
----------------------------------------------------------------------
------------------------ Structure Collection ------------------------
----------------------------------------------------------------------

 - Number of structures: 6
 - Elements: Na-Sb

                              Structures
  - OQMD_5156           Na6Sb2              [True  True  True ]
  - OQMD_300783         Na3Sb               [True  True  True ]
  - OQMD_311325         Na3Sb               [True  True  True ]
  - OQMD_323874         Na6Sb2              [True  True  True ]
  - OQMD_348360         Na3Sb               [True  True  True ]
  - OQMD_2030774        Na3Sb               [True  True  True ]
----------------------------------------------------------------------

All constraints can be removed via the function remove_constraints:

[9]:
strct_imp.remove_constraints()
print(strct_imp)
----------------------------------------------------------------------
------------------------ Structure Collection ------------------------
----------------------------------------------------------------------

                         Imported from: oqmd
   - Number of structures: 122
   - Elements: Cs-Na-Sb-Te

----------------------------------------------------------------------

                     Chemical element constraints
   Neglecting elemental structures: False

                     Chemical formula constraints
   Not set.

                        Attribute constraints
   Not set.

----------------------------------------------------------------------

Generating random crystal structure interfacing the PyXtaL package

In addition to the interfaces to online databases the StructureImporter can also generate random crystal structures with a certain composition by making use of the PyXtaL python package.

To do so the function generate_random_crystals is used:

[10]:
random_crystals = strct_imp.generate_random_crystals("Cs2Te", max_structures=3)
print(random_crystals)
----------------------------------------------------------------------
------------------------ Structure Collection ------------------------
----------------------------------------------------------------------

 - Number of structures: 3
 - Elements: Cs-Te

                              Structures
  - pyxtal_6746c3f3cf794990a93e105ee1613732 Cs4Te2              [True  True  True ]
  - pyxtal_e3f58370b43541bca657a40e4f129972 Cs16Te8             [True  True  True ]
  - pyxtal_2cb2d02798334b1e8977fd1d9a0eb6ee Cs14Te7             [True  True  True ]
----------------------------------------------------------------------