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
09875794
Commit
09875794
authored
12 years ago
by
Anton Akhmerov
Committed by
Christoph Groth
12 years ago
Browse files
Options
Downloads
Patches
Plain Diff
fix a bug in TranslationalSymmetry.act and add a test case for it
parent
9c067105
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
kwant/lattice.py
+11
-1
11 additions, 1 deletion
kwant/lattice.py
kwant/tests/test_lattice.py
+6
-1
6 additions, 1 deletion
kwant/tests/test_lattice.py
with
17 additions
and
2 deletions
kwant/lattice.py
+
11
−
1
View file @
09875794
...
...
@@ -340,9 +340,19 @@ class TranslationalSymmetry(builder.Symmetry):
raise
ValueError
(
msg
.
format
(
self
.
num_directions
,
element
))
if
b
is
None
:
return
builder
.
Site
(
a
.
group
,
a
.
tag
+
delta
,
True
)
el
se
:
el
if
b
.
group
is
a
.
group
:
return
builder
.
Site
(
a
.
group
,
a
.
tag
+
delta
,
True
),
\
builder
.
Site
(
b
.
group
,
b
.
tag
+
delta
,
True
)
else
:
m_part
=
self
.
_get_site_group_data
(
b
.
group
)[
0
]
try
:
delta2
=
ta
.
dot
(
m_part
,
element
)
except
ValueError
:
msg
=
'
Expecting a {0}-tuple group element,
'
+
\
'
but got `{1}` instead.
'
raise
ValueError
(
msg
.
format
(
self
.
num_directions
,
element
))
return
builder
.
Site
(
a
.
group
,
a
.
tag
+
delta
,
True
),
\
builder
.
Site
(
b
.
group
,
b
.
tag
+
delta2
,
True
)
def
to_fd
(
self
,
a
,
b
=
None
):
return
self
.
act
(
-
self
.
which
(
a
),
a
,
b
)
...
...
This diff is collapsed.
Click to expand it.
kwant/tests/test_lattice.py
+
6
−
1
View file @
09875794
...
...
@@ -57,7 +57,6 @@ def test_translational_symmetry():
assert_raises
(
ValueError
,
sym
.
add_site_group
,
g2
)
# Test lattices with dimension smaller than dimension of space.
g2in3
=
lattice
.
make_lattice
([[
4
,
4
,
0
],
[
4
,
-
4
,
0
]])
sym
=
ts
((
8
,
0
,
0
))
sym
.
add_site_group
(
g2in3
)
...
...
@@ -95,6 +94,12 @@ def test_translational_symmetry():
assert_equal
(
sym
.
to_fd
(
site2
,
shifted
(
site2
,
hop
)),
(
site
,
shifted
(
site
,
hop
)))
# Test act for hoppings belonging to different lattices.
g2p
=
lattice
.
make_lattice
(
2
*
np
.
identity
(
2
))
sym
=
ts
(
*
(
2
*
np
.
identity
(
2
)))
assert
sym
.
act
((
1
,
1
),
g2
(
0
,
0
),
g2p
(
0
,
0
))
==
(
g2
(
2
,
2
),
g2p
(
1
,
1
))
assert
sym
.
act
((
1
,
1
),
g2p
(
0
,
0
),
g2
(
0
,
0
))
==
(
g2p
(
1
,
1
),
g2
(
2
,
2
))
def
test_translational_symmetry_reversed
():
def
assert_equal_symmetry
(
a
,
b
):
...
...
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