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
1690d19d
Commit
1690d19d
authored
12 years ago
by
Christoph Groth
Browse files
Options
Downloads
Patches
Plain Diff
fix possible_hoppings, add test
parent
95504e09
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/builder.py
+12
-9
12 additions, 9 deletions
kwant/builder.py
kwant/tests/test_builder.py
+39
-2
39 additions, 2 deletions
kwant/tests/test_builder.py
with
51 additions
and
11 deletions
kwant/builder.py
+
12
−
9
View file @
1690d19d
...
...
@@ -889,12 +889,15 @@ class Builder(object):
self
.
leads
.
extend
(
other_sys
.
leads
)
return
self
def
possible_hoppings
(
self
,
delta
,
group_
b
,
group_
a
):
def
possible_hoppings
(
self
,
delta
,
group_
a
,
group_
b
):
"""
Return all matching possible hoppings between existing sites.
A hopping ``(a, b)`` matches precisely when the site group of ``a`` is
`group_a` and that of ``b`` is `group_b` and ``(a.tag - b.tag)``
(interpreted as vectors) equals to `delta`.
`group_a` and that of ``b`` is `group_b` and ``(a.tag - b.tag)`` is
equal to `delta`.
In other words, the matching hoppings have the form:
``(group_a(x + delta), group_b(x))``
Parameters
----------
...
...
@@ -910,13 +913,13 @@ class Builder(object):
"""
H
=
self
.
H
symtofd
=
self
.
symmetry
.
to_fd
d
=
-
ta
.
array
(
delta
,
int
)
for
site0
in
self
.
H
:
if
site0
.
group
is
not
group_a
:
d
elta
=
ta
.
array
(
delta
,
int
)
for
a
in
self
.
H
:
if
a
.
group
is
not
group_a
:
continue
site1
=
Site
(
group_b
,
site0
.
tag
+
d
,
True
)
if
symtofd
(
site1
)
in
H
:
# if site1 in self
yield
site0
,
site1
b
=
Site
(
group_b
,
a
.
tag
-
d
elta
,
True
)
if
symtofd
(
b
)
in
H
:
yield
a
,
b
def
attach_lead
(
self
,
lead_builder
,
origin
=
None
):
"""
Attach a lead to the builder, possibly adding missing sites.
...
...
This diff is collapsed.
Click to expand it.
kwant/tests/test_builder.py
+
39
−
2
View file @
1690d19d
...
...
@@ -492,10 +492,47 @@ def test_iadd():
sys
+=
other_sys
assert_equal
(
sys
.
leads
,
[
lead0
,
lead1
])
expected
=
sorted
([[(
0
,),
1
],
[(
1
,),
2
],
[(
2
,),
2
]])
assert_equal
(
sorted
(((
s
.
tag
,
v
)
for
s
,
v
in
sys
.
site_value_pairs
())),
assert_equal
(
sorted
(((
s
.
tag
,
v
)
for
s
,
v
in
sys
.
site_value_pairs
())),
expected
)
expected
=
sorted
([[(
0
,),
(
1
,),
1
],
[(
1
,),
(
2
,),
1
]])
assert_equal
(
sorted
(((
a
.
tag
,
b
.
tag
,
v
)
for
(
a
,
b
),
v
in
sys
.
hopping_value_pairs
())),
for
(
a
,
b
),
v
in
sys
.
hopping_value_pairs
())),
expected
)
# y=0: y=1:
#
# hhhh hhhh
# gggh gggh
# hhgh hhgh
# ghgh hhgh
#
def
test_possible_hoppings
():
g
=
kwant
.
make_lattice
(
ta
.
identity
(
3
))
h
=
kwant
.
make_lattice
(
ta
.
identity
(
3
))
sym
=
kwant
.
TranslationalSymmetry
((
0
,
2
,
0
))
sys
=
builder
.
Builder
(
sym
)
sys
[((
h
if
max
(
x
,
y
,
z
)
%
2
else
g
)(
x
,
y
,
z
)
for
x
in
range
(
4
)
for
y
in
range
(
2
)
for
z
in
range
(
4
))]
=
None
for
delta
,
group_a
,
group_b
,
n
in
[((
1
,
0
,
0
),
g
,
h
,
4
),
((
1
,
0
,
0
),
h
,
g
,
7
),
((
0
,
1
,
0
),
g
,
h
,
1
),
((
0
,
4
,
0
),
h
,
h
,
21
),
((
0
,
0
,
1
),
g
,
h
,
4
)
]:
ph
=
list
(
sys
.
possible_hoppings
(
delta
,
group_a
,
group_b
))
assert_equal
(
len
(
ph
),
n
)
ph
=
set
(
ph
)
assert_equal
(
len
(
ph
),
n
)
ph2
=
list
((
sym
.
to_fd
(
b
,
a
)
for
a
,
b
in
sys
.
possible_hoppings
(
ta
.
negative
(
delta
),
group_b
,
group_a
)))
assert_equal
(
len
(
ph2
),
n
)
ph2
=
set
(
ph2
)
assert_equal
(
ph2
,
ph
)
for
a
,
b
in
ph
:
assert
a
.
group
is
group_a
assert
b
.
group
is
group_b
assert
sym
.
to_fd
(
a
)
==
a
assert_equal
(
a
.
tag
-
b
.
tag
,
delta
)
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