Skip to content

Commit f021d33

Browse files
authored
Merge pull request #21 from mili1247/3.3.x
move_double implementation (to solve issue #19)
2 parents 0dc2238 + 63c2fe9 commit f021d33

28 files changed

+1129
-0
lines changed

benchmark/dimer/dimer.out.h5

669 KB
Binary file not shown.

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/move_double/ctint.ref.h5

2.58 MB
Binary file not shown.

benchmark/move_double/multiorb.py

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
# Multi-orbital impurity with diagonal Delta(tau).
2+
# Number of orbitals can be changed.
3+
from triqs.gf import *
4+
from triqs.gf.descriptors import Function
5+
from triqs.utility import mpi
6+
from triqs.operators import n
7+
from h5 import *
8+
import numpy as np
9+
from triqs.utility.h5diff import h5diff
10+
from triqs_ctseg import Solver
11+
12+
# Number of orbitals
13+
n_orb = 3
14+
15+
# Numerical values
16+
beta = 20.0 # inverse temperature
17+
mu = 0.2 # chemical potential
18+
eps = 0.3 # hybridization levels
19+
V = 1. # hybridization strengths
20+
U = 2.0 # same orbital interaction
21+
Up = 1.0 # different orbital interaction
22+
J = 0.1 # Hund coupling
23+
n_tau = 1001
24+
n_tau_bosonic = 1001
25+
26+
# Solver construction parameters
27+
gf_struct = [(f'up{(l+2)//2}', 1) if l % 2 == 0 else (f'down{(l+1)//2}', 1) for l in range(2 * n_orb)]
28+
constr_params = {
29+
"gf_struct": gf_struct,
30+
"beta": beta,
31+
"n_tau": n_tau,
32+
"n_tau_bosonic": n_tau_bosonic
33+
}
34+
35+
# Construct solver
36+
S = Solver(**constr_params)
37+
38+
# Interaction Hamiltonian
39+
h_int = 0
40+
for l in range(n_orb):
41+
h_int += U * n(f'up{l+1}', 0) * n(f'down{l+1}', 0)
42+
for l1 in range(n_orb):
43+
for l2 in range(l1+1, n_orb):
44+
h_int += (Up - J) * (n(f'up{l1+1}', 0) * n(f'up{l2+1}', 0) + n(f'down{l1+1}', 0) * n(f'down{l2+1}', 0))
45+
h_int += Up * (n(f'up{l1+1}', 0) * n(f'down{l2+1}', 0) + n(f'down{l1+1}', 0) * n(f'up{l2+1}', 0))
46+
47+
# Local Hamiltonian
48+
h_loc0 = -mu * sum(n(f"up{i + 1}", 0) + n(f"down{i + 1}", 0) for i in range(n_orb) )
49+
50+
# Hybridization Delta(tau)
51+
for name, block in S.Delta_tau:
52+
Delta_iw = GfImFreq(indices=[0], beta=beta, n_points=n_tau//2)
53+
Delta_iw << V**2 * inverse(iOmega_n - eps)
54+
block << Fourier(Delta_iw)
55+
56+
# Solve parameters
57+
solve_params = {
58+
"h_int": h_int,
59+
"h_loc0": h_loc0,
60+
"length_cycle": 50,
61+
"n_warmup_cycles": 10000,
62+
"n_cycles": 2000000,
63+
"measure_F_tau": True,
64+
"measure_nn_tau": True,
65+
"measure_nn_static": True,
66+
"move_double_insert_segment": True,
67+
"move_double_remove_segment": True,
68+
}
69+
70+
# Solve
71+
S.solve(**solve_params)
72+
73+
# Save and compare to reference
74+
if mpi.is_master_node():
75+
with HDFArchive("multiorb.out.h5", 'w') as A:
76+
A['G_tau'] = S.results.G_tau
77+
A['F_tau'] = S.results.F_tau
78+
A["nn_tau"] = S.results.nn_tau
79+
A['nn'] = S.results.nn_static
80+
A['densities'] = S.results.densities
81+

benchmark/move_double/multiorb.ref.h5

836 KB
Binary file not shown.

benchmark/move_double/plot.ipynb

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

benchmark/move_double/spin_spin.py

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
# Single orbital with dynamical spin-spin interactions.
2+
# Can be compared with reference obtained with CTINT (ctint.ref.h5)
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+
"move_double_insert_segment": True,
62+
"move_double_remove_segment": True,
63+
}
64+
65+
# Solve
66+
S.solve(**solve_params)
67+
68+
# Save and compare to reference
69+
if mpi.is_master_node():
70+
with h5.HDFArchive("spin_spin.out.h5", 'w') as A:
71+
A['G_tau'] = S.results.G_tau
72+
A['F_tau'] = S.results.F_tau
73+
A['nn_tau'] = S.results.nn_tau
74+
A['nn'] = S.results.nn_static
75+
A['densities'] = S.results.densities
76+
220 KB
Binary file not shown.

benchmark/spin_spin/ctint.ref.h5

2.58 MB
Binary file not shown.

0 commit comments

Comments
 (0)