Esempio n. 1
0
File: cell.py Progetto: dlmv/qcldm
    def __init__(self, atoms, vectors, cryst_mat, symops, assym_n):
        self.vectors = vectors
        self.cryst_mat = cryst_mat
        self.symops = symops
        self.assym_n = assym_n
        self.atoms = atoms
        self.coord_param_mat = None
        self.vector_param_mat = None
        self.cell = self.shift([0, 0, 0])
        if self.vectors:
            self.bordered_cell = [a.real_atom() for a in self.shift([0, 0, 0])]
            start = Vector(0, 0, 0)
            for i in range(2):
                for j in range(2):
                    for k in range(2):
                        self.bordered_cell.append(
                            AtomVector(
                                'x', start + self.vectors[0] * i +
                                self.vectors[1] * j + self.vectors[2] * k, {}))

        if self.vectors:
            self.supercell = self.extended_cell(1)
        else:
            self.supercell = self.cell
        self.neighbours = NeighbourCache(self)
Esempio n. 2
0
File: cell.py Progetto: dlmv/qcldm
 def cartesian_atom(self, atom, cryst_cell=False):
     vector_basis = np.array([v._data for v in self.vectors])
     if (cryst_cell):
         crysmat = np.array(self.cryst_mat)
         vector_basis = np.transpose(crysmat).dot(vector_basis)
     unrel = np.transpose(vector_basis).dot(atom.position()._data)
     return AtomVector(atom.name(), Vector(unrel), {})
Esempio n. 3
0
def reflect(c, ax1, ax2):
    ax_refl = ax1.position().cross(ax2.position())
    res = []
    for a in c:
        res.append(
            AtomVector(a._name, a._vector - a._vector.projection(ax_refl) * 2))
    return res
Esempio n. 4
0
def rotate_to_axis(ax1, ax2, c2):
    ax_rot = ax1.position().cross(ax2.position())
    if rough_equal(ax_rot.length, 0, 0.000001):
        if rough_equal(ax1.distance(ax2), 0, 0.000001):
            return c2
        else:
            res = []
            for a in c2:
                res.append(AtomVector(a._name, -a._vector))
            return res
    angle = ax2.position().signed_angle_to(ax1.position(), ax_rot)
    rot = Orientation.new_axis_angle(ax_rot, angle)
    res = []
    for a in c2:
        res.append(AtomVector(a._name, rot * a._vector))
    return res
Esempio n. 5
0
File: cell.py Progetto: dlmv/qcldm
 def true_relative_atom(self, atom, cryst_cell=False):
     vector_basis = np.array([v._data for v in self.vectors])
     if (cryst_cell):
         crysmat = np.array(self.cryst_mat)
         vector_basis = np.transpose(crysmat).dot(vector_basis)
     rel = np.linalg.inv(np.transpose(vector_basis)).dot(
         atom.position()._data)
     return AtomVector(atom.name(), Vector(rel), {})
Esempio n. 6
0
def rotate_along(ax2, ay1, ay2, c2):
    ax_rot = ax2.position()
    r1 = ay1.position() - ay1.position().projection(ax_rot)
    r2 = ay2.position() - ay2.position().projection(ax_rot)
    angle = r2.signed_angle_to(r1, ax_rot)
    rot = Orientation.new_axis_angle(ax_rot, angle)
    res = []
    for a in c2:
        res.append(AtomVector(a._name, rot * a._vector))
    return res
Esempio n. 7
0
File: cell.py Progetto: dlmv/qcldm
 def real_atom(self):
     return AtomVector(self.name(), self.position(), self.data())
Esempio n. 8
0
File: cell.py Progetto: dlmv/qcldm
 def apply_symop(self, atom, symop):
     n, inv, rot_mat, translator = symop
     new_vec = np.array(rot_mat).dot(atom.position()._data)
     new_vec += np.array(translator)
     new_vec = self.validate_rel(new_vec)
     return AtomVector(atom.name(), Vector(new_vec), {})