Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
K
kwant
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Joseph Weston
kwant
Commits
4400d00d
Commit
4400d00d
authored
8 years ago
by
Tómas
Browse files
Options
Downloads
Patches
Plain Diff
test commutator in validate
parent
bda40454
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
kwant/physics/tests/test_symmetry.py
+39
-0
39 additions, 0 deletions
kwant/physics/tests/test_symmetry.py
with
39 additions
and
0 deletions
kwant/physics/tests/test_symmetry.py
+
39
−
0
View file @
4400d00d
...
@@ -10,9 +10,11 @@
...
@@ -10,9 +10,11 @@
import
numpy
as
np
import
numpy
as
np
import
scipy.linalg
as
la
import
scipy.linalg
as
la
from
scipy
import
sparse
from
scipy
import
sparse
from
scipy.sparse
import
csr_matrix
as
csr
from
pytest
import
raises
from
pytest
import
raises
from
kwant.physics
import
DiscreteSymmetry
from
kwant.physics
import
DiscreteSymmetry
import
kwant
import
kwant
from
kwant._common
import
ensure_rng
def
test_projectors
():
def
test_projectors
():
"""
Test setting projectors
"""
"""
Test setting projectors
"""
...
@@ -165,3 +167,40 @@ def test_validate():
...
@@ -165,3 +167,40 @@ def test_validate():
sym
=
DiscreteSymmetry
(
chiral
=
csr
(
np
.
diag
((
1
,
-
1
))))
sym
=
DiscreteSymmetry
(
chiral
=
csr
(
np
.
diag
((
1
,
-
1
))))
assert
sym
.
validate
(
np
.
eye
(
2
))
==
'
Chiral
'
assert
sym
.
validate
(
np
.
eye
(
2
))
==
'
Chiral
'
assert
sym
.
validate
(
1
-
np
.
eye
(
2
))
is
None
assert
sym
.
validate
(
1
-
np
.
eye
(
2
))
is
None
def
random_onsite_hop
(
n
,
rng
=
0
):
rng
=
ensure_rng
(
rng
)
onsite
=
rng
.
randn
(
n
,
n
)
+
1j
*
rng
.
randn
(
n
,
n
)
onsite
=
onsite
+
onsite
.
T
.
conj
()
hop
=
rng
.
rand
(
n
,
n
)
+
1j
*
rng
.
rand
(
n
,
n
)
return
onsite
,
hop
def
test_validate_commutator
():
symm_class
=
[
'
AI
'
,
'
AII
'
,
'
D
'
,
'
C
'
,
'
AIII
'
]
n
=
10
rng
=
10
for
sym
in
symm_class
:
# Random matrix in symmetry class
h
=
kwant
.
rmt
.
gaussian
(
n
,
sym
,
rng
=
rng
)
if
kwant
.
rmt
.
p
(
sym
):
p_mat
=
np
.
array
(
kwant
.
rmt
.
h_p_matrix
[
sym
])
p_mat
=
csr
(
np
.
kron
(
np
.
identity
(
n
//
len
(
p_mat
)),
p_mat
))
else
:
p_mat
=
None
if
kwant
.
rmt
.
t
(
sym
):
t_mat
=
np
.
array
(
kwant
.
rmt
.
h_t_matrix
[
sym
])
t_mat
=
csr
(
np
.
kron
(
np
.
identity
(
n
//
len
(
t_mat
)),
t_mat
))
else
:
t_mat
=
None
if
kwant
.
rmt
.
c
(
sym
):
c_mat
=
csr
(
np
.
kron
(
np
.
identity
(
n
//
2
),
np
.
diag
([
1
,
-
1
])))
else
:
c_mat
=
None
disc_symm
=
DiscreteSymmetry
(
particle_hole
=
p_mat
,
time_reversal
=
t_mat
,
chiral
=
c_mat
)
assert
disc_symm
.
validate
(
h
)
==
None
a
=
random_onsite_hop
(
n
,
rng
=
rng
)[
1
]
assert
disc_symm
.
validate
(
a
)
in
[
'
Time reversal
'
,
'
Particle-hole
'
,
'
Chiral
'
]
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment