Пример #1
0
def test_start_experiment(exp):
    args = [
        "-d 3",
        "-l 2,archi=a8:at86rf231+site=grenoble",
        "-l 2,archi=a8:at86rf231+site=saclay",
    ]
    ret = run("experiment-cli submit " + " ".join(args))
    exp.id = str(ret["id"])
    run("experiment-cli wait -i " + exp.id)
Пример #2
0
def do_run_script(exp, nodes):
    script = "tests/sample_script.sh"
    frontend = site + ".iot-lab.info"
    script_out = "'A8/script_out.*'"
    ssh(frontend, "rm -f " + script_out)

    run("open-a8-cli -i " + exp.id + " run-script " + script + a8_nodes_list(nodes))

    # script runs _async_ on A8 nodes. sample_script sleeps 3-4s. wait
    time.sleep(10)
    ret = ssh(frontend, "cat " + script_out)
    assert ret == "{}\n".format(time.strftime("%F")) * len(nodes)
Пример #3
0
def test_wait_for_running(exp):
    run("experiment-cli wait -i " + exp.id, raw=True)

    ret = run("experiment-cli get -s -i " + exp.id)
    assert ret["state"] == "Running"
Пример #4
0
"""Test the 2D methods.
"""

import pytest
import numpy as np
from numpy.linalg import norm, inv
import matplotlib.pyplot as plt

from bzi_3D.all_2D import *

from bzi_3D.utilities import check_contained, make_unique

from conftest import run

tests = run("all 2D")

@pytest.mark.skipif("test_make2D_lattice_basis" not in tests,
    reason="different tests")
def test_get_bragg_planes():

    lattice_constants = [2.1, 3.2]
    lattice_angle = np.pi/3

    lattice_basis = make2D_lattice_basis(lattice_constants, lattice_angle)
    a1 = lattice_basis[:,0]
    a2 = lattice_basis[:,1]

    assert np.allclose(lattice_constants, norm(lattice_basis, axis=0))
    assert np.isclose(lattice_angle, np.arccos( np.dot(a1, a2)/( norm(a1)*norm(a2) )))

def test_experiment_info_list(site):
    res = run("experiment-cli info -l --site " + site)

    assert len(res["items"]) > 0
    assert res["items"][0]["site"] == site
def test_experiment_info_list_a8(site):
    res = run("experiment-cli info -li --site " + site)

    alive_a8 = res["items"][0][site]["a8"]["Alive"]
    assert len(alive_a8.split('+')) > 4
Пример #7
0
"""Unit tests for utilities.py module.
"""

import pytest
import numpy as np
from copy import deepcopy

from BZI.utilities import *
from conftest import run

tests = run("all utilities")


@pytest.mark.skipif("test_swap_rows_columns" not in tests,
                    reason="different tests")
def test_swap_rows_columns():

    test = np.random.uniform(-4, 4, size=(3, 3))
    test_copy = swap_rows_columns(test, 0, 1, rows=True)

    all(test[0, :] == test_copy[1, :])
    all(test[1, :] == test_copy[0, :])

    test_copy = swap_rows_columns(test, 0, 1, rows=False)

    all(test[:, 0] == test_copy[:, 1])
    all(test[:, 1] == test_copy[:, 0])


@pytest.mark.skipif("test_remove_points" not in tests,
                    reason="different tests")
Пример #8
0
"""Unit tests for tetrahedron module."""

import numpy as np
import pytest
import itertools

from BZI.tetrahedron import *
from BZI.pseudopots import FreeElectronModel, Al_EPM, free_EPM
from BZI.symmetry import make_ptvecs, make_rptvecs, Lattice
from conftest import run

print(Al_EPM.energy_cutoff)

tests = run("all tetrahedra")


@pytest.mark.skipif("test_find_tetrahedra" not in tests,
                    reason="different tests")
