Commit b18a63a1 authored by Malthe Kjær Bisbo's avatar Malthe Kjær Bisbo
Browse files

added traceback to bfgslinesearch_constrainted

parent 3de1629c
...@@ -6,6 +6,8 @@ from ase.ga.utilities import get_mic_distance ...@@ -6,6 +6,8 @@ from ase.ga.utilities import get_mic_distance
from utils import check_valid_bondlengths from utils import check_valid_bondlengths
import traceback
class BFGSLineSearch_constrained(BFGSLineSearch): class BFGSLineSearch_constrained(BFGSLineSearch):
def __init__(self, atoms, pos_init=None, restart=None, logfile='-', maxstep=.2, def __init__(self, atoms, pos_init=None, restart=None, logfile='-', maxstep=.2,
......
...@@ -185,6 +185,7 @@ class GOFEE(): ...@@ -185,6 +185,7 @@ class GOFEE():
self.comm.barrier() self.comm.barrier()
def initialize(self): def initialize(self):
self.get_initial_structures()
self.steps = 0 self.steps = 0
def get_initial_structures(self): def get_initial_structures(self):
...@@ -198,22 +199,14 @@ class GOFEE(): ...@@ -198,22 +199,14 @@ class GOFEE():
they are generated by heavily rattling the supplied structures. they are generated by heavily rattling the supplied structures.
""" """
# Collect potentially supplied structures and evaluate # Collect potentially supplied structures.
# energies and forces if not present.
structures_init = []
if self.structures is not None: if self.structures is not None:
for a in self.structures: for a in self.structures:
a.info = {'origin': 'PreSupplied'} a.info = {'origin': 'PreSupplied'}
calc = a.get_calculator() else:
if isinstance(calc, SinglePointCalculator): self.structures = []
if 'energy' in calc.results and 'forces' in calc.results:
# Add without evaluating.
structures_init.append(a)
continue
a = self.evaluate(a)
structures_init.append(a)
Nremaining = self.Ninit - len(structures_init) Nremaining = self.Ninit - len(self.structures)
if Nremaining > 0 and self.startgenerator is None: if Nremaining > 0 and self.startgenerator is None:
# Initialize rattle-mutation for all atoms. # Initialize rattle-mutation for all atoms.
...@@ -227,21 +220,33 @@ class GOFEE(): ...@@ -227,21 +220,33 @@ class GOFEE():
a = self.startgenerator.get_new_candidate() a = self.startgenerator.get_new_candidate()
else: else:
# Perform two times rattle of all atoms. # Perform two times rattle of all atoms.
a0 = structures_init[i % len(structures_init)] a0 = self.structures[i % len(self.structures)]
a = rattle.get_new_candidate([a]) a = rattle.get_new_candidate([a])
a = rattle.get_new_candidate([a]) a = rattle.get_new_candidate([a])
self.structures.append(a)
def evaluate_initial_structures(self):
structures_init = []
for a in self.structures:
calc = a.get_calculator()
if isinstance(calc, SinglePointCalculator):
if 'energy' in calc.results and 'forces' in calc.results:
# Write without evaluating.
structures_init.append(a)
continue
a = self.evaluate(a) a = self.evaluate(a)
structures_init.append(a) structures_init.append(a)
for a in structures_init: for a in structures_init:
self.write(a) self.write(a)
self.gpr.memory.save_data(structures_init) self.gpr.memory.save_data(structures_init)
self.population.add(structures_init) self.population.add(structures_init)
def run(self): def run(self):
""" Method to run the search. """ Method to run the search.
""" """
self.get_initial_structures() if self.steps == 0:
self.evaluate_initial_structures()
while self.steps < self.max_steps: while self.steps < self.max_steps:
self.print_master('\n ### steps: {} ###\n'.format(self.steps)) self.print_master('\n ### steps: {} ###\n'.format(self.steps))
......
...@@ -80,7 +80,7 @@ class GPR(): ...@@ -80,7 +80,7 @@ class GPR():
if kernel is 'single': if kernel is 'single':
self.kernel = gauss_kernel() self.kernel = gauss_kernel()
elif kernel is 'double': elif kernel is 'double':
self.kernel = double_gauss_kernel(Nsplit_eta=self.descriptor.Nelements_2body) self.kernel = double_gauss_kernel()
else: else:
self.kernel = kernel self.kernel = kernel
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment