@@ -22,14 +22,21 @@ class Supercell(BaseDriver_):
22
22
mult: iterable
23
23
Multiplicity to construct the supercell in the a,b,c
24
24
directions.
25
+ lattice: bool
26
+ If the lattice should be constructed for the supercell. If the lattice
27
+ is not constructed, then the supercell is build around the positive
28
+ and negative directions of the given unit cell. If the lattice is
29
+ constructed, then the supercell is only built in the positive directions.
25
30
26
31
"""
27
32
def __init__ (self ,
28
33
mult = (3 ,3 ,3 ),
34
+ lattice = True ,
29
35
track_molecules = True ,
30
36
standardize = True ,
31
37
bonds_kw = {}):
32
38
self .mult = mult
39
+ self .lattice = lattice
33
40
self .track_molecules = track_molecules
34
41
self .bonds_kw = bonds_kw
35
42
self .standardize = standardize
@@ -108,19 +115,29 @@ def construct_supercell(self, struct=None):
108
115
109
116
if self .track_molecules :
110
117
supercell .properties ["molecule_idx" ] = supercell_molecule_idx
118
+
119
+ if self .lattice :
120
+ supercell_lv = np .dot (np .diag (self .mult ), lv )
121
+ supercell .lattice = supercell_lv
111
122
112
123
return supercell
113
124
114
125
115
126
def get_range (self , idx ):
116
- ### Put half on the positive and negative side of unit cell
117
- temp_half = int (self .mult [idx ]/ 2 )
118
- if (self .mult [idx ] % 2 ) == 0 :
119
- correction = 1
127
+ if not self .lattice :
128
+ ### Put half on the positive and negative side of unit cell
129
+ temp_half = int (self .mult [idx ]/ 2 )
130
+ if (self .mult [idx ] % 2 ) == 0 :
131
+ correction = 1
132
+ else :
133
+ correction = 0
134
+ first_half = np .arange (0 ,temp_half + 1 )
135
+ second_half = np .arange (- temp_half + correction ,0 )
136
+ final_range = np .hstack ([first_half , second_half ])
137
+ return final_range
120
138
else :
121
- correction = 0
122
-
123
- return np .arange (- temp_half + correction , temp_half + 1 )
139
+ ### Return only positive direction for construction
140
+ return np .arange (0 ,self .mult [idx ],1 )
124
141
125
142
126
143
0 commit comments