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
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Quantum Tinkerer
MeanFi
Commits
a2f5787b
Commit
a2f5787b
authored
May 15, 2024
by
Kostas Vilkelis
Browse files
Options
Downloads
Patches
Plain Diff
remove complex part from diagonal
parent
9078195e
Branches
Branches containing commit
Tags
Tags containing commit
1 merge request
!16
Density cost
Pipeline
#181322
failed
May 15, 2024
Stage: test
Changes
2
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
meanfi/params/param_transforms.py
+16
-5
16 additions, 5 deletions
meanfi/params/param_transforms.py
meanfi/params/rparams.py
+2
-5
2 additions, 5 deletions
meanfi/params/rparams.py
with
18 additions
and
10 deletions
meanfi/params/param_transforms.py
+
16
−
5
View file @
a2f5787b
...
...
@@ -22,9 +22,14 @@ def tb_to_flat(tb: _tb_type) -> np.ndarray:
hopping_keys
=
sorted
([
key
for
key
in
tb
.
keys
()
if
key
!=
onsite_key
])
hopping_keys
=
hopping_keys
[:
len
(
hopping_keys
)
//
2
]
onsite_val
=
tb
[
onsite_key
][
np
.
triu_indices
(
tb
[
onsite_key
].
shape
[
-
1
])].
flatten
()
onsite_upper_vals
=
tb
[
onsite_key
][
np
.
triu_indices
(
tb
[
onsite_key
].
shape
[
-
1
],
k
=
1
)
].
flatten
()
onsite_diag_vals
=
np
.
diag
(
tb
[
onsite_key
]).
real
.
flatten
()
hopping_vals
=
[
tb
[
key
].
flatten
()
for
key
in
hopping_keys
]
return
np
.
concatenate
([
onsite_val
]
+
hopping_vals
)
complex_vals
=
np
.
concatenate
([
onsite_upper_vals
,
*
hopping_vals
])
return
np
.
concatenate
([
onsite_diag_vals
,
complex_to_real
(
complex_vals
)])
def
flat_to_tb
(
...
...
@@ -57,16 +62,22 @@ def flat_to_tb(
onsite_idxs
=
ndof
+
ndof
*
(
ndof
-
1
)
//
2
onsite_key
=
tuple
(
np
.
zeros
((
ndim
,),
dtype
=
int
))
# reconstruct the complex values
onsite_diag_vals
=
tb_param_complex
[:
ndof
]
complex_vals
=
real_to_complex
(
tb_param_complex
[
ndof
:])
onsite_upper_vals
=
complex_vals
[:
onsite_idxs
-
ndof
]
hopping_vals
=
complex_vals
[(
onsite_idxs
-
ndof
)
:]
# first build onsite matrix
onsite_matrix
=
np
.
zeros
((
ndof
,
ndof
),
dtype
=
complex
)
onsite_matrix
[
np
.
triu_indices
(
ndof
)]
=
tb_param_complex
[:
onsite_idxs
]
onsite_matrix
[
np
.
triu_indices
(
ndof
,
k
=
1
)]
=
onsite_upper_vals
onsite_matrix
+=
onsite_matrix
.
conj
().
T
onsite_matrix
[
np
.
diag_indices
(
ndof
)]
/
=
2
onsite_matrix
[
np
.
diag_indices
(
ndof
)]
=
onsite_diag_vals
# then build hopping matrices
hopping_matrices
=
np
.
zeros
(
hopping_shape
,
dtype
=
complex
)
N
=
len
(
tb_keys
)
//
2
hopping_matrices
[:
N
]
=
tb_param_complex
[
onsite_idxs
:]
.
reshape
(
N
,
*
hopping_shape
[
1
:])
hopping_matrices
[:
N
]
=
hopping_vals
.
reshape
(
N
,
*
hopping_shape
[
1
:])
hopping_matrices
[
N
:]
=
np
.
moveaxis
(
np
.
flip
(
hopping_matrices
[:
N
],
axis
=
0
),
-
1
,
-
2
).
conj
()
...
...
This diff is collapsed.
Click to expand it.
meanfi/params/rparams.py
+
2
−
5
View file @
a2f5787b
import
numpy
as
np
from
meanfi.params.param_transforms
import
(
complex_to_real
,
flat_to_tb
,
real_to_complex
,
tb_to_flat
,
)
from
meanfi.tb.tb
import
_tb_type
...
...
@@ -22,7 +20,7 @@ def tb_to_rparams(tb: _tb_type) -> np.ndarray:
:
1D real vector that parametrises the tight-binding dictionary.
"""
return
complex_to_real
(
tb_to_flat
(
tb
)
)
return
tb_to_flat
(
tb
)
def
rparams_to_tb
(
...
...
@@ -44,5 +42,4 @@ def rparams_to_tb(
:
Tight-biding dictionary.
"""
flat_matrix
=
real_to_complex
(
tb_params
)
return
flat_to_tb
(
flat_matrix
,
ndof
,
tb_keys
)
return
flat_to_tb
(
tb_params
,
ndof
,
tb_keys
)
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