Exemplo n.º 1
0
def test_ethene_rotation(tmpdir):

    tmpdir.chdir()

    # Optimise molecule
    initial = molecule('C2H6')
    smart_cell(initial, vac=4.0, h=0.01)
    initial.set_calculator(iEspresso(pw=300, dw=4000, kpts='gamma'))
    qn = QuasiNewton(initial, 'initial.traj')
    qn.run(fmax=0.01)

    # Create final state
    final = initial.copy()
    final.positions[2:5] = initial.positions[[3, 4, 2]]
    final.set_calculator(iEspresso(pw=300, dw=4000, kpts='gamma'))
    final.get_potential_energy()

    # Generate blank images
    images = [initial]
    nimage = 7

    for i in range(nimage):
        image = initial.copy()
        image.set_calculator(iEspresso(pw=300, dw=4000, kpts='gamma'))
        images.append(image)
    images.append(final)

    # Run IDPP interpolation
    neb = NEBEspresso(images)
    neb.interpolate('idpp')

    # Run NEB calculation
    qn = QuasiNewton(neb, logfile='ethane_linear.log', trajectory='neb.traj')
    qn.run(fmax=0.05)

    nt = NEBTools(neb.images)
    print('fmax: ', nt.get_fmax())
    print('Ef, dE: ', nt.get_barrier())
Exemplo n.º 2
0
import numpy as np

from ase.io import read
from ase.constraints import FixAtoms
from ase.calculators.emt import EMT
from ase.neb import NEB
from ase.optimize.fire import FIRE as QuasiNewton

initial = read('N2.traj')
final = read('2N.traj')

configs = [initial.copy() for i in range(8)] + [final]

constraint = FixAtoms(mask=[atom.symbol != 'N' for atom in initial])
for config in configs:
    config.set_calculator(EMT())
    config.set_constraint(constraint)

band = NEB(configs)
band.interpolate()

# Create a quickmin object:
relax = QuasiNewton(band)

relax.run(steps=20)

e0 = initial.get_potential_energy()
for config in configs:
    d = config[-2].position - config[-1].position
    print np.linalg.norm(d), config.get_potential_energy() - e0
Exemplo n.º 3
0
from ase.build import molecule
from ase.neb import NEB
from ase.calculators.emt import EMT
from ase.optimize.fire import FIRE as QuasiNewton

# Optimise molecule.
initial = molecule('C2H6')
initial.calc = EMT()
relax = QuasiNewton(initial)
relax.run(fmax=0.05)

# Create final state.
final = initial.copy()
final.positions[2:5] = initial.positions[[3, 4, 2]]

# Generate blank images.
images = [initial]

for i in range(9):
    images.append(initial.copy())

for image in images:
    image.calc = EMT()
   
images.append(final)

# Run IDPP interpolation.
neb = NEB(images)
neb.interpolate('idpp')

# Run NEB calculation.
Exemplo n.º 4
0
x3 = 2.759
y1 = 0.0
y2 = 2.238
z1 = 7.165
z2 = 6.439

#Add the adatom to the list of atoms and set constraints of surface atoms.
slab += Atoms('N', [((x2 + x1) / 2, y1, z1 + 1.5)])
mask = [atom.symbol == 'Pt' for atom in slab]
slab.set_constraint(FixAtoms(mask=mask))

#optimise the initial state
# Atom below step
initial = slab.copy()
initial.set_calculator(EMT())
relax = QuasiNewton(initial)
relax.run(fmax=0.05)
view(initial)

#optimise the initial state
# Atom above step
slab[-1].position = (x3, y2 + 1, z2 + 3.5)
final = slab.copy()
final.set_calculator(EMT())
relax = QuasiNewton(final)
relax.run(fmax=0.05)
view(final)

#create a list of images for interpolation
images = [initial]
for i in range(nimages):
Exemplo n.º 5
0
write('initial.traj', initial)

# Create final state
final = initial.copy()
final.positions[2:5] = initial.positions[[3, 4, 2]]
write('final.traj', final)

# Generate blank images
images = [initial]
nimage = 7

for i in range(nimage):
    images.append(initial.copy())

images.append(final)

# Run IDPP interpolation
neb = NEB(images)
neb.interpolate()

calcs = NEBEspresso(neb, kpts='gamma', pw=300, dw=4000)

# Run NEB calculation
qn = QuasiNewton(neb, logfile='ethane_linear.log')

for j in range(nimage):
    traj = Trajectory('neb%d.traj' % j, 'w', images[j + 1])
    qn.attach(traj)

qn.run(fmax=0.05)
Exemplo n.º 6
0
#print(mol.get_chemical_symbols())

# Set NC
aens = ensemblemolecule(cnstfile, saefile, nnfdir, Nn, 5)

# Set ANI calculator
mol.set_calculator(ANIENS(aens, sdmx=20000000.0))

print(mol.get_potential_energy())
print(np.where(mol.get_forces() > 200.0))

print("size: ", len(mol.get_chemical_symbols()))

# Optimize molecule
start_time = time.time()
dyn = QuasiNewton(mol)
dyn.run(fmax=C)
print('[ANI Total time:', time.time() - start_time, 'seconds]')

#print(hdt.evtokcal*mol.get_potential_energy())
#print(hdt.evtokcal*mol.get_forces())

# Save optimized mol
spc = mol.get_chemical_symbols()
pos = mol.get_positions(wrap=False).reshape(1, len(spc), 3)

hdt.writexyzfile(optfile, pos, spc)

# Open MD output
mdcrd = open(xyzfile, 'w')