Skip to content

Commit 69185e6

Browse files
authored
Merge pull request #7 from TRIQS/multiorb_dyn_test
[build] add multiorbital test with dynamic interaction
2 parents b90fc38 + 88d0168 commit 69185e6

File tree

3 files changed

+76
-0
lines changed

3 files changed

+76
-0
lines changed

test/python/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ set(all_tests
99
./spin_spin
1010
./two_orbitals
1111
./multiorb
12+
./dynamic_int_multiorb
1213
./dimer
1314
)
1415

@@ -18,3 +19,6 @@ foreach(test ${all_tests})
1819
add_test(NAME Py_${test_name} COMMAND ${TRIQS_PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/${test_dir}/${test_name}.py WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${test_dir})
1920
set_property(TEST Py_${test_name} APPEND PROPERTY ENVIRONMENT PYTHONPATH=${PROJECT_BINARY_DIR}/python:$ENV{PYTHONPATH} ${SANITIZER_RT_PRELOAD})
2021
endforeach()
22+
23+
# Copy input data for multi-orbital dynamic interaction test
24+
FILE(COPY dynamic_int_multiorb_input.h5 DESTINATION ${test_dir})

test/python/dynamic_int_multiorb.py

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
import numpy as np
2+
from h5 import HDFArchive
3+
4+
from triqs.gf import make_gf_imtime
5+
from triqs.operators import util
6+
7+
from triqs_ctseg import SolverCore as Solver
8+
9+
# load input data from h5
10+
# the input data is generated from the github.com/TRIQS/solid_dmft/tree/3.3.x/test/python/svo_gw_emb_dyn test
11+
with HDFArchive('dynamic_int_multiorb_input.h5', 'r') as ar:
12+
delta_tau = ar['delta_tau']
13+
chemical_potential = ar['chemical_potential']
14+
Uloc_dlr_2idx = ar['Uloc_dlr_2idx']
15+
Uloc_dlr_2idx_prime = ar['Uloc_dlr_2idx_prime']
16+
Vloc = ar['Vloc']
17+
18+
# Number of orbitals and time mesh for interaction
19+
n_orb = Vloc.shape[0]
20+
n_tau_k = 10001
21+
22+
# Solver construction parameters
23+
constr_params = {
24+
'gf_struct': [(block, 1) for block in delta_tau.indices],
25+
'beta': delta_tau.mesh.beta,
26+
'n_tau': len(delta_tau.mesh),
27+
'n_tau_k': n_tau_k,
28+
}
29+
30+
# Construct solver
31+
S = Solver(**constr_params)
32+
33+
# Hybridization Delta(tau)
34+
for name, block in S.Delta_tau:
35+
block << delta_tau[name]
36+
37+
# Interaction Hamiltonian
38+
Umat, Upmat = util.reduce_4index_to_2index(Vloc)
39+
40+
h_int = util.h_int_density(['down', 'up'], n_orb, off_diag=False, U=Umat, Uprime=Upmat)
41+
42+
# create full frequency interaction on full time mesh
43+
Uloc_tau_2idx = make_gf_imtime(Uloc_dlr_2idx, n_tau=n_tau_k)
44+
Uloc_tau_2idx_prime = make_gf_imtime(Uloc_dlr_2idx_prime, n_tau=n_tau_k)
45+
46+
# fill D0_tau from Uloc_tau_2idx and Uloc_tau_2idx_prime
47+
# same spin interaction
48+
S.D0_tau[0:n_orb, 0:n_orb] << Uloc_tau_2idx.real
49+
S.D0_tau[n_orb:2*n_orb, n_orb:2*n_orb] << Uloc_tau_2idx.real
50+
# opposite spin interaction
51+
S.D0_tau[0:n_orb, n_orb:2*n_orb] << Uloc_tau_2idx_prime.real
52+
S.D0_tau[n_orb:2*n_orb, 0:n_orb] << Uloc_tau_2idx_prime.real
53+
54+
# Solve parameters
55+
solve_params = {
56+
'h_int': h_int,
57+
'chemical_potential': chemical_potential,
58+
'length_cycle': 600,
59+
'n_warmup_cycles': 2000,
60+
'n_cycles': 40000,
61+
'measure_perturbation_order_histograms': True,
62+
'measure_statehist': True,
63+
'measure_n': True
64+
}
65+
66+
# Solve
67+
S.solve(**solve_params)
68+
69+
# very basic check of the results
70+
ref_occ = np.array([0.1673 for occ in range(2*n_orb)])
71+
assert(np.allclose(S.results.densities, ref_occ, atol=1e-2))
72+
1.19 MB
Binary file not shown.

0 commit comments

Comments
 (0)