示例#1
0
文件: atoms.py 项目: nateharms/hotbit
class ExtendedTrajectory:
    def __init__(self,filename,atoms,n,mode='w',fixrcm=False):
        """
        Trajectory for multiple copies of unit cell.

        parameters:
        ===========
        filename:    output .traj -file
        atoms:       hotbit.Atoms object
        n:           tuple of number of symmetry operations
                     or list of tuples for the symmetry operations
        mode:        'w' write or 'a' append
        fixrcm:      Write trajectory with center of mass fixed at origin.
        """
        self.atoms = atoms
        self.n = n
        self.ext = self.atoms.extended_copy(n)
        self.traj = PickleTrajectory(filename,mode,self.ext) #,properties=['energy'])
        self.fixrcm = fixrcm

    def set_atoms(self,atoms):
        self.atoms = atoms
        self.ext = self.atoms.extended_copy(self.n)
        self.traj.set_atoms(self.ext)

    def write(self):
        cp = self.atoms.extended_copy(self.n)
        if self.fixrcm:
            cp.translate( -cp.get_center_of_mass() )
        self.ext.set_positions( cp.get_positions() )
        self.traj.write()
示例#2
0
文件: atoms.py 项目: pekkosk/hotbit
class ExtendedTrajectory:
    def __init__(self,filename,atoms,n,mode='w',fixrcm=False):
        """
        Trajectory for multiple copies of unit cell.

        parameters:
        ===========
        filename:    output .traj -file
        atoms:       hotbit.Atoms object
        n:           tuple of number of symmetry operations
                     or list of tuples for the symmetry operations
        mode:        'w' write or 'a' append
        fixrcm:      Write trajectory with center of mass fixed at origin.
        """
        self.atoms = atoms
        self.n = n
        self.ext = self.atoms.extended_copy(n)
        self.traj = PickleTrajectory(filename,mode,self.ext) #,properties=['energy'])
        self.fixrcm = fixrcm

    def set_atoms(self,atoms):
        self.atoms = atoms
        self.ext = self.atoms.extended_copy(self.n)
        self.traj.set_atoms(self.ext)

    def write(self):
        cp = self.atoms.extended_copy(self.n)
        if self.fixrcm:
            cp.translate( -cp.get_center_of_mass() )
        self.ext.set_positions( cp.get_positions() )
        self.traj.write()