def test_espresso_input_edit(): """ Load a structure in from qe_input_1, change the position and cell, then edit and re-parse :return: """ os.system('cp test_files/qe_input_1.in .') positions, species, cell, masses = parse_dft_input('./qe_input_1.in') _, coded_species = get_unique_species(species) structure = Structure(cell, coded_species, positions, masses, species_labels=species) structure.vec1 += np.random.randn(3) structure.positions[0] += np.random.randn(3) new_file = edit_dft_input_positions('./qe_input_1.in', structure=structure) positions, species, cell, masses = parse_dft_input(new_file) assert np.equal(positions[0], structure.positions[0]).all() assert np.equal(structure.vec1, cell[0, :]).all() os.remove('qe_input_1.in')
def test_espresso_calling(qe_input, qe_output): dft_loc = os.environ.get('PWSCF_COMMAND') os.system(' '.join(['cp', qe_input, 'pwscf.in'])) positions, species, cell, masses = parse_dft_input(qe_input) structure = Structure(cell=cell, species=species, positions=positions, mass_dict=masses, species_labels=species) forces = run_dft('pwscf.in', structure, dft_loc) ref_forces = parse_dft_forces(qe_output) assert len(forces) == len(ref_forces) for i in range(structure.nat): assert np.isclose(forces[i], ref_forces[i]).all() cleanup_espresso_run()
def test_espresso_calling(qe_input, qe_output): dft_loc = os.environ.get('PWSCF_COMMAND') shutil.copyfile(qe_input, 'pwscf.in') positions, species, cell, masses = parse_dft_input(qe_input) structure = Structure(cell=cell, species=species, positions=positions, mass_dict=masses, species_labels=species) forces = run_dft_par('pwscf.in', structure, dft_loc, dft_out='pwscf.out') ref_forces = parse_dft_forces('pwscf.out') assert len(forces) == len(ref_forces) for i in range(structure.nat): assert np.allclose(forces[i], ref_forces[i]) cleanup_espresso_run('pwscf')
def test_cell_parsing(qe_input, exp_cell): positions, species, cell, masses = parse_dft_input(qe_input) assert np.all(exp_cell == cell)
def test_species_parsing(qe_input, exp_spec): positions, species, cell, masses = parse_dft_input(qe_input) assert len(species) == len(exp_spec) for i, spec in enumerate(species): assert spec == exp_spec[i]