flexiblesusy is hosted by Hepforge, IPPP Durham
FlexibleSUSY
error.hpp
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#ifndef ERROR_H
20#define ERROR_H
21
22#include <cstring>
23#include <stdexcept>
24#include <string>
25
26namespace flexiblesusy {
27
28class Error : public std::runtime_error {
29public:
30 explicit Error(const std::string& msg) : std::runtime_error(msg) {}
31 explicit Error(const char* msg) : std::runtime_error(msg) {}
32 virtual ~Error() = default;
33 virtual std::string what_detailed() const { return what(); }
34};
35
36class FatalError : public Error {
37public:
38 FatalError() : Error("Fatal error") {}
39 virtual ~FatalError() = default;
40};
41
46class SetupError : public Error {
47public:
48 explicit SetupError(const std::string& msg) : Error(msg) {}
49 explicit SetupError(const char* msg) : Error(msg) {}
50 virtual ~SetupError() = default;
51};
52
57class NoConvergenceError : public Error {
58public:
59 explicit NoConvergenceError(int number_of_iterations_, const std::string& msg = "")
60 : Error(msg)
61 , number_of_iterations(number_of_iterations_) {}
62 virtual ~NoConvergenceError() = default;
63 std::string what_detailed() const override {
64 const auto msg = Error::what();
65
66 if (std::strlen(msg) > 0) {
67 return msg;
68 }
69
70 return "NoConvergenceError: no convergence after "
71 + std::to_string(number_of_iterations) + " iterations";
72 }
74private:
76};
77
83public:
84 NoGFermiConvergenceError(int number_of_iterations_, double g_fermi_)
85 : Error("Calculation G_Fermi did not converge")
86 , number_of_iterations(number_of_iterations_)
87 , g_fermi(g_fermi_)
88 {}
89 virtual ~NoGFermiConvergenceError() = default;
90 std::string what_detailed() const override {
91 return "NoGFermiConvergenceError: no convergence after "
92 + std::to_string(number_of_iterations) + " iterations (G_Fermi="
93 + std::to_string(g_fermi) + ")";
94 }
96 double get_g_fermi() const { return g_fermi; }
97private:
99 double g_fermi;
100};
101
107public:
108 NoSinThetaWConvergenceError(int number_of_iterations_,
109 double sin_theta_)
110 : Error("Calculation of Weinberg angle did not converge")
111 , number_of_iterations(number_of_iterations_)
112 , sin_theta(sin_theta_)
113 {}
114 virtual ~NoSinThetaWConvergenceError() = default;
115 std::string what_detailed() const override {
116 return "NoSinThetaWConvergenceError: no convergence after "
117 + std::to_string(number_of_iterations) + " iterations (sin(theta)="
118 + std::to_string(sin_theta) + ")";
119 }
121 double get_sin_theta() const { return sin_theta; }
122private:
124 double sin_theta;
125};
126
132public:
134 : Error("NonPerturbativeSinThetaW: sin(theta) non-perturbative") {}
135 virtual ~NonPerturbativeSinThetaW() = default;
136};
137
143public:
154 explicit NonPerturbativeRunningError(double scale_, int parameter_index_ = -1, double value_ = 0)
155 : Error("Non-perturbative RG running")
156 , scale(scale_)
157 , value(value_)
158 , parameter_index(parameter_index_)
159 {}
160 virtual ~NonPerturbativeRunningError() = default;
161 std::string what_detailed() const override {
162 if (parameter_index == -1) {
163 return "NonPerturbativeRunningError: scale Q = " + std::to_string(value);
164 }
165
166 return "NonPerturbativeRunningError: non-perturbative running of parameter "
168 }
169 std::string what_parameter(const std::string& parameter_name) const {
170 return "NonPerturbativeRunningError: non-perturbative running"
171 " of " + parameter_name + " = " + std::to_string(value)
172 + " to scale " + std::to_string(scale);
173 }
174 int get_parameter_index() const { return parameter_index; }
175 double get_parameter_value() const { return value; }
176 double get_scale() const { return scale; }
177private:
178 double scale;
179 double value;
181};
182
184public:
185 explicit NonPerturbativeRunningQedQcdError(const std::string& msg) : Error(msg) {}
186 explicit NonPerturbativeRunningQedQcdError(const char* msg) : Error(msg) {}
188};
189
194class OutOfMemoryError : public Error {
195public:
196 explicit OutOfMemoryError(const std::string& msg) : Error(msg) {}
197 explicit OutOfMemoryError(const char* msg) : Error(msg) {}
198 virtual ~OutOfMemoryError() = default;
199 virtual std::string what_detailed() const override {
200 return std::string("OutOfMemoryError: Not enought memory: ") + what();
201 }
202};
203
208class OutOfBoundsError : public Error {
209public:
210 explicit OutOfBoundsError(const std::string& msg) : Error(msg) {}
211 explicit OutOfBoundsError(const char* msg) : Error(msg) {}
212 virtual ~OutOfBoundsError() = default;
213};
214
215class ReadError : public Error {
216public:
217 explicit ReadError(const std::string& msg) : Error(msg) {}
218 explicit ReadError(const char* msg) : Error(msg) {}
219 virtual ~ReadError() = default;
220};
221
226class PhysicalError : public Error {
227public:
228 explicit PhysicalError(const std::string& msg) : Error(msg) {}
229 explicit PhysicalError(const char* msg) : Error(msg) {}
230 virtual ~PhysicalError() = default;
231};
232
233class HimalayaError : public Error {
234public:
235 explicit HimalayaError(const std::string& msg) : Error(msg) {}
236 explicit HimalayaError(const char* msg) : Error(msg) {}
237 virtual ~HimalayaError() = default;
238};
239
240} // namespace flexiblesusy
241
242#endif
Error(const char *msg)
Definition: error.hpp:31
virtual ~Error()=default
virtual std::string what_detailed() const
Definition: error.hpp:33
Error(const std::string &msg)
Definition: error.hpp:30
virtual ~FatalError()=default
HimalayaError(const char *msg)
Definition: error.hpp:236
HimalayaError(const std::string &msg)
Definition: error.hpp:235
virtual ~HimalayaError()=default
No convergence while solving the RGEs.
Definition: error.hpp:57
virtual ~NoConvergenceError()=default
int get_number_of_iterations() const
Definition: error.hpp:73
std::string what_detailed() const override
Definition: error.hpp:63
NoConvergenceError(int number_of_iterations_, const std::string &msg="")
Definition: error.hpp:59
No convergence while calculating G_Fermi.
Definition: error.hpp:82
NoGFermiConvergenceError(int number_of_iterations_, double g_fermi_)
Definition: error.hpp:84
std::string what_detailed() const override
Definition: error.hpp:90
No convergence while calculating the sinThetaW parameter.
Definition: error.hpp:106
NoSinThetaWConvergenceError(int number_of_iterations_, double sin_theta_)
Definition: error.hpp:108
std::string what_detailed() const override
Definition: error.hpp:115
Non-perturbative RG running.
Definition: error.hpp:142
double scale
renormalization scale
Definition: error.hpp:178
std::string what_detailed() const override
Definition: error.hpp:161
NonPerturbativeRunningError(double scale_, int parameter_index_=-1, double value_=0)
Definition: error.hpp:154
std::string what_parameter(const std::string &parameter_name) const
Definition: error.hpp:169
int parameter_index
index of parameter that becomes non-perturbative
Definition: error.hpp:180
double value
value of parameter that becomes non-perturbative
Definition: error.hpp:179
NonPerturbativeRunningQedQcdError(const std::string &msg)
Definition: error.hpp:185
Calculation of sin(theta) became non-perturbative.
Definition: error.hpp:131
Out of bounds access.
Definition: error.hpp:208
OutOfBoundsError(const char *msg)
Definition: error.hpp:211
OutOfBoundsError(const std::string &msg)
Definition: error.hpp:210
virtual ~OutOfBoundsError()=default
Not enough memory.
Definition: error.hpp:194
virtual ~OutOfMemoryError()=default
OutOfMemoryError(const char *msg)
Definition: error.hpp:197
OutOfMemoryError(const std::string &msg)
Definition: error.hpp:196
virtual std::string what_detailed() const override
Definition: error.hpp:199
Exception class to be used in the FlexibleSUSY model file.
Definition: error.hpp:226
virtual ~PhysicalError()=default
PhysicalError(const std::string &msg)
Definition: error.hpp:228
PhysicalError(const char *msg)
Definition: error.hpp:229
ReadError(const std::string &msg)
Definition: error.hpp:217
ReadError(const char *msg)
Definition: error.hpp:218
virtual ~ReadError()=default
Spectrum generator was not setup correctly.
Definition: error.hpp:46
SetupError(const std::string &msg)
Definition: error.hpp:48
virtual ~SetupError()=default
SetupError(const char *msg)
Definition: error.hpp:49
std::string to_string(char a)