Ejemplo n.º 1
0
def test_detect_ffatypes():
    system = get_system_quartz()
    rules = [
        ('Si', '14'),
        ('O', '8'),
    ]
    check_detect_ffatypes(system, rules)
Ejemplo n.º 2
0
def test_detect_ffatypes():
    system = get_system_quartz()
    rules = [
        ('Si', '14'),
        ('O', '8'),
    ]
    check_detect_ffatypes(system, rules)
Ejemplo n.º 3
0
def test_remove_duplicate1():
    system1 = get_system_quartz()
    system2 = system1.remove_duplicate()
    assert system1.natom == system2.natom
    assert system1.nbond == system2.nbond
    assert (system1.numbers == system2.numbers).all()
    assert (system1.pos == system2.pos).all()
    assert (system1.ffatype_ids == system2.ffatype_ids).all()
    assert system1.neighs1 == system2.neighs1
Ejemplo n.º 4
0
def test_remove_duplicate1():
    system1 = get_system_quartz()
    system2 = system1.remove_duplicate()
    assert system1.natom == system2.natom
    assert system1.nbond == system2.nbond
    assert (system1.numbers == system2.numbers).all()
    assert (system1.pos == system2.pos).all()
    assert (system1.ffatype_ids == system2.ffatype_ids).all()
    assert system1.neighs1 == system2.neighs1
Ejemplo n.º 5
0
def test_remove_duplicate2():
    system1 = get_system_quartz()
    system2 = system1.supercell(1, 2, 1)
    system2.cell = system1.cell
    system3 = system2.remove_duplicate()
    assert system1.natom == system3.natom
    assert system1.nbond == system3.nbond
    assert system1.numbers.sum() == system3.numbers.sum()
    assert abs(system1.pos.mean(axis=0) - system3.pos.mean(axis=0)).max() < 1e-10
    assert system1.ffatype_ids.sum() == system3.ffatype_ids.sum()
Ejemplo n.º 6
0
def test_remove_duplicate2():
    system1 = get_system_quartz()
    system2 = system1.supercell(1, 2, 1)
    system2.cell = system1.cell
    system3 = system2.remove_duplicate()
    assert system1.natom == system3.natom
    assert system1.nbond == system3.nbond
    assert system1.numbers.sum() == system3.numbers.sum()
    assert abs(system1.pos.mean(axis=0) - system3.pos.mean(axis=0)).max() < 1e-10
    assert system1.ffatype_ids.sum() == system3.ffatype_ids.sum()
Ejemplo n.º 7
0
def test_subsystem():
    system1 = get_system_quartz()
    system1.dipoles = np.random.rand(system1.natom, 3)
    system2 = system1.subsystem((system1.numbers == 8).nonzero()[0])
    assert system2.natom == 6
    assert (system2.numbers == 8).all()
    assert len(system2.bonds) == 0
    assert system2.scopes is None
    assert system2.get_ffatype(0) == 'O'
    assert (system2.charges == -0.9).all()
    assert (system1.cell.rvecs == system2.cell.rvecs).all()
    assert np.shape(system2.dipoles)[1] == 3
Ejemplo n.º 8
0
def test_subsystem():
    system1 = get_system_quartz()
    system1.dipoles = np.random.rand( system1.natom , 3 )
    system2 = system1.subsystem((system1.numbers == 8).nonzero()[0])
    assert system2.natom == 6
    assert (system2.numbers == 8).all()
    assert len(system2.bonds) == 0
    assert system2.scopes is None
    assert system2.get_ffatype(0) == 'O'
    assert (system2.charges == -0.9).all()
    assert (system1.cell.rvecs == system2.cell.rvecs).all()
    assert np.shape(system2.dipoles)[1] == 3
