Esempio n. 1
0
    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()
Esempio n. 3
0
    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()
Esempio n. 4
0
def test_fake_ase():
    # pysisyphus
    pysis_calc = LennardJones()
    ase_calc = FakeASE(pysis_calc)

    # ASE atoms, pysisyphus calculator
    atoms_pysis = Icosahedron("Ar", noshells=2, latticeconstant=3)
    # ASE atoms, ASE calculator
    atoms_ase = atoms_pysis.copy()

    atoms_pysis.set_calculator(ase_calc)
    atoms_ase.set_calculator(ase_LJ())

    pysis_forces = atoms_pysis.get_forces()
    ase_forces = atoms_ase.get_forces()
    np.testing.assert_allclose(pysis_forces, ase_forces, atol=1e-15)
Esempio n. 5
0
    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 = {
        "default": {
            "G2": {
                "etas": np.logspace(np.log10(0.05), np.log10(5.0), num=4),
                "rs_s": [0],
            },
            "G4": {
                "etas": [0.005],
Esempio n. 6
0
    cluster = LocalCluster(processes=True, threads_per_worker=1)
    client = Client(cluster)
    EnsembleCalc.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=60,
                                maxstep=0.04)

    Gs = {
        "default": {
            "G2": {
                "etas": np.logspace(np.log10(0.05), np.log10(5.0), num=4),
                "rs_s": [0],
            },
            "G4": {
                "etas": [0.005],