TRIQS/nrgljubljana_interface 4.0.0
A TRIQS application
Loading...
Searching...
No Matches
solver_core.hpp
1/*******************************************************************************
2 *
3 * nrgljubljana_interface: A TRIQS interface to the nrgljubliana impurity solver
4 *
5 * Copyright (c) 2019 The Simons foundation
6 * authors: Rok Zitko, Nils Wentzell
7 *
8 * nrgljubljana_interface is free software: you can redistribute it and/or modify it under the
9 * terms of the GNU General Public License as published by the Free Software
10 * Foundation, either version 3 of the License, or (at your option) any later
11 * version.
12 *
13 * nrgljubljana_interface is distributed in the hope that it will be useful, but WITHOUT ANY
14 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
15 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
16 * details.
17 *
18 * You should have received a copy of the GNU General Public License along with
19 * nrgljubljana_interface. If not, see <http://www.gnu.org/licenses/>.
20 *
21 ******************************************************************************/
22#pragma once
23#include "./container_set.hpp"
24#include "./params.hpp"
25#include "./types.hpp"
26
27#include <iostream>
28#include <fstream>
29#include <string>
30
31#include <triqs/gfs/hilbert_transform.hpp>
32#include <triqs/utility/macros.hpp>
33
34namespace nrgljubljana_interface {
35
43 class solver_core : public container_set {
44
45 private:
46 // Mpi Communicator
47 mpi::communicator world;
48
49 // Return reference to container_set
50 container_set &result_set() { return static_cast<container_set &>(*this); }
51 [[nodiscard]] container_set const &result_set() const { return static_cast<container_set const &>(*this); }
52
53 public:
59 explicit solver_core(constr_params_t cp);
60
61 // Delete assignement operator because of const members
62 solver_core(solver_core const &s) = default;
63 solver_core(solver_core &&s) = default;
64 solver_core &operator=(solver_core const &s) = delete;
65 solver_core &operator=(solver_core &&s) = default;
66 ~solver_core() = default;
67
76 void solve(solve_params_t const &solve_params);
77
85 gf_struct_t read_structure(const std::string &filename, bool mandatory);
86
93 std::string create_tempdir(const std::string &tempdir_);
94
96 void write_gamma();
97
104 void instantiate(double z, const std::string &taskdir);
105
111 void solve_one(const std::string &taskdir);
112
119
121 void set_params();
122
128 void check_model_params(const solve_params_t &sp);
129
135 void generate_param_file(double z);
136
139
142
144 std::optional<solve_params_t> last_solve_params;
145
147 bool verbose = false;
148
150 bool keep_temp_dir = false;
151
153 gf_struct_t gf_struct;
154
156 gf_struct_t Delta_struct;
157
159 gf_struct_t chi_struct;
160
162 refreq_log log_mesh;
163
165 g_w_t Delta_w;
166
172 void readexpv(int Nz);
173
179 void readtdfdm(int Nz);
180
188 C2PY_IGNORE void readGF(const std::string &name, std::optional<g_w_t> &G_w, gf_struct_t &_gf_struct);
189
199 C2PY_IGNORE void readA(const std::string &name, std::optional<g_w_t> &A_w, gf_struct_t &_gf_struct);
200
202 // void readc(const std::string &name, std::optional<s_w_t> &s_w); // TO DO
203
205 void be_quiet() { verbose = false; }
206
212 void set_verbosity(bool v) { verbose = v; }
213
215 static std::string hdf5_format() { return "NRGLJUBLJANA_INTERFACE_SolverCore"; }
216
218 friend void h5_write(h5::group h5group, std::string subgroup_name, solver_core const &s);
219
221 C2PY_IGNORE
222 static solver_core h5_read_construct(h5::group h5group, std::string subgroup_name);
223 };
224
232 std::complex<double> hilbert_transform_refreq(const c_w_cvt &gf, std::complex<double> z);
233
241 matrix<std::complex<double>> hilbert_transform_elementwise(const m_w_cvt &gf, std::complex<double> z);
242
243} // namespace nrgljubljana_interface
TRIQS interface to the NRGLjubljana numerical renormalization group impurity solver.
void set_verbosity(bool v)
Set the verbosity (see also be_quiet()).
nrg_params_t nrg_params
Low-level NRG parameters.
std::optional< solve_params_t > last_solve_params
Parameters used for the most recent solve process.
static std::string hdf5_format()
HDF5 format tag for the solver object.
void be_quiet()
Read a scalar real-valued function name.dat.
void readtdfdm(int Nz)
Read thermodynamic variables (FDM algorithm) from the NRG output files.
constr_params_t constr_params
Parameters used for the solver construction.
C2PY_IGNORE void readGF(const std::string &name, std::optional< g_w_t > &G_w, gf_struct_t &_gf_struct)
Read a block Green's function from (im/re)name-block-ij.dat files.
refreq_log log_mesh
Logarithmic real-frequency mesh.
g_w_t Delta_w
The hybridization function on the real-frequency axis.
friend void h5_write(h5::group h5group, std::string subgroup_name, solver_core const &s)
Write a solver object to an HDF5 file.
void solve(solve_params_t const &solve_params)
Solve the impurity problem.
void generate_param_file(double z)
Produce the param file for a given value of the twist parameter .
gf_struct_t gf_struct
The Green's function structure object.
void check_model_params(const solve_params_t &sp)
Check that all required model parameters have been defined.
gf_struct_t Delta_struct
The hybridization function structure object.
solver_core(constr_params_t cp)
Construct an NRGLjubljana_interface solver.
void set_params()
Establish good defaults for the low-level NRG parameters.
gf_struct_t chi_struct
The susceptibility structure object.
std::string create_tempdir(const std::string &tempdir_)
Create a temporary working directory for a series of NRG runs.
C2PY_IGNORE void readA(const std::string &name, std::optional< g_w_t > &A_w, gf_struct_t &_gf_struct)
Read a block spectral function from name-block-ij.dat files.
gf_struct_t read_structure(const std::string &filename, bool mandatory)
Read the block structure of Green's function objects from a file.
void solve_one(const std::string &taskdir)
Perform an individual NRG calculation. Called from solve().
void readexpv(int Nz)
Read expectation values from the NRG output files.
void set_nrg_params(nrg_params_t const &nrg_params)
Adjust the advanced (low-level) NRG parameters.
void write_gamma()
Write to a file.
bool verbose
If true, detailed output from NRGLjubljana and its tools is sent to stdout.
bool keep_temp_dir
Keep the temporary directories after the calculation.
void instantiate(double z, const std::string &taskdir)
Prepare the input files for an individual NRG calculation. Called from solve().
static C2PY_IGNORE solver_core h5_read_construct(h5::group h5group, std::string subgroup_name)
Construct a solver object from an HDF5 file.
Construction parameters for the NRGLjubljana solver.
Definition params.hpp:28
Collection of all output containers held by the solver.
std::optional< g_w_t > G_w
The retarded Green's function .
std::optional< g_w_t > A_w
The spectral function .
Low-level NRG parameters.
Definition params.hpp:154
Parameters for the solve() method.
Definition params.hpp:108