def get_reciprocal_metric_tensor(lattice: Lattice) -> np.ndarray: """Reciprocal metric tensor as defined in EMsoft. Parameters ---------- lattice Crystal structure lattice. Returns ------- np.ndarray """ a, b, c = lattice.abcABG()[:3] ca, cb, cg = lattice.ca, lattice.cb, lattice.cg sa, sb, sg = lattice.sa, lattice.sb, lattice.sg terms_12_21 = a * b * (c ** 2) * (ca * cb - cg) terms_13_31 = a * (b ** 2) * c * (cg * ca - cb) terms_23_32 = (a ** 2) * b * c * (cb * cg - ca) return np.array( [ [(b * c * sa) ** 2, terms_12_21, terms_13_31], [terms_12_21, (a * c * sb) ** 2, terms_23_32], [terms_13_31, terms_23_32, (a * b * sg) ** 2], ] ) / np.linalg.det(lattice.metrics)
def get_direct_structure_matrix(lattice: Lattice) -> np.ndarray: """Direct structure matrix as defined in EMsoft. Parameters ---------- lattice Crystal structure lattice. Returns ------- """ a, b, c = lattice.abcABG()[:3] ca, cb, cg = lattice.ca, lattice.cb, lattice.cg sa, sb, sg = lattice.sa, lattice.sb, lattice.sg return np.array([ [a, b * cg, c * cb], [0, b * sg, -c * (cb * cg - ca) / sg], [0, 0, lattice.volume / (a * b * sg)], ])