Skip to content
Snippets Groups Projects
Commit e279ca32 authored by Johanna Zijderveld's avatar Johanna Zijderveld
Browse files

change test temporarily to kvector one

parent 03c11e4e
No related branches found
No related tags found
1 merge request!4Interface refactoring
# %%
import numpy as np
from codes.model import Model
from codes.solvers import solver
from codes.solvers import solverkvector
from codes import kwant_examples
from codes.kwant_helper import utils
from codes.tb.utils import compute_gap
from codes.tb.tb import addTb
import pytest
repeatNumber = 10
# %%
graphene_builder, int_builder = kwant_examples.graphene_extended_hubbard()
h_0 = utils.builder2h_0(graphene_builder)
# %%
def gap_prediction(U, V):
"""
......@@ -28,8 +31,8 @@ def gap_prediction(U, V):
params = {"U": U, "V": V}
# Compare to phase diagram in https://arxiv.org/pdf/1204.4531.pdf
upperPhaseLine = 0.181*U + 0.416
lowerPhaseLine = 1.707*U - 3.823
upperPhaseLine = 0.181 * U + 0.416
lowerPhaseLine = 1.707 * U - 3.823
triplePoint = (2.78, 0.92)
gapped = False
......@@ -46,7 +49,9 @@ def gap_prediction(U, V):
guess = utils.generate_guess(frozenset(h_int), len(list(h_0.values())[0]))
model = Model(h_0, h_int, filling)
mf_sol = solver(model, guess, nK=nK, optimizer_kwargs={'verbose' : True, 'M' : 0})
mf_sol = solverkvector(
model, guess, nK=nK, optimizer_kwargs={"verbose": True, "M": 0}
)
gap = compute_gap(addTb(h_0, mf_sol), n=100)
# Check if the gap is predicted correctly
......@@ -54,11 +59,14 @@ def gap_prediction(U, V):
gappedPredicted = True
else:
gappedPredicted = False
assert gapped == gappedPredicted, f"Mean-field theory failed to predict the gap for U = {U}, V = {V}"
assert (
gapped == gappedPredicted
), f"Mean-field theory failed to predict the gap for U = {U}, V = {V}"
# %%
@pytest.mark.repeat(repeatNumber)
def test_gap():
U = np.random.uniform(0, 2)
V = np.random.uniform(0, 1)
gap_prediction(U, V)
\ No newline at end of file
gap_prediction(U, V)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment