Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
K
kwantspectrum
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
kwant
kwantspectrum
Commits
7e19751e
Commit
7e19751e
authored
Sep 24, 2020
by
Kloss
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix problem when roots are exactly on knots
parent
8edf45e7
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
0 deletions
+18
-0
kwantspectrum/kwant_spectrum.py
kwantspectrum/kwant_spectrum.py
+18
-0
No files found.
kwantspectrum/kwant_spectrum.py
View file @
7e19751e
...
...
@@ -938,6 +938,9 @@ class BandSketching:
if
derivative_order
==
0
:
# use tabulated values, faster
y
=
self
.
y
[:,
band
]
dy
=
self
.
dy
[:,
band
]
elif
derivative_order
==
1
:
y
=
self
.
dy
[:,
band
]
dy
=
self
.
_func
(
self
.
x
,
derivative_order
+
1
)[:,
band
]
else
:
y
=
self
.
_func
(
self
.
x
,
derivative_order
)[:,
band
]
dy
=
self
.
_func
(
self
.
x
,
derivative_order
+
1
)[:,
band
]
...
...
@@ -950,7 +953,22 @@ class BandSketching:
y
[
np
.
abs
(
y
-
y_mean
)
<
ytol
]
=
y_mean
dy
[
np
.
abs
(
dy
)
<
100
*
ytol
]
=
0
# derivative dy less acurate than y
g
=
y
-
f
# roots of g give the intersection points we are seeking
roots
=
self
.
interpolation
(
self
.
x
,
y
-
f
,
dy
).
roots
()
# the interpolation/rootfinding can fail if roots are exactly on the
# knots (the gridpoints self.x). In that case we check if g(i) == 0
# and also if the sign on g(i - 1) and g(i + 1) is different
# (necessary condition for g(i) == 0). This condition is important
# to not find spurious zeros of g when it is actually flat.
g_signchange
=
[
np
.
sign
(
g
[
i
-
1
]
*
g
[
i
+
1
])
==
-
1
for
i
in
range
(
1
,
len
(
g
)
-
1
)]
# at the endpoints, check only that g is not flat
g_signchange
.
append
(
np
.
sign
(
g
[
-
2
])
!=
0
)
g_signchange
.
insert
(
0
,
np
.
sign
(
g
[
1
])
!=
0
)
roots_on_knots
=
self
.
x
[
np
.
logical_and
(
np
.
abs
(
g
)
<
ytol
,
g_signchange
)]
roots
=
np
.
append
(
roots
,
roots_on_knots
)
roots
=
remove_nan
(
roots
)
if
self
.
period
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment