Skip to article frontmatterSkip to article content

Building structures

In the following we show examples on how to generate some complex structures like surfaces, supercells, heterostructures. Basically, we rely on already well established libraries (ASE, Pymatgen) to build up the structure and attach some properties, and then we generate the StructureDataMutable.

Surfaces

The first examples is a simple Al(111) surface with an adsorbed H atom on top. We follow the ASE example. Moreover, we want to have our adsorbed H with +1 charge.

from aiida import load_profile
load_profile()

from aiida_atomistic import StructureData, StructureDataMutable

from ase.build import fcc111, add_adsorbate

slab = fcc111('Al', size=(2,2,3))
add_adsorbate(slab, 'H', 1.5, 'ontop')

slab.set_initial_charges([0]*(len(slab)-1)+[1])

slab.center(vacuum=10.0, axis=2)

Then, we can transform it into our StructureDataMutable:

mutable_structure = StructureDataMutable.from_ase(slab)
mutable_structure.properties.sites
[<SiteImmutable: kind name 'Al0' @ 1.4318912319027588,0.8267027881893224,10.0>, <SiteImmutable: kind name 'Al0' @ 4.295673695708277,0.8267027881893224,10.0>, <SiteImmutable: kind name 'Al0' @ 2.8637824638055176,3.3068111527572897,10.0>, <SiteImmutable: kind name 'Al0' @ 5.727564927611035,3.3068111527572897,10.0>, <SiteImmutable: kind name 'Al0' @ -1.5983186326405526e-17,1.6534055763786448,12.338268590217984>, <SiteImmutable: kind name 'Al0' @ 2.8637824638055176,1.6534055763786448,12.338268590217984>, <SiteImmutable: kind name 'Al0' @ 1.4318912319027586,4.133513940946612,12.338268590217984>, <SiteImmutable: kind name 'Al0' @ 4.295673695708277,4.133513940946612,12.338268590217984>, <SiteImmutable: kind name 'Al0' @ 0.0,0.0,14.676537180435968>, <SiteImmutable: kind name 'Al0' @ 2.8637824638055176,0.0,14.676537180435968>, <SiteImmutable: kind name 'Al0' @ 1.4318912319027588,2.4801083645679673,14.676537180435968>, <SiteImmutable: kind name 'Al0' @ 4.295673695708277,2.4801083645679673,14.676537180435968>, <SiteImmutable: kind name 'H12' @ 0.0,0.0,16.176537180435968>]

We can then verify that indeed the periodic boundary conditions (PBC) are the expected ones:

mutable_structure.properties.pbc
[True, True, False]

and that indeed the last sites in the structure (the H) is positively charged:

mutable_structure.properties.charges
[0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0]

Supercells

from pymatgen.core.structure import Structure

