population_size = 20
mutation_probability = 0.3
n_to_test = 20

# Initialize the different components of the GA
da = DataConnection('gadb.db')
atom_numbers_to_optimize = da.get_atom_numbers_to_optimize()
n_to_optimize = len(atom_numbers_to_optimize)
slab = da.get_slab()
all_atom_types = get_all_atom_types(slab, atom_numbers_to_optimize)
blmin = closest_distances_generator(all_atom_types,
                                    ratio_of_covalent_radii=0.7)

comp = InteratomicDistanceComparator(n_top=n_to_optimize,
                                     pair_cor_cum_diff=0.015,
                                     pair_cor_max=0.7,
                                     dE=0.02,
                                     mic=False)

pairing = CutAndSplicePairing(slab, n_to_optimize, blmin)
mutations = OperationSelector([1., 1., 1.],
                              [MirrorMutation(blmin, n_to_optimize),
                               RattleMutation(blmin, n_to_optimize),
                               PermutationMutation(n_to_optimize)])

# Relax all unrelaxed structures (e.g. the starting population)
while da.get_number_of_unrelaxed_candidates() > 0:
    a = da.get_an_unrelaxed_candidate()
    a.set_calculator(EMT())
    print('Relaxing starting candidate {0}'.format(a.info['confid']))
    dyn = BFGS(a, trajectory=None, logfile=None)
Ejemplo n.º 2
0
from ase.ga.standard_comparators import InteratomicDistanceComparator
from ase import Atoms
from ase.calculators.singlepoint import SinglePointCalculator

a1 = Atoms('AgAgAg', positions=[[0, 0, 0], [1.5, 0, 0], [1.5, 1.5, 0]])
a2 = Atoms('AgAgAg', positions=[[0, 0, 0], [1.4, 0, 0], [1.5, 1.5, 0]])

e1 = 1.0
e2 = 0.8

a1.set_calculator(SinglePointCalculator(e1, None, None, None, a1))
a2.set_calculator(SinglePointCalculator(e2, None, None, None, a2))

comp1 = InteratomicDistanceComparator(n_top=3,
                                      pair_cor_cum_diff=0.03,
                                      pair_cor_max=0.7,
                                      dE=0.3)
assert comp1.looks_like(a1, a2)


comp2 = InteratomicDistanceComparator(n_top=3,
                                      pair_cor_cum_diff=0.03,
                                      pair_cor_max=0.7,
                                      dE=0.15)
assert not comp2.looks_like(a1, a2)


comp3 = InteratomicDistanceComparator(n_top=3,
                                      pair_cor_cum_diff=0.02,
                                      pair_cor_max=0.7,
                                      dE=0.3)
Ejemplo n.º 3
0
                                         SequentialComparator)
from ase import Atoms
from ase.calculators.singlepoint import SinglePointCalculator
from ase.ga import set_raw_score

a1 = Atoms('AgAgAg', positions=[[0, 0, 0], [1.5, 0, 0], [1.5, 1.5, 0]])
a2 = Atoms('AgAgAg', positions=[[0, 0, 0], [1.4, 0, 0], [1.5, 1.5, 0]])

e1 = 1.0
e2 = 0.8

a1.set_calculator(SinglePointCalculator(a1, energy=e1))
a2.set_calculator(SinglePointCalculator(a2, energy=e2))

comp1 = InteratomicDistanceComparator(n_top=3,
                                      pair_cor_cum_diff=0.03,
                                      pair_cor_max=0.7,
                                      dE=0.3)
assert comp1.looks_like(a1, a2)

comp2 = InteratomicDistanceComparator(n_top=3,
                                      pair_cor_cum_diff=0.03,
                                      pair_cor_max=0.7,
                                      dE=0.15)
assert not comp2.looks_like(a1, a2)

comp3 = InteratomicDistanceComparator(n_top=3,
                                      pair_cor_cum_diff=0.02,
                                      pair_cor_max=0.7,
                                      dE=0.3)
assert not comp3.looks_like(a1, a2)