Exemplo n.º 1
0
def test_vasp_calling(cmd, poscar):
    cleanup_vasp_run()

    structure = dft_input_to_structure(poscar)

    forces1 = run_dft('.', cmd, structure=structure, en=False)
    forces2, energy2 = run_dft('.', cmd, structure=structure, en=True)
    forces3 = parse_dft_forces('./test_files/test_vasprun.xml')
    forces4, energy4 = parse_dft_forces_and_energy(
        './test_files/test_vasprun.xml')

    vr_step = Vasprun('./test_files/test_vasprun.xml').ionic_steps[-1]
    ref_forces = vr_step['forces']
    ref_energy = vr_step['electronic_steps'][-1]['e_0_energy']

    assert len(forces1) == len(ref_forces)
    assert len(forces2) == len(ref_forces)
    assert len(forces3) == len(ref_forces)
    assert len(forces4) == len(ref_forces)

    for i in range(structure.nat):
        assert np.isclose(forces1[i], ref_forces[i]).all()
        assert np.isclose(forces2[i], ref_forces[i]).all()
        assert np.isclose(forces3[i], ref_forces[i]).all()
        assert np.isclose(forces4[i], ref_forces[i]).all()
        assert energy2 == ref_energy
        assert energy4 == ref_energy

    cleanup_vasp_run()
Exemplo n.º 2
0
def test_vasp_calling_fail(cmd, poscar):
    structure = dft_input_to_structure(poscar)
    with raises(FileNotFoundError):
        _ = run_dft('.', cmd, structure=structure, en=False)