Пример #1
0
def load_cells():
    """Load the two test supercells."""
    p1 = os.path.join(testdir(), "POSCAR")
    c1 = aread(p1, format="vasp")
    p2 = os.path.join(testdir(), "POSCAR2")
    c2 = aread(p2, format="vasp")
    return (c1, c2)
Пример #2
0
def load_cells():
    """Load the two test supercells."""
    p1 = os.path.join(testdir(), "POSCAR")
    c1 = aread(p1, format="vasp")
    p2 = os.path.join(testdir(), "POSCAR2")
    c2 = aread(p2, format="vasp")
    return (c1, c2)
def read_initial_positions(args):
    # Initial cif files
    print("Give data directory path:")
    DATAPATH = input()
    print("Give directories with datafiles:")
    data_flist = [folder for folder in input().split(',')]

    init_dict = {}
    print("Creating dictionary to keep initial positions...")
    for folder in data_flist:
        folder_path = DATAPATH + '/' + folder
        for path in Path(folder_path).rglob('*.cif'):  # every structure
            struct_dict = {}
            atoms = aread(path)
            positions = atoms.get_positions()
            count_ions = 0
            for ion in atoms.get_chemical_symbols():
                struct_dict[ion + str(count_ions)] = tuple(
                    list(positions[count_ions, :]))
                count_ions += 1
            init_dict[(path.name, folder)] = struct_dict
            # print("File "+path.name+" is done.")

    print("Dumped " + str(len(init_dict.keys())) + " structures\' initial \
	positions into " + args.test_dir + "/temp.p")
    import pickle
    pickle.dump(init_dict, open(args.test_dir + "/temp.p", "wb"))
Пример #4
0
 def setUp(self):
     # The test POSCAR file is in the same directory.
     path = os.path.join(testdir(), "POSCAR")
     self.cell = aread(path, format="vasp")
Пример #5
0
def energy_function_wrapper(r, N, *args):
    assert r.shape == (3 * N, )
    pos = r.reshape(15, 3)

    Cpot = pot.Coulomb()
    Cpot.set_parameters(*args[1:6])

    Bpot = pot.Buckingham()
    Bpot.set_parameters(*args[6:])
    energy = buckingham_coulomb(pos, Cpot, Bpot, N, *args[0])
    print(energy)


if __name__ == '__main__':
    atoms = aread("../../Data/random/RandomStart_Sr3Ti3O9/1.cif")
    r = np.array(flatten(atoms.positions))
    vects = np.array(atoms.get_cell())
    volume = abs(np.linalg.det(vects))
    N = len(atoms.get_positions())
    accuracy = 0.00001  # Demanded accuracy of terms
    alpha = N**(1 / 6) * pi**(1 / 2) / volume**(1 / 3)
    real_cut = (-np.log(accuracy))**(1 / 2) / alpha
    recip_cut = 2 * alpha * (-np.log(accuracy))**(1 / 2)


    energy_function_wrapper(r, len(atoms.positions), alpha, real_cut,\
           recip_cut, atoms.get_chemical_symbols(),\
           charge_dict)
    # res = minimize(funct, atoms.positions, method='BFGS', \
    # 	               options={'gtol': 1e-3, 'disp': True})
Пример #6
0
 def setUp(self):
     # The test POSCAR file is in the same directory.
     path = os.path.join(testdir(), "POSCAR")
     self.cell = aread(path, format="vasp")