diff --git a/setup.py b/setup.py index 115b569..8fb3992 100644 --- a/setup.py +++ b/setup.py @@ -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) @@ -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'], diff --git a/src/sparse_ir/augment.py b/src/sparse_ir/augment.py index 4144a0d..69ae465 100644 --- a/src/sparse_ir/augment.py +++ b/src/sparse_ir/augment.py @@ -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): @@ -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 @@ -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): diff --git a/src/sparse_ir/basis_set.py b/src/sparse_ir/basis_set.py index 63c9a7d..02bcbb3 100644 --- a/src/sparse_ir/basis_set.py +++ b/src/sparse_ir/basis_set.py @@ -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. @@ -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 @@ -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) diff --git a/src/sparse_ir/sampling.py b/src/sparse_ir/sampling.py index 92b0434..cec9b7d 100644 --- a/src/sparse_ir/sampling.py +++ b/src/sparse_ir/sampling.py @@ -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. @@ -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 diff --git a/tutorials/flex_py.py b/tutorials/flex_py.py index ed4bb35..8b085a8 100644 --- a/tutorials/flex_py.py +++ b/tutorials/flex_py.py @@ -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) @@ -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) @@ -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) @@ -428,7 +430,6 @@ def frit_calc(self): plt.colorbar() plt.show() -# %% # %%%%%%%%%%%%%%% Parameter settings print('Initialization...') # system parameters