forked from DanielMarchand/aiida-alloy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaiida_create_triplet_structures.py
executable file
·75 lines (63 loc) · 2.62 KB
/
aiida_create_triplet_structures.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#!/usr/bin/env python
import aiida
aiida.load_profile()
from aiida.orm import Group
from aiida_create_solutesupercell_structures import *
import ase
import ase.build
import click
import numpy as np
import random
import itertools
@click.command()
@click.option('-a', '--lattice_size', required=True,
help="lattice length (in Ang) to use")
@click.option('-spsh', '--supercell_shape', required=True,
help="shape of the supercell to use, format: Nx,Ny,Nz")
@click.option('-me', '--matrix_element', required=True,
help="element to be used as the matrix")
@click.option('-te', '--triplet_elements', required=True,
help="elements to be used for the solute triplets")
@click.option('-sg', '--structure_group_label', required=True,
help="Output AiiDA group to store created structures")
@click.option('-sgd', '--structure_group_description', default="",
help="Description for output AiiDA group")
@click.option('-dr', '--dryrun', is_flag=True,
help="Prints structures and extras but does not store anything")
def launch(lattice_size, supercell_shape, matrix_element,
triplet_elements,
structure_group_label, structure_group_description,
dryrun):
"""
Script for generating solute triplets
"""
if not dryrun:
structure_group = Group.objects.get_or_create(
label=structure_group_label, description=structure_group_description)[0]
else:
structure_group = None
lattice_size = float(lattice_size)
supercell_shape = supercell_shape.split(',')
if len(supercell_shape) != 3:
sys.exit("supercell_shape must be of the form Nx,Ny,Nz")
base_extras = {
'lattice_size':lattice_size,
'supercell_shape':supercell_shape,
'matrix_element':matrix_element,
}
pure_structure = gen_ase_supercell(lattice_size, supercell_shape, matrix_element)
pure_extras = copy.deepcopy(base_extras)
triplet_elements = prep_elementlist(triplet_elements)
triplets = list(itertools.combinations_with_replacement(
triplet_elements, 3))
for triplet in triplets:
triplet_extras = copy.deepcopy(base_extras)
triplet_extras['triplet'] = triplet
triplet_structure = copy.deepcopy(pure_structure)
triplet_structure[0].symbol = triplet[0]
triplet_structure[1].symbol = triplet[1]
triplet_structure[2].symbol = triplet[2]
store_asestructure(triplet_structure, triplet_extras,
structure_group, dryrun)
if __name__ == "__main__":
launch()