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
dfd8a9ed
Commit
dfd8a9ed
authored
Mar 22, 2019
by
Kloss
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
rearange arguments of _match_functions, update tests
parent
3e1668f5
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
6 deletions
+22
-6
kwant_spectrum.py
kwant_spectrum.py
+8
-5
test_kwant_spectrum.py
test_kwant_spectrum.py
+14
-1
No files found.
kwant_spectrum.py
View file @
dfd8a9ed
...
...
@@ -419,7 +419,7 @@ def _save_ordering(func):
def
_match_functions
(
func
,
xmin
=-
1
,
xmax
=
1
,
tol
=
1E-8
,
min_iter
=
10
,
interval_converged
=
None
,
evaluated
=
None
,
max_iter
=
100000
):
max_iter
=
100000
,
interval_converged
=
None
,
evaluated
=
None
):
"""Match the elements of a vector valued function, such that
each vector element describes a continous function.
...
...
@@ -434,13 +434,16 @@ def _match_functions(func, xmin=-1, xmax=1, tol=1E-8, min_iter=10,
Upper interval boundary to order the function. Defaut = 1.
tol : float, optional
Numerical tolerance.
min_iter : int, optional
Minimal number of iterations of the matching alorithm.
Defaut = 10
max_iter : int, optional
Maximum number of iterations of the matching alorithm. Defaut = 100000
interval_converged : callable, optional
Error estimate for the interval.
Defaut: 3-point estimate for local cubic interpolants
evaluated : dict, optional
Dict of precalculated function values
max_iter : int, optional
Maximum number of iterations of the matching alorithm. Defaut = 100000
Returns
-------
...
...
@@ -501,9 +504,9 @@ def _match_functions(func, xmin=-1, xmax=1, tol=1E-8, min_iter=10,
assert
_is_type
(
xmin
,
'real_number'
)
assert
_is_type
(
xmax
,
'real_number'
)
assert
_is_type
(
tol
,
'real_number'
)
assert
_is_type
(
max_iter
,
'integer'
)
assert
_is_type
(
min_iter
,
'integer'
)
assert
min_iter
>
0
assert
_is_type
(
max_iter
,
'integer'
)
assert
0
<
min_iter
<
max_iter
assert
tol
>
0
assert
callable
(
func
)
...
...
test_kwant_spectrum.py
View file @
dfd8a9ed
...
...
@@ -126,7 +126,7 @@ def test_gap_detection_tolerance():
def
gap_detected
(
x0
,
gap
,
tol
):
func
=
partial
(
gap_function
,
gap
=
gap
,
x0
=
x0
)
x
,
y
,
dy
,
*
_
=
ks
.
_match_functions
(
func
,
-
1
,
1
,
tol
=
tol
)
x
,
y
,
dy
,
*
_
=
ks
.
_match_functions
(
func
,
-
1
,
1
,
tol
=
tol
,
min_iter
=
1
)
yy
=
func
(
x
)[
0
].
T
return
np
.
allclose
(
y
,
yy
)
...
...
@@ -292,6 +292,19 @@ def test_function_mapping():
xr
=
2
assert
not
ks
.
_leftmost_crossing
(
func
(
xl
),
func
(
xr
),
xl
,
xr
)
# test from benoit rossignol where
# f(-pi) = f(0) = f(pi) = 1 and f'(-pi) = f'(0) = f'(pi) = 0
# such that the symmetric center point convergence estimate
# (on the points -pi, 0, pi) fails. if no minimal number of splits
# is required (which can be simulated by setting min_split = 1) the
# algorithm will erroneously assume to be converged with only three points.
def
f
(
x
):
return
np
.
array
([[
np
.
cos
(
2
*
x
)],
[
-
2
*
np
.
sin
(
2
*
x
)]])
x
,
y
,
dy
,
*
_
=
ks
.
_match_functions
(
f
,
xmin
=-
np
.
pi
,
xmax
=
np
.
pi
)
assert
len
(
x
)
>
3
def
test_cost_matrix
():
# take linear functions since cost matrix is calculated in linear approx.
...
...
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