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
from utils import check_valid_bondlengths
import traceback
class BFGSLineSearch_constrained(BFGSLineSearch):
def __init__(self, atoms, pos_init=None, restart=None, logfile='-', maxstep=.2,
......
......@@ -185,6 +185,7 @@ class GOFEE():
self.comm.barrier()
def initialize(self):
self.get_initial_structures()
self.steps = 0
def get_initial_structures(self):
......@@ -198,22 +199,14 @@ class GOFEE():
they are generated by heavily rattling the supplied structures.
"""
# Collect potentially supplied structures and evaluate
# energies and forces if not present.
structures_init = []
# Collect potentially supplied structures.
if self.structures is not None:
for a in self.structures:
a.info = {'origin': 'PreSupplied'}
calc = a.get_calculator()
if isinstance(calc, SinglePointCalculator):
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)
else:
self.structures = []
Nremaining = self.Ninit - len(structures_init)
Nremaining = self.Ninit - len(self.structures)
if Nremaining > 0 and self.startgenerator is None:
# Initialize rattle-mutation for all atoms.
......@@ -227,9 +220,20 @@ class GOFEE():
a = self.startgenerator.get_new_candidate()
else:
# 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])
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)
structures_init.append(a)
......@@ -241,7 +245,8 @@ class GOFEE():
def run(self):
""" Method to run the search.
"""
self.get_initial_structures()
if self.steps == 0:
self.evaluate_initial_structures()
while self.steps < self.max_steps:
self.print_master('\n ### steps: {} ###\n'.format(self.steps))
......
......@@ -80,7 +80,7 @@ class GPR():
if kernel is 'single':
self.kernel = gauss_kernel()
elif kernel is 'double':
self.kernel = double_gauss_kernel(Nsplit_eta=self.descriptor.Nelements_2body)
self.kernel = double_gauss_kernel()
else:
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