2021-10-20 13:48:02 +01:00
|
|
|
import numpy as np
|
|
|
|
import pyerrors as pe
|
|
|
|
import pytest
|
|
|
|
|
|
|
|
np.random.seed(0)
|
|
|
|
|
|
|
|
|
|
|
|
def test_gamma_matrices():
|
2021-10-21 09:07:04 +01:00
|
|
|
for matrix in pe.dirac.gamma:
|
2021-10-20 13:48:02 +01:00
|
|
|
assert np.allclose(matrix @ matrix, np.identity(4))
|
|
|
|
assert np.allclose(matrix, matrix.T.conj())
|
2021-10-21 09:07:04 +01:00
|
|
|
assert np.allclose(pe.dirac.gamma5, pe.dirac.gamma[0] @ pe.dirac.gamma[1] @ pe.dirac.gamma[2] @ pe.dirac.gamma[3])
|
2021-12-07 17:11:50 +00:00
|
|
|
|
|
|
|
|
|
|
|
def test_grid_dirac():
|
|
|
|
for gamma in ['Identity',
|
|
|
|
'Gamma5',
|
|
|
|
'GammaX',
|
|
|
|
'GammaY',
|
|
|
|
'GammaZ',
|
|
|
|
'GammaT',
|
|
|
|
'GammaXGamma5',
|
|
|
|
'GammaYGamma5',
|
|
|
|
'GammaZGamma5',
|
|
|
|
'GammaTGamma5',
|
|
|
|
'SigmaXT',
|
|
|
|
'SigmaXY',
|
|
|
|
'SigmaXZ',
|
|
|
|
'SigmaYT',
|
|
|
|
'SigmaYZ',
|
|
|
|
'SigmaZT']:
|
|
|
|
pe.dirac.Grid_gamma(gamma)
|
2024-12-24 15:35:59 +01:00
|
|
|
with pytest.raises(ValueError):
|
2021-12-07 17:14:21 +00:00
|
|
|
pe.dirac.Grid_gamma('Not a gamma matrix')
|
2021-12-23 12:00:10 +01:00
|
|
|
|
|
|
|
|
|
|
|
def test_epsilon_tensor():
|
|
|
|
check = {(1, 2, 3) : 1.0,
|
|
|
|
(3, 1, 2) : 1.0,
|
|
|
|
(2, 3, 1) : 1.0,
|
|
|
|
(1, 1, 1) : 0.0,
|
|
|
|
(3, 2, 1) : -1.0,
|
|
|
|
(1, 3, 2) : -1.0,
|
|
|
|
(1, 1, 3) : 0.0}
|
|
|
|
for key, value in check.items():
|
|
|
|
assert pe.dirac.epsilon_tensor(*key) == value
|
2024-12-24 15:35:59 +01:00
|
|
|
with pytest.raises(ValueError):
|
2021-12-23 12:06:28 +01:00
|
|
|
pe.dirac.epsilon_tensor(0, 1, 3)
|
|
|
|
|
|
|
|
|
|
|
|
def test_epsilon_tensor_rank4():
|
|
|
|
check = {(1, 4, 3, 2) : -1.0,
|
|
|
|
(1, 2, 3, 4) : 1.0,
|
|
|
|
(2, 1, 3, 4) : -1.0,
|
|
|
|
(4, 3, 2, 1) : 1.0,
|
|
|
|
(3, 2, 4, 3) : 0.0,
|
|
|
|
(0, 1, 2, 3) : 1.0,
|
|
|
|
(1, 1, 1, 1) : 0.0,
|
|
|
|
(1, 2, 3, 1) : 0.0}
|
|
|
|
for key, value in check.items():
|
|
|
|
assert pe.dirac.epsilon_tensor_rank4(*key) == value
|
2024-12-24 15:35:59 +01:00
|
|
|
with pytest.raises(ValueError):
|
2021-12-23 12:06:28 +01:00
|
|
|
pe.dirac.epsilon_tensor_rank4(0, 1, 3, 4)
|