def fun(args, consts):
        log = {}
        # get uuid
        calc_uuid = uuid.uuid4().hex[:8]
        # logging
        log["uuid"] = calc_uuid
        # make directories for the calculation
        dirname = os.path.join(calc["element"], calc_uuid)
        if not os.path.exists(dirname):
            os.makedirs(dirname)

        os.chdir(dirname)
        # generate radii iterable 
        radii = list(args) + list(consts)
        log["radii"] = radii
        pseudo_file, log["err_pseudo"] = generate_pseudo(calc, electrons, radii)
        log["err_mean"], log["err_max"] = test_pseudo(calc, configs)
        volumes = np.linspace(0.98, 1.02, 3)
        alats = (volumes * equil_volume * nat) ** (1./3.)
        x, y = [], []
        for alat in alats:
            prepare_siesta_calc(fdf_file, pseudo_file, alat, siesta_calc)
            run_siesta_calc(alat, siesta_calc)
            e = read_energy(alat)
            if e is not None:
                x.append(float(e[0]))
                y.append(e[1])
        os.chdir(cwd)
        # making x and y arrays
        x = (np.array(x) ** 3) / nat
        y = np.array(y)
        p = np.polyfit(x, y, 2)
        min_p = -p[1] / (2*p[0])
        log["min_p"] = min_p
        x_p = np.linspace(0.94*min_p, 1.06*min_p, 7)
        y_p = np.polyval(p, x_p)
        vol, bulk_mod, bulk_deriv, res = BM(np.vstack((x_p, y_p)).T)
        our_data = np.core.records.fromrecords([(element, vol, bulk_mod, bulk_deriv), ], names=('element', 'V0', 'B0', 'BP'))
        delta, delta_rel, delta1 = calcDelta_one(our_data, ref_data_el, useasymm=False)
        log["delta"] = delta
        log["delta_rel"] = delta_rel
        log["delta1"] = delta1
        log_entry(log, element)
        return delta
Esempio n. 2
0
    log["radii"] = radii
    pseudo_file, log["err_pseudo"] = generate_pseudo(calc, electrons, radii)
    log["err_mean"], log["err_max"] = test_pseudo(calc, configs)
    volumes = np.linspace(0.98, 1.02, 3)
    # possible alats (3 points near Wien2K equilibrium)
    alats = (volumes * equil_volume * nat) ** (1./3.)    
    x, y = [], []
    for alat in alats:
        prepare_siesta_calc(fdf_file, pseudo_file, alat, siesta_calc)
        run_siesta_calc(alat, siesta_calc)
        e = read_energy(alat)
        if e is not None:
            x.append(float(e[0]))
            y.append(e[1])
    os.chdir(cwd)
    # making x and y arrays
    x = (np.array(x) ** 3) / nat
    y = np.array(y)
    p = np.polyfit(x, y, 2)
    min_p = -p[1] / (2*p[0])
    log["min_p"] = min_p
    x_p = np.linspace(0.94*min_p, 1.06*min_p, 7)
    y_p = np.polyval(p, x_p)
    vol, bulk_mod, bulk_deriv, res = BM(np.vstack((x_p, y_p)).T)
    our_data = np.core.records.fromrecords([(element, vol, bulk_mod, bulk_deriv), ], names=('element', 'V0', 'B0', 'BP'))
    delta, delta_rel, delta1 = calcDelta_one(our_data, ref_data_el, useasymm=False)
    log["delta"] = delta
    log["delta_rel"] = delta_rel
    log["delta1"] = delta1
    log_entry(log, element)
Esempio n. 3
0
    for root, dirs, files in os.walk(os.getcwd()):
        for dir_i in dirs:
            try:
                alat = float(dir_i)
            except:
                continue
            energies = read_energy(alat)
            if energies is not None:
                x_i, y_i = energies
                x.append(x_i)
                y.append(y_i)
    os.chdir(wd)
    x = (np.array(x) ** 3) / nat
    y = np.array(y)
    p = np.polyfit(x, y, 2)
    x_min = -p[1] / (2*p[0])
    x_p = np.linspace(0.94*x_min, 1.06*x_min, 7)
    y_p = np.polyval(p, x_p)
#    vol, bulk_mod, bulk_deriv, res = BM(np.vstack((x_p, y_p)).T)
    vol, bulk_mod, bulk_deriv, res = BM(np.vstack((x, y)).T)
    ref_data = read_ref_data("delta/WIEN2k.txt")
    ref_data_el = ref_data[ref_data['element'] == element]
    our_data = np.core.records.fromrecords([(element, vol, bulk_mod, bulk_deriv), ], names=('element', 'V0', 'B0', 'BP'))

    print calcDelta_one(our_data, ref_data_el, useasymm=False)
    
    plt.plot(np.array(x), np.array(y), "o")
    plt.plot(x_p, y_p, "--")
    plt.show()