コード例 #1
0
    def step(self, step=None):
        """ Does one simulation time step."""

        activearrays = self.pre_step(step)

        # First construct complete hessian from reduced
        h0 = red2comp(activearrays["hessian"], self.im.dbeads.nbeads, self.im.dbeads.natoms, self.im.coef)

        # Add spring terms to the physical hessian
        h1 = np.add(self.im.h, h0)

        # Get eigenvalues and eigenvector.
        d, w = clean_hessian(h1, self.im.dbeads.q, self.im.dbeads.natoms,
                             self.im.dbeads.nbeads, self.im.dbeads.m, self.im.dbeads.m3, self.options["hessian_asr"])

        # d,w =np.linalg.eigh(h1) #Cartesian
        info('\n@Nichols: 1st freq {} cm^-1'.format(units.unit_to_user('frequency', 'inversecm', np.sign(d[0]) * np.sqrt(np.absolute(d[0])))), verbosity.medium)
        info('@Nichols: 2nd freq {} cm^-1'.format(units.unit_to_user('frequency', 'inversecm', np.sign(d[1]) * np.sqrt(np.absolute(d[1])))), verbosity.medium)
        info('@Nichols: 3rd freq {} cm^-1'.format(units.unit_to_user('frequency', 'inversecm', np.sign(d[2]) * np.sqrt(np.absolute(d[2])))), verbosity.medium)
        #info('@Nichols: 4th freq {} cm^-1'.format(units.unit_to_user('frequency','inversecm',np.sign(d[3])*np.sqrt(np.absolute(d[3])))),verbosity.medium)
        #info('@Nichols: 8th freq {} cm^-1\n'.format(units.unit_to_user('frequency','inversecm',np.sign(d[7])*np.sqrt(np.absolute(d[7])))),verbosity.medium)

        # Find new movement direction
        if self.options["mode"] == 'rate':
            f = activearrays["old_f"] * (self.im.coef[1:] + self.im.coef[:-1]) / 2
            d_x = nichols(f, self.im.f, d, w, self.im.dbeads.m3, activearrays["big_step"])
        elif self.options["mode"] == 'splitting':
            d_x = nichols(activearrays["old_f"], self.im.f, d, w, self.im.dbeads.m3, activearrays["big_step"], mode=0)

        # Rescale step if necessary
        if np.amax(np.absolute(d_x)) > activearrays["big_step"]:
            info("Step norm, scaled down to {}".format(activearrays["big_step"]), verbosity.low)
            d_x *= activearrays["big_step"] / np.amax(np.absolute(d_x))

        # Get the new full-position
        d_x_full = self.fix.get_full_vector(d_x, t=1)
        new_x = self.optarrays["old_x"].copy() + d_x_full

        self.post_step(step, new_x, d_x, activearrays)
コード例 #2
0
        print("We can not recognize the mode. STOP HERE")
        sys.exit()

# ----------------------------------------------------------START----------------------------------------------
beta = 1.0 / (kb * temp)
betaP = 1.0 / (kb * (nbeads) * temp)

print(("\nTemperature: {} K".format(temp / K2au)))
print(("NBEADS: {}".format(nbeads)))
print(("atoms:  {}".format(natoms)))
print(("ASR:    {}".format(asr)))
print(("1/(betaP*hbar) = {:8.5f}".format((1 / (betaP * hbar)))))

if not quiet:
    print("Diagonalization ... \n\n")
    d, w, detI = clean_hessian(h, pos, natoms, nbeads, m, m3, asr, mofi=True)
    print("Final lowest 10 frequencies (cm^-1)")
    d10 = np.array2string(
        np.sign(d[0:10]) * np.absolute(d[0:10]) ** 0.5 / cm2au,
        precision=2,
        max_line_width=100,
        formatter={"float_kind": lambda x: "%.2f" % x},
    )
    print(("{}".format(d10)))

if case == "reactant":
    Qtras = ((np.sum(m)) / (2 * np.pi * beta * hbar ** 2)) ** 1.5

    if asr == "poly":
        Qrot = (8 * np.pi * detI / ((hbar) ** 6 * (beta) ** 3)) ** 0.5
    else:
