Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
kwant
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
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
kwant
kwant
Commits
ce22f5d7
Commit
ce22f5d7
authored
12 years ago
by
Christoph Groth
Browse files
Options
Downloads
Patches
Plain Diff
sparse solver: speed up LDOS calculation
parent
ee494c84
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
kwant/solvers/sparse.py
+20
-10
20 additions, 10 deletions
kwant/solvers/sparse.py
with
20 additions
and
10 deletions
kwant/solvers/sparse.py
+
20
−
10
View file @
ce22f5d7
...
@@ -385,7 +385,7 @@ class BlockResult(namedtuple('BlockResultTuple', ['data', 'lead_info'])):
...
@@ -385,7 +385,7 @@ class BlockResult(namedtuple('BlockResultTuple', ['data', 'lead_info'])):
ttdag
-=
np
.
dot
(
ttdag
,
ttdag
)
ttdag
-=
np
.
dot
(
ttdag
,
ttdag
)
return
np
.
trace
(
ttdag
).
real
return
np
.
trace
(
ttdag
).
real
def
ldos
(
fsys
,
e
=
0
):
def
ldos
(
fsys
,
e
nergy
=
0
):
"""
"""
Calculate the local density of states of a system at a given energy.
Calculate the local density of states of a system at a given energy.
...
@@ -402,17 +402,27 @@ def ldos(fsys, e=0):
...
@@ -402,17 +402,27 @@ def ldos(fsys, e=0):
ldos : a numpy array
ldos : a numpy array
local density of states at each orbital of the system.
local density of states at each orbital of the system.
"""
"""
for
lead
in
fsys
.
leads
:
if
not
isinstance
(
lead
,
system
.
InfiniteSystem
):
# TODO: fix this
msg
=
'
ldos only works when all leads are tight binding systems.
'
raise
ValueError
(
msg
)
(
h
,
rhs
,
keep_vars
),
lead_info
=
\
make_linear_sys
(
fsys
,
[],
xrange
(
len
(
fsys
.
leads
)),
energy
)
Modes
=
physics
.
Modes
Modes
=
physics
.
Modes
linsys
,
lead_info
=
make_linear_sys
(
fsys
,
[],
[],
e
)
h
=
linsys
.
h_sys
num_extra_vars
=
sum
(
li
.
vecs
.
shape
[
1
]
-
li
.
nmodes
num_extra_vars
=
sum
(
li
.
vecs
.
shape
[
1
]
-
li
.
nmodes
for
li
in
lead_info
if
isinstance
(
li
,
Modes
))
for
li
in
lead_info
if
isinstance
(
li
,
Modes
))
num_orb
=
h
.
shape
[
0
]
-
num_extra_vars
num_orb
=
h
.
shape
[
0
]
-
num_extra_vars
vec
=
np
.
zeros
(
h
.
shape
[
0
],
complex
)
ldos
=
np
.
zeros
(
num_orb
,
float
)
ldos
=
np
.
zeros
(
num_orb
,
complex
)
slv
=
factorized
(
h
)
slv
=
factorized
(
h
)
for
i
in
xrange
(
num_orb
):
vec
=
np
.
empty
(
h
.
shape
[
0
],
complex
)
vec
[
i
]
=
1
for
mat
in
rhs
:
ldos
[
i
]
=
slv
(
vec
)[
i
]
if
mat
.
shape
[
1
]
==
0
:
vec
[
i
]
=
0
continue
return
ldos
.
imag
/
np
.
pi
mat
=
sp
.
csr_matrix
(
mat
)
for
j
in
xrange
(
mat
.
shape
[
1
]):
vec
[:
mat
.
shape
[
0
]]
=
mat
[:,
j
].
todense
().
flatten
()
vec
[
mat
.
shape
[
0
]
:]
=
0
psi
=
slv
(
vec
)[:
num_orb
]
ldos
+=
abs
(
psi
)
**
2
return
ldos
*
(
0.5
/
np
.
pi
)
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