Пример #1
0
Файл: md.py Проект: wes-amat/ase
    def __init__(self, atoms, timestep, trajectory, logfile=None,
                 loginterval=1, append_trajectory=False):

        # dt as to be attached _before_ parent class is initialized
        self.dt = timestep

        Dynamics.__init__(self, atoms, logfile=None, trajectory=trajectory,
                          append_trajectory=append_trajectory)

        self.masses = self.atoms.get_masses()
        self.max_steps = None

        if 0 in self.masses:
            warnings.warn('Zero mass encountered in atoms; this will '
                          'likely lead to errors if the massless atoms '
                          'are unconstrained.')

        self.masses.shape = (-1, 1)

        if not self.atoms.has('momenta'):
            self.atoms.set_momenta(np.zeros([len(self.atoms), 3]))

        if logfile:
            self.attach(MDLogger(dyn=self, atoms=atoms, logfile=logfile),
                        interval=loginterval)
Пример #2
0
    def __init__(self,
                 atoms,
                 timestep,
                 integrator='verlet',
                 trajectory=None,
                 traj_interval=1000,
                 logfile=None,
                 loginterval=100):
        Dynamics.__init__(self, atoms, None, None)

        self.dt = timestep

        if integrator == 'verlet':
            self.run_style = 'verlet'
        else:
            raise RuntimeError('Unknown integrator: %s' % thermostat)

        if trajectory:
            if isinstance(trajectory, str):
                trajectory = PickleTrajectory(trajectory, 'w', atoms)
            self.attach(trajectory, interval=traj_interval)

        if logfile:
            self.attach(MDLogger(dyn=self, atoms=atoms, logfile=logfile),
                        interval=loginterval)

        self.fix = None
        self.cell_relaxed = False
Пример #3
0
Файл: md.py Проект: slabanja/ase
 def __init__(self,
              atoms,
              timestep,
              trajectory,
              logfile=None,
              loginterval=1):
     Dynamics.__init__(self, atoms, logfile=None, trajectory=trajectory)
     self.dt = timestep
     self.masses = self.atoms.get_masses()
     self.masses.shape = (-1, 1)
     if logfile:
         self.attach(MDLogger(dyn=self, atoms=atoms, logfile=logfile),
                     interval=loginterval)
Пример #4
0
Файл: md.py Проект: uu1477/MyAse
 def __init__(self, atoms, timestep, trajectory, logfile=None,
              loginterval=1):
     Dynamics.__init__(self, atoms, logfile=None, trajectory=trajectory)
     self.dt = timestep
     self.masses = self.atoms.get_masses()
     if 0 in self.masses:
         warnings.warn('Zero mass encountered in atoms; this will '
                       'likely lead to errors if the massless atoms '
                       'are unconstrained.')
     self.masses.shape = (-1, 1)
     if logfile:
         self.attach(MDLogger(dyn=self, atoms=atoms, logfile=logfile),
                     interval=loginterval)
Пример #5
0
def md_run(origin_poscar_path, index):
    print('%d' % index + ' In directory : %s' % origin_poscar_path)
    atoms = read(origin_poscar_path)

    calc = ANNCalculator(potentials={
        "Ga": "Ga.10t-10t.nn",
        "N": "N.10t-10t.nn"
    })
    atoms.set_calculator(calc)

    MaxwellBoltzmannDistribution(atoms, 1200 * kB)
    Stationary(atoms)

    md = NVT(atoms, timestep=2 * fs, temperature=1000 * kB, friction=0.05)
    logger = MDLogger(md, atoms, '-', stress=True)
    md.attach(logger, interval=1)
    traj = Trajectory(
        "nvt_%s.traj" % (origin_poscar_path.split('/')[-1].split('.xsf')[0]),
        "w", atoms)
    md.attach(traj.write, interval=200)

    md.run(40000)
Пример #6
0
    def __init__(self,
                 atoms,
                 timestep,
                 trajectory,
                 logfile=None,
                 loginterval=1,
                 append_trajectory=False):

        # dt as to be attached _before_ parent class is initialized
        self.dt = timestep

        Dynamics.__init__(self, atoms, logfile=None, trajectory=None)

        self.masses = self.atoms.get_masses()
        self.max_steps = None

        if 0 in self.masses:
            warnings.warn('Zero mass encountered in atoms; this will '
                          'likely lead to errors if the massless atoms '
                          'are unconstrained.')

        self.masses.shape = (-1, 1)

        if not self.atoms.has('momenta'):
            self.atoms.set_momenta(np.zeros([len(self.atoms), 3]))

        # Trajectory is attached here instead of in Dynamics.__init__
        # to respect the loginterval argument.
        if trajectory is not None:
            if isinstance(trajectory, str):
                mode = "a" if append_trajectory else "w"
                trajectory = Trajectory(trajectory, mode=mode, atoms=atoms)
            self.attach(trajectory, interval=loginterval)

        if logfile:
            self.attach(MDLogger(dyn=self, atoms=atoms, logfile=logfile),
                        interval=loginterval)
Пример #7
0
    def __init__(self, atoms, timestep, trajectory, logfile=None,
                 loginterval=1, append_trajectory=False):
        """Molecular Dynamics object.

        Parameters:

        atoms: Atoms object
            The Atoms object to operate on.

        timestep: float
            The time step in ASE time units.

        trajectory: Trajectory object or str
            Attach trajectory object.  If *trajectory* is a string a
            Trajectory will be constructed.  Use *None* for no
            trajectory.

        logfile: file object or str (optional)
            If *logfile* is a string, a file with that name will be opened.
            Use '-' for stdout.

        loginterval: int (optional)
            Only write a log line for every *loginterval* time steps.  
            Default: 1

        append_trajectory: boolean (optional)
            Defaults to False, which causes the trajectory file to be
            overwriten each time the dynamics is restarted from scratch.
            If True, the new structures are appended to the trajectory
            file instead.
        """
        # dt as to be attached _before_ parent class is initialized
        self.dt = timestep

        Dynamics.__init__(self, atoms, logfile=None, trajectory=None)

        self.masses = self.atoms.get_masses()
        self.max_steps = None

        if 0 in self.masses:
            warnings.warn('Zero mass encountered in atoms; this will '
                          'likely lead to errors if the massless atoms '
                          'are unconstrained.')

        self.masses.shape = (-1, 1)

        if not self.atoms.has('momenta'):
            self.atoms.set_momenta(np.zeros([len(self.atoms), 3]))

        # Trajectory is attached here instead of in Dynamics.__init__
        # to respect the loginterval argument.
        try:
            if trajectory is not None:
                if isinstance(trajectory, str):
                    mode = "a" if append_trajectory else "w"
                    trajectory = self.ensureclose(
                        Trajectory(trajectory, mode=mode, atoms=atoms)
                    )
                self.attach(trajectory, interval=loginterval)

            if logfile:
                logger = self.ensureclose(
                    MDLogger(dyn=self, atoms=atoms, logfile=logfile))
                self.attach(logger, loginterval)

        except BaseException:
            self._closefiles()
            raise