Example #1
0
 def init(self, iterative):
     self.timestep_press = iterative.timestep
     if not self.restart:
         clean_momenta(iterative.pos, iterative.vel, iterative.masses, iterative.ff.system.cell)
     # determine the internal degrees of freedom
     if iterative.ndof is None:
         iterative.ndof = get_ndof_internal_md(len(iterative.ff.system.numbers), iterative.ff.system.cell.nvec)
     # determine barostat 'mass' following W = timecon*np.sqrt(n_part) * m_av
     #n_part = len(iterative.masses)
     #self.mass_press = self.timecon_press*np.sum(iterative.masses)/np.sqrt(len(iterative.ff.system.numbers))
     angfreq = 2*np.pi/self.timecon_press
     self.mass_press = (iterative.ndof+self.dim**2)*boltzmann*self.temp/angfreq**2/self.vol0**(2./3)
     if self.vel_press is None:
         # define initial barostat velocity
         self.vel_press = get_random_vel_press(self.mass_press, self.temp)
         if not self.anisotropic:
             self.vel_press = self.vel_press[0][0]
     # initialize the barostat thermostat if present
     if self.baro_thermo is not None:
         self.baro_thermo.chain.timestep = iterative.timestep
         self.baro_thermo.chain.set_ndof(self.baro_ndof)
     # make sure the volume of the cell will not change if applicable
     if self.vol_constraint:
         self.vel_press -= np.trace(self.vel_press)/3*np.eye(3)
     # compute gpos and vtens, since they differ
     # after symmetrising the cell tensor
     iterative.gpos[:] = 0.0
     iterative.vtens[:] = 0.0
     iterative.epot = iterative.ff.compute(iterative.gpos,iterative.vtens)
Example #2
0
File: npt.py Project: yfyh2013/yaff
 def init(self, iterative):
     self.timestep_press = iterative.timestep
     if not self.restart:
         clean_momenta(iterative.pos, iterative.vel, iterative.masses, iterative.ff.system.cell)
     # determine the internal degrees of freedom
     if iterative.ndof is None:
         iterative.ndof = get_ndof_internal_md(len(iterative.ff.system.numbers), iterative.ff.system.cell.nvec)
     # determine barostat 'mass' following W = timecon*np.sqrt(n_part) * m_av
     #n_part = len(iterative.masses)
     #self.mass_press = self.timecon_press*np.sum(iterative.masses)/np.sqrt(len(iterative.ff.system.numbers))
     angfreq = 2*np.pi/self.timecon_press
     self.mass_press = (iterative.ndof+self.dim**2)*boltzmann*self.temp/angfreq**2/self.vol0**(2./3)
     if self.vel_press is None:
         # define initial barostat velocity
         self.vel_press = get_random_vel_press(self.mass_press, self.temp)
         if not self.anisotropic:
             self.vel_press = self.vel_press[0][0]
     # initialize the barostat thermostat if present
     if self.baro_thermo is not None:
         self.baro_thermo.chain.timestep = iterative.timestep
         self.baro_thermo.chain.set_ndof(self.baro_ndof)
     # make sure the volume of the cell will not change if applicable
     if self.vol_constraint:
         self.vel_press -= np.trace(self.vel_press)/3*np.eye(3)
     # compute gpos and vtens, since they differ
     # after symmetrising the cell tensor
     iterative.gpos[:] = 0.0
     iterative.vtens[:] = 0.0
     iterative.epot = iterative.ff.compute(iterative.gpos,iterative.vtens)
Example #3
0
File: nvt.py Project: boegel/yaff
 def init(self, iterative):
     # It is mandatory to zero the external momenta.
     clean_momenta(iterative.pos, iterative.vel, iterative.masses,
                   iterative.ff.system.cell)
     if iterative.ndof is None:
         iterative.ndof = get_ndof_internal_md(
             iterative.pos.shape[0], iterative.ff.system.cell.nvec)
     self.kin = 0.5 * iterative.ndof * boltzmann * self.temp
Example #4
0
File: nvt.py Project: boegel/yaff
 def init(self, iterative):
     if not self.restart:
         # It is mandatory to zero the external momenta.
         clean_momenta(iterative.pos, iterative.vel, iterative.masses,
                       iterative.ff.system.cell)
     if iterative.ndof is None:
         iterative.ndof = get_ndof_internal_md(
             iterative.pos.shape[0], iterative.ff.system.cell.nvec)
Example #5
0
File: nvt.py Project: tovrstra/yaff
 def init(self, iterative):
     # It is mandatory to zero the external momenta.
     clean_momenta(iterative.pos, iterative.vel, iterative.masses, iterative.ff.system.cell)
     # If needed, determine the number of _internal_ degrees of freedom.
     if iterative.ndof is None:
         iterative.ndof = get_ndof_internal_md(iterative.pos.shape[0], iterative.ff.system.cell.nvec)
     # Configure the chain.
     self.chain.timestep = iterative.timestep
     self.chain.set_ndof(iterative.ndof)