def test_find_tetrahedra():
    vertices = np.array([[.5, 0, 0], [1, 0, 0], [0, 1, 0], [1, 1, 0],
                         [0, 0, 1], [1, 0, 1], [0, 1, 1], [1, 1, 1]])

    tetrahedra = np.sort([[2, 4, 1, 8], [4, 1, 3, 8], [1, 3, 8, 7],
                          [1, 8, 5, 7], [1, 6, 8, 5], [2, 1, 6, 8]])
    assert np.allclose(tetrahedra, find_tetrahedra(vertices))

    vertices = np.array([[0, 0, 0], [.5, 0, 0], [0, 1, 0], [1, 1, 0],
                         [0, 0, 1], [1, 0, 1], [0, 1, 1], [1, 1, 1]])
    tetrahedra = np.sort([[4, 3, 2, 7], [3, 2, 1, 7], [2, 1, 7, 5],
                          [2, 7, 6, 5], [2, 8, 7, 6], [4, 2, 8, 7]])
    assert np.allclose(tetrahedra, find_tetrahedra(vertices))
Пример #9
0
def test_let_die(exp):
    run("experiment-cli wait --state Terminated -i " + exp.id, raw=True)
Пример #10
0
"""Unit tests for read_and_write module."""

import numpy as np
import pytest
from BZI.read_and_write import read_QE, read_vasp, read_vasp_input
from BZI.utilities import check_contained
from conftest import run
import os

tests = run("all read_and_write")


@pytest.mark.skipif("test_read_qe" not in tests, reason="different tests")
def test_read_qe():
    location = os.path.join(os.getcwd(), "tests")
    QE_data_Al = read_QE(location, "Al")

    assert QE_data_Al["bravais-lattice index"] == 2.0
    assert QE_data_Al["lattice parameter"] == "4.0460 a.u."
    assert QE_data_Al["unit-cell volume"] == "16.5584 (a.u.)^3"
    assert QE_data_Al["number of atoms/cell"] == 4.0
    assert QE_data_Al["number of atomic types"] == 1.0
    assert QE_data_Al["number of electrons"] == 12.0
    assert QE_data_Al["number of Kohn-Sham states"] == 10.0
    assert QE_data_Al["kinetic-energy cutoff"] == "40.0000 Ry"
    assert QE_data_Al["charge density cutoff"] == "160.0000 Ry"
    assert QE_data_Al["convergence threshold"] == 1.0E-08
    assert QE_data_Al["mixing beta"] == 0.7
    assert QE_data_Al["number of iterations used"] == ["8 plain", "0 mixing"]
    assert QE_data_Al[
        "Exchange-correlation"] == "SLA-PW-PBX-PBC ( 1  4  3  4 0 0)"
Пример #11
0
def test_start_experiment(exp):
    args = "-d 6 -l 60,archi=a8:at86rf231+site=" + site  # => ~30 nodes boot
    ret = run("experiment-cli submit " + args)
    exp.id = str(ret["id"])
    run("experiment-cli wait -i " + exp.id)
Пример #12
0
def test_run_script_naive_2(exp):
    ret = run("open-a8-cli -i " + exp.id + " wait-for-boot")
    booted_nodes = ret["wait-for-boot"]["0"]
    do_run_script(exp, booted_nodes)
Пример #13
0
def test_run_script_naive(exp):
    run("open-a8-cli -i " + exp.id + " wait-for-boot")
    do_run_script(exp, None)
Пример #14
0
def test_run_script(exp):
    info = run("experiment-cli get -p -i " + exp.id)
    deployed_nodes = info["deploymentresults"]["0"]
    ret = run("open-a8-cli -i " + exp.id + " wait-for-boot" + a8_nodes_list(deployed_nodes))
    booted_nodes = ret["wait-for-boot"]["0"]
    do_run_script(exp, booted_nodes)
Пример #15
0
def test_stop_experiment(exp):
    ret = run("experiment-cli stop -i " + exp.id)
    assert ret["id"] == exp.id
    assert ret["status"] == "Delete request registered"
Пример #16
0
def test_wait_for_stopped(exp):
    # stopped experiments eventually report as "Error"
    run("experiment-cli wait --state Error -i " + exp.id, raw=True)
