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
8f56ff50
Commit
8f56ff50
authored
1 year ago
by
Kostas Vilkelis
Browse files
Options
Downloads
Patches
Plain Diff
define mean field model classes
parent
d7e96d28
No related branches found
No related tags found
1 merge request
!4
Interface refactoring
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
codes/model.py
+82
-70
82 additions, 70 deletions
codes/model.py
with
82 additions
and
70 deletions
codes/model.py
+
82
−
70
View file @
8f56ff50
from
.
import
utils
from
.
import
utils
import
numpy
as
np
import
numpy
as
np
import
hf
class
Model
:
class
BaseMf
Model
:
"""
"""
A period tight-binding model class.
Base class for periodic hamiltonian with an interacting potential
treated within the mean-field approximation.
Attributes
Attributes
----------
----------
tb_model : dict
H0_k : function
Non-interacting tight-binding model.
Non-interacting hamiltonian part H0(k) evaluated on a k-point grid.
int_model : dict
V_k : function
Interacting tight-binding model.
Interaction potential V(k) evaluated on a k-point grid.
Vk : function
filling : float
Interaction potential V(k). Used if `int_model = None`.
Filling factor of the system.
guess : dict
Initial guess for self-consistent calculation.
Methods
dim : int
-------
Number of translationally invariant real-space dimensions.
densityMatrix(mf_k)
ndof : int
Returns the density matrix given the mean-field correction to the
Number of internal degrees of freedom (orbitals).
non-interacting hamiltonian mf_k.
hamiltonians_0 : nd-array
meanField(rho)
Non-interacting amiltonian evaluated on a k-point grid.
Calculates the mean-field correction from a given density matrix.
H_int : nd-array
Interacting amiltonian evaluated on a k-point grid.
"""
"""
def
__init__
(
self
,
H0_k
,
V_k
,
filling
):
"""
Parameters
----------
H0_k : function
Non-interacting hamiltonian part H0(k) evaluated on a k-point grid.
V_k : function
Interaction potential V(k) evaluated on a k-point grid.
filling : float
Filling factor of the system.
"""
self
.
H0_k
=
H0_k
self
.
V_k
=
V_k
self
.
filling
=
filling
def
__init__
(
self
,
tb_model
,
int_model
=
None
,
Vk
=
None
,
guess
=
None
):
def
densityMatrix
(
self
,
mf_k
):
self
.
tb_model
=
tb_model
self
.
dim
=
len
([
*
tb_model
.
keys
()][
0
])
if
self
.
dim
>
0
:
self
.
hk
=
utils
.
model2hk
(
tb_model
=
tb_model
)
self
.
int_model
=
int_model
if
self
.
int_model
is
not
None
:
self
.
int_model
=
int_model
if
self
.
dim
>
0
:
self
.
Vk
=
utils
.
model2hk
(
tb_model
=
int_model
)
else
:
if
self
.
dim
>
0
:
self
.
Vk
=
Vk
self
.
ndof
=
len
([
*
tb_model
.
values
()][
0
])
self
.
guess
=
guess
if
self
.
dim
==
0
:
self
.
hamiltonians_0
=
tb_model
[()]
self
.
H_int
=
int_model
[()]
def
random_guess
(
self
,
vectors
):
"""
"""
Generate random guess.
Parameters
----------
mf_k : nd-array
Mean-field correction to the non-interacting hamiltonian.
Returns
-------
rho : nd-array
Density matrix.
"""
vals
,
vecs
=
np
.
linalg
.
eigh
(
self
.
H0_k
+
mf_k
)
vecs
=
np
.
linalg
.
qr
(
vecs
)[
0
]
E_F
=
utils
.
get_fermi_energy
(
vals
,
self
.
filling
)
return
hf
.
density_matrix
(
vals
=
vals
,
vecs
=
vecs
,
E_F
=
E_F
)
Parameters:
def
meanField
(
self
,
rho
):
-----------
vectors : list of tuples
Hopping vectors for the mean-field corrections.
"""
"""
if
self
.
int_model
is
None
:
Parameters
scale
=
0.1
----------
else
:
rho : nd-array
scale
=
0.1
*
(
1
+
np
.
max
(
np
.
abs
([
*
self
.
int_model
.
values
()])))
Density matrix.
self
.
guess
=
utils
.
generate_guess
(
vectors
=
vectors
,
ndof
=
self
.
ndof
,
scale
=
scale
)
def
kgrid_evaluation
(
self
,
nk
):
Returns
-------
mf_k : nd-array
Mean-field correction to the non-interacting hamiltonian.
"""
"""
Evaluates hamiltonians on a k-grid.
return
hf
.
compute_mf
(
rho
,
self
.
V_k
)
Parameters:
class
MfModel
(
BaseMfModel
):
-----------
"""
nk : int
BaseMfModel with the non-interacting hamiltonian and the interaction
Number of k-points along each direction.
potential given as tight-binding models.
"""
def
__init__
(
self
,
tb_model
,
filling
,
int_model
):
"""
"""
self
.
hamiltonians_0
,
self
.
ks
=
utils
.
kgrid_hamiltonian
(
Parameters
nk
=
nk
,
----------
hk
=
self
.
hk
,
tb_model : dict
dim
=
self
.
dim
,
Non-interacting tight-binding model.
return_ks
=
True
filling : float
)
Filling factor of the system.
self
.
H_int
=
utils
.
kgrid_hamiltonian
(
nk
=
nk
,
hk
=
self
.
Vk
,
dim
=
self
.
dim
)
int_model : dict
self
.
mf_k
=
utils
.
kgrid_hamiltonian
(
Interacting tight-binding model.
nk
=
nk
,
"""
hk
=
utils
.
model2hk
(
self
.
guess
),
dim
=
self
.
dim
,
self
.
filling
=
filling
)
dim
=
len
([
*
tb_model
.
keys
()][
0
])
if
dim
>
0
:
self
.
H0_k
=
utils
.
model2hk
(
tb_model
=
tb_model
)
self
.
V_k
=
utils
.
model2hk
(
tb_model
=
int_model
)
if
dim
==
0
:
self
.
H0_k
=
tb_model
[()]
self
.
V_k
=
int_model
[()]
\ No newline at end of file
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