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

update

parent 747db96a
......@@ -155,9 +155,8 @@ class GOFEE():
Ei = a.get_potential_energy()
Fi = a.get_forces()
self.gpr.memory.save_data([a])
self.trajectory.write(a, energy=Ei, forces=Fi)
#self.population.add_structure(a, Ei, Fi)
self.population.add_structure(a)
self.trajectory.write(a)
self.population.add(a)
def run(self):
self.initialize_search()
......@@ -169,18 +168,30 @@ class GOFEE():
relaxed_candidates = self.get_surrogate_relaxed_candidates()
kappa = self.kappa
anew = self.select_with_acquisition(relaxed_candidates, kappa)
self.print_master('aq done')
anew = self.evaluate(anew)
self.print_master('sp done')
if self.dualpoint:
adp = self.get_dualpoint(anew)
adp = self.evaluate(adp)
self.print_master('dp done')
self.gpr.memory.save_data([anew, adp])
a_add = []
for _ in range(5):
try:
anew = self.select_with_acquisition(relaxed_candidates, kappa)
self.print_master('aq done')
anew = self.evaluate(anew)
a_add.append(anew)
self.print_master('sp done')
if self.dualpoint:
adp = self.get_dualpoint(anew)
adp = self.evaluate(adp)
a_add.append(adp)
self.print_master('dp done')
break
except Exception as err:
kappa /=2
if self.master:
traceback.print_exc(file=sys.stderr)
self.gpr.memory.save_data(a_add)
self.counter += 1 + int(self.dualpoint)
# Add structure to population
self.population.add(a_add)
"""
E = anew.get_potential_energy()
if self.dualpoint:
Edp = adp.get_potential_energy()
......@@ -190,8 +201,9 @@ class GOFEE():
self.population.add_structure(anew)
else:
self.population.add_structure(anew)
"""
if self.master:
print('info:', anew.info)
print('anew pred:', anew.info['key_value_pairs']['Epred'], anew.info['key_value_pairs']['Epred_std'])
print('E_true:', anew.get_potential_energy(), adp.get_potential_energy())
print('pop:', [a.get_potential_energy() for a in self.population.pop])
......
import numpy as np
from ase.calculators.singlepoint import SinglePointCalculator
from ase import Atoms
class population():
......@@ -40,16 +40,22 @@ class population():
for k in sorted(structures2remove)[::-1]:
del self.pop[k]
del self.pop_MLrelaxed[k]
def add_structure(self, a, E=None, F=None):
def add(self, structures):
if isinstance(structures, Atoms):
self.__add_structure(structures)
elif isinstance(structures, list):
assert isinstance(structures[0], Atoms)
for a in structures:
self.__add_structure(a)
def __add_structure(self, a):
self.remove_duplicate_structures()
if E is None:
assert 'energy' in a.get_calculator().results
E = a.get_potential_energy()
if F is None:
assert 'forces' in a.get_calculator().results
F = a.get_forces()
assert 'energy' in a.get_calculator().results
E = a.get_potential_energy()
assert 'forces' in a.get_calculator().results
F = a.get_forces()
if E > self.largest_energy and len(self.pop) == self.pop_size:
return
......
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