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
dirname = os.path.join(element, calc_uuid) if not os.path.exists(dirname): os.makedirs(dirname) os.chdir(dirname) 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)
fdf_file = read_fdf_file() data_dir = os.path.join("Fe", "37518ef0") #data_dir = os.path.join(element, sys.argv[1]) x, y = [], [] wd = os.getcwd() os.chdir(data_dir) pseudo_file = glob.glob("*.psf")[0] for root, dirs, files in os.walk(os.getcwd()): if "check" in root: continue 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) x = (np.array(x) ** 3) / nat y = np.array(y) p = np.polyfit(x, y, 2) # find equilibrium volume x_min = -p[1] / (2*p[0]) alats = (np.linspace(0.94*x_min, 1.06*x_min, 7) * nat) ** (1./3.) np.savetxt("text.txt", np.vstack((alats, np.polyval(p,np.linspace(0.94*x_min, 1.06*x_min, 7)))).T) # get check directory if not os.path.exists("check"): os.makedirs("check") shutil.copy(pseudo_file, "check")