From 4a41879afc7024784676a1253ba86de5289ed2ce Mon Sep 17 00:00:00 2001 From: Sherri Hadian Date: Sun, 3 Feb 2019 14:32:13 +0100 Subject: [PATCH] handling two issues: 1- enforces low index axis in tilt/symmtilts 2- handles the decimal cell in fcc/bcc --- gb_code/csl_generator.py | 51 +++++++++++++++++++++++++++++----------- gb_code/gb_generator.py | 3 ++- 2 files changed, 39 insertions(+), 15 deletions(-) diff --git a/gb_code/csl_generator.py b/gb_code/csl_generator.py index 2ac0711..71b5ca6 100644 --- a/gb_code/csl_generator.py +++ b/gb_code/csl_generator.py @@ -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. @@ -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]) @@ -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))) diff --git a/gb_code/gb_generator.py b/gb_code/gb_generator.py index 3d10cc2..b578937 100644 --- a/gb_code/gb_generator.py +++ b/gb_code/gb_generator.py @@ -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: