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
75dc86c1
Commit
75dc86c1
authored
1 year ago
by
Kostas Vilkelis
Browse files
Options
Downloads
Patches
Plain Diff
remove redundant functions
parent
0bd4ae7e
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!4
Interface refactoring
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
codes/hf.py
+1
-32
1 addition, 32 deletions
codes/hf.py
codes/interface.py
+0
-66
0 additions, 66 deletions
codes/interface.py
with
1 addition
and
98 deletions
codes/hf.py
+
1
−
32
View file @
75dc86c1
...
...
@@ -126,35 +126,4 @@ def total_energy(h, rho):
total_energy : float
System total energy computed as tr[h@rho].
"""
return
np
.
sum
(
np
.
trace
(
h
@
rho
,
axis1
=-
1
,
axis2
=-
2
)).
real
/
np
.
prod
(
rho
.
shape
[:
-
2
])
def
updated_matrices
(
mf_k
,
model
):
"""
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`.
Returns:
--------
mf_new : nd-array
Updated mean-field solution.
"""
# Generate the Hamiltonian
hamiltonians
=
model
.
hamiltonians_0
+
mf_k
vals
,
vecs
=
np
.
linalg
.
eigh
(
hamiltonians
)
vecs
=
np
.
linalg
.
qr
(
vecs
)[
0
]
E_F
=
utils
.
get_fermi_energy
(
vals
,
model
.
filling
)
rho
=
density_matrix
(
vals
=
vals
,
vecs
=
vecs
,
E_F
=
E_F
)
return
rho
,
compute_mf
(
rho
=
rho
,
H_int
=
model
.
H_int
)
-
E_F
*
np
.
eye
(
model
.
hamiltonians_0
.
shape
[
-
1
])
return
np
.
sum
(
np
.
trace
(
h
@
rho
,
axis1
=-
1
,
axis2
=-
2
)).
real
/
np
.
prod
(
rho
.
shape
[:
-
2
])
\ No newline at end of file
This diff is collapsed.
Click to expand it.
codes/interface.py
deleted
100644 → 0
+
0
−
66
View file @
0bd4ae7e
from
scipy
import
optimize
from
.
import
utils
,
solvers
import
numpy
as
np
def
find_groundstate_ham
(
model
,
filling
,
nk
=
10
,
cutoff_Vk
=
0
,
solver
=
solvers
.
kspace_solver
,
cost_function
=
solvers
.
kspace_cost
,
optimizer
=
optimize
.
anderson
,
optimizer_kwargs
=
{},
return_mf
=
False
,
return_kspace
=
False
):
"""
Self-consistent loop to find groundstate Hamiltonian.
Parameters:
-----------
tb_model : dict
Tight-binding model. Must have the following structure:
- Keys are tuples for each hopping vector (in units of lattice vectors).
- Values are hopping matrices.
filling: int
Number of electrons per cell.
guess : nd-array
Initial guess. Same format as `H_int`.
return_mf : bool
Returns mean-field result. Useful if wanted to reuse as guess in upcoming run.
Returns:
--------
scf_model : dict
Tight-binding model of Hartree-Fock solution.
"""
model
.
nk
=
nk
model
.
filling
=
filling
if
model
.
int_model
is
not
None
:
model
.
vectors
=
[
*
model
.
int_model
.
keys
()]
else
:
model
.
vectors
=
utils
.
generate_vectors
(
cutoff_Vk
,
model
.
dim
)
if
model
.
guess
is
None
:
model
.
random_guess
(
model
.
vectors
)
solver
(
model
,
optimizer
,
cost_function
,
optimizer_kwargs
)
model
.
vectors
=
[
*
model
.
vectors
,
*
model
.
tb_model
.
keys
()]
assert
np
.
allclose
(
model
.
mf_k
-
np
.
moveaxis
(
model
.
mf_k
,
-
1
,
-
2
).
conj
(),
0
,
atol
=
1e-15
)
vals
,
_
=
np
.
linalg
.
eigh
(
model
.
hamiltonians_0
+
model
.
mf_k
)
EF
=
utils
.
get_fermi_energy
(
vals
,
filling
)
model
.
mf_k
-=
EF
*
np
.
eye
(
model
.
hamiltonians_0
.
shape
[
-
1
])
if
return_kspace
:
return
model
.
hamiltonians_0
+
model
.
mf_k
else
:
if
model
.
dim
>
0
:
scf_tb
=
utils
.
hk2tb_model
(
model
.
hamiltonians_0
+
model
.
mf_k
,
model
.
vectors
,
model
.
ks
)
if
return_mf
:
mf_tb
=
utils
.
hk2tb_model
(
model
.
mf_k
,
model
.
vectors
,
model
.
ks
)
return
scf_tb
,
mf_tb
else
:
return
scf_tb
else
:
if
return_mf
:
return
{()
:
model
.
hamiltonians_0
+
model
.
mf_k
},
{()
:
model
.
mf_k
}
else
:
return
{()
:
model
.
hamiltonians_0
+
model
.
mf_k
}
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