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
anew = self.select_with_acquisition(relaxed_candidates, kappa) a_add = []
self.print_master('aq done') for _ in range(5):
anew = self.evaluate(anew) try:
self.print_master('sp done') anew = self.select_with_acquisition(relaxed_candidates, kappa)
if self.dualpoint: self.print_master('aq done')
adp = self.get_dualpoint(anew) anew = self.evaluate(anew)
adp = self.evaluate(adp) a_add.append(anew)
self.print_master('dp done') self.print_master('sp done')
self.gpr.memory.save_data([anew, adp]) 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) 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():
...@@ -40,16 +40,22 @@ class population(): ...@@ -40,16 +40,22 @@ class population():
for k in sorted(structures2remove)[::-1]: for k in sorted(structures2remove)[::-1]:
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() assert 'forces' in a.get_calculator().results
if F is None: F = a.get_forces()
assert 'forces' in a.get_calculator().results
F = a.get_forces()
if E > self.largest_energy and len(self.pop) == self.pop_size: if E > self.largest_energy and len(self.pop) == self.pop_size:
return 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