Skip to content

Commit 4a41879

Browse files
committed
handling two issues: 1- enforces low index axis in tilt/symmtilts 2- handles the decimal cell in fcc/bcc
1 parent 7a5a97d commit 4a41879

File tree

2 files changed

+39
-15
lines changed

2 files changed

+39
-15
lines changed

gb_code/csl_generator.py

Lines changed: 37 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,24 @@ def SmallestInteger(a):
157157
break
158158
return (testV, i) if integer_array(testV) else None
159159

160+
def integerMatrix(a):
161+
"""
162+
returns an integer matrix from row vectors.
163+
"""
164+
Found = True
165+
b = np.zeros((3,3))
166+
a = np.array(a)
167+
for i in range(3):
168+
for j in range(1, 2000):
169+
testV = j * a[i]
170+
if integer_array(testV):
171+
b[i] = testV
172+
break
173+
if all(b[i] == 0):
174+
Found = False
175+
print("Can not make integer matrix!")
176+
return (b) if Found else None
177+
160178
def SymmEquivalent(arr):
161179
"""
162180
returns cubic symmetric eqivalents of the given 2 dimensional vector.
@@ -419,19 +437,23 @@ def Find_Orthogonal_cell(basis, uvw, m, n, GB1):
419437
Min_1, Min_2 = Create_minimal_cell_Method_1(Sigma, uvw, R)
420438
# Find Ortho vectors:
421439
tol = 0.001
422-
Found = False
423-
for i in range(len(indice_0)):
424-
v1 = (indice_0[i, 0] * Min_1[:, 0] +
425-
indice_0[i, 1] * Min_1[:, 1] +
426-
indice_0[i, 2] * Min_1[:, 2])
427-
v2 = (indice_0[i, 0] * Min_2[:, 0] +
428-
indice_0[i, 1] * Min_2[:, 1] +
429-
indice_0[i, 2] * Min_2[:, 2])
430-
if ang(v1, OrthoCell_1[:, 0]) < tol:
431-
OrthoCell_1[:, 1] = v1
432-
OrthoCell_2[:, 1] = v2
433-
Found = True
434-
break
440+
if ang(OrthoCell_1[:, 0], uvw) < tol:
441+
OrthoCell_1[:, 1] = uvw
442+
OrthoCell_2[:, 1] = uvw
443+
else:
444+
445+
for i in range(len(indice_0)):
446+
447+
v1 = (indice_0[i, 0] * Min_1[:, 0] +
448+
indice_0[i, 1] * Min_1[:, 1] +
449+
indice_0[i, 2] * Min_1[:, 2])
450+
v2 = (indice_0[i, 0] * Min_2[:, 0] +
451+
indice_0[i, 1] * Min_2[:, 1] +
452+
indice_0[i, 2] * Min_2[:, 2])
453+
if ang(v1, OrthoCell_1[:, 0]) < tol:
454+
OrthoCell_1[:, 1] = v1
455+
OrthoCell_2[:, 1] = v2
456+
break
435457
OrthoCell_1[:, 2] = np.cross(OrthoCell_1[:, 0], OrthoCell_1[:, 1])
436458
OrthoCell_2[:, 2] = np.cross(OrthoCell_2[:, 0], OrthoCell_2[:, 1])
437459

@@ -451,7 +473,8 @@ def Find_Orthogonal_cell(basis, uvw, m, n, GB1):
451473
OrthoCell_1 = OrthoCell_1.astype(float)
452474
OrthoCell_2 = OrthoCell_2.astype(float)
453475

454-
if basis == 'sc' or basis == 'diamond':
476+
if basis == 'sc' or basis == 'diamond' :
477+
455478
return ((OrthoCell_1.astype(float),
456479
OrthoCell_2.astype(float), Num.astype(int)))
457480

gb_code/gb_generator.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,13 +174,14 @@ def CSL_Ortho_unitcell_atom_generator(self):
174174
populates a unitcell from the orthogonal vectors.
175175
"""
176176
Or = self.ortho.T
177+
Orint = cslgen.integerMatrix(Or)
177178
LoopBound = np.zeros((3, 2), dtype=float)
178179
transformed = []
179180
CubeCoords = np.array([[1, 0, 0], [0, 1, 0], [0, 0, 1], [1, 1, 0],
180181
[0, 1, 1], [1, 0, 1], [1, 1, 1], [0, 0, 0]],
181182
dtype=float)
182183
for i in range(len(CubeCoords)):
183-
transformed.append(np.dot(Or.T, CubeCoords[i]))
184+
transformed.append(np.dot(Orint.T, CubeCoords[i]))
184185

185186
# Finding bounds for atoms in a CSL unitcell:
186187

0 commit comments

Comments
 (0)