示例#1
0
def test_strain():
    from math import sqrt
    from ase import Atoms
    from ase.constraints import StrainFilter
    from ase.optimize.mdmin import MDMin
    from ase.io import Trajectory
    try:
        from asap3 import EMT
    except ImportError:
        pass
    else:
        a = 3.6
        b = a / 2
        cu = Atoms('Cu', cell=[(0,b,b),(b,0,b),(b,b,0)], pbc=1) * (6, 6, 6)

        cu.set_calculator(EMT())
        f = StrainFilter(cu, [1, 1, 1, 0, 0, 0])
        opt = MDMin(f, dt=0.01)
        t = Trajectory('Cu.traj', 'w', cu)
        opt.attach(t)
        opt.run(0.001)

    # HCP:
        from ase.build import bulk
        cu = bulk('Cu', 'hcp', a=a / sqrt(2))
        cu.cell[1,0] -= 0.05
        cu *= (6, 6, 3)

        cu.set_calculator(EMT())
        f = StrainFilter(cu)
        opt = MDMin(f, dt=0.01)
        t = Trajectory('Cu.traj', 'w', cu)
        opt.attach(t)
        opt.run(0.01)
示例#2
0
def test_strain_fcc(asap3):
    cu = bulk('Cu', a=a) * (6, 6, 6)
    cu.calc = asap3.EMT()
    f = StrainFilter(cu, [1, 1, 1, 0, 0, 0])
    opt = MDMin(f, dt=0.01)
    t = Trajectory('Cu.traj', 'w', cu)
    opt.attach(t)
    opt.run(0.001)
示例#3
0
def test_strain_hcp(asap3):
    cu = bulk('Cu', 'hcp', a=a / sqrt(2))
    cu.cell[1, 0] -= 0.05
    cu *= (6, 6, 3)

    cu.calc = asap3.EMT()
    f = StrainFilter(cu)
    opt = MDMin(f, dt=0.01)
    opt.run(0.01)
示例#4
0
def test_strain_hcp(asap3):
    cu = bulk('Cu', 'hcp', a=a / sqrt(2))
    cu.cell[1, 0] -= 0.05
    cu *= (6, 6, 3)

    cu.calc = asap3.EMT()
    f = StrainFilter(cu)
    opt = MDMin(f, dt=0.01)
    t = Trajectory('Cu.traj', 'w', cu)
    opt.attach(t)
    opt.run(0.01)
示例#5
0
def test_strain_emt():
    """This test checks that the StrainFilter works using the default
    built-in EMT calculator."""

    import numpy as np
    from ase.constraints import StrainFilter
    from ase.optimize.mdmin import MDMin
    from ase.calculators.emt import EMT
    from ase.build import bulk

    cu = bulk('Cu', 'fcc', a=3.6)

    class EMTPlus(EMT):
        def get_stress(self, atoms):
            return np.zeros(6)

    cu.calc = EMTPlus()
    f = StrainFilter(cu)
    opt = MDMin(f, dt=0.01)
    opt.run(0.1, steps=2)
示例#6
0
def test_vacancy():
    from ase import Atoms
    from ase.optimize import QuasiNewton
    from ase.neb import NEB
    from ase.optimize.mdmin import MDMin
    try:
        from asap3 import EMT
    except ImportError:
        pass
    else:

        a = 3.6
        b = a / 2
        initial = Atoms('Cu4',
                        positions=[(0, 0, 0),
                                   (0, b, b),
                                   (b, 0, b),
                                   (b, b, 0)],
                        cell=(a, a, a),
                        pbc=True)
        initial *= (4, 4, 4)
        del initial[0]
        images = [initial] + [initial.copy() for i in range(6)]
        images[-1].positions[0] = (0, 0, 0)
        for image in images:
            image.calc = EMT()
            #image.calc = ASAP()

        for image in [images[0], images[-1]]:
            QuasiNewton(image).run(fmax=0.01)
        neb = NEB(images)
        neb.interpolate()

        for a in images:
            print(a.positions[0], a.get_potential_energy())

        dyn = MDMin(neb, dt=0.1, trajectory='mep1.traj')
        #dyn = QuasiNewton(neb)
        print(dyn.run(fmax=0.01, steps=25))
        for a in images:
            print(a.positions[0], a.get_potential_energy())
