コード例 #1
0
ファイル: test_sqs.py プロジェクト: yiwang62/dfttk
def test_equality_of_sqs_objects():
    """SQS structures with different underlying crystal structures are equivalent iff sublattice models are equivalent."""
    config = [['A', 'B'], ['A']]
    occupancy = [[0.5, 0.5], [1]]
    site_ratios = [3, 1]
    # Use same sublattice for different underlying structures. Should be equal
    s1 = PRLStructure(Lattice.hexagonal(1, 2), ['Mg', 'Mg'],
                      [[0, 0, 0], [0.3333, 0.66666, 0.5]],
                      sublattice_configuration=config,
                      sublattice_occupancies=occupancy,
                      sublattice_site_ratios=site_ratios)
    s2 = PRLStructure(Lattice.cubic(1), ['Fe'], [[0, 0, 0]],
                      sublattice_configuration=config,
                      sublattice_occupancies=occupancy,
                      sublattice_site_ratios=site_ratios)
    assert s1 == s2

    # Use same underlying crystal structures, but different sublattice configurations. Should be not equal
    s1.sublattice_site_ratios = [2, 1]
    assert s1 != s2
    s1.sublattice_site_ratios = site_ratios

    s1.sublattice_occupancies = [[0.25, 0.5], [1]]
    assert s1 != s2
    s1.sublattice_occupancies = occupancy

    s1.sublattice_configuration = [['A', 'A'], ['A']]
    assert s1 != s2
    s1.sublattice_configuration = config

    assert s1 == s2
コード例 #2
0
def test_equality_of_sqs_objects_with_different_indexing():
    """SQS structures that are the same, but indexed differently should be equal."""
    # TODO: implement this behavior in SQS.__eq__
    config_1 = [['A', 'B'], ['A']]
    occupancy_1 = [[0.25, 0.75], [1]]
    site_ratios_1 = [3, 1]

    config_2 = [['A'], ['A', 'B']]
    occupancy_2 = [[1], [0.25, 0.75]]
    site_ratios_2 = [1, 3]

    s1 = PRLStructure(Lattice.hexagonal(1, 2), ['Mg', 'Mg'], [[0, 0, 0], [0.3333, 0.66666, 0.5]], sublattice_configuration=config_1, sublattice_occupancies=occupancy_1, sublattice_site_ratios=site_ratios_1)
    s2 = PRLStructure(Lattice.hexagonal(1, 2), ['Mg', 'Mg'], [[0, 0, 0], [0.3333, 0.66666, 0.5]], sublattice_configuration=config_2, sublattice_occupancies=occupancy_2, sublattice_site_ratios=site_ratios_2)

    assert s1 == s2
コード例 #3
0
ファイル: test_sqs.py プロジェクト: yiwang62/dfttk
def test_structures_can_be_made_from_pmg_structures():
    """PMG Structures should make a PRLStructure with equivalent wyckoff sites"""
    SIGMA_POSCAR = """H10 H4 H16
1.0
1.900000 0.000000 0.000000
-0.000000 1.900000 0.000000
0.000000 0.000000 1.000000
B H C H  Y
1 1 2 24 2
direct
0.000000 0.000000 0.500000 B
0.500000 0.500000 0.000000 H
0.561000 0.235000 0.000000 C
0.235000 0.561000 0.000000 C
-0.235000 -0.561000 0.000000 H
-0.561000 -0.235000 0.000000 H
1.061000 0.265000 -0.500000 H
0.265000 1.061000 -0.500000 H
0.735000 -0.061000 -0.500000 H
-0.061000 0.735000 -0.500000 H
0.103000 0.103000 0.000000 H
-0.103000 -0.103000 0.000000 H
0.603000 0.397000 -0.500000 H
0.397000 0.603000 -0.500000 H
0.318000 0.318000 0.730000 H
-0.318000 -0.318000 0.730000 H
0.318000 0.318000 0.270000 H
-0.318000 -0.318000 0.270000 H
0.818000 0.182000 0.230000 H
0.182000 0.818000 0.230000 H
0.818000 0.182000 -0.230000 H
0.182000 0.818000 -0.230000 H
0.367000 0.038000 0.000000 H
0.038000 0.367000 0.000000 H
-0.038000 -0.367000 0.000000 H
-0.367000 -0.038000 0.000000 H
0.867000 0.462000 -0.500000 H
0.462000 0.867000 -0.500000 H
0.538000 0.133000 -0.500000 Y
0.133000 0.538000 -0.500000 Y
    """

    s = Structure.from_str(SIGMA_POSCAR, fmt='POSCAR')
    ps = PRLStructure.from_structure(s, [['j', 'b']])

    assert ps.sublattice_occupancies == [[0.1, 0.9], [1.0],
                                         [0.125, 0.75, 0.125]]
    assert ps.sublattice_site_ratios == [10, 4, 16]
    assert ps.sublattice_configuration == [['B', 'H'], ['H'], ['C', 'H', 'Y']]