Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/sparse_ir/sampling.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ def evaluate(self, al, axis=0):
ndarray
Values at sampling points
"""
al = np.ascontiguousarray(al)
output_dims = list(al.shape)
ndim = len(output_dims)
input_dims = np.asarray(al.shape, dtype=np.int32)
Expand Down Expand Up @@ -104,6 +105,7 @@ def fit(self, ax, axis=0):
"""
Fit basis coefficients from sampling point values.
"""
ax = np.ascontiguousarray(ax)
ndim = len(ax.shape)
input_dims = np.asarray(ax.shape, dtype=np.int32)
output_dims = list(ax.shape)
Expand Down
23 changes: 8 additions & 15 deletions tutorials/flex_py.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# ---
# jupyter:
# jupytext:
# cell_metadata_filter: -all
# cell_metadata_filter: cell_depth,title,-all
# custom_cell_magics: kql
# text_representation:
# extension: .py
Expand All @@ -19,7 +19,7 @@
import scipy as sc
import scipy.optimize
from warnings import warn
import pylibsparseir as sparse_ir
import sparse_ir
# %matplotlib inline
import matplotlib.pyplot as plt

Expand Down Expand Up @@ -142,8 +142,6 @@ def __init__(self, mesh, U, n, sigma_init=0, sfc_tol=1e-4,
self.grit_calc()
self.ckio_calc()


#%%%%%%%%%%% Loop solving instance
def solve(self):
""" FLEXSolver.solve() executes FLEX loop until convergence """
# check whether U < U_crit! Otherwise, U needs to be renormalized.
Expand Down Expand Up @@ -180,8 +178,6 @@ def loop(self):
self.grit_calc()
self.ckio_calc()


#%%%%%%%%%%% U renormalization loop instance
def U_renormalization(self):
""" Loop for renormalizing U if Stoner enhancement U*max{chi0} >= 1. """
print('WARNING: U is too large and the spin susceptibility denominator will diverge/turn unphysical!')
Expand Down Expand Up @@ -211,8 +207,6 @@ def U_renormalization(self):
break
print('Leaving U renormalization...')


#%%%%%%%%%%% Calculation steps
def gkio_calc(self, mu):
""" calculate Green function G(iw,k) """
self.gkio = (self.mesh.iwn_f_ - (self.mesh.ek_ - mu) - self.sigma)**(-1)
Expand Down Expand Up @@ -257,8 +251,6 @@ def sigma_calc(self):
sigma = self.mesh.r_to_k(sigma)
self.sigma = self.mesh.tau_to_wn('F', sigma)


#%%%%%%%%%%% Setting chemical potential mu
def calc_electron_density(self, mu):
""" Calculate electron density from Green function """
self.gkio_calc(mu)
Expand All @@ -278,6 +270,7 @@ def mu_calc(self):

self.mu = sc.optimize.brentq(f, np.amax(self.mesh.ek)*3, np.amin(self.mesh.ek)*3)


# %%
# initialize calculation
IR_basis_set = sparse_ir.FiniteTempBasisSet(beta, wmax, eps=IR_tol)
Expand Down Expand Up @@ -369,7 +362,6 @@ def solve(self):
if abs(self.lam-lam_old) < self.sfc_tol:
break

#%%%%%%%%%%% Calculation steps
def V_singlet_calc(self):
""" Set up interaction in real space and imaginary time """

Expand All @@ -389,6 +381,8 @@ def frit_calc(self):
frit = self.mesh.k_to_r(self.fkio)
self.frit = self.mesh.wn_to_tau('F', frit)

# %%%%%%%%%%% Calculation steps


# %%
gap_solver = LinearizedGapSolver(solver, maxiter=maxiter, sfc_tol=sfc_tol)
Expand Down Expand Up @@ -435,7 +429,7 @@ def frit_calc(self):
plt.show()

# %%
#%%%%%%%%%%%%%%% Parameter settings
# %%%%%%%%%%%%%%% Parameter settings
print('Initialization...')
# system parameters
t = 1 # hopping amplitude
Expand Down Expand Up @@ -468,7 +462,7 @@ def frit_calc(self):
chiSmax_T = np.empty((len(T_values)))


#%%%%%%%%%%%%%%% Calculation for different T values
# %%%%%%%%%%%%%%% Calculation for different T values
for T_it, T in enumerate(T_values):
print("Now: T = {}".format(T))
beta = 1/T
Expand All @@ -494,8 +488,7 @@ def frit_calc(self):
if T == 0.03:
chi_s_plt = np.real(solver.chi_spin)[mesh.iw0_b].reshape(mesh.nk1,mesh.nk2)

# %%
#%%%%%%%%%%%%%%%% Plot results in a combined figure
# %%%%%%%%%%%%%%%% Plot results in a combined figure
import matplotlib.gridspec as gridspec

fig = plt.figure(figsize=(10,4),constrained_layout=True)
Expand Down