コード例 #3
0
    def step(self, step=None):
        """ Does one simulation time step."""

        activearrays = self.pre_step(step)

        fff = activearrays["old_f"] * (self.im.coef[1:] + self.im.coef[:-1]) / 2
        f = (fff + self.im.f).reshape(self.im.dbeads.natoms * 3 * self.im.dbeads.nbeads, 1)

        banded = False
        banded = True
        if banded:
            # BANDED Version
            # MASS-scaled
            dyn_mat = get_dynmat(activearrays["hessian"], self.im.dbeads.m3, self.im.dbeads.nbeads)
            h_up_band = banded_hessian(dyn_mat, self.im, masses=False, shift=0.000000001)  # create upper band matrix
            f = np.multiply(f, self.im.dbeads.m3.reshape(f.shape)**-0.5)
            # CARTESIAN
            # h_up_band = banded_hessian(activearrays["hessian"], self.im,masses=True)  # create upper band matrix

            d = diag_banded(h_up_band)
        else:
            # FULL dimensions version
            h_0 = red2comp(activearrays["hessian"], self.im.dbeads.nbeads, self.im.dbeads.natoms, self.im.coef)
            h_test = np.add(self.im.h, h_0)  # add spring terms to the physical hessian
            d, w = clean_hessian(h_test, self.im.dbeads.q, self.im.dbeads.natoms,
                                 self.im.dbeads.nbeads, self.im.dbeads.m, self.im.dbeads.m3, None)
            # CARTESIAN
            # d,w =np.linalg.eigh(h_test) #Cartesian
        info('\n@Lanczos: 1st freq {} cm^-1'.format(units.unit_to_user('frequency', 'inversecm', np.sign(d[0]) * np.sqrt(np.absolute(d[0])))), verbosity.medium)
        info('@Lanczos: 2nd freq {} cm^-1'.format(units.unit_to_user('frequency', 'inversecm', np.sign(d[1]) * np.sqrt(np.absolute(d[1])))), verbosity.medium)
        info('@Lanczos: 3rd freq {} cm^-1\n'.format(units.unit_to_user('frequency', 'inversecm', np.sign(d[2]) * np.sqrt(np.absolute(d[2])))), verbosity.medium)

        if d[0] > 0:
            if d[1] / 2 > d[0]:
                alpha = 1
                lamb = (2 * d[0] + d[1]) / 4
            else:
                alpha = (d[1] - d[0]) / d[1]
                lamb = (3 * d[0] + d[1]) / 4  # midpoint between b[0] and b[1]*(1-alpha/2)
        elif d[1] < 0:  # Jeremy Richardson
            if (d[1] >= d[0] / 2):
                alpha = 1
                lamb = (d[0] + 2 * d[1]) / 4
            else:
                alpha = (d[0] - d[1]) / d[1]
                lamb = (d[0] + 3 * d[1]) / 4
        # elif d[1] < 0:  #Litman for Second Order Saddle point
        #    alpha = 1
        #    lamb = (d[1] + d[2]) / 4
        #    print 'WARNING: We are not using the standard Nichols'
        #    print 'd_x', d_x[0],d_x[1]

        else:  # Only d[0] <0
            alpha = 1
            lamb = (d[0] + d[1]) / 4

        if banded:
            h_up_band[-1, :] += - np.ones(h_up_band.shape[1]) * lamb
            d_x = invmul_banded(h_up_band, f)
        else:
            h_test = alpha * (h_test - np.eye(h_test.shape[0]) * lamb)
            d_x = np.linalg.solve(h_test, f)

        d_x.shape = self.im.dbeads.q.shape

        # MASS-scaled
        d_x = np.multiply(d_x, self.im.dbeads.m3**-0.5)

        # Rescale step if necessary
        if np.amax(np.absolute(d_x)) > activearrays["big_step"]:
            info("Step norm, scaled down to {}".format(activearrays["big_step"]), verbosity.low)
            d_x *= activearrays["big_step"] / np.amax(np.absolute(d_x))

        # Get the new full-position
        d_x_full = self.fix.get_full_vector(d_x, t=1)
        new_x = self.optarrays["old_x"].copy() + d_x_full

        self.post_step(step, new_x, d_x, activearrays)