run_search.py 1.82 KB
Newer Older
1
2
3
import numpy as np

from ase.calculators.dftb import Dftb
Malthe Kjær Bisbo's avatar
Malthe Kjær Bisbo committed
4
from ase.io import read
5
6
7

from candidate_operations.candidate_generation import CandidateGenerator, StartGenerator, OperationConstraint
from candidate_operations.basic_mutations import RattleMutation, RattleMutation2, PermutationMutation
Malthe Kjær Bisbo's avatar
Malthe Kjær Bisbo committed
8
from gofee import GOFEE
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33

import sys

### Set up StartGenerator and mutations ###
# read slab
slab = read('slab.traj', index='0')

# Stoichiometry of atoms to be placed
stoichiometry = 5*[22]+10*[8]

# Box in which to place atoms
c = slab.get_cell()
c[2,2] = 25
slab.set_cell(c)
v = np.copy(c)
v[2,2] = 2.3
p0 = np.array((0.0,0.,8.))
box = [p0, v]

# initialize startgenerator
sg = StartGenerator(slab, stoichiometry, box)

# initialize rattle mutation
n_to_optimize = len(stoichiometry)
candidate_generator = CandidateGenerator([0.2, 0.2, 0.6],
Malthe Kjær Bisbo's avatar
Malthe Kjær Bisbo committed
34
35
36
                                        [sg,
                                         PermutationMutation(n_to_optimize, Npermute=2),
                                         RattleMutation(n_to_optimize, Nrattle=3, rattle_range=4)])
37
38
39
40
41
42
43
44
45
46
47
48
49

### Define calculator ###
calc = Dftb(label='TiO2_surface',
            Hamiltonian_SCC='No',
            Hamiltonian_MaxAngularMomentum_='',
            Hamiltonian_MaxAngularMomentum_Ti='"d"',
            Hamiltonian_MaxAngularMomentum_O='"p"',
            Hamiltonian_Charge='0.000000',
            Hamiltonian_Filling ='Fermi {',
            Hamiltonian_Filling_empty= 'Temperature [Kelvin] = 0.000000',
            kpts=(2,1,1))

### Initialize and run search ###
Malthe Kjær Bisbo's avatar
Malthe Kjær Bisbo committed
50
search = GOFEE(calc=calc,
51
52
53
               startgenerator=sg,
               candidate_generator=candidate_generator,
               max_steps=200,
Malthe Kjær Bisbo's avatar
Malthe Kjær Bisbo committed
54
               max_relax_dist=4,
55
56
57
58
59
               population_size=5,
               kappa=1,
               dualpoint=True,
               restart='restart')

Malthe Kjær Bisbo's avatar
Malthe Kjær Bisbo committed
60
search.run()