def test_to_pmg_structure(varied_test_struc): pmgstruc = pytest.importorskip("pymatgen.core.structure") new_struc = Structure.to_pmg_structure(varied_test_struc) assert len(varied_test_struc) == len(varied_test_struc) assert np.equal(new_struc.cart_coords, varied_test_struc.positions).all() assert (new_struc.atomic_numbers == varied_test_struc.coded_species).all()
def edit_dft_input_positions(output_name: str, structure: Structure): """ Writes a VASP POSCAR file from structure with the name poscar . WARNING: Destructively replaces the file with the name specified by poscar :param poscar: Name of file :param structure: structure to write to file """ if os.path.isfile(output_name): shutil.copyfile(output_name, output_name + ".bak") poscar = Poscar(structure.to_pmg_structure()) poscar.write_file(output_name) return output_name
def edit_dft_input_positions(poscar: str, structure: Structure): """ Writes a VASP POSCAR file from structure with the name poscar . WARNING: Destructively replaces the file with the name specified by poscar :param poscar: Name of file :param structure: structure to write to file """ if os.path.isfile(poscar): shutil.copyfile(poscar, poscar + '.bak') f = open(poscar, 'w') f.write( Poscar( structure.to_pmg_structure()).get_string(significant_figures=15)) f.close() return poscar
def test_to_pmg_structure(varied_test_struc): new_struc = Structure.to_pmg_structure(varied_test_struc) assert len(varied_test_struc) == len(varied_test_struc) assert np.equal(new_struc.cart_coords, varied_test_struc.positions).all() assert (new_struc.atomic_numbers == varied_test_struc.coded_species).all()