flexiblesusy is hosted by Hepforge, IPPP Durham
FlexibleSUSY
problems.cpp
Go to the documentation of this file.
1// ====================================================================
2// This file is part of FlexibleSUSY.
3//
4// FlexibleSUSY is free software: you can redistribute it and/or modify
5// it under the terms of the GNU General Public License as published
6// by the Free Software Foundation, either version 3 of the License,
7// or (at your option) any later version.
8//
9// FlexibleSUSY is distributed in the hope that it will be useful, but
10// WITHOUT ANY WARRANTY; without even the implied warranty of
11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12// General Public License for more details.
13//
14// You should have received a copy of the GNU General Public License
15// along with FlexibleSUSY. If not, see
16// <http://www.gnu.org/licenses/>.
17// ====================================================================
18
19#include "problems.hpp"
20#include "config.h"
21#include "logger.hpp"
22#include "names.hpp"
23#include "string_format.hpp"
24#include "string_utils.hpp"
25
26#include <algorithm>
27#include <iostream>
28#include <vector>
29
30namespace flexiblesusy {
31namespace {
32
33template <class T>
34void vector_or(std::vector<T>& v1, const std::vector<T>& v2)
35{
36 if (v1.size() != v2.size()) {
37 ERROR("Cannot combine vectors of incompatible size.");
38 return;
39 }
40
41 for (typename std::vector<T>::size_type i = 0; i < v2.size(); i++)
42 if (v2[i]) v1[i] = v2[i];
43}
44
45template <class T1, class T2>
46void map_or(std::map<T1,T2>& m1, const std::map<T1,T2>& m2)
47{
48 m1.insert(m2.cbegin(), m2.cend());
49}
50
51} // anonymous namespace
52
53Problems::Problems(const std::string& model_name_,
54 const Names* particle_names_, const Names* parameter_names_)
55 : model_name(model_name_)
56 , particle_names(particle_names_)
57 , parameter_names(parameter_names_)
58 , bad_masses(particle_names_->size())
59 , running_tachyons(particle_names_->size())
60 , pole_tachyons(particle_names_->size())
61 , failed_pole_mass_convergence(particle_names_->size())
62{
63}
64
66{
67 std::fill(bad_masses.begin(), bad_masses.end(), 0);
68 std::fill(running_tachyons.begin(), running_tachyons.end(), 0);
69 std::fill(pole_tachyons.begin(), pole_tachyons.end(), 0);
71 non_pert_pars.clear();
72 failed_minimum.clear();
73 failed_root.clear();
74 exception_msg = "";
75 failed_ewsb = false;
78 non_perturbative = false;
81}
82
106
108{
109 return number_of_problems() > 0;
110}
111
113{
114 unsigned count = 0;
115 if (have_tachyon()) count++;
116 if (failed_ewsb) count++;
117 if (failed_ewsb_tree_level) count++;
118 if (failed_GFermi_convergence) count++;
120 if (failed_sinThetaW_convergence) count++;
121 if (failed_GF_convergence) count++;
122 if (no_minimum()) count++;
123 if (no_root()) count++;
124 if (have_thrown()) count++;
126 return count;
127}
128
130{
131 return number_of_warnings() > 0;
132}
133
135{
136 unsigned count = 0;
137 if (have_bad_mass()) count++;
138 return count;
139}
140
141std::string Problems::get_parameter_name(int idx) const
142{
143 if (idx == -1)
144 return "Q";
145
146 return parameter_names->get(idx);
147}
148
149std::string Problems::get_particle_name(int idx) const
150{
151 return particle_names->get(idx);
152}
153
154std::vector<std::string> Problems::get_problem_strings() const
155{
156 std::vector<std::string> strings;
157 const auto n_particles = particle_names->size();
158
159 for (int i = 0; i < n_particles; ++i) {
160 if (running_tachyons[i])
161 strings.emplace_back("running tachyon " + particle_names->get(i));
162 }
163 for (int i = 0; i < n_particles; ++i) {
164 if (pole_tachyons[i])
165 strings.emplace_back("pole tachyon " + particle_names->get(i));
166 }
167 if (failed_ewsb)
168 strings.emplace_back("no ewsb");
170 strings.emplace_back("no ewsb at tree-level");
172 strings.emplace_back("no GFermi convergence");
174 strings.emplace_back("non-perturbative");
176 strings.emplace_back("no sinThetaW convergence");
178 strings.emplace_back("no GF convergence");
179 if (have_thrown())
180 strings.emplace_back("exception thrown(" + exception_msg + ")");
181 for (int i = 0; i < n_particles; ++i) {
183 strings.emplace_back("no M" + particle_names->get(i) + " pole convergence");
184 }
185
186 for (const auto& par: non_pert_pars) {
187 const std::string par_name = get_parameter_name(par.first);
188 std::string str("non-perturbative " + par_name);
189 if (par.second.threshold > 0) {
190 str += " [|" + par_name + "|(" +
191 flexiblesusy::to_string(par.second.scale) + ") = " +
192 flexiblesusy::to_string(par.second.value) +
193 " > " + flexiblesusy::to_string(par.second.threshold) + "]";
194 } else {
195 str += " [" + par_name + "(" +
196 flexiblesusy::to_string(par.second.scale) +
197 ") = " + flexiblesusy::to_string(par.second.value) + "]";
198 }
199 strings.emplace_back(str);
200 }
201
202 for (const auto& m: failed_minimum) {
203 strings.emplace_back(std::string("no minimum for parameters ") + m.first);
204 }
205
206 for (const auto& m: failed_root) {
207 strings.emplace_back(std::string("no root for parameters ") + m.first);
208 }
209
210 strings.shrink_to_fit();
211
212 return strings;
213}
214
215std::vector<std::string> Problems::get_warning_strings() const
216{
217 std::vector<std::string> strings;
218 const auto n_particles = particle_names->size();
219
220 for (int i = 0; i < n_particles; ++i) {
221 if (bad_masses[i])
222 strings.emplace_back("Warning: imprecise M" + particle_names->get(i));
223 }
224
225 return strings;
226}
227
228std::string Problems::get_problem_string(const std::string& sep) const
229{
230 return concat(get_problem_strings(), sep);
231}
232
233std::string Problems::get_warning_string(const std::string& sep) const
234{
235 return concat(get_warning_strings(), sep);
236}
237
239{
240 print_problems(std::cerr);
241}
242
243void Problems::print_problems(std::ostream& ostr) const
244{
245 if (!have_problem())
246 return;
247
248 ostr << get_problem_string();
249}
250
252{
253 print_warnings(std::cerr);
254}
255
256void Problems::print_warnings(std::ostream& ostr) const
257{
258 if (!have_warning())
259 return;
260
261 ostr << get_warning_string();
262}
263
264const std::string& Problems::get_model_name() const
265{
266 return model_name;
267}
268
269void Problems::flag_bad_mass(int particle, bool flag)
270{
271 bad_masses.at(particle) = flag;
272}
273
274void Problems::flag_running_tachyon(int particle, bool flag)
275{
276 running_tachyons.at(particle) = flag;
277#if defined(ENABLE_VERBOSE) || defined(ENABLE_DEBUG)
278 if (flag)
279 WARNING("running " << particle_names->get(particle) << " tachyon");
280#endif
281}
282
283void Problems::flag_pole_tachyon(int particle, bool flag)
284{
285 pole_tachyons.at(particle) = flag;
286#if defined(ENABLE_VERBOSE) || defined(ENABLE_DEBUG)
287 if (flag)
288 WARNING("pole " << particle_names->get(particle) << " tachyon");
289#endif
290}
291
292void Problems::flag_thrown(const std::string& msg)
293{
294 exception_msg = msg;
295}
296
298{
299 failed_ewsb = true;
300}
301
306
311
316
318{
319 failed_pole_mass_convergence.at(particle) = true;
320}
321
323 int parameter, double value, double scale, double threshold)
324{
325 const auto n_parameters = parameter_names->size();
326
327 if (parameter < -1 || parameter >= n_parameters)
328 ERROR("Parameter index " << parameter << " out of range [" << -1 << ", "
329 << (n_parameters - 1) << "]");
330
331 VERBOSE_MSG("Problem: " << get_parameter_name(parameter) << "(Q = "
332 << scale << ") = " << value
333 << " is non-perturbative (threshold = " << threshold << ").");
334
335 non_pert_pars[parameter] = NonPerturbativeValue(value, scale, threshold);
336}
337
342
347
348void Problems::flag_no_minimum(const std::string& msg, int status)
349{
350 failed_minimum[msg] = status;
351}
352
353void Problems::flag_no_root(const std::string& msg, int status)
354{
355 failed_root[msg] = status;
356}
357
359{
360 bad_masses.at(particle) = false;
361}
362
364{
365 std::fill(bad_masses.begin(), bad_masses.end(), 0);
366}
367
369{
370 running_tachyons.at(particle) = false;
371}
372
374{
375 pole_tachyons.at(particle) = false;
376}
377
379{
380 std::fill(running_tachyons.begin(), running_tachyons.end(), 0);
381 std::fill(pole_tachyons.begin(), pole_tachyons.end(), 0);
382}
383
385{
386 exception_msg = "";
387}
388
390{
391 failed_ewsb = false;
392}
393
398
403
408
410{
411 failed_pole_mass_convergence.at(particle) = false;
412}
413
415{
416 non_pert_pars.erase(parameter);
417}
418
423
428
433
434void Problems::unflag_no_minimum(const std::string& msg)
435{
436 failed_minimum.erase(msg);
437}
438
439void Problems::unflag_no_root(const std::string& msg)
440{
441 failed_root.erase(msg);
442}
443
444bool Problems::is_bad_mass(int particle) const
445{
446 return bad_masses.at(particle);
447}
448
449bool Problems::is_running_tachyon(int particle) const
450{
451 return running_tachyons.at(particle);
452}
453
454bool Problems::is_pole_tachyon(int particle) const
455{
456 return pole_tachyons.at(particle);
457}
458
460{
461 return std::any_of(bad_masses.cbegin(), bad_masses.cend(),
462 [](bool x) { return x; });
463}
464
466{
467 return std::any_of(running_tachyons.cbegin(), running_tachyons.cend(),
468 [](bool x) { return x; });
469}
470
472{
473 return std::any_of(pole_tachyons.cbegin(), pole_tachyons.cend(),
474 [](bool x) { return x; });
475}
476
478{
480}
481
483{
484 return !exception_msg.empty();
485}
486
488{
489 return !non_pert_pars.empty();
490}
491
493{
494 return std::any_of(failed_pole_mass_convergence.cbegin(),
496 [](bool x) { return x; });
497}
498
500{
501 return failed_ewsb;
502}
503
505{
507}
508
513
515{
516 return non_perturbative;
517}
518
523
528
530{
531 return !failed_minimum.empty();
532}
533
535{
536 return !failed_root.empty();
537}
538
539std::vector<int> Problems::get_bad_masses() const
540{
541 return bad_masses;
542}
543
544std::vector<int> Problems::get_running_tachyons() const
545{
546 return running_tachyons;
547}
548
549std::vector<int> Problems::get_pole_tachyons() const
550{
551 return pole_tachyons;
552}
553
558
559std::ostream& operator<<(std::ostream& ostr, const Problems& problems)
560{
561 problems.print_problems(ostr);
562 problems.print_warnings(ostr);
563 return ostr;
564}
565
566} // namespace flexiblesusy
Generic interface to access names of parameters and particles.
Definition names.hpp:30
virtual const std::string & get(int) const =0
virtual int size() const =0
stores problem flags for the spectrum generator
Definition problems.hpp:35
bool have_problem() const
problems which yield invalid spectrum
Definition problems.cpp:107
std::vector< std::string > get_warning_strings() const
Definition problems.cpp:215
void flag_no_pole_mass_convergence(int particle)
Definition problems.cpp:317
void flag_no_sinThetaW_convergence()
Definition problems.cpp:338
std::string model_name
model name
Definition problems.hpp:122
bool is_pole_tachyon(int particle) const
Definition problems.cpp:454
bool have_thrown() const
Definition problems.cpp:482
const std::string & get_model_name() const
Definition problems.cpp:264
bool no_perturbative() const
Definition problems.cpp:514
bool no_sinThetaW_convergence() const
Definition problems.cpp:519
bool failed_ewsb_tree_level
no tree-level EWSB
Definition problems.hpp:134
bool have_tachyon() const
Definition problems.cpp:477
void flag_thrown(const std::string &msg="unknown")
Definition problems.cpp:292
void unflag_all_non_perturbative_parameters()
Definition problems.cpp:419
bool have_failed_pole_mass_convergence() const
Definition problems.cpp:492
std::vector< std::string > get_problem_strings() const
Definition problems.cpp:154
void unflag_pole_tachyon(int particle)
Definition problems.cpp:373
void unflag_no_root(const std::string &msg)
Definition problems.cpp:439
std::string get_particle_name(int) const
returns particle name
Definition problems.cpp:149
bool is_bad_mass(int particle) const
Definition problems.cpp:444
void unflag_bad_mass(int particle)
Definition problems.cpp:358
std::vector< int > get_bad_masses() const
Definition problems.cpp:539
bool have_bad_mass() const
Definition problems.cpp:459
bool is_running_tachyon(int particle) const
Definition problems.cpp:449
std::map< std::string, int > failed_minimum
no minimum found (message, status code)
Definition problems.hpp:130
void flag_running_tachyon(int particle, bool flag=true)
Definition problems.cpp:274
bool no_minimum() const
Definition problems.cpp:529
std::map< int, NonPerturbativeValue > non_pert_pars
non-perturbative parmeters
Definition problems.hpp:129
bool have_pole_tachyon() const
Definition problems.cpp:471
Problems(const std::string &model_name_, const Names *particle_names_, const Names *parameter_names_)
Definition problems.cpp:53
void flag_non_perturbative_parameter(int parameter, double value, double scale, double threshold=0.)
Definition problems.cpp:322
bool no_G_fermi_convergence() const
Definition problems.cpp:524
std::vector< int > failed_pole_mass_convergence
no convergence during pole mass calculation
Definition problems.hpp:128
std::vector< int > get_failed_pole_mass_convergence() const
Definition problems.cpp:554
void clear()
clear all problems
Definition problems.cpp:65
bool have_running_tachyon() const
Definition problems.cpp:465
void unflag_no_minimum(const std::string &msg)
Definition problems.cpp:434
void unflag_running_tachyon(int particle)
Definition problems.cpp:368
void unflag_no_G_fermi_convergence()
Definition problems.cpp:429
unsigned number_of_warnings() const
returns number of warnings
Definition problems.cpp:134
bool no_GFermi_convergence() const
Definition problems.cpp:509
std::string get_parameter_name(int) const
returns parameter name
Definition problems.cpp:141
void flag_no_G_fermi_convergence()
Definition problems.cpp:343
std::map< std::string, int > failed_root
no root found (message, status code)
Definition problems.hpp:131
const Names * particle_names
access to particle names
Definition problems.hpp:123
std::vector< int > running_tachyons
tachyonic particles (running mass)
Definition problems.hpp:126
void flag_no_root(const std::string &msg, int status)
Definition problems.cpp:353
std::vector< int > pole_tachyons
tachyonic particles (pole mass)
Definition problems.hpp:127
std::vector< int > get_pole_tachyons() const
Definition problems.cpp:549
bool failed_GFermi_convergence
G_Fermi not converged.
Definition problems.hpp:135
void flag_bad_mass(int particle, bool flag=true)
Definition problems.cpp:269
void unflag_no_sinThetaW_convergence()
Definition problems.cpp:424
unsigned number_of_problems() const
returns number of problems
Definition problems.cpp:112
void unflag_non_perturbative_parameter(int parameter)
Definition problems.cpp:414
std::string get_warning_string(const std::string &sep="\n") const
Definition problems.cpp:233
void unflag_no_GFermi_convergence()
Definition problems.cpp:399
bool no_ewsb_tree_level() const
Definition problems.cpp:504
void flag_pole_tachyon(int particle, bool flag=true)
Definition problems.cpp:283
void add(const Problems &)
add problems from other class
Definition problems.cpp:83
const Names * parameter_names
access to parameter names
Definition problems.hpp:124
bool have_warning() const
warnings
Definition problems.cpp:129
void unflag_no_pole_mass_convergence(int particle)
Definition problems.cpp:409
std::string exception_msg
exception message
Definition problems.hpp:132
void flag_no_GFermi_convergence()
Definition problems.cpp:307
void print_warnings() const
Definition problems.cpp:251
std::vector< int > bad_masses
imprecise mass eigenvalues
Definition problems.hpp:125
std::vector< int > get_running_tachyons() const
Definition problems.cpp:544
std::string get_problem_string(const std::string &sep="\n") const
Definition problems.cpp:228
bool failed_sinThetaW_convergence
sinThetaW-parameter not converged
Definition problems.hpp:137
void print_problems() const
Definition problems.cpp:238
bool non_perturbative
non-perturbative running
Definition problems.hpp:136
bool failed_ewsb
no EWSB
Definition problems.hpp:133
bool have_non_perturbative_parameter() const
Definition problems.cpp:487
void flag_no_minimum(const std::string &msg, int status)
Definition problems.cpp:348
bool failed_GF_convergence
GF calculation did not converge.
Definition problems.hpp:138
#define ERROR(msg)
Definition logger.hpp:65
#define WARNING(msg)
Definition logger.hpp:63
#define VERBOSE_MSG(msg)
Definition logger.hpp:57
void map_or(std::map< T1, T2 > &m1, const std::map< T1, T2 > &m2)
Definition problems.cpp:46
void vector_or(std::vector< T > &v1, const std::vector< T > &v2)
Definition problems.cpp:34
std::string to_string(char a)
std::ostream & operator<<(std::ostream &ostr, const Dynamic_array_view< ElementType > &av)
std::string concat(const std::vector< std::string > &strings)
concatenate strings