Beispiel #1
0
def hook5(lattice):
    lattice.logger.info(
        "Hook5: Output water molecules as rigid rotors (Euler).")
    cellmat = lattice.repcell.mat
    s = ""
    if cellmat[1, 0] == 0 and cellmat[2, 0] == 0 and cellmat[2, 1] == 0:
        s += "@BOX3\n"
        s += "{0} {1} {2}\n".format(cellmat[0, 0] * 10, cellmat[1, 1] * 10,
                                    cellmat[2, 2] * 10)
    else:
        s += "@BOX9\n"
        for d in range(3):
            s += "{0} {1} {2}\n".format(cellmat[0, d] * 10, cellmat[1, d] * 10,
                                        cellmat[2, d] * 10)
    s += "@NX3A\n"
    s += "{0}\n".format(len(lattice.reppositions))
    for pos, rot in zip(lattice.reppositions, lattice.rotmatrices):
        position = np.dot(pos, cellmat) * 10  #in Angstrom
        euler = rigid.quat2euler(rigid.rotmat2quat(rot.transpose()))
        s += "{0:9.4f} {1:9.4f} {2:9.4f}  {3:9.4f} {4:9.4f} {5:9.4f}\n".format(
            position[0], position[1], position[2], euler[0], euler[1],
            euler[2])
    s = "\n".join(lattice.doc) + "\n" + s
    print(s, end="")
    lattice.logger.info("Hook5: end.")
Beispiel #2
0
def hook5(lattice):
    lattice.logger.info("Hook5: Output water molecules as rigid rotors (Quaternion).")
    cellmat = lattice.repcell.mat
    s = ""
    if cellmat[1,0] == 0 and cellmat[2,0] == 0 and cellmat[2,1] == 0:
        s += "@BOX3\n"
        s += "{0} {1} {2}\n".format(cellmat[0,0]*10,cellmat[1,1]*10,cellmat[2,2]*10)
    else:
        s += "@BOX9\n"
        for d in range(3):
            s += "{0} {1} {2}\n".format(cellmat[0,d]*10,cellmat[1,d]*10,cellmat[2,d]*10)
    s += "@NX4A\n"
    s += "{0}\n".format(len(lattice.reppositions))
    for pos,rot in zip(lattice.reppositions, lattice.rotmatrices):
        position = np.dot(pos, cellmat)*10   #in Angstrom
        quat     = rigid.rotmat2quat(rot.transpose())
        s += "{0:9.4f} {1:9.4f} {2:9.4f}  {3:9.4f} {4:9.4f} {5:9.4f} {6:9.4f}\n".format(position[0],
                                                                        position[1],
                                                                        position[2],
                                                                        quat[0],
                                                                        quat[1],
                                                                        quat[2],
                                                                        quat[3])
    s = "\n".join(lattice.doc) + "\n" + s
    print(s,end="")
    lattice.logger.info("Hook5: end.")
Beispiel #3
0
def hook5(lattice):
    lattice.logger.info("Hook5: Output water molecules as rigid rotors (Quaternion).")
    s = ""
    if lattice.repcell[1,0] == 0 and lattice.repcell[2,0] == 0 and lattice.repcell[2,1] == 0:
        s += "@BOX3\n"
        s += "{0} {1} {2}\n".format(lattice.repcell[0,0]*10,lattice.repcell[1,1]*10,lattice.repcell[2,2]*10)
    else:
        s += "@BOX9\n"
        for d in range(3):
            s += "{0} {1} {2}\n".format(lattice.repcell[0,d]*10,lattice.repcell[1,d]*10,lattice.repcell[2,d]*10)
    s += "@NX4A\n"
    s += "{0}\n".format(len(lattice.reppositions))
    for i in range(len(lattice.reppositions)):
        position = np.dot(lattice.reppositions[i],lattice.repcell)*10   #in Angstrom
        quat     = rigid.rotmat2quat(lattice.rotmatrices[i].transpose())
        s += "{0:9.4f} {1:9.4f} {2:9.4f}  {3:9.4f} {4:9.4f} {5:9.4f} {6:9.4f}\n".format(position[0],
                                                                        position[1],
                                                                        position[2],
                                                                        quat[0],
                                                                        quat[1],
                                                                        quat[2],
                                                                        quat[3])
    s = "\n".join(lattice.doc) + "\n" + s
    print(s,end="")
    lattice.logger.info("Hook5: end.")
Beispiel #4
0
def format_quaternion(positions, cell, rotmatrices, celltype):
    logger = logging.getLogger()
    logger.info("Output water molecules as rigid rotors (Quaternion).")
    s = ""
    if celltype == "rect":
        s += "@BOX3\n"
        s += "{0} {1} {2}\n".format(cell[0, 0] * 10, cell[1, 1] * 10,
                                    cell[2, 2] * 10)
    else:
        s += "@BOX9\n"
        for d in range(3):
            s += "{0} {1} {2}\n".format(cell[0, d] * 10, cell[1, d] * 10,
                                        cell[2, d] * 10)
    s += "@NX4A\n"
    s += "{0}\n".format(len(positions))
    for i in range(len(positions)):
        position = np.dot(positions[i], cell) * 10  #in Angstrom
        quat = rigid.rotmat2quat(rotmatrices[i].transpose())
        s += "{0:9.4f} {1:9.4f} {2:9.4f}  {3:9.4f} {4:9.4f} {5:9.4f} {6:9.4f}\n".format(
            position[0], position[1], position[2], quat[0], quat[1], quat[2],
            quat[3])
    return s