TRIQS/triqs_ctint 4.0.0
A TRIQS application
Loading...
Searching...
No Matches
solver_core.hpp
1// Copyright (c) 2017--present, The Simons Foundation
2// This file is part of TRIQS/ctint and is licensed under the terms of GPLv3 or later.
3// SPDX-License-Identifier: GPL-3.0-or-later
4// See LICENSE in the root of this distribution for details.
5
6#pragma once
7#include <triqs/utility/macros.hpp>
8#include "./params.hpp"
9#include "./qmc_config.hpp"
10#include "./container_set.hpp"
11
12namespace triqs_ctint {
13
15 class solver_core : public container_set {
16
17 public:
19 g_iw_t G0_iw;
20
22 g_iw_t G0_iw_inv;
23
25 std::optional<block2_gf<mesh::dlr_imfreq, matrix_valued>> D0_iw;
26
28 std::optional<gf<mesh::dlr_imfreq, matrix_valued>> Jperp_iw;
29
35 solver_core(constr_params_t const &constr_params_);
36
37 // Delete assignement operator because of const members
38 solver_core(solver_core const &p) = default;
39 solver_core(solver_core &&p) = default;
40 ~solver_core() = default;
41 solver_core &operator=(solver_core const &p) = delete;
42 solver_core &operator=(solver_core &&p) = default;
43
49 void solve(solve_params_t const &solve_params);
50
53
55 g_tau_t G0_shift_tau;
56
58 C2PY_IGNORE void prepare_G0_shift_iw(params_t const &params);
59
62
64 std::optional<solve_params_t> last_solve_params;
65
66 private:
67 // Mpi Communicator
68 mpi::communicator world;
69
70 // Return reference to container_set
71 container_set &result_set() { return static_cast<container_set &>(*this); }
72 container_set const &result_set() const { return static_cast<container_set const &>(*this); }
73
74 // Function to perform the post-processing steps
75 void post_process(params_t const &p);
76
77 public:
79 void post_process() {
80 if (not last_solve_params) TRIQS_RUNTIME_ERROR << "You need to run the solver once before you post-process";
82 }
83
84 static std::string hdf5_format() { return "CTINT_SolverCore"; }
85
86 // Function that writes the solver_core to hdf5 file
87 friend void h5_write(h5::group h5group, std::string subgroup_name, solver_core const &s) {
88 auto grp = h5group.create_group(subgroup_name);
89 write_hdf5_format(grp, s);
90 h5_write_attribute(grp, "TRIQS_GIT_HASH", std::string(STRINGIZE(TRIQS_GIT_HASH)));
91 h5_write_attribute(grp, "CTINT_GIT_HASH", std::string(STRINGIZE(CTINT_GIT_HASH)));
92 h5_write(grp, "", s.result_set());
93 h5_write(grp, "constr_params", s.constr_params);
94 h5_write(grp, "last_solve_params", s.last_solve_params);
95 h5_write(grp, "G0_iw", s.G0_iw);
96 h5_write(grp, "G0_iw_inv", s.G0_iw_inv);
97 h5_write(grp, "G0_shift_iw", s.G0_shift_iw);
98 h5_write(grp, "G0_shift_tau", s.G0_shift_tau);
99 h5_write(grp, "D0_iw", s.D0_iw);
100 h5_write(grp, "Jperp_iw", s.Jperp_iw);
101 }
102
103 // Function that read all containers to hdf5 file
104 C2PY_IGNORE
105 static solver_core h5_read_construct(h5::group h5group, std::string subgroup_name) {
106 auto grp = h5group.open_group(subgroup_name);
107 auto constr_params = h5_read<constr_params_t>(grp, "constr_params");
108 auto s = solver_core{constr_params};
109 h5_read(grp, "", s.result_set());
110 h5_read(grp, "last_solve_params", s.last_solve_params);
111 h5_read(grp, "G0_iw", s.G0_iw);
112 h5::try_read(grp, "G0_iw_inv", s.G0_iw_inv);
113 h5_read(grp, "G0_shift_iw", s.G0_shift_iw);
114 h5_read(grp, "G0_shift_tau", s.G0_shift_tau);
115 h5_read(grp, "D0_iw", s.D0_iw);
116 h5_read(grp, "Jperp_iw", s.Jperp_iw);
117 return s;
118 }
119 };
120} // namespace triqs_ctint
g_iw_t G0_iw
Non-interacting Green's function in Matsubara frequencies.
solver_core(constr_params_t const &constr_params_)
Construct a CT-INT solver.
void solve(solve_params_t const &solve_params)
void post_process()
Retrigger post-processing with the last set of parameters.
constr_params_t constr_params
Parameters used to construct the solver.
C2PY_IGNORE void prepare_G0_shift_iw(params_t const &params)
Calculate the shifted non-interacting Green's function given .
std::optional< solve_params_t > last_solve_params
Parameters used in the last solve (empty until the solver has been run).
g_iw_t G0_shift_iw
The shifted non-interacting Green's function in Matsubara frequencies.
std::optional< block2_gf< mesh::dlr_imfreq, matrix_valued > > D0_iw
Dynamic density-density interaction in Matsubara frequencies (DLR mesh).
std::optional< gf< mesh::dlr_imfreq, matrix_valued > > Jperp_iw
Dynamic spin-spin interaction in Matsubara frequencies (DLR mesh).
g_tau_t G0_shift_tau
The shifted non-interacting Green's function in imaginary time.
g_iw_t G0_iw_inv
Inverse of the non-interacting Green's function .
Parameters used for constructing the solver class.
Definition params.hpp:13
Container for all (optional) quantities measured and post-processed by the solver.
friend void h5_read(h5::group h5group, std::string subgroup_name, container_set &c)
Function that reads all containers from hdf5 file.
A struct combining both constr_params_t and solve_params_t.
Definition params.hpp:210
Parameters passed to the solve method of the solver class.
Definition params.hpp:57