Exemple #1
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()
Exemple #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)
Exemple #3
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)
Exemple #4
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())
def diamond_pwscf():
    from pylada.espresso import Pwscf

    pwscf = Pwscf()
    pwscf.system.ecutwfc = 12.0
    pwscf.kpoints.subtitle = None
    pwscf.kpoints.value = "2\n" "0.25 0.25 0.75 3.0\n" "0.25 0.25 0.25 1.0\n"
    pwscf.add_specie("Si", "Si.pz-vbc.UPF")
    return pwscf
Exemple #6
0
def diamond_pwscf():
    from pylada.espresso import Pwscf
    pwscf = Pwscf()
    pwscf.system.ecutwfc = 12.0
    pwscf.kpoints.subtitle = None
    pwscf.kpoints.value = "2\n"\
        "0.25 0.25 0.75 3.0\n"\
        "0.25 0.25 0.25 1.0\n"
    pwscf.add_specie('Si', 'Si.pz-vbc.UPF')
    return pwscf
Exemple #7
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)
Exemple #8
0
def pwscf():
    from pylada.espresso import Pwscf
    from quantities import Ry
    pwscf = Pwscf()
    pwscf.system.ecutwfc = 12.0 * Ry
    pwscf.kpoints.subtitle = None
    pwscf.kpoints.value = "2\n"\
        "0.25 0.25 0.75 3.0\n"\
        "0.25 0.25 0.25 1.0\n"
    pwscf.add_specie('Al', 'Al.pz-vbc.UPF')
    return pwscf
Exemple #9
0
def aluminum_pwscf():
    from pylada.espresso import Pwscf
    pwscf = Pwscf()
    pwscf.system.ecutwfc = 12.0
    pwscf.system.occupations = 'smearing'
    pwscf.system.smearing = 'marzari-vanderbilt'
    pwscf.system.degauss = 0.06
    pwscf.kpoints.subtitle = 'automatic'
    pwscf.kpoints.value = '6 6 6 1 1 1'
    pwscf.add_specie('Al', 'Al.pz-vbc.UPF')
    return pwscf
def pwscf():
    from pylada.espresso import Pwscf
    from quantities import Ry
    pwscf = Pwscf()
    pwscf.system.ecutwfc = 12.0*Ry
    pwscf.kpoints.subtitle = None
    pwscf.kpoints.value = "2\n"\
        "0.25 0.25 0.75 3.0\n"\
        "0.25 0.25 0.25 1.0\n"
    pwscf.add_specie('Al', 'Al.pz-vbc.UPF')
    return pwscf
Exemple #11
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)
def aluminum_pwscf():
    from pylada.espresso import Pwscf

    pwscf = Pwscf()
    pwscf.system.ecutwfc = 12.0
    pwscf.system.occupations = "smearing"
    pwscf.system.smearing = "marzari-vanderbilt"
    pwscf.system.degauss = 0.06
    pwscf.kpoints.subtitle = "automatic"
    pwscf.kpoints.value = "6 6 6 1 1 1"
    pwscf.add_specie("Al", "Al.pz-vbc.UPF")
    return pwscf
Exemple #13
0
def pwscf():
    from pylada.espresso import Pwscf
    from quantities import Ry
    pwscf = Pwscf()
    pwscf.system.ecutwfc = 12.0*Ry
    pwscf.kpoints.subtitle = None
    pwscf.kpoints.value = "2\n"\
        "0.25 0.25 0.75 3.0\n"\
        "0.25 0.25 0.25 1.0\n"
    pwscf.control.calculation = 'vc-relax'
    pwscf.cell.factor = 2.0
    pwscf.add_specie('Si', 'Si.pz-vbc.UPF')
    return pwscf
Exemple #14
0
def pwscf():
    from pylada.espresso import Pwscf
    from quantities import Ry
    pwscf = Pwscf()
    pwscf.system.ecutwfc = 12.0 * Ry
    pwscf.kpoints.subtitle = None
    pwscf.kpoints.value = "2\n"\
        "0.25 0.25 0.75 3.0\n"\
        "0.25 0.25 0.25 1.0\n"
    pwscf.control.calculation = 'vc-relax'
    pwscf.cell.factor = 2.0
    pwscf.add_specie('Si', 'Si.pz-vbc.UPF')
    return pwscf
Exemple #15
0
def test_ecutwfc_required():
    from py.test import raises
    from pylada.espresso import Pwscf
    from pylada import error
    pwscf = Pwscf()
    pwscf.system.ecutwfc = 12
    pwscf.system.namelist()

    pwscf.system.ecutwfc = None
    with raises(error.ValueError):
        pwscf.system.namelist()

    with raises(error.ValueError):
        pwscf.write()
Exemple #16
0
def test_ecutwfc_required():
    from py.test import raises
    from pylada.espresso import Pwscf
    from pylada import error

    pwscf = Pwscf()
    pwscf.system.ecutwfc = 12
    pwscf.system.namelist()

    pwscf.system.ecutwfc = None
    with raises(error.ValueError):
        pwscf.system.namelist()

    with raises(error.ValueError):
        pwscf.write()
Exemple #17
0
def test_aliases():
    espresso = Pwscf()
    espresso.electrons.itermax = 1
    ms = espresso.electrons.electron_maxstep
    assert ms == 1
    espresso.electrons.itermax = 10
    assert espresso.electrons.electron_maxstep == 10
    espresso.electrons.electron_maxstep = None
    assert espresso.electrons.itermax is None
    assert 'itermax' not in espresso.electrons.namelist()
    assert 'electron_maxstep' not in espresso.electrons.namelist()
Exemple #18
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
Exemple #19
0
def pwscf(text):
    from quantities import Ry
    from pylada.espresso import Pwscf
    pwscf = Pwscf()
    exec(text, globals(), {'pwscf': pwscf, 'Ry': Ry})
    return pwscf
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
Exemple #21
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'
def empty_pwscf():
    from pylada.espresso import Pwscf
    return Pwscf()
Exemple #23
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'
Exemple #24
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!")
Exemple #25
0
def espresso():
    pwscf = Pwscf()
    # Required for all writing because required by Pwscf
    pwscf.system.ecutwfc = 12.0
    return pwscf
Exemple #26
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
Exemple #27
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