Example #6
0
 def init(self, iterative):
     # It is mandatory to zero the external momenta
     clean_momenta(iterative.pos, iterative.vel, iterative.masses, iterative.ff.system.cell)
     # Initialize the additional momenta
     self.s = 0.5*boltzmann*self.temp*np.random.normal(size=(self.ns, iterative.pos.size))
     # Determine the update matrices
     eigval, eigvec = np.linalg.eig(-self.a_p * iterative.timestep/2)
     self.t = np.dot(eigvec*np.exp(eigval), np.linalg.inv(eigvec)).real
     self.S = stabilized_cholesky_decomp(self.c_p - np.dot(np.dot(self.t,self.c_p),self.t.T)).real
     # Store the number of atoms for later use
     self.n_atoms = iterative.pos.shape[0]
Example #7
0
File: nvt.py Project: boegel/yaff
 def init(self, iterative):
     if not self.restart:
         # It is mandatory to zero the external momenta
         clean_momenta(iterative.pos, iterative.vel, iterative.masses,
                       iterative.ff.system.cell)
     # If needed, determine the number of _internal_ degrees of freedom
     if iterative.ndof is None:
         iterative.ndof = get_ndof_internal_md(
             iterative.pos.shape[0], iterative.ff.system.cell.nvec)
     # Configure the chain
     self.chain.timestep = iterative.timestep
     self.chain.set_ndof(iterative.ndof)
Example #8
0
 def init(self, iterative):
     self.timestep_press = iterative.timestep
     if not self.restart:
         clean_momenta(iterative.pos, iterative.vel, iterative.masses, iterative.ff.system.cell)
     # compute gpos and vtens, since they differ
     # after symmetrising the cell tensor
     iterative.gpos[:] = 0.0
     iterative.vtens[:] = 0.0
     iterative.epot = iterative.ff.compute(iterative.gpos,iterative.vtens)
     if iterative.ndof is None:
         iterative.ndof = get_ndof_internal_md(iterative.pos.shape[0], iterative.ff.system.cell.nvec)
     # rescaling of the barostat mass, to be in accordance with Langevin and MTTK
     self.mass_press *= np.sqrt(iterative.ndof)
Example #9
0
File: npt.py Project: yfyh2013/yaff
 def init(self, iterative):
     self.timestep_press = iterative.timestep
     if not self.restart:
         clean_momenta(iterative.pos, iterative.vel, iterative.masses, iterative.ff.system.cell)
     # compute gpos and vtens, since they differ
     # after symmetrising the cell tensor
     iterative.gpos[:] = 0.0
     iterative.vtens[:] = 0.0
     iterative.epot = iterative.ff.compute(iterative.gpos,iterative.vtens)
     if iterative.ndof is None:
         iterative.ndof = get_ndof_internal_md(iterative.pos.shape[0], iterative.ff.system.cell.nvec)
     # rescaling of the barostat mass, to be in accordance with Langevin and MTTK
     self.mass_press *= np.sqrt(iterative.ndof)
Example #10
0
File: nvt.py Project: boegel/yaff
 def init(self, iterative):
     # It is mandatory to zero the external momenta
     clean_momenta(iterative.pos, iterative.vel, iterative.masses,
                   iterative.ff.system.cell)
     # Initialize the additional momenta
     self.s = 0.5 * boltzmann * self.temp * np.random.normal(
         size=(self.ns, iterative.pos.size))
     # Determine the update matrices
     eigval, eigvec = np.linalg.eig(-self.a_p * iterative.timestep / 2)
     self.t = np.dot(eigvec * np.exp(eigval), np.linalg.inv(eigvec)).real
     self.S = stabilized_cholesky_decomp(
         self.c_p - np.dot(np.dot(self.t, self.c_p), self.t.T)).real
     # Store the number of atoms for later use
     self.n_atoms = iterative.pos.shape[0]
Example #11
0
 def pre(self, iterative, G1_add = None):
     # Andersen thermostat step before usual Verlet hook, since it largely affects the velocities
     # Needed to correct the conserved quantity
     ekin_before = iterative._compute_ekin()
     # Change the (selected) velocities
     if self.select is None:
         iterative.vel[:] = get_random_vel(self.temp, False, iterative.masses)
     else:
         iterative.vel[self.select] = get_random_vel(self.temp, False, iterative.masses, self.select)
     # Zero any external momenta after choosing new velocities
     clean_momenta(iterative.pos, iterative.vel, iterative.masses, iterative.ff.system.cell)
     # Update the kinetic energy and the reference for the conserved quantity
     ekin_after = iterative._compute_ekin()
     self.econs_correction += ekin_before - ekin_after
     # Optional annealing
     self.temp *= self.annealing
