Exemple #1
0
def ecut_convergence_study(ecuts=range(10, 40, 5)):
    """
    H2 molecule in a big box
    Generate a flow to compute the total energy and forces as a function of the interatomic distance
    """
    inputs = []
    for ecut in ecuts:
        inputs += h2_h_input(ecut=ecut)

    flow = flowtk.Flow.from_inputs("flow_h2h_ecut", inputs)
    flow.make_scheduler().start()

    import matplotlib.pyplot as plt
    import pandas as pd

    with abilab.abirobot(flow, "GSR") as robot:
        frame = robot.get_dataframe()
        frame = frame[["formula", "ecut", "energy"]]
        print(frame)

        grouped = frame.groupby("ecut")
        rows = []
        for ecut, group in grouped:
            group = group.set_index("formula")
            atomization = 2 * group["energy"]["H1"] - group["energy"]["H2"]
            atomization = abilab.Energy(atomization, "eV").to("Ha")
            rows.append(dict(ecut=ecut, atomization=atomization))

        atomization_frame = pd.DataFrame(rows)
        print(atomization_frame)

        atomization_frame.plot("ecut", "atomization")
        plt.show()
Exemple #2
0
def acell_convergence_study(acell_list=range(8, 20, 2), ecut=10):
    """
    H2 molecule in a big box
    Generate a flow to compute the total energy and the forces as function of the interatomic distance
    """
    inputs = []
    for acell in acell_list:
        inputs += h2_h_input(ecut=ecut, acell=3 * [acell])
    flow = flowtk.Flow.from_inputs("flow_h2h_acell", inputs)
    flow.make_scheduler().start()

    def hh_dist(gsr):
        """This function receives a GSR file and computes the H-H distance"""
        if len(gsr.structure) == 1:
            l = None
        else:
            cart_coords = gsr.structure.cart_coords
            l = np.sqrt(np.linalg.norm(cart_coords[1] - cart_coords[0]))
        return "hh_dist", l

    import matplotlib.pyplot as plt
    import pandas as pd

    with abilab.abirobot(flow, "GSR") as robot:
        frame = robot.get_dataframe(funcs=hh_dist)
        frame = frame[["formula", "a", "energy", "hh_dist"]]
        print(frame)

        grouped = frame.groupby("a")
        rows = []
        for a, group in grouped:
            group = group.set_index("formula")
            atomization = 2 * group["energy"]["H1"] - group["energy"]["H2"]
            atomization = abilab.Energy(atomization, "eV").to("Ha")
            # FIXME Values for hh_dist are wrong! why?
            rows.append(
                dict(a=a,
                     atomization=atomization,
                     hh_dist=group["hh_dist"]["H2"]))

        atomization_frame = pd.DataFrame(rows)
        print(atomization_frame)

        atomization_frame.plot("a", "atomization")
        plt.show()