def from_directory(input_dir): """ Read in a set of FEFF input files from a directory, which is useful when existing FEFF input needs some adjustment. """ sub_d = {} for fname, ftype in [("HEADER", Header), ("PARAMETERS", Tags)]: fullzpath = zpath(os.path.join(input_dir, fname)) sub_d[fname.lower()] = ftype.from_file(fullzpath) # Generation of FEFFDict set requires absorbing atom, need to search # the index of absorption atom in the structure according to the # distance matrix and shell species information contained in feff.inp absorber_index = [] radius = None feffinp = zpath(os.path.join(input_dir, 'feff.inp')) if "RECIPROCAL" not in sub_d["parameters"]: input_atoms = Atoms.cluster_from_file(feffinp) shell_species = np.array([x.species_string for x in input_atoms]) # First row of distance matrix represents the distance from the absorber to # the rest atoms distance_matrix = input_atoms.distance_matrix[0, :] # Get radius value from math import ceil radius = int(ceil(input_atoms.get_distance(input_atoms.index(input_atoms[0]), input_atoms.index(input_atoms[-1])))) for site_index, site in enumerate(sub_d['header'].struct): if site.specie == input_atoms[0].specie: site_atoms = Atoms(sub_d['header'].struct, absorbing_atom=site_index, radius=radius) site_distance = np.array(site_atoms.get_lines())[:, 5].astype(np.float64) site_shell_species = np.array(site_atoms.get_lines())[:, 4] shell_overlap = min(shell_species.shape[0], site_shell_species.shape[0]) if np.allclose(distance_matrix[:shell_overlap], site_distance[:shell_overlap]) and \ np.all(site_shell_species[:shell_overlap] == shell_species[:shell_overlap]): absorber_index.append(site_index) if "RECIPROCAL" in sub_d["parameters"]: absorber_index = sub_d["parameters"]["TARGET"] absorber_index[0] = int(absorber_index[0]) - 1 # Generate the input set if 'XANES' in sub_d["parameters"]: CONFIG = loadfn(os.path.join(MODULE_DIR, "MPXANESSet.yaml")) if radius is None: radius = 10 return FEFFDictSet(absorber_index[0], sub_d['header'].struct, radius=radius, config_dict=CONFIG, edge=sub_d["parameters"]["EDGE"], nkpts=1000, user_tag_settings=sub_d["parameters"])
sg=186, lattice=zno_lattice_init, species=[Element('Zn'), Element('O')], coords=[ [1 / 3, 2 / 3, 0.00000], [1 / 3, 2 / 3, 0.37780], ], coords_are_cartesian=False, tol=1e-9, ) print(zno_structure) print(zno_structure.get_space_group_info()) out_file_name = '/home/yugin/PycharmProjects/neurons/data/src/feff.inp.new2' file_name = '/home/yugin/PycharmProjects/neurons/data/src/feff.inp.old' atoms_obj = Atoms(zno_structure, 'O', 12) pprint(atoms_obj.struct.cart_coords) pprint(atoms_obj.get_lines()) header_obj = Header(struct=zno_structure) pot_obj = Potential(zno_structure, 'O') tags_obj = Tags().from_file(filename=file_name) pprint(tags_obj.as_dict()) pot_obj.pot_string_from_file(filename=file_name) pprint(pot_obj) atoms_obj.atoms_string_from_file(filename=file_name) pprint(atoms_obj.as_dict()) header_obj.write_file(out_file_name) tags_obj.write_file(out_file_name)