Ejemplo n.º 9
0
def test_iter_matches_quartz_quartz():
    system = get_system_quartz()
    assert system.ffatypes is not None
    result0 = list(system.iter_matches(system))
    assert len(result0) == 48
    for match in result0:
        np.testing.assert_equal(system.numbers, system.numbers[list(match)])
    system.ffatypes = None
    system.ffatype_ids = None
    result1 = list(system.iter_matches(system))
    assert len(result1) == 48
    for match in result1:
        np.testing.assert_equal(system.numbers, system.numbers[list(match)])
    assert sorted(result0) == sorted(result1)
Ejemplo n.º 10
0
def test_iter_matches_quartz_quartz():
    system = get_system_quartz()
    assert system.ffatypes is not None
    result0 = list(system.iter_matches(system))
    assert len(result0) == 48
    for match in result0:
        np.testing.assert_equal(system.numbers, system.numbers[list(match)])
    system.ffatypes = None
    system.ffatype_ids = None
    result1 = list(system.iter_matches(system))
    assert len(result1) == 48
    for match in result1:
        np.testing.assert_equal(system.numbers, system.numbers[list(match)])
    assert sorted(result0) == sorted(result1)
Ejemplo n.º 11
0
def test_supercell_quartz_222():
    system111 = get_system_quartz()
    system222 = system111.supercell(2, 2, 2)
    assert abs(system222.cell.volume - system111.cell.volume*8) < 1e-10
    assert abs(system222.cell.rvecs - system111.cell.rvecs*2).max() < 1e-10
    assert system222.natom == system111.natom*8
    assert len(system222.bonds) == len(system111.bonds)*8
    assert abs(system222.pos[9:18] - system111.pos - system111.cell.rvecs[2]).max() < 1e-10
    assert abs(system222.pos[-9:] - system111.pos - system111.cell.rvecs.sum(axis=0)).max() < 1e-10
    assert issubclass(system222.bonds.dtype.type, int)
    rules = [
        ('Si', '14'),
        ('O', '8'),
    ]
    check_detect_ffatypes(system222, rules)
    check_detect_bonds(system222)
    assert issubclass(system222.bonds.dtype.type, int)
Ejemplo n.º 12
0
def test_supercell_mil53_121():
    system111 = get_system_quartz()
    system121 = system111.supercell(1, 2, 1)
    assert abs(system121.cell.volume - system111.cell.volume*2) < 1e-10
    assert abs(system121.cell.rvecs[0] - system111.cell.rvecs[0]).max() < 1e-10
    assert abs(system121.cell.rvecs[1] - system111.cell.rvecs[1]*2).max() < 1e-10
    assert abs(system121.cell.rvecs[2] - system111.cell.rvecs[2]).max() < 1e-10
    assert system121.natom == system111.natom*2
    assert len(system121.bonds) == len(system111.bonds)*2
    assert abs(system121.pos[:system111.natom] - system111.pos).max() < 1e-10
    assert abs(system121.pos[system111.natom:] - system111.pos - system111.cell.rvecs[1]).max() < 1e-10
    assert (system121.numbers[:system111.natom] == system111.numbers).all()
    assert (system121.numbers[system111.natom:] == system111.numbers).all()
    assert (system121.ffatype_ids[:system111.natom] == system111.ffatype_ids).all()
    assert (system121.ffatype_ids[system111.natom:] == system111.ffatype_ids).all()
    assert (system121.ffatypes == system111.ffatypes).all()
    check_detect_bonds(system121)
