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;
80}
81
82void Problems::add(const Problems& other)
83{
84 if (model_name != other.get_model_name())
85 WARNING("Adding problems from " << other.get_model_name() << " to " << model_name);
86
94
95 if (exception_msg.empty() && !other.exception_msg.empty())
97
103}
104
106{
107 return number_of_problems() > 0;
108}
109
111{
112 unsigned count = 0;
113 if (have_tachyon()) count++;
114 if (failed_ewsb) count++;
115 if (failed_ewsb_tree_level) count++;
116 if (failed_GFermi_convergence) count++;
118 if (failed_sinThetaW_convergence) count++;
119 if (no_minimum()) count++;
120 if (no_root()) count++;
121 if (have_thrown()) count++;
123 return count;
124}
125
127{
128 return number_of_warnings() > 0;
129}
130
132{
133 unsigned count = 0;
134 if (have_bad_mass()) count++;
135 return count;
136}
137
138std::string Problems::get_parameter_name(int idx) const
139{
140 if (idx == -1)
141 return "Q";
142
143 return parameter_names->get(idx);
144}
145
146std::string Problems::get_particle_name(int idx) const
147{
148 return particle_names->get(idx);
149}
150
151std::vector<std::string> Problems::get_problem_strings() const
152{
153 std::vector<std::string> strings;
154 const auto n_particles = particle_names->size();
155
156 for (int i = 0; i < n_particles; ++i) {
157 if (running_tachyons[i])
158 strings.emplace_back("running tachyon " + particle_names->get(i));
159 }
160 for (int i = 0; i < n_particles; ++i) {
161 if (pole_tachyons[i])
162 strings.emplace_back("pole tachyon " + particle_names->get(i));
163 }
164 if (failed_ewsb)
165 strings.emplace_back("no ewsb");
167 strings.emplace_back("no ewsb at tree-level");
169 strings.emplace_back("no GFermi convergence");
171 strings.emplace_back("non-perturbative");
173 strings.emplace_back("no sinThetaW convergence");
174 if (have_thrown())
175 strings.emplace_back("exception thrown(" + exception_msg + ")");
176 for (int i = 0; i < n_particles; ++i) {
178 strings.emplace_back("no M" + particle_names->get(i) + " pole convergence");
179 }
180
181 for (const auto& par: non_pert_pars) {
182 const std::string par_name = get_parameter_name(par.first);
183 std::string str("non-perturbative " + par_name);
184 if (par.second.threshold > 0) {
185 str += " [|" + par_name + "|(" +
186 flexiblesusy::to_string(par.second.scale) + ") = " +
187 flexiblesusy::to_string(par.second.value) +
188 " > " + flexiblesusy::to_string(par.second.threshold) + "]";
189 } else {
190 str += " [" + par_name + "(" +
191 flexiblesusy::to_string(par.second.scale) +
192 ") = " + flexiblesusy::to_string(par.second.value) + "]";
193 }
194 strings.emplace_back(str);
195 }
196
197 for (const auto& m: failed_minimum) {
198 strings.emplace_back(std::string("no minimum for parameters ") + m.first);
199 }
200
201 for (const auto& m: failed_root) {
202 strings.emplace_back(std::string("no root for parameters ") + m.first);
203 }
204
205 strings.shrink_to_fit();
206
207 return strings;
208}
209
210std::vector<std::string> Problems::get_warning_strings() const
211{
212 std::vector<std::string> strings;
213 const auto n_particles = particle_names->size();
214
215 for (int i = 0; i < n_particles; ++i) {
216 if (bad_masses[i])
217 strings.emplace_back("Warning: imprecise M" + particle_names->get(i));
218 }
219
220 return strings;
221}
222
223std::string Problems::get_problem_string(const std::string& sep) const
224{
225 return concat(get_problem_strings(), sep);
226}
227
228std::string Problems::get_warning_string(const std::string& sep) const
229{
230 return concat(get_warning_strings(), sep);
231}
232
234{
235 print_problems(std::cerr);
236}
237
238void Problems::print_problems(std::ostream& ostr) const
239{
240 if (!have_problem())
241 return;
242
243 ostr << get_problem_string();
244}
245
247{
248 print_warnings(std::cerr);
249}
250
251void Problems::print_warnings(std::ostream& ostr) const
252{
253 if (!have_warning())
254 return;
255
256 ostr << get_warning_string();
257}
258
259const std::string& Problems::get_model_name() const
260{
261 return model_name;
262}
263
264void Problems::flag_bad_mass(int particle, bool flag)
265{
266 bad_masses.at(particle) = flag;
267}
268
269void Problems::flag_running_tachyon(int particle, bool flag)
270{
271 running_tachyons.at(particle) = flag;
272#if defined(ENABLE_VERBOSE) || defined(ENABLE_DEBUG)
273 if (flag)
274 WARNING("running " << particle_names->get(particle) << " tachyon");
275#endif
276}
277
278void Problems::flag_pole_tachyon(int particle, bool flag)
279{
280 pole_tachyons.at(particle) = flag;
281#if defined(ENABLE_VERBOSE) || defined(ENABLE_DEBUG)
282 if (flag)
283 WARNING("pole " << particle_names->get(particle) << " tachyon");
284#endif
285}
286
287void Problems::flag_thrown(const std::string& msg)
288{
289 exception_msg = msg;
290}
291
293{
294 failed_ewsb = true;
295}
296
298{
300}
301
303{
305}
306
308{
309 non_perturbative = true;
310}
311
313{
314 failed_pole_mass_convergence.at(particle) = true;
315}
316
318 int parameter, double value, double scale, double threshold)
319{
320 const auto n_parameters = parameter_names->size();
321
322 if (parameter < -1 || parameter >= n_parameters)
323 ERROR("Parameter index " << parameter << " out of range [" << -1 << ", "
324 << (n_parameters - 1) << "]");
325
326 VERBOSE_MSG("Problem: " << get_parameter_name(parameter) << "(Q = "
327 << scale << ") = " << value
328 << " is non-perturbative (threshold = " << threshold << ").");
329
330 non_pert_pars[parameter] = NonPerturbativeValue(value, scale, threshold);
331}
332
334{
336}
337
338void Problems::flag_no_minimum(const std::string& msg, int status)
339{
340 failed_minimum[msg] = status;
341}
342
343void Problems::flag_no_root(const std::string& msg, int status)
344{
345 failed_root[msg] = status;
346}
347
349{
350 bad_masses.at(particle) = false;
351}
352
354{
355 std::fill(bad_masses.begin(), bad_masses.end(), 0);
356}
357
359{
360 running_tachyons.at(particle) = false;
361}
362
364{
365 pole_tachyons.at(particle) = false;
366}
367
369{
370 std::fill(running_tachyons.begin(), running_tachyons.end(), 0);
371 std::fill(pole_tachyons.begin(), pole_tachyons.end(), 0);
372}
373
375{
376 exception_msg = "";
377}
378
380{
381 failed_ewsb = false;
382}
383
385{
387}
388
390{
392}
393
395{
396 non_perturbative = false;
397}
398
400{
401 failed_pole_mass_convergence.at(particle) = false;
402}
403
405{
406 non_pert_pars.erase(parameter);
407}
408
410{
411 non_pert_pars.clear();
412}
413
415{
417}
418
419void Problems::unflag_no_minimum(const std::string& msg)
420{
421 failed_minimum.erase(msg);
422}
423
424void Problems::unflag_no_root(const std::string& msg)
425{
426 failed_root.erase(msg);
427}
428
429bool Problems::is_bad_mass(int particle) const
430{
431 return bad_masses.at(particle);
432}
433
434bool Problems::is_running_tachyon(int particle) const
435{
436 return running_tachyons.at(particle);
437}
438
439bool Problems::is_pole_tachyon(int particle) const
440{
441 return pole_tachyons.at(particle);
442}
443
445{
446 return std::any_of(bad_masses.cbegin(), bad_masses.cend(),
447 [](bool x) { return x; });
448}
449
451{
452 return std::any_of(running_tachyons.cbegin(), running_tachyons.cend(),
453 [](bool x) { return x; });
454}
455
457{
458 return std::any_of(pole_tachyons.cbegin(), pole_tachyons.cend(),
459 [](bool x) { return x; });
460}
461
463{
465}
466
468{
469 return !exception_msg.empty();
470}
471
473{
474 return !non_pert_pars.empty();
475}
476
478{
479 return std::any_of(failed_pole_mass_convergence.cbegin(),
481 [](bool x) { return x; });
482}
483
485{
486 return failed_ewsb;
487}
488
490{
492}
493
495{
497}
498
500{
501 return non_perturbative;
502}
503
505{
507}
508
510{
511 return !failed_minimum.empty();
512}
513
515{
516 return !failed_root.empty();
517}
518
519std::vector<int> Problems::get_bad_masses() const
520{
521 return bad_masses;
522}
523
524std::vector<int> Problems::get_running_tachyons() const
525{
526 return running_tachyons;
527}
528
529std::vector<int> Problems::get_pole_tachyons() const
530{
531 return pole_tachyons;
532}
533
535{
537}
538
539std::ostream& operator<<(std::ostream& ostr, const Problems& problems)
540{
541 problems.print_problems(ostr);
542 problems.print_warnings(ostr);
543 return ostr;
544}
545
546} // 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:105
std::vector< std::string > get_warning_strings() const
Definition: problems.cpp:210
void flag_no_pole_mass_convergence(int particle)
Definition: problems.cpp:312
void flag_no_sinThetaW_convergence()
Definition: problems.cpp:333
std::string model_name
model name
Definition: problems.hpp:119
bool is_pole_tachyon(int particle) const
Definition: problems.cpp:439
bool have_thrown() const
Definition: problems.cpp:467
const std::string & get_model_name() const
Definition: problems.cpp:259
bool no_perturbative() const
Definition: problems.cpp:499
bool no_sinThetaW_convergence() const
Definition: problems.cpp:504
bool failed_ewsb_tree_level
no tree-level EWSB
Definition: problems.hpp:131
bool have_tachyon() const
Definition: problems.cpp:462
void flag_thrown(const std::string &msg="unknown")
Definition: problems.cpp:287
void unflag_all_non_perturbative_parameters()
Definition: problems.cpp:409
bool no_root() const
Definition: problems.cpp:514
bool have_failed_pole_mass_convergence() const
Definition: problems.cpp:477
std::vector< std::string > get_problem_strings() const
Definition: problems.cpp:151
void unflag_pole_tachyon(int particle)
Definition: problems.cpp:363
void unflag_no_root(const std::string &msg)
Definition: problems.cpp:424
std::string get_particle_name(int) const
returns particle name
Definition: problems.cpp:146
bool is_bad_mass(int particle) const
Definition: problems.cpp:429
void unflag_bad_mass(int particle)
Definition: problems.cpp:348
std::vector< int > get_bad_masses() const
Definition: problems.cpp:519
bool have_bad_mass() const
Definition: problems.cpp:444
bool is_running_tachyon(int particle) const
Definition: problems.cpp:434
std::map< std::string, int > failed_minimum
no minimum found (message, status code)
Definition: problems.hpp:127
void flag_running_tachyon(int particle, bool flag=true)
Definition: problems.cpp:269
bool no_minimum() const
Definition: problems.cpp:509
std::map< int, NonPerturbativeValue > non_pert_pars
non-perturbative parmeters
Definition: problems.hpp:126
bool have_pole_tachyon() const
Definition: problems.cpp:456
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:317
std::vector< int > failed_pole_mass_convergence
no convergence during pole mass calculation
Definition: problems.hpp:125
void unflag_no_ewsb_tree_level()
Definition: problems.cpp:384
std::vector< int > get_failed_pole_mass_convergence() const
Definition: problems.cpp:534
void clear()
clear all problems
Definition: problems.cpp:65
bool have_running_tachyon() const
Definition: problems.cpp:450
void unflag_no_minimum(const std::string &msg)
Definition: problems.cpp:419
bool no_ewsb() const
Definition: problems.cpp:484
void unflag_running_tachyon(int particle)
Definition: problems.cpp:358
unsigned number_of_warnings() const
returns number of warnings
Definition: problems.cpp:131
bool no_GFermi_convergence() const
Definition: problems.cpp:494
std::string get_parameter_name(int) const
returns parameter name
Definition: problems.cpp:138
std::map< std::string, int > failed_root
no root found (message, status code)
Definition: problems.hpp:128
const Names * particle_names
access to particle names
Definition: problems.hpp:120
std::vector< int > running_tachyons
tachyonic particles (running mass)
Definition: problems.hpp:123
void flag_no_root(const std::string &msg, int status)
Definition: problems.cpp:343
std::vector< int > pole_tachyons
tachyonic particles (pole mass)
Definition: problems.hpp:124
std::vector< int > get_pole_tachyons() const
Definition: problems.cpp:529
bool failed_GFermi_convergence
G_Fermi not converged.
Definition: problems.hpp:132
void flag_bad_mass(int particle, bool flag=true)
Definition: problems.cpp:264
void unflag_no_sinThetaW_convergence()
Definition: problems.cpp:414
unsigned number_of_problems() const
returns number of problems
Definition: problems.cpp:110
void unflag_non_perturbative_parameter(int parameter)
Definition: problems.cpp:404
std::string get_warning_string(const std::string &sep="\n") const
Definition: problems.cpp:228
void unflag_no_GFermi_convergence()
Definition: problems.cpp:389
bool no_ewsb_tree_level() const
Definition: problems.cpp:489
void flag_pole_tachyon(int particle, bool flag=true)
Definition: problems.cpp:278
void add(const Problems &)
add problems from other class
Definition: problems.cpp:82
const Names * parameter_names
access to parameter names
Definition: problems.hpp:121
bool have_warning() const
warnings
Definition: problems.cpp:126
void unflag_no_pole_mass_convergence(int particle)
Definition: problems.cpp:399
std::string exception_msg
exception message
Definition: problems.hpp:129
void flag_no_GFermi_convergence()
Definition: problems.cpp:302
void print_warnings() const
Definition: problems.cpp:246
std::vector< int > bad_masses
imprecise mass eigenvalues
Definition: problems.hpp:122
void flag_no_ewsb_tree_level()
Definition: problems.cpp:297
std::vector< int > get_running_tachyons() const
Definition: problems.cpp:524
std::string get_problem_string(const std::string &sep="\n") const
Definition: problems.cpp:223
bool failed_sinThetaW_convergence
sinThetaW-parameter not converged
Definition: problems.hpp:134
void print_problems() const
Definition: problems.cpp:233
bool non_perturbative
non-perturbative running
Definition: problems.hpp:133
bool failed_ewsb
no EWSB
Definition: problems.hpp:130
bool have_non_perturbative_parameter() const
Definition: problems.cpp:472
void flag_no_minimum(const std::string &msg, int status)
Definition: problems.cpp:338
#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)
Definition: array_view.hpp:143
std::string concat(const std::vector< std::string > &strings)
concatenate strings