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
3f41572b
Commit
3f41572b
authored
1 year ago
by
Johanna Zijderveld
Browse files
Options
Downloads
Patches
Plain Diff
make generate_guess function variable dimensional
parent
798a3bb5
No related branches found
No related tags found
1 merge request
!2
Remove kwant dependencies
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
codes/utils.py
+14
-11
14 additions, 11 deletions
codes/utils.py
with
14 additions
and
11 deletions
codes/utils.py
+
14
−
11
View file @
3f41572b
...
...
@@ -32,10 +32,12 @@ def potential2hamiltonian(
wrapped_V
=
kwant
.
wraparound
.
wraparound
(
V
).
finalized
()
return
syst2hamiltonian
(
kxs
=
ks
,
kys
=
ks
,
syst
=
wrapped_V
,
params
=
params
)
def
generate_guess
(
kxs
,
kys
,
hopping_vecs
,
ndof
,
scale
=
0.1
):
def
generate_guess
(
nk
,
dim
,
hopping_vecs
,
ndof
,
scale
=
0.1
):
"""
kxs, kys : int
number of k points in x and y directions
nk : int
number of k points
dim : int
dimension of the system
hopping_vecs : np.array
hopping vectors as obtained from extract_hopping_vectors
norb_list : np.array
...
...
@@ -48,12 +50,12 @@ def generate_guess(kxs, kys, hopping_vecs, ndof, scale=0.1):
Notes:
-----
Assumes that the desired max nearest neighbour distance is included in the hopping_vecs information.
Creates a square grid by definition, might still want to change that
"""
guess
=
np
.
zeros
((
kxs
,
kys
,
ndof
,
ndof
),
dtype
=
complex
)
kxs_range
=
np
.
linspace
(
-
np
.
pi
,
np
.
pi
,
kxs
)
kys_range
=
np
.
linspace
(
-
np
.
pi
,
np
.
pi
,
kys
)
kgrid
=
np
.
asarray
(
np
.
meshgrid
(
kxs_range
,
kys_range
)).
reshape
(
2
,
-
1
).
T
dim
=
2
klenlist
=
[
nk
for
i
in
range
(
dim
)]
guess
=
np
.
zeros
((
klenlist
+
[
ndof
,
ndof
]),
dtype
=
complex
)
kgrid
=
np
.
asarray
(
np
.
meshgrid
(
*
[
np
.
linspace
(
-
np
.
pi
,
np
.
pi
,
nk
)
for
i
in
range
(
dim
)])).
reshape
(
dim
,
-
1
).
T
#always include onsite/internal hopping
amplitude
=
np
.
random
.
rand
(
ndof
,
ndof
)
...
...
@@ -61,16 +63,17 @@ def generate_guess(kxs, kys, hopping_vecs, ndof, scale=0.1):
rand_hermitian
=
amplitude
*
np
.
exp
(
1j
*
phase
)
rand_hermitian
+=
rand_hermitian
.
T
.
conj
()
rand_hermitian
/=
2
guess
+=
rand_hermitian
.
reshape
(
1
,
1
,
ndof
,
ndof
)
#no k-dependence for onsite
reshape_order
=
[
1
for
i
in
range
(
dim
)]
#could use a better name
guess
+=
rand_hermitian
.
reshape
(
reshape_order
+
[
ndof
,
ndof
])
#no k-dependence for onsite
for
hop
in
hopping_vecs
:
k_dependence
=
np
.
exp
(
1j
*
np
.
dot
(
kgrid
,
hop
)).
reshape
(
k
xs
,
kys
,
1
,
1
)
k_dependence
=
np
.
exp
(
1j
*
np
.
dot
(
kgrid
,
hop
)).
reshape
(
k
lenlist
+
[
1
,
1
]
)
amplitude
=
np
.
random
.
rand
(
ndof
,
ndof
)
phase
=
2
*
np
.
pi
*
np
.
random
.
rand
(
ndof
,
ndof
)
rand_hermitian
=
amplitude
*
np
.
exp
(
1j
*
phase
)
rand_hermitian
+=
rand_hermitian
.
T
.
conj
()
rand_hermitian
/=
2
guess
+=
rand_hermitian
.
reshape
(
1
,
1
,
ndof
,
ndof
)
*
k_dependence
guess
+=
rand_hermitian
.
reshape
(
reshape_order
+
[
ndof
,
ndof
]
)
*
k_dependence
return
guess
*
scale
...
...
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