Skip to content

Commit 0f059e5

Browse files
authored
Merge pull request #2 from manny405/make_unit_tests
Add lattice...
2 parents 419e4b8 + 60bc1c3 commit 0f059e5

File tree

3 files changed

+25
-7
lines changed

3 files changed

+25
-7
lines changed

mcse/crystals/supercell.py

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,21 @@ class Supercell(BaseDriver_):
2222
mult: iterable
2323
Multiplicity to construct the supercell in the a,b,c
2424
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.
2530
2631
"""
2732
def __init__(self,
2833
mult=(3,3,3),
34+
lattice=True,
2935
track_molecules=True,
3036
standardize=True,
3137
bonds_kw={}):
3238
self.mult = mult
39+
self.lattice = lattice
3340
self.track_molecules = track_molecules
3441
self.bonds_kw = bonds_kw
3542
self.standardize = standardize
@@ -108,19 +115,29 @@ def construct_supercell(self, struct=None):
108115

109116
if self.track_molecules:
110117
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
111122

112123
return supercell
113124

114125

115126
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
120138
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)
124141

125142

126143

mcse/dimers/__init__.py

Whitespace-only changes.

setup.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
'mcse/plot',
1515
'mcse/libmpi',
1616
'mcse/workflow',
17+
'mcse/dimers',
1718
],
1819
install_requires=[
1920
'scipy>=1.5.0',

0 commit comments

Comments
 (0)