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(): ...@@ -155,9 +155,8 @@ class GOFEE():
Ei = a.get_potential_energy() Ei = a.get_potential_energy()
Fi = a.get_forces() Fi = a.get_forces()
self.gpr.memory.save_data([a]) self.gpr.memory.save_data([a])
self.trajectory.write(a, energy=Ei, forces=Fi) self.trajectory.write(a)
#self.population.add_structure(a, Ei, Fi) self.population.add(a)
self.population.add_structure(a)
def run(self): def run(self):
self.initialize_search() self.initialize_search()
...@@ -169,18 +168,30 @@ class GOFEE(): ...@@ -169,18 +168,30 @@ class GOFEE():
relaxed_candidates = self.get_surrogate_relaxed_candidates() relaxed_candidates = self.get_surrogate_relaxed_candidates()
kappa = self.kappa kappa = self.kappa
a_add = []
for _ in range(5):
try:
anew = self.select_with_acquisition(relaxed_candidates, kappa) anew = self.select_with_acquisition(relaxed_candidates, kappa)
self.print_master('aq done') self.print_master('aq done')
anew = self.evaluate(anew) anew = self.evaluate(anew)
a_add.append(anew)
self.print_master('sp done') self.print_master('sp done')
if self.dualpoint: if self.dualpoint:
adp = self.get_dualpoint(anew) adp = self.get_dualpoint(anew)
adp = self.evaluate(adp) adp = self.evaluate(adp)
a_add.append(adp)
self.print_master('dp done') self.print_master('dp done')
self.gpr.memory.save_data([anew, adp]) 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) self.counter += 1 + int(self.dualpoint)
# Add structure to population # Add structure to population
self.population.add(a_add)
"""
E = anew.get_potential_energy() E = anew.get_potential_energy()
if self.dualpoint: if self.dualpoint:
Edp = adp.get_potential_energy() Edp = adp.get_potential_energy()
...@@ -190,8 +201,9 @@ class GOFEE(): ...@@ -190,8 +201,9 @@ class GOFEE():
self.population.add_structure(anew) self.population.add_structure(anew)
else: else:
self.population.add_structure(anew) self.population.add_structure(anew)
"""
if self.master: if self.master:
print('info:', anew.info)
print('anew pred:', anew.info['key_value_pairs']['Epred'], anew.info['key_value_pairs']['Epred_std']) 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('E_true:', anew.get_potential_energy(), adp.get_potential_energy())
print('pop:', [a.get_potential_energy() for a in self.population.pop]) print('pop:', [a.get_potential_energy() for a in self.population.pop])
......
import numpy as np import numpy as np
from ase.calculators.singlepoint import SinglePointCalculator from ase.calculators.singlepoint import SinglePointCalculator
from ase import Atoms
class population(): class population():
...@@ -41,13 +41,19 @@ class population(): ...@@ -41,13 +41,19 @@ class population():
del self.pop[k] del self.pop[k]
del self.pop_MLrelaxed[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() self.remove_duplicate_structures()
if E is None:
assert 'energy' in a.get_calculator().results assert 'energy' in a.get_calculator().results
E = a.get_potential_energy() E = a.get_potential_energy()
if F is None:
assert 'forces' in a.get_calculator().results assert 'forces' in a.get_calculator().results
F = a.get_forces() F = a.get_forces()
......
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