Skip to content

Commit 77ddaed

Browse files
committed
implement double insert / remove segments
1 parent 64759d3 commit 77ddaed

34 files changed

+929
-3
lines changed

benchmark/dimer/dimer.out.h5

669 KB
Binary file not shown.

benchmark/dimer/dimer.py

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
# Two impurity sites coupled to two bath sites.
2+
# Data in dimer.ref.h5 is obtained by running this script on 800 cores.
3+
4+
from triqs.gf import *
5+
from triqs.gf.tools import *
6+
from triqs.gf.gf_factories import make_gf_from_fourier
7+
from triqs.operators.util import U_matrix_kanamori, h_int_density
8+
import h5
9+
import triqs.utility.mpi as mpi
10+
from triqs.utility.h5diff import h5diff
11+
from triqs.operators import n
12+
13+
from triqs_ctseg import Solver
14+
15+
import numpy as np
16+
from numpy import linalg
17+
18+
# Numerical values
19+
beta = 10. # Inverse temperature
20+
mu = 0.0 # Chemical potential
21+
eps = np.array([0.0, 0.1]) # Impurity site energies
22+
eps_bath = np.array([0.27, -0.4]) # Bath site energies
23+
U = 1. # Density-density interaction
24+
J = 0.2 # Hund's coupling
25+
V = 1 # Bath-impurity coupling
26+
block_names = ['up', 'dn']
27+
n_orb = len(eps)
28+
n_orb_bath = len(eps_bath)
29+
n_tau = 10001
30+
gf_struct = [(s, n_orb) for s in block_names] # Green's function structure
31+
32+
########################################################################
33+
# --------------- Construct Delta(tau) and h_loc0 ---------------
34+
35+
# Non-interacting impurity Hamiltonian in matrix representation
36+
h_0_mat = np.diag(eps - mu)
37+
38+
# Bath Hamiltonian in matrix representation
39+
h_bath_mat = np.diag(eps_bath)
40+
41+
# Coupling matrix
42+
V_mat = np.matrix([[V, V],
43+
[V, V]])
44+
45+
# Total non-interacting Hamiltonian
46+
h_tot_mat = np.block([[h_0_mat, V_mat],
47+
[V_mat.H, h_bath_mat]])
48+
49+
# Non-interacting impurity Green's function
50+
n_iw = int(10 * beta)
51+
iw_mesh = MeshImFreq(beta, 'Fermion', n_iw)
52+
G0_iw = BlockGf(mesh=iw_mesh, gf_struct=gf_struct)
53+
for bl, iw in product(block_names, iw_mesh):
54+
G0_iw[bl][iw] = linalg.inv(iw.value * np.eye(2*n_orb) - h_tot_mat)[:n_orb, :n_orb]
55+
56+
# Get Delta(iw) and h_loc0 from G0(iw)
57+
def get_h0_Delta(G0_iw):
58+
h0_lst, Delta_iw = [], G0_iw.copy()
59+
for bl in G0_iw.indices:
60+
Delta_iw[bl] << iOmega_n - inverse(G0_iw[bl])
61+
tail, err = fit_hermitian_tail(Delta_iw[bl])
62+
Delta_iw[bl] << Delta_iw[bl] - tail[0]
63+
h0_lst.append(tail[0].real)
64+
return h0_lst, Delta_iw
65+
66+
h0_lst, Delta_iw = get_h0_Delta(G0_iw)
67+
h_loc0 = sum(h0_lst[i][0,0] * n(bl, 0) + h0_lst[i][1,1] * n(bl, 1) for i, bl in enumerate(block_names))
68+
69+
# Fourier-transform to get Delta(tau)
70+
tau_mesh = MeshImTime(beta, 'Fermion', n_tau)
71+
Delta_tau = BlockGf(mesh = tau_mesh, gf_struct = gf_struct)
72+
for name, g0 in Delta_iw:
73+
known_moments = make_zero_tail(Delta_iw[name], 1)
74+
tail, err = fit_hermitian_tail(Delta_iw[name], known_moments)
75+
Delta_tau[name] << make_gf_from_fourier(Delta_iw[name], tau_mesh, tail).real
76+
###########################################################
77+
78+
# --------- Construct the CTSEG solver ----------
79+
constr_params = {
80+
'beta': beta,
81+
'gf_struct': gf_struct,
82+
'n_tau': n_tau,
83+
}
84+
S = Solver(**constr_params)
85+
86+
# Input Delta(tau)
87+
S.Delta_tau << Delta_tau
88+
89+
# Impurity interaction Hamiltonian
90+
Umat, Upmat = U_matrix_kanamori(n_orb, U_int=U, J_hund=J)
91+
h_int = h_int_density(block_names, n_orb, Umat, Upmat, off_diag=True)
92+
93+
# --------- Solve parameters ----------
94+
solve_params = {
95+
'h_int': h_int,
96+
'h_loc0': h_loc0,
97+
'n_warmup_cycles': 5000,
98+
'n_cycles': 200000000,
99+
'length_cycle': 100,
100+
}
101+
102+
# ---------- Solve ----------
103+
S.solve(**solve_params)
104+
105+
# --------- Save output ---------
106+
if mpi.is_master_node():
107+
with h5.HDFArchive("dimer.out.h5", 'w') as A:
108+
A['G_tau'] = S.results.G_tau
109+

