TRIQS/triqs_cthyb 4.0.0
A TRIQS application
Loading...
Searching...
No Matches
solver_core.hpp
1
2/*******************************************************************************
3 *
4 * TRIQS: a Toolbox for Research in Interacting Quantum Systems
5 *
6 * Copyright (C) 2014-2017, H. U.R. Strand, P. Seth, I. Krivenko,
7 * M. Ferrero and O. Parcollet
8 *
9 * TRIQS is free software: you can redistribute it and/or modify it under the
10 * terms of the GNU General Public License as published by the Free Software
11 * Foundation, either version 3 of the License, or (at your option) any later
12 * version.
13 *
14 * TRIQS is distributed in the hope that it will be useful, but WITHOUT ANY
15 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
16 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
17 * details.
18 *
19 * You should have received a copy of the GNU General Public License along with
20 * TRIQS. If not, see <http://www.gnu.org/licenses/>.
21 *
22 ******************************************************************************/
23#pragma once
24#include <triqs/mc_tools.hpp>
25#include <triqs/utility/callbacks.hpp>
26#include <triqs/operators/many_body_operator.hpp>
27#include <triqs/stat/histograms.hpp>
28#include <triqs/atom_diag/atom_diag.hpp>
29#include <triqs/atom_diag/functions.hpp>
30#include <triqs/utility/macros.hpp>
31#include <optional>
32
33#include "types.hpp"
34#include "container_set.hpp"
35#include "parameters.hpp"
36#include "configuration.hpp"
37
38namespace triqs_cthyb {
39
42
43 double beta; // inverse temperature
44 atom_diag h_diag; // diagonalization of the local problem
45 gf_struct_t gf_struct; // Block structure of the Green function
46 many_body_op_t _h_loc; // The local Hamiltonian = h_int + h0
47 many_body_op_t _h_loc0; //noninteracting part of the local Hamiltonian
48 int n_iw, n_tau, n_l;
49 bool delta_interface;
50
51 std::vector<matrix_t> _density_matrix; // density matrix, when used in Norm mode
52 mpi::communicator _comm; // define the communicator, here MPI_COMM_WORLD
53 histo_map_t _performance_analysis; // Histograms used for performance analysis
54 mc_weight_t _average_sign; // average sign of the QMC
55 double _average_order; // average perturbation order
56 double _auto_corr_time; // Auto-correlation time in units of MC cycles
57 bool _auto_corr_time_converged = true; // Whether the auto-correlation time estimate has saturated
58 int _solve_status; // Status of the solve upon exit: 0 for clean termination, > 0 otherwise.
59 std::optional<configuration> _last_configuration; // Final configuration of the run
60
61 // Single-particle Green's function containers
62 std::optional<G_iw_t> _G0_iw; // Non-interacting Matsubara Green's function
63 G_tau_t _Delta_tau; // Imaginary-time Hybridization function
64 std::optional<std::vector<matrix<dcomplex>>> Delta_infty_vec; // Quadratic instantaneous part of G0_iw
65
66 // Return reference to container_set
67 container_set_t &container_set() { return static_cast<container_set_t &>(*this); }
68 container_set_t const &container_set() const { return static_cast<container_set_t const &>(*this); }
69
70 public:
73
76
83
84 // Delete assignement operator because of const members
85 solver_core(solver_core const &p) = default;
86 solver_core(solver_core &&p) = default;
87 solver_core &operator=(solver_core const &p) = delete;
88 solver_core &operator=(solver_core &&p) = default;
89
95 void solve(solve_parameters_t const &p);
96
98 many_body_op_t h_loc() const { return _h_loc; }
99
101 many_body_op_t h_loc0() const { return _h_loc0; }
102
105
108
110 [[deprecated("Use h_loc0() instead.")]]
111 std::vector<matrix<dcomplex>> Delta_infty() {
112 if (delta_interface) TRIQS_RUNTIME_ERROR << "Delta_infty cannot be accessed when using the Delta interface";
113 return Delta_infty_vec.value();
114 }
115
117 block_gf_view<imtime> Delta_tau() { return _Delta_tau; }
118
120 block_gf_view<imfreq> G0_iw() {
121 if (delta_interface) TRIQS_RUNTIME_ERROR << "G0_iw cannot be accessed when using the Delta interface";
122 return _G0_iw.value();
123 }
124
126 //block_gf_view<imtime> atomic_gf() const { return ::triqs_cthyb::atomic_gf(h_diag, beta, gf_struct, _Delta_tau[0].mesh().size()); }
127
129 std::vector<matrix_t> density_matrix() const { return _density_matrix; }
130
132 atom_diag const &h_loc_diagonalization() const { return h_diag; }
133
135 C2PY_PROPERTY_GET(performance_analysis) histo_map_t get_performance_analysis() const { return _performance_analysis; }
136
138 mc_weight_t average_sign() const { return _average_sign; }
139
141 double average_order() const { return _average_order; }
142
144 double auto_corr_time() const { return _auto_corr_time; }
145
147 bool auto_corr_time_converged() const { return _auto_corr_time_converged; }
148
150 int solve_status() const { return _solve_status; }
151
153 std::optional<configuration> last_configuration() const { return _last_configuration; }
154
157#ifdef HYBRIDISATION_IS_COMPLEX
158 return true;
159#else
160 return false;
161#endif
162 }
163
166#ifdef LOCAL_HAMILTONIAN_IS_COMPLEX
167 return true;
168#else
169 return false;
170#endif
171 }
172
173 static std::string hdf5_format() { return "CTHYB_SolverCore"; }
174
175 // Function that writes the solver_core to hdf5 file
176 friend void h5_write(h5::group h5group, std::string subgroup_name, solver_core const &s) {
177 h5::group grp = subgroup_name.empty() ? h5group : h5group.create_group(subgroup_name);
178 write_hdf5_format(grp, s);
179 h5_write_attribute(grp, "TRIQS_GIT_HASH", std::string(STRINGIZE(TRIQS_GIT_HASH)));
180 h5_write_attribute(grp, "CTHYB_GIT_HASH", std::string(STRINGIZE(CTHYB_GIT_HASH)));
181 h5_write(grp, "container_set", s.container_set());
182 h5_write(grp, "constr_parameters", s.constr_parameters);
183 h5_write(grp, "solve_parameters", s.solve_parameters);
184 h5_write(grp, "G0_iw", s._G0_iw);
185 h5_write(grp, "Delta_tau", s._Delta_tau);
186
187 h5_write(grp, "h_diag", s.h_diag);
188 h5_write(grp, "h_loc", s._h_loc);
189 h5_write(grp, "density_matrix", s._density_matrix);
190 h5_write(grp, "average_sign", s._average_sign);
191 h5_write(grp, "average_order", s._average_order);
192 h5_write(grp, "auto_corr_time", s._auto_corr_time);
193 h5_write(grp, "auto_corr_time_converged", s._auto_corr_time_converged);
194 h5_write(grp, "solve_status", s._solve_status);
195 h5_write(grp, "Delta_infty_vec", s.Delta_infty_vec);
196 }
197
198 // Function that read all containers to hdf5 file
199 C2PY_IGNORE static solver_core h5_read_construct(h5::group h5group, std::string subgroup_name) {
200 h5::group grp = subgroup_name.empty() ? h5group : h5group.open_group(subgroup_name);
201 auto constr_parameters = h5::h5_read<constr_parameters_t>(grp, "constr_parameters");
203 h5_read(grp, "container_set", s.container_set());
204 h5_read(grp, "solve_parameters", s.solve_parameters);
205 h5_read(grp, "G0_iw", s._G0_iw);
206 h5_read(grp, "Delta_tau", s._Delta_tau);
207
208 h5::try_read(grp, "h_diag", s.h_diag);
209 h5::try_read(grp, "h_loc", s._h_loc);
210 h5::try_read(grp, "density_matrix", s._density_matrix);
211 h5::try_read(grp, "average_sign", s._average_sign);
212 h5::try_read(grp, "average_order", s._average_order);
213 h5::try_read(grp, "auto_corr_time", s._auto_corr_time);
214 h5::try_read(grp, "auto_corr_time_converged", s._auto_corr_time_converged);
215 h5::try_read(grp, "solve_status", s._solve_status);
216 h5::try_read(grp, "Delta_infty_vec", s.Delta_infty_vec);
217
218 return s;
219 }
220 };
221} // namespace triqs_cthyb
constr_parameters_t constr_parameters
Parameters used for constructing the solver.
C2PY_PROPERTY_GET(performance_analysis) histo_map_t get_performance_analysis() const
Histograms related to the performance analysis.
many_body_op_t h_loc() const
The local Hamiltonian used in the last solve.
double average_order() const
Average perturbation order.
solve_parameters_t last_solve_parameters() const
Parameters used in the last solve.
std::optional< configuration > last_configuration() const
Final configuration of the last solve call.
block_gf_view< imfreq > G0_iw()
Non-interacting Green's function in Matsubara frequencies.
atom_diag const & h_loc_diagonalization() const
Diagonalization of .
int solve_status() const
Status of the solve on exit.
double auto_corr_time() const
Auto-correlation time in units of MC cycles.
constr_parameters_t last_constr_parameters() const
Parameters used for constructing the solver.
solve_parameters_t solve_parameters
Parameters passed to the solve method.
void solve(solve_parameters_t const &p)
mc_weight_t average_sign() const
Monte Carlo average sign.
std::vector< matrix_t > density_matrix() const
Atomic :math:G(\tau) in imaginary time.
many_body_op_t h_loc0() const
The noninteracting part of the local Hamiltonian.
bool local_hamiltonian_is_complex() const
Is the solver compiled with support for a complex local Hamiltonian?
bool auto_corr_time_converged() const
Whether the auto-correlation time estimate has saturated (false: it is only a lower bound,...
bool hybridisation_is_complex() const
Is the solver compiled with support for complex hybridization?
block_gf_view< imtime > Delta_tau()
Hybridization function in imaginary time.
std::vector< matrix< dcomplex > > Delta_infty()
in Matsubara frequencies.
solver_core(constr_parameters_t const &p)
Container for all results accumulated by the simulation.
friend void h5_read(h5::group h5group, std::string subgroup_name, container_set_t &c)
Function that reads all containers to hdf5 file.
Parameters used for constructing the solver class.
Parameters passed to the solve method of the solver class.