コード例 #1
0
ファイル: barostats.py プロジェクト: johanmcquillan/i-pi-dev
    def qcstep(self):
        """Propagates the centroid position and momentum and the volume."""

        v = self.p / self.m[0]
        expq, expp = (matrix_exp(v * self.dt), matrix_exp(-v * self.dt))

        m = dstrip(self.beads.m)

        saveq = self.nm.qnm[0].copy()
        savep = self.nm.pnm[0].copy()
        for i in range(self.beads.natoms):
            self.nm.qnm[0, 3 * i:3 * (i + 1)] = np.dot(
                expq, self.nm.qnm[0, 3 * i:3 * (i + 1)])
            self.nm.qnm[0, 3 * i:3 * (i + 1)] += np.dot(
                np.dot(invert_ut3x3(v), (expq - expp) / (2.0)),
                dstrip(self.nm.pnm)[0, 3 * i:3 * (i + 1)] / m[i])
            self.nm.pnm[0, 3 * i:3 * (i + 1)] = np.dot(
                expp, self.nm.pnm[0, 3 * i:3 * (i + 1)])

        #self.cell.h[:2, :2] = np.dot(expq[:2, :2], self.cell.h[:2, :2])
        #self.cell.h[2, :2] = 0.
        #self.cell.h[:2, 2] = 0.

        # Only expand and contract cell parallel to x-y axes; do not shear or change z
        self.cell.h = np.array([[expq[0, 0] * self.cell.h[0, 0], 0., 0.],
                                [0., expq[1, 1] * self.cell.h[1, 1], 0.],
                                [0., 0., self.cell.h[2, 2]]])
コード例 #2
0
   def qcstep(self):
      """Propagates the centroid position and momentum and the volume."""

      v = self.p/self.m[0]
      expq, expp = (matrix_exp(v*self.dt), matrix_exp(-v*self.dt))

      m = depstrip(self.beads.m)

      saveq=self.nm.qnm[0].copy()
      savep=self.nm.pnm[0].copy()
      for i in range(self.beads.natoms):
         self.nm.qnm[0,3*i:3*(i+1)] = np.dot(expq, self.nm.qnm[0,3*i:3*(i+1)])
         self.nm.qnm[0,3*i:3*(i+1)] += np.dot(np.dot(invert_ut3x3(v),(expq-expp)/(2.0)),depstrip(self.nm.pnm)[0,3*i:3*(i+1)]/m[i])
         self.nm.pnm[0,3*i:3*(i+1)] = np.dot(expp, self.nm.pnm[0,3*i:3*(i+1)])

      self.cell.h = np.dot(expq,self.cell.h)
コード例 #3
0
ファイル: barostats.py プロジェクト: epfl-cosmo/i-pi-dev
    def qcstep(self):
        """Propagates the centroid position and momentum and the volume."""

        v = self.p / self.m[0]
        halfdt = self.qdt
        expq, expp = (matrix_exp(v * halfdt), matrix_exp(-v * halfdt))

        m = dstrip(self.beads.m)

        sinh = np.dot(invert_ut3x3(v), (expq - expp) / (2.0))
        for i in range(self.beads.natoms):
            self.nm.qnm[0, 3 * i:3 * (i + 1)] = np.dot(expq, self.nm.qnm[0, 3 * i:3 * (i + 1)])
            self.nm.qnm[0, 3 * i:3 * (i + 1)] += np.dot(sinh, dstrip(self.nm.pnm)[0, 3 * i:3 * (i + 1)] / m[i])
            self.nm.pnm[0, 3 * i:3 * (i + 1)] = np.dot(expp, self.nm.pnm[0, 3 * i:3 * (i + 1)])

        self.cell.h = np.dot(expq, self.cell.h)