Example #12
0
File: nvt.py Project: boegel/yaff
 def pre(self, iterative, G1_add=None):
     # Andersen thermostat step before usual Verlet hook, since it largely affects the velocities
     # Needed to correct the conserved quantity
     ekin_before = iterative._compute_ekin()
     # Change the (selected) velocities
     if self.select is None:
         iterative.vel[:] = get_random_vel(self.temp, False,
                                           iterative.masses)
     else:
         iterative.vel[self.select] = get_random_vel(
             self.temp, False, iterative.masses, self.select)
     # Zero any external momenta after choosing new velocities
     clean_momenta(iterative.pos, iterative.vel, iterative.masses,
                   iterative.ff.system.cell)
     # Update the kinetic energy and the reference for the conserved quantity
     ekin_after = iterative._compute_ekin()
     self.econs_correction += ekin_before - ekin_after
     # Optional annealing
     self.temp *= self.annealing
Example #13
0
File: npt.py Project: yfyh2013/yaff
    def init(self, iterative):
        self.timestep_press = iterative.timestep
        clean_momenta(iterative.pos, iterative.vel, iterative.masses, iterative.ff.system.cell)
        # set the number of internal degrees of freedom (no restriction on p_cm)
        if iterative.ndof is None:
            iterative.ndof = iterative.pos.size
        # define the barostat 'mass'
        self.mass_press = (iterative.ndof+3)/3*boltzmann*self.temp*(self.timecon/(2*np.pi))**2
        # define initial barostat velocity
        self.vel_press = get_random_vel_press(self.mass_press, self.temp)
        # make sure the volume of the cell will not change if applicable
        if self.vol_constraint:
            self.vel_press -= np.trace(self.vel_press)/3*np.eye(3)
        if not self.anisotropic:
            self.vel_press = self.vel_press[0][0]

        # compute gpos and vtens, since they differ
        # after symmetrising the cell tensor
        iterative.gpos[:] = 0.0
        iterative.vtens[:] = 0.0
        iterative.epot = iterative.ff.compute(iterative.gpos,iterative.vtens)
Example #14
0
    def init(self, iterative):
        self.timestep_press = iterative.timestep
        clean_momenta(iterative.pos, iterative.vel, iterative.masses, iterative.ff.system.cell)
        # set the number of internal degrees of freedom (no restriction on p_cm)
        if iterative.ndof is None:
            iterative.ndof = iterative.pos.size
        # define the barostat 'mass'
        self.mass_press = (iterative.ndof+3)/3*boltzmann*self.temp*(self.timecon/(2*np.pi))**2
        # define initial barostat velocity
        self.vel_press = get_random_vel_press(self.mass_press, self.temp)
        # make sure the volume of the cell will not change if applicable
        if self.vol_constraint:
            self.vel_press -= np.trace(self.vel_press)/3*np.eye(3)
        if not self.anisotropic:
            self.vel_press = self.vel_press[0][0]

        # compute gpos and vtens, since they differ
        # after symmetrising the cell tensor
        iterative.gpos[:] = 0.0
        iterative.vtens[:] = 0.0
        iterative.epot = iterative.ff.compute(iterative.gpos,iterative.vtens)
Example #15
0
 def init(self, iterative):
     # It is mandatory to zero the external momenta.
     clean_momenta(iterative.pos, iterative.vel, iterative.masses, iterative.ff.system.cell)
Example #16
0
File: nvt.py Project: boegel/yaff
 def init(self, iterative):
     # It is mandatory to zero the external momenta.
     clean_momenta(iterative.pos, iterative.vel, iterative.masses,
                   iterative.ff.system.cell)
Example #17
0
 def init(self, iterative):
     # It is mandatory to zero the external momenta.
     clean_momenta(iterative.pos, iterative.vel, iterative.masses, iterative.ff.system.cell)
     if iterative.ndof is None:
         iterative.ndof = get_ndof_internal_md(iterative.pos.shape[0], iterative.ff.system.cell.nvec)
     self.kin = 0.5*iterative.ndof*boltzmann*self.temp
Example #18
0
 def init(self, iterative):
     if not self.restart:
         # It is mandatory to zero the external momenta.
         clean_momenta(iterative.pos, iterative.vel, iterative.masses, iterative.ff.system.cell)
     if iterative.ndof is None:
         iterative.ndof = get_ndof_internal_md(iterative.pos.shape[0], iterative.ff.system.cell.nvec)