Пример #1
0
def test_except():
    with pytest.raises(ValueError):
        Structure(symbols=['U'], positions=[[0, 0, 0]], ncells=[1, 1, 1, 2])

    structure = Structure()
    with pytest.raises(ValueError):
        structure.add_atom(symbol='U')
Пример #2
0
def test_except():
    with pytest.raises(ValueError):
        Structure(symbols=['U'], positions=[[0, 0, 0]], ncells=[1, 1, 1, 2])

    structure = Structure()
    with pytest.raises(ValueError):
        structure.add_atom(symbol='U')
Пример #3
0
def test_one_atom_add():
    structure = Structure()
    structure.unitcell.cell = (3.0, 4.0, 5.0, 90.0, 90.0, 90.0)
    structure.add_atom(symbol='Au', position=[0.5, 0, 0.25])
    assert structure.number_of_atoms == 1
    assert_array_equal(structure.element, ['Au'])
    assert_array_equal(structure.get_atom_symbols(), ['Au'])
    assert_array_equal(structure.get_atom_count(), 1)
    assert_array_equal(structure.get_chemical_symbols(), ['Au'])
    assert_array_equal(structure.get_atom_Zs(), [79])
    assert_array_equal(structure.get_atomic_numbers(), [79])
    assert_array_equal(structure.x, [0.5])
    assert_array_equal(structure.y, [0])
    assert_array_equal(structure.z, [0.25])
    assert_array_equal(structure.xyz, [[0.5, 0, 0.25]])
    assert_array_equal(structure.get_scaled_positions(), [[0.5, 0, 0.25]])
    assert_array_almost_equal(structure.xyz_cartn, [[1.5, 0, 1.25]])
    assert_array_almost_equal(structure.get_positions(), [[1.5, 0, 1.25]])
    assert_array_equal(structure.unitcell.cell, (3.0, 4.0, 5.0, 90.0, 90.0, 90.0))
Пример #4
0
def test_one_atom_add():
    structure = Structure()
    structure.unitcell.cell = (3.0, 4.0, 5.0, 90.0, 90.0, 90.0)
    structure.add_atom(symbol='Au', position=[0.5, 0, 0.25])
    assert structure.number_of_atoms == 1
    assert_array_equal(structure.element, ['Au'])
    assert_array_equal(structure.get_atom_symbols(), ['Au'])
    assert_array_equal(structure.get_atom_count(), 1)
    assert_array_equal(structure.get_chemical_symbols(), ['Au'])
    assert_array_equal(structure.get_atom_Zs(), [79])
    assert_array_equal(structure.get_atomic_numbers(), [79])
    assert_array_equal(structure.x, [0.5])
    assert_array_equal(structure.y, [0])
    assert_array_equal(structure.z, [0.25])
    assert_array_equal(structure.xyz, [[0.5, 0, 0.25]])
    assert_array_equal(structure.get_scaled_positions(), [[0.5, 0, 0.25]])
    assert_array_almost_equal(structure.xyz_cartn, [[1.5, 0, 1.25]])
    assert_array_almost_equal(structure.get_positions(), [[1.5, 0, 1.25]])
    assert_array_equal(structure.unitcell.cell,
                       (3.0, 4.0, 5.0, 90.0, 90.0, 90.0))