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
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

class CMakeBuild(build_ext):
def run(self):
# サブモジュールのビルド
# Build submodule
build_dir = os.path.abspath(self.build_temp)
os.makedirs(build_dir, exist_ok=True)

Expand All @@ -19,7 +19,7 @@ def run(self):

subprocess.check_call(['cmake', '--build', '.', '--config', 'Release'], cwd=build_dir)

# sdistとwheelで異なるpackage_dataを設定
# Set package_data differently for sdist and wheel
if 'bdist_wheel' in sys.argv:
package_data = {
'pylibsparseir': ['libsparseir*.dylib', 'libsparseir*.so', 'libsparseir*.dll'],
Expand Down
6 changes: 3 additions & 3 deletions src/sparse_ir/augment.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ def __init__(self, beta):
self._beta = beta

def __call__(self, tau):
tau = _util.check_range(tau, 0, self._beta)
tau = _util.check_range(tau, -self._beta, self._beta)
return np.broadcast_to(1 / np.sqrt(self._beta), tau.shape)

def deriv(self, n=1):
Expand Down Expand Up @@ -282,7 +282,7 @@ def __init__(self, beta):
self._norm = np.sqrt(3/beta)

def __call__(self, tau):
tau = _util.check_range(tau, 0, self._beta)
tau = _util.check_range(tau, -self._beta, self._beta)
x = 2/self._beta * tau - 1
return self._norm * x

Expand Down Expand Up @@ -314,7 +314,7 @@ def __init__(self, beta):
self._beta = beta

def __call__(self, tau):
tau = _util.check_range(tau, 0, self._beta)
tau = _util.check_range(tau, -self._beta, self._beta)
return np.broadcast_to(np.nan, tau.shape)

def deriv(self, n=1):
Expand Down
12 changes: 9 additions & 3 deletions src/sparse_ir/basis_set.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class FiniteTempBasisSet:
Sparse sampling for Matsubara frequency & boson
"""

def __init__(self, beta, wmax, eps=None, sve_result=None):
def __init__(self, beta, wmax, eps=None, sve_result=None, use_positive_taus=False):
"""
Create basis sets for fermion and boson and associated sampling objects.

Expand All @@ -50,6 +50,12 @@ def __init__(self, beta, wmax, eps=None, sve_result=None):
sve_result : SVEResult, optional
Pre-computed SVE result to use for basis construction.
If not provided, SVE will be computed internally.
use_positive_taus : bool, optional
If `use_positive_taus=False`, the sampling points are within
the range [-β/2, β/2] and the distribution is symmetric.
If `use_positive_taus=True`, the sampling points are
folded to the positive tau domain [0, β), which is
the default behavior of sparseir 1.x.x.
"""
if sve_result is None:
# Create bases by sve of the logistic kernel
Expand All @@ -64,8 +70,8 @@ def __init__(self, beta, wmax, eps=None, sve_result=None):
)

# Tau sampling
self.smpl_tau_f = TauSampling(self.basis_f)
self.smpl_tau_b = TauSampling(self.basis_b)
self.smpl_tau_f = TauSampling(self.basis_f, use_positive_taus=use_positive_taus)
self.smpl_tau_b = TauSampling(self.basis_b, use_positive_taus=use_positive_taus)

# Matsubara sampling
self.smpl_wn_f = MatsubaraSampling(self.basis_f)
Expand Down
8 changes: 6 additions & 2 deletions src/sparse_ir/sampling.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
class TauSampling:
"""Sparse sampling in imaginary time."""

def __init__(self, basis, sampling_points=None, use_positive_taus=True):
def __init__(self, basis, sampling_points=None, use_positive_taus=False):
"""
Initialize tau sampling.

Expand All @@ -22,7 +22,11 @@ def __init__(self, basis, sampling_points=None, use_positive_taus=True):
sampling_points : array_like, optional
Tau sampling points. If None, use default.
use_positive_taus : bool, optional
If `use_positive_taus=True`, the sampling points are folded to the positive tau domain [0, β).
If `use_positive_taus=False`, the sampling points are within
the range [-β/2, β/2] and the distribution is symmetric.
If `use_positive_taus=True`, the sampling points are
folded to the positive tau domain [0, β), which is
the default behavior of sparseir 1.x.x.
"""
self.basis = basis

Expand Down
7 changes: 4 additions & 3 deletions tutorials/flex_py.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ def __init__(self,IR_basis_set,nk1,nk2):
self.iwn_f = 1j * self.IR_basis_set.wn_f * np.pi * T
self.iwn_f_ = np.tensordot(self.iwn_f, np.ones(nk), axes=0)

print(self.IR_basis_set.smpl_tau_f.sampling_points)

# ek mesh
self.ek_ = np.tensordot(np.ones(len(self.iwn_f)), self.ek, axes=0)

Expand Down Expand Up @@ -219,7 +221,7 @@ def grit_calc(self):

def ckio_calc(self):
""" Calculate irreducible susciptibility chi0(iv,q) """
ckio = self.grit * self.grit[::-1, :]
ckio = self.grit * (self.grit[::-1, :]) # changed for libsparseir

# Fourier transform
ckio = self.mesh.r_to_k(ckio)
Expand Down Expand Up @@ -273,7 +275,7 @@ def mu_calc(self):

# %%
# initialize calculation
IR_basis_set = sparse_ir.FiniteTempBasisSet(beta, wmax, eps=IR_tol)
IR_basis_set = sparse_ir.FiniteTempBasisSet(beta, wmax, eps=IR_tol, use_positive_taus=True)
mesh = Mesh(IR_basis_set, nk1, nk2)
solver = FLEXSolver(mesh, U, n, sigma_init=0, sfc_tol=sfc_tol, maxiter=maxiter, U_maxiter=U_maxiter, mix=mix)

Expand Down Expand Up @@ -428,7 +430,6 @@ def frit_calc(self):
plt.colorbar()
plt.show()

# %%
# %%%%%%%%%%%%%%% Parameter settings
print('Initialization...')
# system parameters
Expand Down