def fit_force_and_energy(self, confs, forces, glob_confs, energies, ncores=1): """ Fit the GP to a set of training forces and energies using 2-body single species force-force, energy-force and energy-energy kernels Args: confs (list): List of M x 5 arrays containing coordinates and atomic numbers of atoms within a cutoff from the central one forces (array) : Array containing the vector forces on the central atoms of the training configurations glob_confs (list of lists): List of configurations arranged so that grouped configurations belong to the same snapshot energies (array) : Array containing the total energy of each snapshot ncores (int): number of CPUs to use for the gram matrix evaluation """ if self.rep_sig: self.rep_sig = utility.find_repulstion_sigma(confs) self.rep_energies = utility.get_repulsive_energies( glob_confs, self.rep_sig) energies -= self.rep_energies self.rep_forces = utility.get_repulsive_forces(confs, self.rep_sig) forces -= self.rep_forces self.gp.fit_force_and_energy(confs, forces, glob_confs, energies, ncores=ncores)
def fit(self, confs, forces, ncores=1): """ Fit the GP to a set of training forces using a 2- and 3-body single species force-force kernel functions. The 2-body Gaussian process is first fitted, then the 3-body GP is fitted to the difference between the training forces and the 2-body predictions of force on the training configurations Args: confs (list): List of M x 5 arrays containing coordinates and atomic numbers of atoms within a cutoff from the central one forces (array) : Array containing the vector forces on the central atoms of the training configurations ncores (int): number of CPUs to use for the gram matrix evaluation """ hypotetical_model_name = "models/MODEL_ker_TwoBodyManySpecies_ntr_%i.json" %(len(forces)) try: model_2b = models.TwoBodyManySpeciesModel.from_json(hypotetical_model_name) self.rep_sig = model_2b.rep_sig self.gp_2b = model_2b.gp if self.rep_sig: self.rep_sig = utility.find_repulstion_sigma(confs) self.rep_forces = utility.get_repulsive_forces(confs, self.rep_sig) forces -= self.rep_forces print("Loaded 2-body model to bootstart training") except: if self.rep_sig: self.rep_sig = utility.find_repulstion_sigma(confs) self.rep_forces = utility.get_repulsive_forces(confs, self.rep_sig) forces -= self.rep_forces self.gp_2b.fit(confs, forces, ncores=ncores) ntr = len(confs) two_body_forces = self.gp_2b.predict(confs, ncores=ncores) self.gp_3b.fit(confs, forces - two_body_forces, ncores=ncores)
def fit_force_and_energy(self, confs, forces, glob_confs, energies, ncores=1): """ Fit the GP to a set of training energies using a 2- and 3-body single species force-force, energy-energy, and energy-forces kernel functions. The 2-body Gaussian process is first fitted, then the 3-body GP is fitted to the difference between the training energies (and forces) and the 2-body predictions of energies (and forces) on the training configurations. Args: confs (list): List of M x 5 arrays containing coordinates and atomic numbers of atoms within a cutoff from the central one forces (array) : Array containing the vector forces on the central atoms of the training configurations glob_confs (list of lists): List of configurations arranged so that grouped configurations belong to the same snapshot energies (array) : Array containing the total energy of each snapshot ncores (int): number of CPUs to use for the gram matrix evaluation """ hypotetical_model_name = "models/MODEL_ker_TwoBodySingleSpecies_ntr_%i.json" %(len(energies)+len(forces)) try: model_2b = models.TwoBodySingleSpeciesModel.from_json(hypotetical_model_name) self.rep_sig = model_2b.rep_sig self.gp_2b = model_2b.gp if self.rep_sig: self.rep_energies = utility.get_repulsive_energies( glob_confs, self.rep_sig) energies -= self.rep_energies self.rep_forces = utility.get_repulsive_forces(confs, self.rep_sig) forces -= self.rep_forces print("Loaded 2-body model to bootstart training") except: if self.rep_sig: self.rep_sig = utility.find_repulstion_sigma(confs) self.rep_energies = utility.get_repulsive_energies( glob_confs, self.rep_sig) energies -= self.rep_energies self.rep_forces = utility.get_repulsive_forces(confs, self.rep_sig) forces -= self.rep_forces self.gp_2b.fit_force_and_energy( confs, forces, glob_confs, energies, ncores=ncores) two_body_forces = self.gp_2b.predict(confs, ncores=ncores) two_body_energies = self.gp_2b.predict_energy( glob_confs, ncores=ncores) self.gp_3b.fit_force_and_energy( confs, forces - two_body_forces, glob_confs, energies - two_body_energies, ncores=ncores)
def fit_energy(self, glob_confs, energies, ncores=1): """ Fit the GP to a set of training energies using a 2-body single species energy-energy kernel Args: glob_confs (list of lists): List of configurations arranged so that grouped configurations belong to the same snapshot energies (array) : Array containing the total energy of each snapshot ncores (int): number of CPUs to use for the gram matrix evaluation """ if self.rep_sig: self.rep_sig = utility.find_repulstion_sigma(glob_confs) self.rep_energies = utility.get_repulsive_energies( glob_confs, self.rep_sig) energies -= self.rep_energies self.gp.fit_energy(glob_confs, energies, ncores=ncores)
def fit(self, confs, forces, ncores=1): """ Fit the GP to a set of training forces using a 2-body single species force-force kernel Args: confs (list): List of M x 5 arrays containing coordinates and atomic numbers of atoms within a cutoff from the central one forces (array) : Array containing the vector forces on the central atoms of the training configurations ncores (int): number of CPUs to use for the gram matrix evaluation """ if self.rep_sig: self.rep_sig = utility.find_repulstion_sigma(confs) self.rep_forces = utility.get_repulsive_forces(confs, self.rep_sig) forces -= self.rep_forces self.gp.fit(confs, forces, ncores=ncores)
def fit_energy(self, glob_confs, energies, ncores=1): """ Fit the GP to a set of training energies using a 2- and 3-body single species energy-energy kernel functions. The 2-body Gaussian process is first fitted, then the 3-body GP is fitted to the difference between the training energies and the 2-body predictions of energies on the training configurations. Args: glob_confs (list of lists): List of configurations arranged so that grouped configurations belong to the same snapshot energies (array) : Array containing the total energy of each snapshot ncores (int): number of CPUs to use for the gram matrix evaluation """ hypotetical_model_name = "models/MODEL_ker_TwoBodyManySpecies_ntr_%i.json" %(len(energies)) try: model_2b = models.TwoBodyManySpeciesModel.from_json(hypotetical_model_name) self.rep_sig = model_2b.rep_sig self.gp_2b = model_2b.gp if self.rep_sig: self.rep_energies = utility.get_repulsive_energies( glob_confs, self.rep_sig) energies -= self.rep_energies print("Loaded 2-body model to bootstart training") except: if self.rep_sig: self.rep_sig = utility.find_repulstion_sigma(glob_confs) self.rep_energies = utility.get_repulsive_energies( glob_confs, self.rep_sig) energies -= self.rep_energies self.gp_2b.fit_energy(glob_confs, energies, ncores=1) ntr = len(glob_confs) two_body_energies = self.gp_2b.predict_energy( glob_confs, ncores=ncores) self.gp_3b.fit_energy(glob_confs, energies - two_body_energies, ncores=ncores)