コード例 #1
0
ファイル: erm.py プロジェクト: bwibbwz/dimer
 def calculate_image_eigenmode(self, i):
     img = self.images[i]
     if self.decouple_modes:
         img.set_basis(None)
     else:
         nm = normalize(img.get_eigenmode())
         nt = normalize(self.tangents[i])
         img.set_basis(nt)
         img.set_eigenmode(normalize(perpendicular_vector(nm, nt)))
     img.get_forces()
コード例 #2
0
ファイル: erm.py プロジェクト: bwibbwz/dimer
 def invert_eigenmode_forces(self):
     for i in range(1, self.nimages - 1):
         f_r = self.forces['real'][i]
         t = self.tangents[i]
         nt = normalize(t)
         nm = self.images[i].get_eigenmode()
         self.forces['dimer'][i] = f_r - 2 * np.vdot(f_r, nm) * nm
コード例 #3
0
ファイル: run_dimer.py プロジェクト: GengSS/gcbh
            hydrogen_index = pairs[0]
    else:
        new_constraints.append(c)

# remove all FixBondLengths
atoms.set_constraint(new_constraints)

# start DIMER
initial_mode_method = "displacement"
displacement_method = 'vector'

# set up initial guess for DIMER
natoms = atoms.get_number_of_atoms()
displacement_vector = np.zeros(shape=(natoms, 3))
pos = atoms.get_positions()
_delta_x = normalize(pos[carbon_index] - pos[hydrogen_index]) * 0.01
displacement_vector[hydrogen_index] = _delta_x
mask = [False] * natoms
mask[hydrogen_index] = True

