TRIQS/triqs_cthyb 4.0.0
A TRIQS application
Loading...
Searching...
No Matches
parameters.cpp
1/*******************************************************************************
2 *
3 * TRIQS: a Toolbox for Research in Interacting Quantum Systems
4 *
5 * Copyright (C) 2017, H. U.R. Strand, M. Ferrero and O. Parcollet
6 *
7 * TRIQS is free software: you can redistribute it and/or modify it under the
8 * terms of the GNU General Public License as published by the Free Software
9 * Foundation, either version 3 of the License, or (at your option) any later
10 * version.
11 *
12 * TRIQS is distributed in the hope that it will be useful, but WITHOUT ANY
13 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
14 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
15 * details.
16 *
17 * You should have received a copy of the GNU General Public License along with
18 * TRIQS. If not, see <http://www.gnu.org/licenses/>.
19 *
20 ******************************************************************************/
21
22#include "./parameters.hpp"
23
24#include <itertools/itertools.hpp>
25using itertools::enumerate;
26
27namespace triqs_cthyb {
28
29 // -- pair<string, string>
30
31 inline void h5_write(h5::group h5group, std::string name, std::pair<std::string, std::string> const &pair) {
32 h5::group grp = name.empty() ? h5group : h5group.create_group(name);
33 h5_write(grp, "0", std::string(pair.first));
34 h5_write(grp, "1", std::string(pair.second));
35 }
36
37 inline void h5_read(h5::group h5group, std::string name, std::pair<std::string, std::string> &pair) {
38 h5::group grp = name.empty() ? h5group : h5group.open_group(name);
39 assert(grp.get_all_subgroup_names().size() == 2);
40 h5_read(grp, "0", pair.first);
41 h5_read(grp, "1", pair.second);
42 }
43
44 // -- set<pair<string, string>>
45
46 inline void h5_write(h5::group h5group, std::string name, std::set<std::pair<std::string, std::string>> const &pair_set) {
47 h5::group grp = name.empty() ? h5group : h5group.create_group(name);
48 for( auto [idx, pair] : enumerate(pair_set) ) {
49 h5_write(grp, std::to_string(idx), pair);
50 }
51 }
52
53 inline void h5_read(h5::group h5group, std::string name, std::set<std::pair<std::string, std::string>> &pair_set) {
54 h5::group grp = name.empty() ? h5group : h5group.open_group(name);
55 for( auto sgrp_name : grp.get_all_subgroup_names() ) {
56 std::pair<std::string, std::string> pair;
57 h5_read(grp, sgrp_name, pair);
58 pair_set.insert(pair);
59 }
60 }
61
62 void h5_write(h5::group h5group, std::string name, constr_parameters_t const &cp) {
63 h5::group grp = name.empty() ? h5group : h5group.create_group(name);
64 h5_write(grp, "beta", cp.beta);
65 h5_write(grp, "gf_struct", cp.gf_struct);
66 h5_write(grp, "n_iw", cp.n_iw);
67 h5_write(grp, "n_tau", cp.n_tau);
68 h5_write(grp, "n_l", cp.n_l);
69 h5_write(grp, "delta_interface", cp.delta_interface);
70 }
71
72 void h5_read(h5::group h5group, std::string name, constr_parameters_t &cp) {
73 h5::group grp = name.empty() ? h5group : h5group.open_group(name);
74 h5_read(grp, "beta", cp.beta);
75 h5_read(grp, "n_iw", cp.n_iw);
76 h5_read(grp, "n_tau", cp.n_tau);
77 h5_read(grp, "n_l", cp.n_l);
78 h5::try_read(grp, "delta_interface", cp.delta_interface);
79 triqs::gfs::h5_read_gf_struct(grp, "gf_struct", cp.gf_struct);
80 }
81
82 void h5_write(h5::group h5group, std::string name, solve_parameters_t const &sp) {
83 h5::group grp = name.empty() ? h5group : h5group.create_group(name);
84 h5_write(grp, "h_int", sp.h_int);
85
86 h5_write(grp, "n_cycles", sp.n_cycles);
87 h5_write(grp, "partition_method", sp.partition_method);
88 h5_write(grp, "quantum_numbers", sp.quantum_numbers);
89 h5_write(grp, "loc_n_min", sp.loc_n_min);
90 h5_write(grp, "loc_n_max", sp.loc_n_max);
91
92 h5_write(grp, "length_cycle", sp.length_cycle);
93 h5_write(grp, "n_warmup_cycles", sp.n_warmup_cycles);
94 h5_write(grp, "random_seed", sp.random_seed);
95 h5_write(grp, "random_name", sp.random_name);
96 h5_write(grp, "max_time", sp.max_time);
97 h5_write(grp, "verbosity", sp.verbosity);
98
99 h5_write(grp, "move_shift", sp.move_shift);
100 h5_write(grp, "move_double", sp.move_double);
101 h5_write(grp, "use_trace_estimator", sp.use_trace_estimator);
102
103 h5_write(grp, "measure_G_tau", sp.measure_G_tau);
104 h5_write(grp, "measure_G_l", sp.measure_G_l);
105 h5_write(grp, "measure_O_tau", sp.measure_O_tau);
106 h5_write(grp, "measure_O_tau_min_ins", sp.measure_O_tau_min_ins);
107 h5_write(grp, "measure_G2_tau", sp.measure_G2_tau);
108 h5_write(grp, "measure_G2_iw", sp.measure_G2_iw);
109 h5_write(grp, "measure_G2_iw_nfft", sp.measure_G2_iw_nfft);
110 h5_write(grp, "measure_G2_iw_pp", sp.measure_G2_iw_pp);
111 h5_write(grp, "measure_G2_iw_pp_nfft", sp.measure_G2_iw_pp_nfft);
112 h5_write(grp, "measure_G2_iw_ph", sp.measure_G2_iw_ph);
113 h5_write(grp, "measure_G2_iw_ph_nfft", sp.measure_G2_iw_ph_nfft);
114 h5_write(grp, "measure_G2_iwll_pp", sp.measure_G2_iwll_pp);
115 h5_write(grp, "measure_G2_iwll_ph", sp.measure_G2_iwll_ph);
116 h5_write(grp, "measure_G2_block_order", sp.measure_G2_block_order);
117 h5_write(grp, "measure_G2_blocks", sp.measure_G2_blocks);
118
119 h5_write(grp, "measure_G2_n_tau", sp.measure_G2_n_tau);
120 h5_write(grp, "measure_G2_n_bosonic", sp.measure_G2_n_bosonic);
121 h5_write(grp, "measure_G2_n_fermionic", sp.measure_G2_n_fermionic);
122 h5_write(grp, "measure_G2_n_l", sp.measure_G2_n_l);
123
124 h5_write(grp, "measure_G2_iwll_nfft_buf_size", sp.measure_G2_iwll_nfft_buf_size);
125 h5_write(grp, "nfft_buf_sizes", sp.nfft_buf_sizes);
126
127 h5_write(grp, "measure_pert_order", sp.measure_pert_order);
128 h5_write(grp, "measure_density_matrix", sp.measure_density_matrix);
129 h5_write(grp, "use_norm_as_weight", sp.use_norm_as_weight);
130 h5_write(grp, "performance_analysis", sp.performance_analysis);
131 h5_write(grp, "proposal_prob", sp.proposal_prob);
132
133 //h5_write(grp, "move_global", sp.move_global);
134 if( sp.move_global.size() != 0 )
135 TRIQS_RUNTIME_ERROR << "Error serailizing: CTHYB solve_parameters, can not serialize the global moves data type.";
136 h5_write(grp, "move_global_prob", sp.move_global_prob);
137
138 h5_write(grp, "imag_threshold", sp.imag_threshold);
139 h5_write(grp, "off_diag_threshold", sp.off_diag_threshold);
140
141 h5_write(grp, "det_init_size", sp.det_init_size);
142 h5_write(grp, "det_n_operations_before_check", sp.det_n_operations_before_check);
143 h5_write(grp, "det_precision_warning", sp.det_precision_warning);
144 h5_write(grp, "det_precision_error", sp.det_precision_error);
145 h5_write(grp, "det_singular_threshold", sp.det_singular_threshold);
146 h5_write(grp, "h_loc0", sp.h_loc0);
147 }
148
149 void h5_read(h5::group h5group, std::string name, solve_parameters_t &sp) {
150 h5::group grp = name.empty() ? h5group : h5group.open_group(name);
151 h5_read(grp, "h_int", sp.h_int);
152
153 h5_read(grp, "n_cycles", sp.n_cycles);
154 h5_read(grp, "partition_method", sp.partition_method);
155 h5_read(grp, "quantum_numbers", sp.quantum_numbers);
156 h5_read(grp, "loc_n_min", sp.loc_n_min);
157 h5_read(grp, "loc_n_max", sp.loc_n_max);
158
159 h5_read(grp, "length_cycle", sp.length_cycle);
160 h5_read(grp, "n_warmup_cycles", sp.n_warmup_cycles);
161 h5_read(grp, "random_seed", sp.random_seed);
162 h5_read(grp, "random_name", sp.random_name);
163 h5_read(grp, "max_time", sp.max_time);
164 h5_read(grp, "verbosity", sp.verbosity);
165
166 h5_read(grp, "move_shift", sp.move_shift);
167 h5_read(grp, "move_double", sp.move_double);
168 h5_read(grp, "use_trace_estimator", sp.use_trace_estimator);
169
170 h5_read(grp, "measure_G_tau", sp.measure_G_tau);
171 h5_read(grp, "measure_G_l", sp.measure_G_l);
172 if( grp.has_key("measure_O_tau") ) h5_read(grp, "measure_O_tau", sp.measure_O_tau);
173 h5_read(grp, "measure_O_tau_min_ins", sp.measure_O_tau_min_ins);
174 h5_read(grp, "measure_G2_tau", sp.measure_G2_tau);
175 h5_read(grp, "measure_G2_iw", sp.measure_G2_iw);
176 h5_read(grp, "measure_G2_iw_nfft", sp.measure_G2_iw_nfft);
177 h5_read(grp, "measure_G2_iw_pp", sp.measure_G2_iw_pp);
178 h5_read(grp, "measure_G2_iw_pp_nfft", sp.measure_G2_iw_pp_nfft);
179 h5_read(grp, "measure_G2_iw_ph", sp.measure_G2_iw_ph);
180 h5_read(grp, "measure_G2_iw_ph_nfft", sp.measure_G2_iw_ph_nfft);
181 h5_read(grp, "measure_G2_iwll_pp", sp.measure_G2_iwll_pp);
182 h5_read(grp, "measure_G2_iwll_ph", sp.measure_G2_iwll_ph);
183 h5_read(grp, "measure_G2_block_order", sp.measure_G2_block_order);
184 h5_read(grp, "measure_G2_blocks", sp.measure_G2_blocks);
185
186 h5_read(grp, "measure_G2_n_tau", sp.measure_G2_n_tau);
187 h5_read(grp, "measure_G2_n_bosonic", sp.measure_G2_n_bosonic);
188 h5_read(grp, "measure_G2_n_fermionic", sp.measure_G2_n_fermionic);
189 h5_read(grp, "measure_G2_n_l", sp.measure_G2_n_l);
190
191 h5_read(grp, "measure_G2_iwll_nfft_buf_size", sp.measure_G2_iwll_nfft_buf_size);
192 h5_read(grp, "nfft_buf_sizes", sp.nfft_buf_sizes);
193
194 h5_read(grp, "measure_pert_order", sp.measure_pert_order);
195 h5_read(grp, "measure_density_matrix", sp.measure_density_matrix);
196 h5_read(grp, "use_norm_as_weight", sp.use_norm_as_weight);
197 h5_read(grp, "performance_analysis", sp.performance_analysis);
198 h5_read(grp, "proposal_prob", sp.proposal_prob);
199
200 //h5_read(grp, "move_global", sp.move_global);
201 if( grp.has_key("move_global") )
202 TRIQS_RUNTIME_ERROR << "Error reading: CTHYB solve_parameters, can not de-serialize the global moves data type.";
203 h5_read(grp, "move_global_prob", sp.move_global_prob);
204
205 h5_read(grp, "imag_threshold", sp.imag_threshold);
206 h5::try_read(grp, "off_diag_threshold", sp.off_diag_threshold);
207
208 h5_read(grp, "det_init_size", sp.det_init_size);
209 h5_read(grp, "det_n_operations_before_check", sp.det_n_operations_before_check);
210 h5_read(grp, "det_precision_warning", sp.det_precision_warning);
211 h5_read(grp, "det_precision_error", sp.det_precision_error);
212 h5_read(grp, "det_singular_threshold", sp.det_singular_threshold);
213 h5::try_read(grp, "h_loc0", sp.h_loc0);
214 }
215
216} // namespace triqs_cthyb
Parameters used for constructing the solver class.
bool delta_interface
Use and as input instead of .
int n_iw
Number of Matsubara frequencies.
int n_l
Number of Legendre polynomials.
int n_tau
Number of imaginary-time points.
friend void h5_read(h5::group h5group, std::string subgroup_name, constr_parameters_t &sp)
Read constr_parameters_t from hdf5.
friend void h5_write(h5::group h5group, std::string subgroup_name, constr_parameters_t const &sp)
Write constr_parameters_t to hdf5.
gf_struct_t gf_struct
Structure of the Green's function (names and sizes of blocks).
Parameters passed to the solve method of the solver class.
std::optional< std::pair< many_body_op_t, many_body_op_t > > measure_O_tau
Measure by insertion.
bool measure_G2_iw_pp_nfft
Measure in the particle-particle channel.
bool measure_G2_iw_ph
Measure in the particle-hole channel.
long length_cycle
Length of a single QMC cycle.
int loc_n_max
Restrict local Hilbert space to states with at most this number of particles.
bool measure_G2_iwll_ph
Measure in the particle-hole channel.
bool measure_G_tau
Measure ? Hermiticity is enforced.
bool measure_G2_iw_nfft
Measure with three fermionic frequencies.
long random_seed
Seed for random number generator.
std::string partition_method
Partition method.
block_order measure_G2_block_order
Order of block indices in the definition of .
bool measure_pert_order
Measure perturbation order?
bool use_trace_estimator
Calculate the full trace or use an estimate?
int measure_G2_n_bosonic
Number of bosonic Matsubara frequencies for the measurement.
std::string random_name
Name of random number generator.
std::optional< many_body_op_t > h_loc0
Quadratic part of the local Hamiltonian. Must be provided if the interface is used.
std::map< std::string, indices_map_t > move_global
List of global moves (with their names). Each move is specified with an index substitution dictionary...
std::set< std::pair< std::string, std::string > > measure_G2_blocks
List of block index pairs of to measure.
int measure_G2_n_l
Number of Legendre coefficients for the measurement.
bool use_norm_as_weight
Use the norm of the density matrix in the weight (instead of the trace)?
int measure_G2_iwll_nfft_buf_size
NFFT buffer size for the measurement.
long max_time
Maximum runtime in seconds, use -1 to set infinite.
double det_singular_threshold
Bound for the determinant matrix being singular (if , checks for subnormal numbers).
int measure_G2_n_tau
Number of imaginary-time slices for the measurement.
double det_precision_warning
Threshold for determinant precision warnings.
bool measure_G2_iw
Measure with three fermionic frequencies.
bool move_double
Add double insertions as a move?
std::vector< many_body_op_t > quantum_numbers
Quantum numbers.
int measure_G2_n_fermionic
Number of fermionic Matsubara frequencies for the measurement.
bool measure_G2_iw_ph_nfft
Measure in the particle-hole channel.
double imag_threshold
Threshold below which imaginary components of and are set to zero.
bool performance_analysis
Analyse performance of the trace computation with histograms (developers only)?
int loc_n_min
Restrict local Hilbert space to states with at least this number of particles.
std::map< std::string, double > proposal_prob
Operator insertion/removal probabilities for different blocks.
int det_n_operations_before_check
Maximum number of operations before testing the accuracy of and .
bool measure_G2_tau
Measure with three fermionic times.
long n_warmup_cycles
Number of cycles for thermalization.
bool measure_G2_iwll_pp
Measure in the particle-particle channel.
double det_precision_error
Threshold for determinant precision error.
std::map< std::string, long > nfft_buf_sizes
NFFT buffer sizes for different blocks.
bool measure_density_matrix
Measure the reduced impurity density matrix?
friend void h5_write(h5::group h5group, std::string subgroup_name, solve_parameters_t const &sp)
Write solve_parameters_t to hdf5.
bool measure_G2_iw_pp
Measure in the particle-particle channel.
many_body_op_t h_int
Interacting part of the atomic Hamiltonian.
int measure_O_tau_min_ins
Minimum number of operator insertions in the insertion measure.
bool measure_G_l
Measure (Legendre)? No hermiticity is enforced.
bool move_shift
Add shifting an operator as a move?
int det_init_size
The maximum size of the determinant matrix before a resize.
friend void h5_read(h5::group h5group, std::string subgroup_name, solve_parameters_t &sp)
Read solve_parameters_t from hdf5.
double off_diag_threshold
Threshold below which off-diagonal components of are set to zero.
double move_global_prob
Overall probability of the global moves.