예제 #1
0
파일: _cli.py 프로젝트: mailhexu/TBmodels
def _(sym, model, full_group):  # pylint: disable=missing-docstring
    sym_group = sr.SymmetryGroup(
        symmetries=[sym],
        full_group=full_group
        or False  # catches 'None', does nothing for 'True' or 'False'
    )
    return _symmetrize(sym_group, model, full_group)
예제 #2
0
파일: _cli.py 프로젝트: jaemolihm/TBmodels
 def _(sym, model, full_group):
     sym_group = sr.SymmetryGroup(
         symmetries=[sym],
         full_group=full_group
         or False,  # catches 'None', does nothing for 'True' or 'False'
     )
     return _symmetrize(sym_group, model, full_group)
def test_auto_repr(sample):
    """
    Test that the symmetry group created with the automatic representation matrix
    is the matches a reference.
    """
    pos_In = (0, 0, 0)  # pylint: disable=invalid-name
    pos_As = (0.25, 0.25, 0.25)  # pylint: disable=invalid-name

    orbitals = []
    for spin in (sr.SPIN_UP, sr.SPIN_DOWN):
        orbitals.extend([
            sr.Orbital(position=pos_In, function_string=fct, spin=spin)
            for fct in sr.WANNIER_ORBITALS['s'] + sr.WANNIER_ORBITALS['p']
        ])
        orbitals.extend([
            sr.Orbital(position=pos_As, function_string=fct, spin=spin)
            for fct in sr.WANNIER_ORBITALS['p']
        ])

    symops, symops_cart = mg.loadfn(sample('InAs_symops.json'))

    symmetry_group = sr.SymmetryGroup(symmetries=[
        sr.SymmetryOperation.from_orbitals(
            orbitals=orbitals,
            real_space_operator=sr.RealSpaceOperator.from_pymatgen(
                sym_reduced),
            rotation_matrix_cartesian=sym_cart.rotation_matrix,
            numeric=True)
        for sym_reduced, sym_cart in zip(symops, symops_cart)
    ],
                                      full_group=True)
    reference = sr.io.load(sample('symmetries_InAs.hdf5'))
    assert symmetry_group.full_group == reference.full_group
    for sym1, sym2 in zip(symmetry_group.symmetries, reference.symmetries):
        assert_allclose(sym1.real_space_operator.rotation_matrix,
                        sym2.real_space_operator.rotation_matrix,
                        atol=1e-12)
        assert_allclose(sym1.real_space_operator.translation_vector,
                        sym2.real_space_operator.translation_vector,
                        atol=1e-12)
        assert sym1.repr.has_cc == sym2.repr.has_cc
        assert_allclose(sym1.repr.matrix, sym2.repr.matrix, atol=1e-12)
예제 #4
0
    )

    # get real-space representations
    analyzer = mg.symmetry.analyzer.SpacegroupAnalyzer(structure)
    symops = analyzer.get_symmetry_operations(cartesian=False)
    symops_cart = analyzer.get_symmetry_operations(cartesian=True)
    rots = [x.rotation_matrix for x in symops]
    taus = [x.translation_vector for x in symops]

    # get corresponding represesentations in the Hamiltonian basis
    reps = []
    for n, (rot, tau) in enumerate(zip(rots, taus)):
        C = symops_cart[n].rotation_matrix
        tauc = symops_cart[n].translation_vector
        prep = C
        spinrep = spin_reps(C)
        R = np.kron(spinrep, la.block_diag(1.0, prep, prep))
        reps.append(R)

    # set up the space group symmetries
    symmetries = [
        sr.SymmetryOperation(
            # r-space and k-space matrices are related by transposing and inverting
            rotation_matrix=rot,
            repr_matrix=repr_mat,
            repr_has_cc=False,
        ) for rot, repr_mat in zip(rots, reps)
    ]
    point_group = sr.SymmetryGroup(symmetries=symmetries, full_group=True)
    sr.io.save([time_reversal, point_group], "results/symmetries.hdf5")
예제 #5
0
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import tempfile

import pytest
import numpy as np

import symmetry_representation as sr

SYM_OP = sr.SymmetryOperation(rotation_matrix=np.array([[1, 2, 3], [4, 5j,
                                                                    9]]),
                              repr_matrix=np.array([[0, 1], [3, 5]]),
                              repr_has_cc=True)
REPR_MATRIX = sr.Representation(matrix=np.array([[1j, 0], [-2j, 3j]]))
SYM_GROUP = sr.SymmetryGroup(symmetries=[SYM_OP, SYM_OP], full_group=True)


@pytest.mark.parametrize('data', [
    SYM_OP, [SYM_OP], REPR_MATRIX, [REPR_MATRIX],
    [SYM_OP, [SYM_OP], REPR_MATRIX], SYM_GROUP,
    [SYM_GROUP, SYM_OP, REPR_MATRIX]
])
def test_save_load(data):
    with tempfile.NamedTemporaryFile() as f:
        print(data)
        sr.io.save(data, f.name)
        result = sr.io.load(f.name)
        np.testing.assert_equal(result, data)

예제 #6
0
for fct in sr.WANNIER_ORBITALS['s'] + sr.WANNIER_ORBITALS['p']:
    for spin in (sr.SPIN_UP, sr.SPIN_DOWN):
        orbitals.append(
            sr.Orbital(position=POS_In, function_string=fct, spin=spin))
for fct in sr.WANNIER_ORBITALS['p']:
    for spin in (sr.SPIN_UP, sr.SPIN_DOWN):
        orbitals.append(
            sr.Orbital(position=POS_Sb, function_string=fct, spin=spin))

structure = mg.Structure(lattice=[[0., 3.239, 3.239], [3.239, 0., 3.239],
                                  [3.239, 3.239, 0.]],
                         species=['In', 'Sb'],
                         coords=np.array([[0, 0, 0], [0.25, 0.25, 0.25]]))

analyzer = mg.symmetry.analyzer.SpacegroupAnalyzer(structure)
symops = analyzer.get_symmetry_operations(cartesian=False)
symops_cart = analyzer.get_symmetry_operations(cartesian=True)

symmetry_group = sr.SymmetryGroup(symmetries=[
    sr.SymmetryOperation.from_orbitals(
        orbitals=orbitals,
        real_space_operator=sr.RealSpaceOperator.from_pymatgen(sym_reduced),
        rotation_matrix_cartesian=sym_cart.rotation_matrix,
        numeric=True) for sym_reduced, sym_cart in zip(symops, symops_cart)
],
                                  full_group=True)
time_reversal = sr.get_time_reversal(orbitals=orbitals, numeric=True)

sr.io.save([time_reversal, symmetry_group], 'inputs/symmetries.hdf5')