コード例 #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)
コード例 #2
0
def check_pwscf_input(tmpdir, filename, pwscf):
    from pylada.espresso import Pwscf
    actual = Pwscf()
    actual.read(tmpdir.join(filename))
    assert abs(actual.system.ecutwfc - pwscf.system.ecutwfc) < 1e-8
    assert actual.kpoints.subtitle == pwscf.kpoints.subtitle
    assert actual.kpoints.value.rstrip().lstrip() == pwscf.kpoints.value.rstrip().lstrip()
コード例 #3
0
def check_pwscf_input(tmpdir, pwscf):
    from pylada.espresso import Pwscf
    actual = Pwscf()
    actual.read(tmpdir.join("pwscf.in"))
    assert abs(actual.system.ecutwfc - pwscf.system.ecutwfc) < 1e-8
    assert actual.kpoints.subtitle == pwscf.kpoints.subtitle
    assert (actual.kpoints.value.rstrip().lstrip() ==
            pwscf.kpoints.value.rstrip().lstrip())
コード例 #4
0
ファイル: test_pwscf.py プロジェクト: pylada/pylada-light
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)
コード例 #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)
コード例 #6
0
ファイル: test_pwscf.py プロジェクト: pylada/pylada-light
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)
コード例 #7
0
def test_ions_and_cells_do_not_appear_unless_relaxing(espresso, tmpdir):
    espresso.ions.something = 1
    espresso.cell.something = 1
    espresso.control.calculation = 'scf'
    espresso.write(str(tmpdir.join('pwscf.in')))

    pwscf = Pwscf()
    pwscf.read(str(tmpdir.join('pwscf.in')))
    assert not hasattr(pwscf.ions, 'something')
    assert not hasattr(pwscf.cell, 'something')

    espresso.control.calculation = 'relax'
    espresso.write(str(tmpdir.join('pwscf.in')))
    pwscf = Pwscf()
    pwscf.read(str(tmpdir.join('pwscf.in')))
    assert getattr(pwscf.ions, 'something', 0) == 1
    assert not hasattr(pwscf.cell, 'something')

    espresso.control.calculation = 'vc-relax'
    espresso.write(str(tmpdir.join('pwscf.in')))
    pwscf = Pwscf()
    pwscf.read(str(tmpdir.join('pwscf.in')))
    assert getattr(pwscf.ions, 'something', 0) == 1
    assert getattr(pwscf.cell, 'something', 0) == 1
コード例 #8
0
ファイル: test_pwscf.py プロジェクト: pylada/pylada-light
def test_ions_and_cells_do_not_appear_unless_relaxing(espresso, tmpdir):
    espresso.ions.something = 1
    espresso.cell.something = 1
    espresso.control.calculation = "scf"
    espresso.write(str(tmpdir.join("pwscf.in")))

    pwscf = Pwscf()
    pwscf.read(str(tmpdir.join("pwscf.in")))
    assert not hasattr(pwscf.ions, "something")
    assert not hasattr(pwscf.cell, "something")

    espresso.control.calculation = "relax"
    espresso.write(str(tmpdir.join("pwscf.in")))
    pwscf = Pwscf()
    pwscf.read(str(tmpdir.join("pwscf.in")))
    assert getattr(pwscf.ions, "something", 0) == 1
    assert not hasattr(pwscf.cell, "something")

    espresso.control.calculation = "vc-relax"
    espresso.write(str(tmpdir.join("pwscf.in")))
    pwscf = Pwscf()
    pwscf.read(str(tmpdir.join("pwscf.in")))
    assert getattr(pwscf.ions, "something", 0) == 1
    assert getattr(pwscf.cell, "something", 0) == 1
コード例 #9
0
ファイル: test_restart.py プロジェクト: pylada/pylada-light
def check_start_from_wfcn(tmpdir):
    from pylada.espresso import Pwscf
    pwscf = Pwscf()
    pwscf.read(tmpdir.join("second", "pwscf.in"))
    assert pwscf.electrons.startingwfc == 'file'
コード例 #10
0
def check_start_from_wfcn(tmpdir):
    from pylada.espresso import Pwscf
    pwscf = Pwscf()
    pwscf.read(tmpdir.join("second", "pwscf.in"))
    assert pwscf.electrons.startingwfc == 'file'
コード例 #11
0
def read_pwscf(tmpdir, filename):
    from pylada.espresso import Pwscf
    assert tmpdir.join(filename).check(file=True)
    result = Pwscf()
    result.read(tmpdir.join(filename))
    return result
コード例 #12
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!")
コード例 #13
0
def read_pwscf(tmpdir, filename):
    from pylada.espresso import Pwscf
    assert tmpdir.join(filename).check(file=True)
    result = Pwscf()
    result.read(tmpdir.join(filename))
    return result