Пример #17
0
import pytest
import numpy as np
from itertools import product
import csv

from BZI.symmetry import (get_minmax_indices, swap_column, swap_row,
                          HermiteNormalForm, UpperHermiteNormalForm)

from BZI.sampling import (make_grid, make_large_grid, sphere_pts,
                          large_sphere_pts, make_cell_points)
from BZI.utilities import check_contained

from BZI.symmetry import make_ptvecs, make_rptvecs
from conftest import run

tests = run("all sampling")


@pytest.mark.skipif("test_make_grid" not in tests, reason="different tests")
def test_make_grid():
    grid_centering = "prim"
    grid_consts = [1, 1, 1]
    grid_angles = [np.pi / 2] * 3
    grid_vecs = make_ptvecs(grid_centering, grid_consts, grid_angles)

    lat_centering = "prim"
    lat_consts = [2] * 3
    lat_angles = [np.pi / 2] * 3
    lat_vecs = make_ptvecs(lat_centering, lat_consts, lat_angles)

    offset = [0] * 3
Пример #18
0
def test_start_experiment(exp):
    args = "-d 1 -l 2,archi=m3:at86rf231+site=grenoble"
    ret = run("experiment-cli submit " + args)
    exp.id = str(ret["id"])
Пример #19
0
"""See the notebook with the empirical pseudopotential plots.
"""

import pytest
import numpy as np
import matplotlib.pyplot as plt
from bzi_3D.plots import plot_band_structure, plot_paths
from bzi_3D.pseudopots import *
from numpy.linalg import norm, inv, det
from conftest import run

tests = run("all pseudopotential")

@pytest.mark.skipif("test_pseudopotentials" not in tests, reason="different tests")
def test_pseudopotentials():
    assert True

    free_energy_shift = free_EPM.eval([0.]*3,1)[0]
    free_args = {"materials_list": ["free"],
               "PPlist": [free_EPM],
               "PPargs_list": [{"neigvals": 1}],
               "lattice": free_EPM.lattice,
               "npts": 1000,
               "neigvals": 1,
               "energy_shift": free_energy_shift,
               "energy_limits": [0,35],
               "show": True}

    # plot_band_structure(**free_args)

    Si_energy_shift = Si_EPM.eval([0.]*3,10)[1]
Пример #20
0
"""Test the irreducible Brillouin zone construction methods.
"""

import pytest
import numpy as np
from numpy.linalg import det
from BZI.symmetry import *
from BZI.make_IBZ import *

from conftest import run

tests = run("all make_IBZ")

@pytest.mark.skipif("test_get_bragg_planes" not in tests, reason="different tests")
def test_get_bragg_planes():
    
    lat_vecs = np.eye(3)
    bplanes = get_bragg_planes(lat_vecs)

    dir_lat_vecs = [[1,0,0],
                    [0,1,0],
                    [1,1,0],
                    [0,0,1],
                    [1,0,1],
                    [0,1,1],
                    [-1,0,0],
                    [0,-1,0],
                    [-1,-1,0],
                    [0,0,-1],
                    [-1,0,-1],
                    [0,-1,-1],
Пример #21
0
"""Unit tests for integration module."""

import numpy as np
from numpy.linalg import norm
import pytest
from bzi_3D.pseudopots import FreeElectronModel
from bzi_3D.integration import *
from bzi_3D.symmetry import Lattice, make_ptvecs, make_rptvecs
from bzi_3D.sampling import make_grid, make_cell_points
from conftest import run

tests = run("all rectangle")


@pytest.mark.skipif("test_rectangular" not in tests, reason="different tests")
def test_rectangular():
    """This will test the rectangular methods of finding the total energy and the
    Fermi level.
    """

    degree_list = range(1, 5)
    for degree in degree_list:
        # Verify the Fermi level of the free electron model.
        lat_angles = [np.pi / 2] * 3
        lat_consts = [1] * 3
        lat_centering = "prim"
        lattice = Lattice(lat_centering, lat_consts, lat_angles)

        free = FreeElectronModel(lattice, degree)

        grid_consts = [40] * 3