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
79338533
Commit
79338533
authored
10 months ago
by
Kostas Vilkelis
Committed by
Johanna Zijderveld
10 months ago
Browse files
Options
Downloads
Patches
Plain Diff
add kgrid_to_tb fun; bump down the default nk values
parent
6171f800
No related branches found
No related tags found
1 merge request
!7
Examples
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
pymf/__init__.py
+2
-1
2 additions, 1 deletion
pymf/__init__.py
pymf/mf.py
+2
-3
2 additions, 3 deletions
pymf/mf.py
pymf/model.py
+1
-1
1 addition, 1 deletion
pymf/model.py
pymf/solvers.py
+2
-2
2 additions, 2 deletions
pymf/solvers.py
pymf/tb/transforms.py
+20
-0
20 additions, 0 deletions
pymf/tb/transforms.py
with
27 additions
and
7 deletions
pymf/__init__.py
+
2
−
1
View file @
79338533
...
...
@@ -14,7 +14,7 @@ from .solvers import solver
from
.model
import
Model
from
.observables
import
expectation_value
from
.tb.tb
import
add_tb
,
scale_tb
from
.tb.transforms
import
tb_to_kgrid
from
.tb.transforms
import
tb_to_kgrid
,
kgrid_to_tb
from
.tb.utils
import
generate_guess
,
calculate_fermi_energy
...
...
@@ -29,6 +29,7 @@ __all__ = [
"
construct_density_matrix
"
,
"
meanfield
"
,
"
tb_to_kgrid
"
,
"
kgrid_to_tb
"
,
"
__version__
"
,
"
__version_tuple__
"
,
]
This diff is collapsed.
Click to expand it.
pymf/mf.py
+
2
−
3
View file @
79338533
import
numpy
as
np
from
scipy.fftpack
import
ifftn
from
typing
import
Tuple
from
pymf.tb.tb
import
add_tb
,
_tb_type
from
pymf.tb.transforms
import
ifftn_to_tb
,
tb_to_kgrid
from
pymf.tb.transforms
import
tb_to_kgrid
,
kgrid_to_tb
def
construct_density_matrix_kgrid
(
...
...
@@ -61,7 +60,7 @@ def construct_density_matrix(
kham
=
tb_to_kgrid
(
h
,
nk
=
nk
)
density_matrix_krid
,
fermi
=
construct_density_matrix_kgrid
(
kham
,
filling
)
return
(
ifftn
_to_tb
(
ifftn
(
density_matrix_krid
,
axes
=
np
.
arange
(
ndim
))
),
kgrid
_to_tb
(
density_matrix_krid
),
fermi
,
)
else
:
...
...
This diff is collapsed.
Click to expand it.
pymf/model.py
+
1
−
1
View file @
79338533
...
...
@@ -76,7 +76,7 @@ class Model:
_check_hermiticity
(
h_0
)
_check_hermiticity
(
h_int
)
def
mfield
(
self
,
mf
:
_tb_type
,
nk
:
int
=
20
0
)
->
_tb_type
:
def
mfield
(
self
,
mf
:
_tb_type
,
nk
:
int
=
20
)
->
_tb_type
:
"""
Computes a new mean-field correction from a given one.
Parameters
...
...
This diff is collapsed.
Click to expand it.
pymf/solvers.py
+
2
−
2
View file @
79338533
...
...
@@ -9,7 +9,7 @@ from pymf.model import Model
from
pymf.tb.utils
import
calculate_fermi_energy
def
cost
(
mf_param
:
np
.
ndarray
,
model
:
Model
,
nk
:
int
=
10
0
)
->
np
.
ndarray
:
def
cost
(
mf_param
:
np
.
ndarray
,
model
:
Model
,
nk
:
int
=
2
0
)
->
np
.
ndarray
:
"""
Defines the cost function for root solver.
The cost function is the difference between the computed and inputted mean-field.
...
...
@@ -40,7 +40,7 @@ def cost(mf_param: np.ndarray, model: Model, nk: int = 100) -> np.ndarray:
def
solver
(
model
:
Model
,
mf_guess
:
np
.
ndarray
,
nk
:
int
=
10
0
,
nk
:
int
=
2
0
,
optimizer
:
Optional
[
Callable
]
=
scipy
.
optimize
.
anderson
,
optimizer_kwargs
:
Optional
[
dict
[
str
,
str
]]
=
{
"
M
"
:
0
},
)
->
_tb_type
:
...
...
This diff is collapsed.
Click to expand it.
pymf/tb/transforms.py
+
20
−
0
View file @
79338533
import
itertools
import
numpy
as
np
from
scipy.fftpack
import
ifftn
from
pymf.tb.tb
import
_tb_type
...
...
@@ -37,6 +38,25 @@ def tb_to_kgrid(tb: _tb_type, nk: int) -> np.ndarray:
return
np
.
sum
(
tb_array
*
k_dependency
,
axis
=
0
)
def
kgrid_to_tb
(
kgrid_array
:
np
.
ndarray
)
->
_tb_type
:
"""
Convert a k-space grid array to a tight-binding dictionary.
Parameters
----------
kgrid_array :
K-space grid array to convert to a tight-binding dictionary.
The array should be of shape (nk, nk, ..., ndof, ndof),
where ndof is number of internal degrees of freedom.
Returns
-------
:
Tight-binding dictionary.
"""
ndim
=
len
(
kgrid_array
.
shape
)
-
2
return
ifftn_to_tb
(
ifftn
(
kgrid_array
,
axes
=
np
.
arange
(
ndim
)))
def
ifftn_to_tb
(
ifft_array
:
np
.
ndarray
)
->
_tb_type
:
"""
Convert the result of `scipy.fft.ifftn` to a tight-binding dictionary.
...
...
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