Ejemplo n.º 1
0
def test_read_aluminum(tmpdir, aluminum_file):
    from pylada.espresso import read_structure
    espresso = Pwscf()
    espresso.read(aluminum_file)
    structure = read_structure(aluminum_file)
    check_aluminum_functional(tmpdir, espresso)
    check_aluminum_structure(structure)
Ejemplo n.º 2
0
def test_read_aluminum(tmpdir, aluminum_file):
    from pylada.espresso import read_structure

    espresso = Pwscf()
    espresso.read(aluminum_file)
    structure = read_structure(aluminum_file)
    check_aluminum_functional(tmpdir, espresso)
    check_aluminum_structure(structure)
Ejemplo n.º 3
0
def structure_is_passed_on(tmpdir, extract):
    from numpy import allclose
    from pylada.espresso import read_structure
    actual = read_structure(str(tmpdir.join("second", "pwscf.in")))
    assert len(actual) == len(extract.structure)
    assert allclose(actual.cell, extract.structure.cell)
    for a, b in zip(actual, extract.structure):
        assert a.type == b.type
        assert allclose(a.pos, b.pos)
Ejemplo n.º 4
0
def structure_is_passed_on(tmpdir, extract):
    from numpy import allclose
    from pylada.espresso import read_structure
    actual = read_structure(str(tmpdir.join("second", "pwscf.in")))
    assert len(actual) == len(extract.structure)
    assert allclose(actual.cell, extract.structure.cell)
    for a, b in zip(actual, extract.structure):
        assert a.type == b.type
        assert allclose(a.pos, b.pos)
Ejemplo n.º 5
0
def test_read_write_loop(aluminum_file, tmpdir, espresso):
    from pylada.espresso import read_structure
    espresso.read(aluminum_file)
    espresso.control.pseudo_dir = str(tmpdir.join('pseudos'))
    tmpdir.join('pseudos', 'Al.vbc.UPF').ensure(file=True)
    structure = read_structure(aluminum_file)
    espresso.write(str(tmpdir.join('al2.scf')), structure=structure)
    espresso = Pwscf()

    espresso.read(str(tmpdir.join('al2.scf')))
    check_aluminum_functional(tmpdir, espresso)
Ejemplo n.º 6
0
def test_read_write_loop(aluminum_file, tmpdir, espresso):
    from pylada.espresso import read_structure

    espresso.read(aluminum_file)
    espresso.control.pseudo_dir = str(tmpdir.join("pseudos"))
    tmpdir.join("pseudos", "Al.vbc.UPF").ensure(file=True)
    structure = read_structure(aluminum_file)
    espresso.write(str(tmpdir.join("al2.scf")), structure=structure)
    espresso = Pwscf()

    espresso.read(str(tmpdir.join("al2.scf")))
    check_aluminum_functional(tmpdir, espresso)
Ejemplo n.º 7
0
def test_iteration(tmpdir, aluminum_file, espresso):
    """ Checks iterations goes through the expected steps """
    from sys import executable as python
    from os.path import dirname, join
    from pylada.espresso import read_structure
    from pylada.espresso.tests.extract import Extract
    structure = read_structure(aluminum_file)
    espresso.read(aluminum_file)
    espresso.program = python + " " + join(dirname(__file__), 'dummy_pwscf.py')
    espresso.Extract = Extract
    tmpdir.join('pseudos', 'Al.vbc.UPF').ensure(file=True)
    iterator = espresso.iter(outdir=str(tmpdir), overwrite=True, structure=structure)
    program_process = next(iterator)
    assert hasattr(program_process, 'start')
    assert hasattr(program_process, 'wait')
    program_process.start()
    program_process.wait()
    assert tmpdir.join("%s.out" % espresso.control.prefix).check()
    extract = next(iterator)
    assert isinstance(extract, Extract)
    assert extract.success
Ejemplo n.º 8
0
def test_iteration(tmpdir, aluminum_file, espresso):
    """ Checks iterations goes through the expected steps """
    from sys import executable as python
    from os.path import dirname, join
    from pylada.espresso import read_structure
    from pylada.espresso.tests.extract import Extract

    structure = read_structure(aluminum_file)
    espresso.read(aluminum_file)
    espresso.program = python + " " + join(dirname(__file__), "dummy_pwscf.py")
    espresso.Extract = Extract
    tmpdir.join("pseudos", "Al.vbc.UPF").ensure(file=True)
    iterator = espresso.iter(outdir=str(tmpdir), overwrite=True, structure=structure)
    program_process = next(iterator)
    assert hasattr(program_process, "start")
    assert hasattr(program_process, "wait")
    program_process.start()
    program_process.wait()
    assert tmpdir.join("%s.out" % espresso.control.prefix).check()
    extract = next(iterator)
    assert isinstance(extract, Extract)
    assert extract.success
Ejemplo n.º 9
0
#
#  PyLaDa is free software: you can redistribute it and/or modify it under the terms of the GNU
#  General Public License as published by the Free Software Foundation, either version 3 of the
#  License, or (at your option) any later version.
#
#  PyLaDa is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
#  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General
#  Public License for more details.
#
#  You should have received a copy of the GNU General Public License along with PyLaDa.  If not, see
#  <http://www.gnu.org/licenses/>.
###############################
# -*- coding: utf-8 -*-
from pylada.espresso import Pwscf
from tempfile import NamedTemporaryFile
from pylada.espresso.tests.fixtures import check_aluminum_functional, check_aluminum_structure
from pylada.espresso import read_structure
from py.path import local
from sys import stdin
pwscf = Pwscf()
with NamedTemporaryFile(mode="w") as file:
    file.write(stdin.read())
    file.flush()
    pwscf.read(file.name)
    structure = read_structure(file.name)

check_aluminum_functional(local(), pwscf)
check_aluminum_structure(structure)
pwscf.pseudos_do_exist(structure)
print("JOB IS DONE!")