示例#7
0
"""This test checks that the StrainFilter works using the default
built-in EMT calculator."""

import numpy as np
from ase.constraints import StrainFilter
from ase.optimize.mdmin import MDMin
from ase.calculators.emt import EMT
from ase.structure import bulk

cu = bulk('Cu', 'fcc', a=3.6)

class EMTPlus(EMT):
    def get_stress(self, atoms):
        return np.zeros(6)

cu.set_calculator(EMTPlus())
f = StrainFilter(cu)
opt = MDMin(f, dt=0.01)
opt.run(0.1, steps=2)
示例#8
0
文件: strain_emt.py 项目: lqcata/ase
"""This test checks that the StrainFilter works using the default
built-in EMT calculator."""

from ase.constraints import StrainFilter
from ase.optimize.mdmin import MDMin
from ase.calculators.emt import EMT
from ase.structure import bulk

cu = bulk('Cu', 'fcc', a=3.6)

cu.set_calculator(EMT(fakestress=True))
f = StrainFilter(cu)
opt = MDMin(f, dt=0.01)
opt.run(0.1, steps=2)
示例#9
0
from ase.io import PickleTrajectory
try:
    from asap3 import EMT
except ImportError:
    pass
else:
    a = 3.6
    b = a / 2
    cu = Atoms('Cu', cell=[(0,b,b),(b,0,b),(b,b,0)], pbc=1) * (6, 6, 6)

    cu.set_calculator(EMT())
    f = StrainFilter(cu, [1, 1, 1, 0, 0, 0])
    opt = MDMin(f, dt=0.01)
    t = PickleTrajectory('Cu.traj', 'w', cu)
    opt.attach(t)
    opt.run(0.001)

# HCP:
    from ase.lattice.surface import hcp0001
    cu = hcp0001('Cu', (1, 1, 2), a=a / sqrt(2))
    cu.cell[1,0] += 0.05
    cu *= (6, 6, 3)

    cu.set_calculator(EMT())
    f = StrainFilter(cu)
    opt = MDMin(f, dt=0.01)
    t = PickleTrajectory('Cu.traj', 'w', cu)
    opt.attach(t)
    opt.run(0.01)

示例#10
0
from ase.optimize.mdmin import MDMin
from ase.io import PickleTrajectory
try:
    from asap3 import EMT
except ImportError:
    pass
else:
    a = 3.6
    b = a / 2
    cu = Atoms('Cu', cell=[(0, b, b), (b, 0, b), (b, b, 0)], pbc=1) * (6, 6, 6)

    cu.set_calculator(EMT())
    f = StrainFilter(cu, [1, 1, 1, 0, 0, 0])
    opt = MDMin(f, dt=0.01)
    t = PickleTrajectory('Cu.traj', 'w', cu)
    opt.attach(t)
    opt.run(0.001)

    # HCP:
    from ase.lattice.surface import hcp0001
    cu = hcp0001('Cu', (1, 1, 2), a=a / sqrt(2))
    cu.cell[1, 0] += 0.05
    cu *= (6, 6, 3)

    cu.set_calculator(EMT())
    f = StrainFilter(cu)
    opt = MDMin(f, dt=0.01)
    t = PickleTrajectory('Cu.traj', 'w', cu)
    opt.attach(t)
    opt.run(0.01)
示例#11
0
def test_strain_emt():
    cu = bulk('Cu', 'fcc', a=3.6)
    cu.calc = EMT()
    f = StrainFilter(cu)
    opt = MDMin(f, dt=0.01)
    opt.run(0.1, steps=2)
示例#12
0
    pass