Ejemplo n.º 13
0
def test_supercell_mil53_121():
    system111 = get_system_quartz()
    system121 = system111.supercell(1, 2, 1)
    assert abs(system121.cell.volume - system111.cell.volume*2) < 1e-10
    assert abs(system121.cell.rvecs[0] - system111.cell.rvecs[0]).max() < 1e-10
    assert abs(system121.cell.rvecs[1] - system111.cell.rvecs[1]*2).max() < 1e-10
    assert abs(system121.cell.rvecs[2] - system111.cell.rvecs[2]).max() < 1e-10
    assert system121.natom == system111.natom*2
    assert len(system121.bonds) == len(system111.bonds)*2
    assert abs(system121.pos[:system111.natom] - system111.pos).max() < 1e-10
    assert abs(system121.pos[system111.natom:] - system111.pos - system111.cell.rvecs[1]).max() < 1e-10
    assert (system121.numbers[:system111.natom] == system111.numbers).all()
    assert (system121.numbers[system111.natom:] == system111.numbers).all()
    assert (system121.ffatype_ids[:system111.natom] == system111.ffatype_ids).all()
    assert (system121.ffatype_ids[system111.natom:] == system111.ffatype_ids).all()
    assert (system121.ffatypes == system111.ffatypes).all()
    check_detect_bonds(system121)
Ejemplo n.º 14
0
def test_supercell_quartz_222():
    system111 = get_system_quartz()
    system222 = system111.supercell(2, 2, 2)
    assert abs(system222.cell.volume - system111.cell.volume*8) < 1e-10
    assert abs(system222.cell.rvecs - system111.cell.rvecs*2).max() < 1e-10
    assert system222.natom == system111.natom*8
    assert len(system222.bonds) == len(system111.bonds)*8
    assert abs(system222.pos[9:18] - system111.pos - system111.cell.rvecs[2]).max() < 1e-10
    assert abs(system222.pos[-9:] - system111.pos - system111.cell.rvecs.sum(axis=0)).max() < 1e-10
    assert issubclass(system222.bonds.dtype.type, int)
    rules = [
        ('Si', '14'),
        ('O', '8'),
    ]
    check_detect_ffatypes(system222, rules)
    check_detect_bonds(system222)
    assert issubclass(system222.bonds.dtype.type, int)
Ejemplo n.º 15
0
def test_align_cell_quartz():
    system = get_system_quartz()
    system.cell = Cell(system.cell.rvecs[::-1].copy())
    lcs = np.array([
        [1, 1, 0],
        [0, 0, 1],
    ])
    system.align_cell(lcs)
    # c should be aligned with z axis
    rvecs = system.cell.rvecs
    assert abs(rvecs[2][0]) < 1e-10
    assert abs(rvecs[2][1]) < 1e-10
    # sum of a and b should be aligned with x axis
    assert abs(rvecs[0][1] + rvecs[1][1]) < 1e-10
    assert abs(rvecs[0][2] + rvecs[1][2]) < 1e-10
    # difference of a and b should be aligned with y axis
    assert abs(rvecs[0][0] - rvecs[1][0]) < 1e-4
    assert abs(rvecs[0][2] - rvecs[1][2]) < 1e-10
    # check if the bonds are the same in the rotated structure
    check_detect_bonds(system)
Ejemplo n.º 16
0
def test_align_cell_quartz():
    system = get_system_quartz()
    system.cell = Cell(system.cell.rvecs[::-1].copy())
    lcs = np.array([
        [1, 1, 0],
        [0, 0, 1],
    ])
    system.align_cell(lcs)
    # c should be aligned with z axis
    rvecs = system.cell.rvecs
    assert abs(rvecs[2][0]) < 1e-10
    assert abs(rvecs[2][1]) < 1e-10
    # sum of a and b should be aligned with x axis
    assert abs(rvecs[0][1] + rvecs[1][1]) < 1e-10
    assert abs(rvecs[0][2] + rvecs[1][2]) < 1e-10
    # difference of a and b should be aligned with y axis
    assert abs(rvecs[0][0] - rvecs[1][0]) < 1e-4
    assert abs(rvecs[0][2] - rvecs[1][2]) < 1e-10
    # check if the bonds are the same in the rotated structure
    check_detect_bonds(system)
Ejemplo n.º 17
0
def test_detect_bonds_quartz():
    system = get_system_quartz()
    check_detect_bonds(system)
Ejemplo n.º 18
0
def test_detect_bonds_quartz():
    system = get_system_quartz()
    check_detect_bonds(system)