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
646ba64b
Commit
646ba64b
authored
1 year ago
by
Antonio Manesco
Browse files
Options
Downloads
Patches
Plain Diff
add docstrings
parent
252e6d27
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
codes/hf.py
+73
-0
73 additions, 0 deletions
codes/hf.py
with
73 additions
and
0 deletions
codes/hf.py
+
73
−
0
View file @
646ba64b
...
...
@@ -45,6 +45,17 @@ def mean_field_F(vals, vecs, E_F):
def
convolution
(
M1
,
M2
):
"""
N-dimensional convolution.
M1 : nd-array
M2 : nd-array
Returns:
--------
V_output : nd-array
Discrete linear convolution of M1 with M2.
"""
cell_size
=
M2
.
shape
[
-
1
]
dim
=
len
(
M2
.
shape
)
-
2
...
...
@@ -64,6 +75,25 @@ def convolution(M1, M2):
def
compute_mf
(
vals
,
vecs
,
filling
,
H_int
):
"""
Compute mean-field correction at self-consistent loop.
Parameters:
-----------
vals : nd-array
Eigenvalues of current loop vals[k_x, ..., k_n, j].
vecs : nd_array
Eigenvectors of current loop vals[k_x, ..., k_n, i, j].
H_int : nd-array
Interaction matrix.
filling: int
Number of electrons per cell.
Returns:
--------
mf : nd-array
Meanf-field correction with same format as `H_int`.
"""
dim
=
len
(
vals
.
shape
)
-
1
nk
=
vals
.
shape
[
0
]
...
...
@@ -76,6 +106,22 @@ def compute_mf(vals, vecs, filling, H_int):
return
direct_mf
-
exchange_mf
def
scf_loop
(
mf
,
H_int
,
filling
,
hamiltonians_0
,
tol
):
"""
Self-consistent loop.
Parameters:
-----------
mf : nd-array
Mean-field correction. Same format as the initial guess.
H_int : nd-array
Interaction matrix.
filling: int
Number of electrons per cell.
hamiltonians_0 : nd-array
Non-interacting Hamiltonian. Same format as `H_int`.
tol : float
Tolerance of meanf-field self-consistent loop.
"""
if
np
.
linalg
.
norm
(
mf
)
<
tol
:
return
0
# Generate the Hamiltonian
...
...
@@ -97,6 +143,33 @@ def scf_loop(mf, H_int, filling, hamiltonians_0, tol):
def
find_groundstate_ham
(
H_int
,
filling
,
hamiltonians_0
,
tol
,
guess
,
mixing
=
0.5
,
order
=
1
,
verbose
=
False
):
"""
Self-consistent loop to find groundstate Hamiltonian.
Parameters:
-----------
H_int: nd-array
Interaction matrix H_int[kx, ky, ..., i, j] where i,j are cell indices.
filling: int
Number of electrons per cell.
hamiltonians_0 : nd-array
Non-interacting Hamiltonian. Same format as `H_int`.
tol : float
Tolerance of meanf-field self-consistent loop.
guess : nd-array
Initial guess. Same format as `H_int`.
mixing : float
Regularization parameter in Anderson optimization. Default: 0.5.
order : int
Number of previous solutions to retain. Default: 1.
verbose : bool
Verbose of Anderson optimization. Default: False.
Returns:
--------
hamiltonian : nd-array
Groundstate Hamiltonian with same format as `H_int`.
"""
fun
=
partial
(
scf_loop
,
H_int
=
H_int
,
...
...
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