Skip to content

Commit

Permalink
handling two issues: 1- enforces low index axis in tilt/symmtilts 2- …
Browse files Browse the repository at this point in the history
…handles the decimal cell in fcc/bcc
  • Loading branch information
oekosheri committed Feb 3, 2019
1 parent 7a5a97d commit 4a41879
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 15 deletions.
51 changes: 37 additions & 14 deletions gb_code/csl_generator.py
Expand Up @@ -157,6 +157,24 @@ def SmallestInteger(a):
break
return (testV, i) if integer_array(testV) else None

def integerMatrix(a):
"""
returns an integer matrix from row vectors.
"""
Found = True
b = np.zeros((3,3))
a = np.array(a)
for i in range(3):
for j in range(1, 2000):
testV = j * a[i]
if integer_array(testV):
b[i] = testV
break
if all(b[i] == 0):
Found = False
print("Can not make integer matrix!")
return (b) if Found else None

def SymmEquivalent(arr):
"""
returns cubic symmetric eqivalents of the given 2 dimensional vector.
Expand Down Expand Up @@ -419,19 +437,23 @@ def Find_Orthogonal_cell(basis, uvw, m, n, GB1):
Min_1, Min_2 = Create_minimal_cell_Method_1(Sigma, uvw, R)
# Find Ortho vectors:
tol = 0.001
Found = False
for i in range(len(indice_0)):
v1 = (indice_0[i, 0] * Min_1[:, 0] +
indice_0[i, 1] * Min_1[:, 1] +
indice_0[i, 2] * Min_1[:, 2])
v2 = (indice_0[i, 0] * Min_2[:, 0] +
indice_0[i, 1] * Min_2[:, 1] +
indice_0[i, 2] * Min_2[:, 2])
if ang(v1, OrthoCell_1[:, 0]) < tol:
OrthoCell_1[:, 1] = v1
OrthoCell_2[:, 1] = v2
Found = True
break
if ang(OrthoCell_1[:, 0], uvw) < tol:
OrthoCell_1[:, 1] = uvw
OrthoCell_2[:, 1] = uvw
else:

for i in range(len(indice_0)):

v1 = (indice_0[i, 0] * Min_1[:, 0] +
indice_0[i, 1] * Min_1[:, 1] +
indice_0[i, 2] * Min_1[:, 2])
v2 = (indice_0[i, 0] * Min_2[:, 0] +
indice_0[i, 1] * Min_2[:, 1] +
indice_0[i, 2] * Min_2[:, 2])
if ang(v1, OrthoCell_1[:, 0]) < tol:
OrthoCell_1[:, 1] = v1
OrthoCell_2[:, 1] = v2
break
OrthoCell_1[:, 2] = np.cross(OrthoCell_1[:, 0], OrthoCell_1[:, 1])
OrthoCell_2[:, 2] = np.cross(OrthoCell_2[:, 0], OrthoCell_2[:, 1])

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

if basis == 'sc' or basis == 'diamond':
if basis == 'sc' or basis == 'diamond' :

return ((OrthoCell_1.astype(float),
OrthoCell_2.astype(float), Num.astype(int)))

Expand Down
3 changes: 2 additions & 1 deletion gb_code/gb_generator.py
Expand Up @@ -174,13 +174,14 @@ def CSL_Ortho_unitcell_atom_generator(self):
populates a unitcell from the orthogonal vectors.
"""
Or = self.ortho.T
Orint = cslgen.integerMatrix(Or)
LoopBound = np.zeros((3, 2), dtype=float)
transformed = []
CubeCoords = np.array([[1, 0, 0], [0, 1, 0], [0, 0, 1], [1, 1, 0],
[0, 1, 1], [1, 0, 1], [1, 1, 1], [0, 0, 0]],
dtype=float)
for i in range(len(CubeCoords)):
transformed.append(np.dot(Or.T, CubeCoords[i]))
transformed.append(np.dot(Orint.T, CubeCoords[i]))

# Finding bounds for atoms in a CSL unitcell:

Expand Down

0 comments on commit 4a41879

Please sign in to comment.