benchmark/dimer/dimer_pyed.ref.h5

529 KB
Binary file not shown.

benchmark/dimer/plot.ipynb

Lines changed: 99 additions & 0 deletions
Large diffs are not rendered by default.

benchmark/spin_spin/ctint.ref.h5

2.58 MB
Binary file not shown.

benchmark/spin_spin/plot.ipynb

Lines changed: 93 additions & 0 deletions
Large diffs are not rendered by default.

benchmark/spin_spin/spin_spin.py

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
# Single orbital with dynamical spin-spin interactions.
2+
# Data in spin_spin.ref.h5 is obtained by running this script on 800 cores.
3+
from triqs.gf import *
4+
import triqs.utility.mpi as mpi
5+
from triqs.gf.descriptors import Function
6+
from triqs.operators import n
7+
import h5
8+
from triqs.utility.h5diff import h5diff
9+
from triqs_ctseg import SolverCore as Solver
10+
11+
# Numerical values
12+
beta = 10
13+
U = 4.0
14+
mu = U/2
15+
J = 0.5
16+
n_tau = 2051
17+
n_tau_bosonic = 2001
18+
19+
# Solver construction parameters
20+
gf_struct = [('down', 1), ('up', 1)]
21+
constr_params = {
22+
"gf_struct": gf_struct,
23+
"beta": beta,
24+
"n_tau": n_tau,
25+
"n_tau_bosonic": n_tau_bosonic
26+
}
27+
28+
# Construct solver
29+
S = Solver(**constr_params)
30+
31+
# Get inputs from reference file
32+
with h5.HDFArchive("ctint.ref.h5", 'r') as Af:
33+
g0 = Af["dmft_loop/i_001/S/G0_iw/up"]
34+
Q_tau = Af["dmft_loop/i_000/Q_tau"]
35+
36+
# Hybridization Delta(tau)
37+
n_iw = 1025
38+
Delta = GfImFreq(indices=[0], beta=beta, n_points=n_iw)
39+
invg0 = GfImFreq(indices=[0], beta=beta, n_points=n_iw)
40+
invg0 << inverse(g0)
41+
Delta << iOmega_n + mu - invg0
42+
S.Delta_tau << Fourier(Delta)
43+
44+
# Spin-spin interaction (D0(tau) and Jperp(tau))
45+
S.Jperp_tau << -J**2*Q_tau
46+
S.D0_tau["up", "up"] << -0.25*J**2*Q_tau
47+
S.D0_tau["down", "down"] << -0.25*J**2*Q_tau
48+
S.D0_tau["up", "down"] << 0.25*J**2*Q_tau
49+
S.D0_tau["down", "up"] << 0.25*J**2*Q_tau
50+
51+
# Solve parameters
52+
solve_params = {
53+
"h_int": U*n("up", 0)*n("down", 0),
54+
"h_loc0": -mu * (n("up", 0) + n("down", 0)),
55+
"length_cycle": 50,
56+
"n_warmup_cycles": 1000,
57+
"n_cycles": 1000000,
58+
"measure_F_tau": True,
59+
"measure_nn_tau": True,
60+
"measure_nn_static": True
61+
}
62+
63+
# Solve
64+
S.solve(**solve_params)
65+
66+
# Save data
67+
if mpi.is_master_node():
68+
with h5.HDFArchive("spin_spin.out.h5", 'w') as A:
69+
A['G_tau'] = S.results.G_tau
70+
A['F_tau'] = S.results.F_tau
71+
A['nn_tau'] = S.results.nn_tau
72+
A['nn'] = S.results.nn_static
73+
A['densities'] = S.results.densities

benchmark/spin_spin/spin_spin.ref.h5

220 KB
Binary file not shown.

c++/triqs_ctseg/moves.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919

2020
#include "./moves/insert_segment.hpp"
2121
#include "./moves/remove_segment.hpp"
22+
#include "./moves/double_insert_segment.hpp"
23+
#include "./moves/double_remove_segment.hpp"
2224
#include "./moves/split_segment.hpp"
2325
#include "./moves/regroup_segment.hpp"
2426
#include "./moves/move_segment.hpp"

0 commit comments

Comments
 (0)