structure = Structure.from_file('../examples/structure/data/Si.cif') 
structure.make_supercell(3)
Structure Summary Lattice abc : 11.600923949999999 11.600923949999999 11.60092395 angles : 59.999999999999986 59.999999999999986 59.999999999999986 volume : 1103.9839041177904 A : 10.046694848071313 0.0 5.800461975000001 B : 3.3488982826904383 9.472114740777569 5.800461975000001 C : 0.0 0.0 11.60092395 pbc : True True True PeriodicSite: Si0 (Si) (3.349, 2.368, 5.8) [0.25, 0.25, 0.25] PeriodicSite: Si0 (Si) (3.349, 2.368, 9.667) [0.25, 0.25, 0.5833] PeriodicSite: Si0 (Si) (3.349, 2.368, 13.53) [0.25, 0.25, 0.9167] PeriodicSite: Si0 (Si) (4.465, 5.525, 7.734) [0.25, 0.5833, 0.25] PeriodicSite: Si0 (Si) (4.465, 5.525, 11.6) [0.25, 0.5833, 0.5833] PeriodicSite: Si0 (Si) (4.465, 5.525, 15.47) [0.25, 0.5833, 0.9167] PeriodicSite: Si0 (Si) (5.581, 8.683, 9.667) [0.25, 0.9167, 0.25] PeriodicSite: Si0 (Si) (5.581, 8.683, 13.53) [0.25, 0.9167, 0.5833] PeriodicSite: Si0 (Si) (5.581, 8.683, 17.4) [0.25, 0.9167, 0.9167] PeriodicSite: Si0 (Si) (6.698, 2.368, 7.734) [0.5833, 0.25, 0.25] PeriodicSite: Si0 (Si) (6.698, 2.368, 11.6) [0.5833, 0.25, 0.5833] PeriodicSite: Si0 (Si) (6.698, 2.368, 15.47) [0.5833, 0.25, 0.9167] PeriodicSite: Si0 (Si) (7.814, 5.525, 9.667) [0.5833, 0.5833, 0.25] PeriodicSite: Si0 (Si) (7.814, 5.525, 13.53) [0.5833, 0.5833, 0.5833] PeriodicSite: Si0 (Si) (7.814, 5.525, 17.4) [0.5833, 0.5833, 0.9167] PeriodicSite: Si0 (Si) (8.93, 8.683, 11.6) [0.5833, 0.9167, 0.25] PeriodicSite: Si0 (Si) (8.93, 8.683, 15.47) [0.5833, 0.9167, 0.5833] PeriodicSite: Si0 (Si) (8.93, 8.683, 19.33) [0.5833, 0.9167, 0.9167] PeriodicSite: Si0 (Si) (10.05, 2.368, 9.667) [0.9167, 0.25, 0.25] PeriodicSite: Si0 (Si) (10.05, 2.368, 13.53) [0.9167, 0.25, 0.5833] PeriodicSite: Si0 (Si) (10.05, 2.368, 17.4) [0.9167, 0.25, 0.9167] PeriodicSite: Si0 (Si) (11.16, 5.525, 11.6) [0.9167, 0.5833, 0.25] PeriodicSite: Si0 (Si) (11.16, 5.525, 15.47) [0.9167, 0.5833, 0.5833] PeriodicSite: Si0 (Si) (11.16, 5.525, 19.33) [0.9167, 0.5833, 0.9167] PeriodicSite: Si0 (Si) (12.28, 8.683, 13.53) [0.9167, 0.9167, 0.25] PeriodicSite: Si0 (Si) (12.28, 8.683, 17.4) [0.9167, 0.9167, 0.5833] PeriodicSite: Si0 (Si) (12.28, 8.683, 21.27) [0.9167, 0.9167, 0.9167] PeriodicSite: Si1 (Si) (2.233, 1.579, 3.867) [0.1667, 0.1667, 0.1667] PeriodicSite: Si1 (Si) (2.233, 1.579, 7.734) [0.1667, 0.1667, 0.5] PeriodicSite: Si1 (Si) (2.233, 1.579, 11.6) [0.1667, 0.1667, 0.8333] PeriodicSite: Si1 (Si) (3.349, 4.736, 5.8) [0.1667, 0.5, 0.1667] PeriodicSite: Si1 (Si) (3.349, 4.736, 9.667) [0.1667, 0.5, 0.5] PeriodicSite: Si1 (Si) (3.349, 4.736, 13.53) [0.1667, 0.5, 0.8333] PeriodicSite: Si1 (Si) (4.465, 7.893, 7.734) [0.1667, 0.8333, 0.1667] PeriodicSite: Si1 (Si) (4.465, 7.893, 11.6) [0.1667, 0.8333, 0.5] PeriodicSite: Si1 (Si) (4.465, 7.893, 15.47) [0.1667, 0.8333, 0.8333] PeriodicSite: Si1 (Si) (5.581, 1.579, 5.8) [0.5, 0.1667, 0.1667] PeriodicSite: Si1 (Si) (5.581, 1.579, 9.667) [0.5, 0.1667, 0.5] PeriodicSite: Si1 (Si) (5.581, 1.579, 13.53) [0.5, 0.1667, 0.8333] PeriodicSite: Si1 (Si) (6.698, 4.736, 7.734) [0.5, 0.5, 0.1667] PeriodicSite: Si1 (Si) (6.698, 4.736, 11.6) [0.5, 0.5, 0.5] PeriodicSite: Si1 (Si) (6.698, 4.736, 15.47) [0.5, 0.5, 0.8333] PeriodicSite: Si1 (Si) (7.814, 7.893, 9.667) [0.5, 0.8333, 0.1667] PeriodicSite: Si1 (Si) (7.814, 7.893, 13.53) [0.5, 0.8333, 0.5] PeriodicSite: Si1 (Si) (7.814, 7.893, 17.4) [0.5, 0.8333, 0.8333] PeriodicSite: Si1 (Si) (8.93, 1.579, 7.734) [0.8333, 0.1667, 0.1667] PeriodicSite: Si1 (Si) (8.93, 1.579, 11.6) [0.8333, 0.1667, 0.5] PeriodicSite: Si1 (Si) (8.93, 1.579, 15.47) [0.8333, 0.1667, 0.8333] PeriodicSite: Si1 (Si) (10.05, 4.736, 9.667) [0.8333, 0.5, 0.1667] PeriodicSite: Si1 (Si) (10.05, 4.736, 13.53) [0.8333, 0.5, 0.5] PeriodicSite: Si1 (Si) (10.05, 4.736, 17.4) [0.8333, 0.5, 0.8333] PeriodicSite: Si1 (Si) (11.16, 7.893, 11.6) [0.8333, 0.8333, 0.1667] PeriodicSite: Si1 (Si) (11.16, 7.893, 15.47) [0.8333, 0.8333, 0.5] PeriodicSite: Si1 (Si) (11.16, 7.893, 19.33) [0.8333, 0.8333, 0.8333]
mutable_structure = StructureDataMutable.from_pymatgen(structure)
mutable_structure.properties.cell
[[10.046694848071313, 0.0, 5.800461975000001], [3.3488982826904383, 9.472114740777569, 5.800461975000001], [0.0, 0.0, 11.60092395]]