calc = Vasp2(encut=400,
             ispin=2,
             ediff=1.0e-7,
             nelm=120,
             nelmin=5,
             xc='pbe',
             kpts=(1, 1, 1),
             gamma=True,
             prec="N",
             algo="N",
             ismear=0,
コード例 #4
0
ファイル: erm.py プロジェクト: bwibbwz/dimer
    def plot_pseudo_3d_pes(self):
        import pylab as plt
        from pylab import subplot, subplot2grid
        fig = plt.figure(figsize = (8,8))
        if self.plot_subplot:
            plt.axes()
            ax1 = subplot2grid((4, 4), (0, 0), rowspan = 3, colspan = 3)
            ax2 = subplot2grid((4, 4), (3, 0), colspan = 3)
            ax3 = subplot2grid((4, 4), (0, 3), rowspan = 3)
            ax2_base_scale = 0.00000002

        else:
            plt.axes()
            ax1 = subplot(111)
            ax2 = None
            ax3 = None

        def make_line(pos, orient, c, size=0.2, width=1, dim=[0, 1], ax=plt):
            p = pos[-1]
            o = orient[-1]
            d1 = dim[0]
            d2 = dim[1]
            ax.plot((p[d1] - o[d1] * size, p[d1] + o[d1] * size), (p[d2] - o[d2] * size, p[d2] + o[d2] * size), c, lw = width)

        def make_arrow(pos, end, c, scale=1.0, width=1, dim=[0,1], ax=plt, head_scale=0.9, base_scale=0.6):
            x = head_scale
            if ax == ax2:
                y = ax2_base_scale
            else:
                y = base_scale
            p = pos[-1]
            e = end[-1]
            d1 = dim[0]
            d2 = dim[1]

            p1 = p[d1]
            p2 = p[d2]

            e1 = e[d1] * scale + p1
            e2 = e[d2] * scale + p2

            a1 = p1 * (1 - x) + x * e1
            a2 = p2 * (1 - x) + x * e2

            b1 = a1 + (a2 - e2)
            b2 = a2 - (a1 - e1)

            c1 = a1 - (a2 - e2)
            c2 = a2 + (a1 - e1)

            b1 = a1 * (1 - y) + y * b1
            b2 = a2 * (1 - y) + y * b2

            c1 = a1 * (1 - y) + y * c1
            c2 = a2 * (1 - y) + y * c2

            ax.plot((p1, e1), (p2, e2), 'k', lw = width + 1)
            ax.plot((b1, e1, c1), (b2, e2, c2), 'k', lw = width + 1)
            ax.plot((p1, e1), (p2, e2), c, lw = width)
            ax.plot((b1, e1, c1), (b2, e2, c2), c, lw = width)

        def make_circle(pos, r, c, dim=[0, 1], ax=plt):
            p = pos[-1]
            d1 = dim[0]
            d2 = dim[1]
            ax.plot((p[d1]), (p[d2]), 'k.', markersize = r + 1)
            ax.plot((p[d1]), (p[d2]), '%s.' % c, markersize = r)

        n = self.nimages
        ts = self.tangents
        ms = []
        ps = []
        for i in range(n):
            ms.append(self.images[i].get_eigenmode())
            ps.append(self.images[i].get_positions())
        f_rs = self.forces['real']
        f_ds = self.forces['dimer']
        f_ss = self.forces['spring']
        f_ns = self.forces['neb']

#        ax1.text(0.6, 0.6, self.phase, color = 'k')
        for i in range(n):
            p = ps[i]
            t = normalize(ts[i]) * 0.25
            m = normalize(ms[i]) * 0.25
            f_r = f_rs[i]
            f_d = f_ds[i]
            f_s = f_ss[i]
            f_n = f_ns[i]
            if i in [0, n - 1]:
                make_circle(p, 20.0, 'y', ax = ax1)
            else:
                if self.climb and i == self.imax:
                    make_circle(p, 35.0, 'c', ax = ax1)
                else:
                    make_circle(p, 35.0, 'y', ax = ax1)
                    make_arrow(p, f_s, 'g', ax = ax1)
                make_arrow(p, f_r, 'w', ax = ax1)
                make_arrow(p, f_d, 'b', ax = ax1)
                make_arrow(p, f_n, 'k', ax = ax1)
                make_line(p, t, 'r', ax = ax1)
                make_line(p, m, 'b', ax = ax1)

            if self.plot_subplot:
                if i in [0, n - 1]:
                    make_circle(p, 20.0, 'y', dim = [0, 2], ax = ax2)
                else:
                    if self.climb and i == self.imax:
                        make_circle(p, 35.0, 'c', dim = [0, 2], ax = ax2)
                    else:
                        make_circle(p, 35.0, 'y', dim = [0, 2], ax = ax2)
                        make_arrow(p, f_s, 'g', dim = [0, 2], ax = ax2)
                    make_arrow(p, f_r, 'w', dim = [0, 2], ax = ax2)
                    make_arrow(p, f_d, 'b', dim = [0, 2], ax = ax2)
                    make_arrow(p, f_n, 'k', dim = [0, 2], ax = ax2)
                    make_line(p, t, 'r', dim = [0, 2], ax = ax2)
                    make_line(p, m, 'b', dim = [0, 2], ax = ax2)

                if i in [0, n - 1]:
                    make_circle(p, 20.0, 'y', dim = [2, 1], ax = ax3)
                else:
                    if self.climb and i == self.imax:
                        make_circle(p, 35.0, 'c', dim = [2, 1], ax = ax3)
                    else:
                        make_circle(p, 35.0, 'y', dim = [2, 1], ax = ax3)
                        make_arrow(p, f_s, 'g', dim = [2, 1], ax = ax3)
                    make_arrow(p, f_r, 'w', dim = [2, 1], ax = ax3)
                    make_arrow(p, f_d, 'b', dim = [2, 1], ax = ax3)
                    make_arrow(p, f_n, 'k', dim = [2, 1], ax = ax3)
                    make_line(p, t, 'r', dim = [2, 1], ax = ax3)
                    make_line(p, m, 'b', dim = [2, 1], ax = ax3)

        if self.plot_e is not None:
            ax1.contourf(self.plot_x, self.plot_y, self.plot_e, 30)

        if self.plot_animate < 10:
            animate = '000' + str(self.plot_animate)
        elif self.plot_animate < 100:
            animate = '00' + str(self.plot_animate)
        elif self.plot_animate < 1000:
            animate = '0' + str(self.plot_animate)
        else:
            animate = str(self.plot_animate)

        axis1 = ax1.get_axes()
        if self.plot_e is not None:
            axis1.set_xlim(xmin = min(self.plot_x), xmax = max(self.plot_x))
            axis1.set_ylim(ymin = min(self.plot_y), ymax = max(self.plot_y))
        else:
            if self.xrange is not None:
                axis1.set_xlim(xmin = self.xrange[0], xmax = self.xrange[1])
            else:
                axis1.set_xlim(xmin = 0.0, xmax = 5.0)
            if self.yrange is not None:
                axis1.set_ylim(ymin = self.yrange[0], ymax = self.yrange[1])
            else:
                axis1.set_ylim(ymin = 0.0, ymax = 5.0)

        if self.plot_subplot:
            axis2 = ax2.get_axes()
            axis3 = ax3.get_axes()
            if self.plot_e is not None:
                axis2.set_xlim(xmin = min(self.plot_x), xmax = max(self.plot_x))
                axis3.set_ylim(ymin = min(self.plot_y), ymax = max(self.plot_y))
            else:
                if self.xrange is not None:
                    axis2.set_xlim(xmin = self.xrange[0], xmax = self.xrange[1])
                    axis3.set_ylim(ymin = self.yrange[0], ymax = self.yrange[1])
                else:
                    axis2.set_xlim(xmin = 0.0, xmax = 5.0)
                    axis3.set_ylim(ymin = 0.0, ymax = 5.0)
#            axis2.set_ylim(ymin = -3.0e-9, ymax = 3.0e-9)

        plt.savefig('_fig-' + animate + '.png')
#        plt.savefig('_fig-' + animate + '.svg')

        plt.draw()
        plt.close()
#        plt.show()
        self.plot_animate += 1