Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/mir-group/flare
Browse files Browse the repository at this point in the history
  • Loading branch information
jonpvandermause committed Sep 24, 2019
2 parents 9c20ad4 + 3b3345a commit a0b6ba8
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions flare/gp_from_aimd.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@ def __init__(self, frames: List[Structure],
calculate_energy: bool = False,
output_name: str = 'gp_from_aimd',
max_atoms_from_frame: int = np.inf, max_trains: int = np.inf,
min_atoms_added: int = 1,
n_cpus: int = 1, shuffle_frames: bool = False,
min_atoms_added: int = 1, shuffle_frames: bool = False,
verbose: int = 0, model_write: str = '',
pre_train_on_skips: bool = False,
pre_train_seed_frames: List[Structure] = None,
Expand Down Expand Up @@ -94,8 +93,6 @@ def __init__(self, frames: List[Structure],

self.output = Output(output_name)

# set number of cpus for parallelization
self.n_cpus = n_cpus

# To later be filled in using the time library
self.start_time = None
Expand Down Expand Up @@ -130,7 +127,8 @@ def pre_run(self):
self.abs_std_tolerance))

self.start_time = time.time()

if self.verbose >= 3:
print("Now beginning pre-run training.")
# If seed environments were passed in, add them to the GP.
for point in self.seed_envs:
self.gp.add_one_env(point[0], point[1], train=False)
Expand All @@ -139,7 +137,7 @@ def pre_run(self):
# Take one of each atom species in the first frame
# so all atomic species are represented in the first step.
# Otherwise use the seed frames passed in by user.
if len(self.gp.training_data) == 0 and self.seed_frames is None:
if len(self.gp.training_data) == 0 and self.seed_frames is []:
self.seed_frames = [self.frames[0]]

for frame in self.seed_frames:
Expand All @@ -161,10 +159,13 @@ def pre_run(self):

# These conditions correspond to if either the GP was never trained
# or if data was added to it during the pre-run.
if self.verbose >= 3:
print("Now commencing initial training of GP (which has "
"non-empty training set)")

if (self.gp.l_mat is None) \
or (self.seed_frames is not None
or self.seed_envs is not None):
or (self.seed_frames is not []
or self.seed_envs is not []):
self.gp.train(output=self.output if self.verbose > 0 else None)

def run(self):
Expand All @@ -174,7 +175,8 @@ def run(self):
the training set upon the triggering of the uncertainty threshold.
:return:
"""

if self.verbose >= 3:
print("Commencing run with pre-run...")
self.pre_run()

# Loop through trajectory
Expand Down

0 comments on commit a0b6ba8

Please sign in to comment.