コード例 #4
0
    def qcstep(self):
        """Propagates the centroid position and momentum and the volume."""

        v = self.p / self.m[0]
        halfdt = self.qdt
        expq, expp = (matrix_exp(v * halfdt), matrix_exp(-v * halfdt))

        m = dstrip(self.beads.m)

        sinh = np.dot(invert_ut3x3(v), (expq - expp) / (2.0))
        for i in range(self.beads.natoms):
            self.nm.qnm[0, 3 * i:3 * (i + 1)] = np.dot(
                expq, self.nm.qnm[0, 3 * i:3 * (i + 1)])
            self.nm.qnm[0, 3 * i:3 * (i + 1)] += np.dot(
                sinh,
                dstrip(self.nm.pnm)[0, 3 * i:3 * (i + 1)] / m[i])
            self.nm.pnm[0, 3 * i:3 * (i + 1)] = np.dot(
                expp, self.nm.pnm[0, 3 * i:3 * (i + 1)])

        self.cell.h = np.dot(expq, self.cell.h)
コード例 #5
0
    def qcstep(self):
        """Propagates the centroid position and momentum and the volume."""

        v = self.p / self.m[0]
        halfdt = self.qdt
        expq, expp = (matrix_exp(v * halfdt), matrix_exp(-v * halfdt))

        sinh = np.dot(invert_ut3x3(v), (expq - expp) / (2.0))

        q = dstrip(self.nm.qnm)[0].copy().reshape((self.beads.natoms, 3))
        p = dstrip(self.nm.pnm)[0].copy()

        q = np.dot(q, expq.T)
        q += np.dot((p / self.beads.m3[0]).reshape((self.beads.natoms, 3)),
                    sinh.T)
        p = np.dot(p.reshape((self.beads.natoms, 3)), expp.T)

        self.nm.qnm[0] = q.reshape((self.beads.natoms * 3))
        self.nm.pnm[0] = p.reshape((self.beads.natoms * 3))

        self.cell.h = np.dot(expq, self.cell.h)
コード例 #6
0
ファイル: barostats.py プロジェクト: stevendengue/i-pi
    def qcstep(self):
        """Propagates the centroid position and momentum and the volume."""

        v = self.p / self.m[0]
        halfdt = self.qdt
        # compute in one go dt sinh v/v to handle zero-velocity cases
        # check eigen vector exists
        if np.count_nonzero(v.diagonal()) == 0:
            # compute sinhv/v by directly taylor, if eigen vector not exists
            sinh = mat_taylor(v * halfdt, function="sinhx/x")
        else:
            eigvals, eigvecs = np.linalg.eig(v)
            ieigvecs = np.linalg.inv(eigvecs)
            sinh = halfdt * np.dot(
                eigvecs, np.dot(np.diag(sinch(halfdt * eigvals)), ieigvecs))
        expq, expp = (matrix_exp(v * halfdt), matrix_exp(-v * halfdt))

        #        oldsinh = np.dot(invert_ut3x3(v), (expq - expp) / (2.0))

        q = dstrip(self.nm.qnm)[0].copy().reshape((self.beads.natoms, 3))
        p = dstrip(self.nm.pnm)[0].copy()

        q = np.dot(q, expq.T)
        q += np.dot((p / self.beads.m3[0]).reshape((self.beads.natoms, 3)),
                    sinh.T)
        p = np.dot(p.reshape((self.beads.natoms, 3)), expp.T)

        # now apply the mask (and accumulate the associated change in conserved quantity)
        # we use the thermostat conserved quantity accumulator, so we don't need to create a new one
        self.thermostat.ethermo += self.kin
        self.p *= self.hmask
        self.thermostat.ethermo -= self.kin

        self.nm.qnm[0] = q.reshape((self.beads.natoms * 3))
        self.nm.pnm[0] = p.reshape((self.beads.natoms * 3))

        self.cell.h = np.dot(expq, self.cell.h)
コード例 #7
0
ファイル: thermostats.py プロジェクト: salinelake/i-pi
    def get_T(self):
        """Calculates the matrix for the overall drift of the velocities."""

        return matrix_exp(-self.dt * self.A)
コード例 #8
0
ファイル: thermostats.py プロジェクト: arielzn/lammps
   def get_T(self):
      """Calculates the matrix for the overall drift of the velocities."""

      return matrix_exp(-0.5*self.dt*self.A)