def test_cp2k_input_edit(): """ Load a structure in from cp2k_input_1, change the position and cell, then edit and re-parse :return: """ positions, species, cell, masses = parse_dft_input( "./test_files/cp2k_input_1.in") _, coded_species = get_unique_species(species) structure = Structure(cell, coded_species, positions, masses, species_labels=species) structure.positions[0] += np.random.randn(3) newfilename = edit_dft_input_positions("./test_files/cp2k_input_1.in", structure=structure) positions, species, cell, masses = parse_dft_input(newfilename) assert np.isclose(positions[0], structure.positions[0]).all() assert np.isclose(structure.vec1, cell[0, :]).all() remove(newfilename) cleanup()
def test_cp2k_calling(cp2k_input, cp2k_output): dft_loc = environ.get('CP2K_COMMAND') copyfile(cp2k_input, 'cp2k.in') positions, species, cell, masses = parse_dft_input(cp2k_input) structure = Structure(cell=cell, species=species, positions=positions, mass_dict=masses, species_labels=species) forces = run_dft_par('cp2k.in', structure, dft_loc) ref_forces = parse_dft_forces(cp2k_output) assert len(forces) == len(ref_forces) for i in range(structure.nat): assert np.isclose(forces[i], ref_forces[i]).all() cleanup()
def test_cell_parsing(cp2k_input, exp_cell): positions, species, cell, masses = parse_dft_input(cp2k_input) assert np.all(exp_cell == cell)
def test_species_parsing(cp2k_input, exp_spec): positions, species, cell, masses = parse_dft_input(cp2k_input) assert len(species) == len(exp_spec) for i, spec in enumerate(species): assert spec == exp_spec[i]