We can notice that actually the kinds now are collapsed into only one, because when we read the Pymatgen structure, an automatic detection of kinds runs and only one if found, i.e. there are no properties which allow a particular distinction:

set(mutable_structure.properties.kinds)
{'Si0'}

we can actually untrigger this detection by setting the detect_kinds input parameter to False, when we initialise the StructureDataMutable from Pymatgen:

mutable_structure = StructureDataMutable.from_pymatgen(structure,detect_kinds=False)
set(mutable_structure.properties.kinds)
{'Si0', 'Si1'}

Supercell and properties

Usually, we want the properties to be propagated in to atoms in a supercell, when we generate it from a unit cell. This can be ensured, once again, using the ASE/Pymatgen libraries:

from ase.build import bulk, make_supercell
atoms = bulk('NaCl', 'rocksalt', a=5.64)
atoms.set_initial_charges([1, -1] * (len(atoms) // 2))
supercell = make_supercell(atoms, [[2, 0, 0], [0, 2, 0], [0, 0, 2]])
supercell.get_initial_charges()
array([ 1., -1., 1., -1., 1., -1., 1., -1., 1., -1., 1., -1., 1., -1., 1., -1.])
mutable_structure = StructureDataMutable.from_ase(supercell)
mutable_structure.properties.charges
[1.0, -1.0, 1.0, -1.0, 1.0, -1.0, 1.0, -1.0, 1.0, -1.0, 1.0, -1.0, 1.0, -1.0, 1.0, -1.0]

Of course, if we want to add a property which is only supported in the atomistic package, e.g. hubbard, we can only attach it once the StructureDataMutable of the ASE/Pymatgen supercell is generated.

set(mutable_structure.properties.kinds)
{'Cl1', 'Na0'}
mutable_structure.initialize_onsites_hubbard("Na0", '3d', 4, 'U', use_kinds=True)
mutable_structure.properties.hubbard.parameters
[HubbardParameters(atom_index=0, atom_manifold='3d', neighbour_index=0, neighbour_manifold='3d', translation=(0, 0, 0), value=4.0, hubbard_type='U')]

please note that this is just a dummy example where we put a random hubbard U on sodium. For more details on how to set up hubbard parameters, please refer to the aiida-quantumespresso with `StructureData page.