else:

    a = 3.6
    b = a / 2
    initial = Atoms('Cu4',
                    positions=[(0, 0, 0), (0, b, b), (b, 0, b), (b, b, 0)],
                    cell=(a, a, a),
                    pbc=True)
    initial *= (4, 4, 4)
    del initial[0]
    images = [initial] + [initial.copy() for i in range(6)]
    images[-1].positions[0] = (0, 0, 0)
    for image in images:
        image.set_calculator(EMT())
        #image.set_calculator(ASAP())

    for image in [images[0], images[-1]]:
        QuasiNewton(image).run(fmax=0.01)
    neb = NEB(images)
    neb.interpolate()

    for a in images:
        print a.positions[0], a.get_potential_energy()

    dyn = MDMin(neb, dt=0.1, trajectory='mep1.traj')
    #dyn = QuasiNewton(neb)
    print dyn.run(fmax=0.01, steps=25)
    for a in images:
        print a.positions[0], a.get_potential_energy()
示例#13
0
def test_strain_fcc(asap3):
    cu = bulk('Cu', a=a) * (6, 6, 6)
    cu.calc = asap3.EMT()
    f = StrainFilter(cu, [1, 1, 1, 0, 0, 0])
    opt = MDMin(f, dt=0.01)
    opt.run(0.001)
示例#14
0
    a = 3.6
    b = a / 2
    initial = Atoms('Cu4',
                    positions=[(0, 0, 0),
                               (0, b, b),
                               (b, 0, b),
                               (b, b, 0)],
                    cell=(a, a, a),
                    pbc=True)
    initial *= (4, 4, 4)
    del initial[0]
    images = [initial] + [initial.copy() for i in range(6)]
    images[-1].positions[0] = (0, 0, 0)
    for image in images:
        image.set_calculator(EMT())
        #image.set_calculator(ASAP())

    for image in [images[0], images[-1]]:
        QuasiNewton(image).run(fmax=0.01)
    neb = NEB(images)
    neb.interpolate()

    for a in images:
        print a.positions[0], a.get_potential_energy()

    dyn = MDMin(neb, dt=0.1, trajectory='mep1.traj')
    #dyn = QuasiNewton(neb)
    print dyn.run(fmax=0.01, steps=25)
    for a in images:
        print a.positions[0], a.get_potential_energy()
示例#15
0
文件: lmp-rlx.py 项目: ssrokyz/tools
## atoms
atoms = read('POSCAR_1_Kooi')

## calc
calc = LAMMPS(
    specorder=['Ge', 'Sb', 'Te'],
    parameters={
        'units': 'metal',
        'boundary': 'p p p',
        'box': 'tilt large',
        'pair_style': 'deepmd frozen_model.pb',
        'pair_coeff': ' ',
        'mass': ['1 72.64', '2 121.76', '3 127.60'],
    },
    files=['frozen_model.pb'],
    # keep_tmp_files=True,
)
atoms.set_calculator(calc)

## rlx
# from ase.optimize.bfgslinesearch import BFGSLineSearch as BFGSL
# from ase.optimize.gpmin.gpmin import GPMin
from ase.optimize.mdmin import MDMin
dyn = MDMin(
    atoms=atoms,
    trajectory='rlx-tmp.traj',
    # force_consistent=False,
    dt=0.1,
)
dyn.run(fmax=1e-2)
示例#16
0
    a = 3.6
    b = a / 2
    initial = Atoms('Cu4',
                    positions=[(0, 0, 0),
                               (0, b, b),
                               (b, 0, b),
                               (b, b, 0)],
                    cell=(a, a, a),
                    pbc=True)
    initial *= (4, 4, 4)
    del initial[0]
    images = [initial] + [initial.copy() for i in range(6)]
    images[-1].positions[0] = (0, 0, 0)
    for image in images:
        image.set_calculator(EMT())
        #image.set_calculator(ASAP())

    for image in [images[0], images[-1]]:
        QuasiNewton(image).run(fmax=0.01)
    neb = NEB(images)
    neb.interpolate()

    for a in images:
        print(a.positions[0], a.get_potential_energy())

    dyn = MDMin(neb, dt=0.1, trajectory='mep1.traj')
    #dyn = QuasiNewton(neb)
    print(dyn.run(fmax=0.01, steps=25))
    for a in images:
        print(a.positions[0], a.get_potential_energy())