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
6e7a22d1
Commit
6e7a22d1
authored
11 months ago
by
Johanna Zijderveld
Browse files
Options
Downloads
Patches
Plain Diff
Try out creating test for mf_sol if zero h_int added
parent
44c230e0
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!4
Interface refactoring
Pipeline
#175282
failed
11 months ago
Stage: test
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
codes/prep_no_int_test.py
+52
-0
52 additions, 0 deletions
codes/prep_no_int_test.py
with
52 additions
and
0 deletions
codes/prep_no_int_test.py
0 → 100644
+
52
−
0
View file @
6e7a22d1
# %%
import
numpy
as
np
from
codes.solvers
import
solver
from
codes.tb
import
utils
from
codes.tb.tb
import
compare_dicts
,
add_tb
from
codes.model
import
Model
# %%
"""
Run a calculation without interactions and check if: 1) the solution is the non-interacting Hamiltonian, and (2) it takes no time for the solver to find that.
"""
# %%
cutoff
=
1
# These should all be random in the test
dim
=
2
ndof
=
4
filling
=
2
random_hopping_vecs
=
utils
.
generate_vectors
(
cutoff
,
dim
)
# %%
h_0_random
=
utils
.
generate_guess
(
random_hopping_vecs
,
ndof
,
scale
=
1
)
# %%
h_int_zeros
=
{}
vectors
=
random_hopping_vecs
for
vector
in
vectors
:
if
vector
not
in
h_int_zeros
.
keys
():
rand_hermitian
=
np
.
zeros
((
ndof
,
ndof
),
dtype
=
complex
)
if
np
.
linalg
.
norm
(
np
.
array
(
vector
))
==
0
:
rand_hermitian
+=
rand_hermitian
.
T
.
conj
()
rand_hermitian
/=
2
h_int_zeros
[
vector
]
=
rand_hermitian
else
:
h_int_zeros
[
vector
]
=
rand_hermitian
h_int_zeros
[
tuple
(
-
np
.
array
(
vector
))]
=
rand_hermitian
.
T
.
conj
()
h_int_only_phases
=
utils
.
generate_guess
(
random_hopping_vecs
,
ndof
,
scale
=
0
)
# %%
guess
=
utils
.
generate_guess
(
random_hopping_vecs
,
ndof
,
scale
=
1
)
model
=
Model
(
h_0_random
,
h_int_only_phases
,
filling
=
filling
)
mf_sol
=
solver
(
model
,
guess
,
nk
=
20
)
# %%
print
(
f
"
Onsite too large:
{
np
.
max
(
mf_sol
[
0
,
0
])
}
"
)
N
=
len
(
mf_sol
.
keys
())
//
2
sorted_vals
=
np
.
array
(
list
(
mf_sol
.
values
()))[
np
.
lexsort
(
np
.
array
(
list
(
mf_sol
.
keys
())).
T
)
]
print
(
f
"
Largest value in hoppings:
{
np
.
max
(
sorted_vals
[
:
N
].
flatten
())
}
"
)
# %%
assert
compare_dicts
(
add_tb
(
mf_sol
,
h_0_random
),
h_0_random
)
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