Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
M
MeanFi
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
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
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
Quantum Tinkerer
MeanFi
Commits
6e131190
Commit
6e131190
authored
11 months ago
by
Johanna Zijderveld
Browse files
Options
Downloads
Patches
Plain Diff
add vectorized tb2kham function
parent
1c6d8695
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!4
Interface refactoring
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
codes/tb/transforms.py
+37
-0
37 additions, 0 deletions
codes/tb/transforms.py
with
37 additions
and
0 deletions
codes/tb/transforms.py
+
37
−
0
View file @
6e131190
...
...
@@ -3,6 +3,43 @@ from scipy.fftpack import ifftn
import
itertools
as
it
def
tb2khamvector
(
h_0
,
nK
,
ndim
):
"""
Real-space tight-binding model to hamiltonian on k-space grid.
Parameters
----------
h_0 : dict
A dictionary with real-space vectors as keys and complex np.arrays as values.
nK : int
Number of k-points along each direction.
ndim : int
Number of dimensions.
Returns
-------
ndarray
Hamiltonian evaluated on a k-point grid.
"""
ks
=
np
.
linspace
(
-
np
.
pi
,
np
.
pi
,
nK
,
endpoint
=
False
)
ks
=
np
.
concatenate
((
ks
[
nK
//
2
:],
ks
[:
nK
//
2
]),
axis
=
0
)
# shift for ifft
kgrid
=
np
.
meshgrid
(
ks
,
ks
,
indexing
=
"
ij
"
)
num_keys
=
len
(
list
(
h_0
.
keys
()))
tb_array
=
np
.
array
(
list
(
h_0
.
values
()))
keys
=
np
.
array
(
list
(
h_0
.
keys
()))
k_dependency
=
np
.
exp
(
-
1j
*
np
.
tensordot
(
keys
,
kgrid
,
1
))[
(...,)
+
(
np
.
newaxis
,)
*
2
]
tb_array
=
tb_array
.
reshape
(
np
.
concatenate
(([
num_keys
],
[
1
]
*
ndim
,
tb_array
.
shape
[
1
:]))
)
return
np
.
sum
(
tb_array
*
k_dependency
,
axis
=
0
)
def
tb2kfunc
(
h_0
):
"""
Fourier transforms a real-space tight-binding model to a k-space function.
...
...
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