def setUpClass(cls) -> None: initial_structure = Icosahedron("Cu", 2) initial_structure.rattle(0.1) initial_structure.set_pbc(True) initial_structure.set_cell([20, 20, 20]) EMT_initial_structure = initial_structure.copy() parent_calc = EMT() cls.emt_counter = CounterCalc(parent_calc) EMT_initial_structure.set_calculator(cls.emt_counter) cls.EMT_structure_optim = Relaxation( EMT_initial_structure, BFGS, fmax=0.01, steps=30 ) cls.EMT_structure_optim.run(cls.emt_counter, "CuNP_emt") offline_initial_structure = compute_with_calc( [initial_structure.copy()], parent_calc )[0] Offline_relaxation = Relaxation( offline_initial_structure, BFGS, fmax=0.01, steps=30, maxstep=0.05 ) cls.offline_learner, cls.trained_calc, cls.Offline_traj = run_offline_al( Offline_relaxation, [offline_initial_structure], "CuNP_offline_al", parent_calc, ) cls.EMT_image = cls.EMT_structure_optim.get_trajectory("CuNP_emt")[-1] cls.EMT_image.set_calculator(parent_calc) cls.offline_final_structure_AL = cls.Offline_traj[-1] cls.offline_final_structure_AL.set_calculator(cls.trained_calc) cls.offline_final_structure_EMT = cls.Offline_traj[-1] cls.offline_final_structure_EMT.set_calculator(parent_calc) cls.description = "CuNP" return super().setUpClass()
def setUpClass(cls) -> None: # Set up parent calculator and image environment initial_structure = Icosahedron("Cu", 2) initial_structure.rattle(0.1) initial_structure.set_pbc(True) initial_structure.set_cell([20, 20, 20]) # Run relaxation with the parent calc EMT_initial_structure = initial_structure.copy() cls.emt_counter = CounterCalc(EMT()) EMT_initial_structure.set_calculator(cls.emt_counter) cls.EMT_structure_optim = Relaxation(EMT_initial_structure, BFGS, fmax=FORCE_THRESHOLD, steps=30) cls.EMT_structure_optim.run(cls.emt_counter, "CuNP_emt") # Run relaxation with active learning chemical_formula = initial_structure.get_chemical_formula() al_config = cls.get_al_config() al_config["links"]["traj"] = "CuNP_emt.traj" cls.oal_results_dict = active_learning(al_config) dbname = (str(al_config["links"]["ml_potential"]) + "_" + str(chemical_formula) + "_oal") cls.OAL_image = Trajectory(dbname + ".traj")[-1] cls.OAL_image.set_calculator(EMT()) # Retain images of the final structure from both relaxations cls.EMT_image = cls.EMT_structure_optim.get_trajectory("CuNP_emt")[-1] cls.EMT_image.set_calculator(EMT()) cls.description = "CuNP" return super().setUpClass()
def icosahedron_grid(element, lattice_constant, size): atoms = Icosahedron(symbol=element, noshells=size, latticeconstant=lattice_constant) atoms.set_pbc(True) atoms.center(vacuum=5.) return atoms
def setUpClass(cls) -> None: # Set up parent calculator and image environment initial_structure = Icosahedron("Cu", 2) initial_structure.rattle(0.1) initial_structure.set_pbc(True) initial_structure.set_cell([20, 20, 20]) # Run relaxation with the parent calc EMT_initial_structure = initial_structure.copy() cls.emt_counter = CounterCalc(EMT()) EMT_initial_structure.set_calculator(cls.emt_counter) cls.EMT_structure_optim = Relaxation(EMT_initial_structure, BFGS, fmax=FORCE_THRESHOLD, steps=30) cls.EMT_structure_optim.run(cls.emt_counter, "CuNP_emt") # Run relaxation with active learning OAL_initial_structure = initial_structure.copy() OAL_initial_structure.set_calculator(EMT()) OAL_relaxation = Relaxation(OAL_initial_structure, BFGS, fmax=0.05, steps=60, maxstep=0.04) cls.OAL_learner, cls.OAL_structure_optim = run_online_al( OAL_relaxation, [OAL_initial_structure], ["Cu"], "CuNP_oal", EMT(), ) # Retain images of the final structure from both relaxations cls.EMT_image = cls.EMT_structure_optim.get_trajectory("CuNP_emt")[-1] cls.EMT_image.set_calculator(EMT()) cls.OAL_image = cls.OAL_structure_optim.get_trajectory("CuNP_oal")[-1] cls.OAL_image.set_calculator(EMT()) cls.description = "CuNP" return super().setUpClass()
import copy # Set up ensemble parallelization if __name__ == "__main__": # import make_ensemble and dask for setting parallelization from al_mlp.ml_potentials.amptorch_ensemble_calc import AmptorchEnsembleCalc from dask.distributed import Client, LocalCluster cluster = LocalCluster(processes=True, threads_per_worker=1) client = Client(cluster) AmptorchEnsembleCalc.set_executor(client) # Set up parent calculator and image environment initial_structure = Icosahedron("Cu", 2) initial_structure.rattle(0.1) initial_structure.set_pbc(True) initial_structure.set_cell([20, 20, 20]) images = [] elements = ["Cu"] parent_calc = EMT() # Run relaxation with active learning OAL_initial_structure = initial_structure.copy() OAL_initial_structure.set_calculator(copy.deepcopy(parent_calc)) OAL_relaxation = Relaxation(OAL_initial_structure, BFGS, fmax=0.05, steps=200, maxstep=0.04) Gs = {