forked from Expander/FlexibleSUSY
/
error.hpp
209 lines (193 loc) · 6.16 KB
/
error.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
// ====================================================================
// This file is part of FlexibleSUSY.
//
// FlexibleSUSY is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published
// by the Free Software Foundation, either version 3 of the License,
// or (at your option) any later version.
//
// FlexibleSUSY is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with FlexibleSUSY. If not, see
// <http://www.gnu.org/licenses/>.
// ====================================================================
#ifndef ERROR_H
#define ERROR_H
#include <string>
#include <sstream>
namespace flexiblesusy {
class Error {
public:
virtual ~Error() {}
virtual std::string what() const = 0;
};
/**
* @class SetupError
* @brief Spectrum generator was not setup correctly
*/
class SetupError : public Error {
public:
explicit SetupError(const std::string& message_) : message(message_) {}
virtual ~SetupError() {}
virtual std::string what() const { return message; }
private:
std::string message;
};
/**
* @class NoConvergenceError
* @brief No convergence while solving the RGEs
*/
class NoConvergenceError : public Error {
public:
explicit NoConvergenceError(unsigned number_of_iterations_, const std::string msg = "")
: number_of_iterations(number_of_iterations_), message(msg) {}
virtual ~NoConvergenceError() {}
virtual std::string what() const {
if (!message.empty())
return message;
return "NoConvergenceError: no convergence after "
+ std::to_string(number_of_iterations) + " iterations";
}
unsigned get_number_of_iterations() const { return number_of_iterations; }
private:
std::string message;
unsigned number_of_iterations;
};
/**
* @class NoRhoConvergenceError
* @brief No convergence while calculating the rho-hat parameter
*/
class NoRhoConvergenceError : public Error {
public:
explicit NoRhoConvergenceError(unsigned number_of_iterations_,
double sin_theta_, double rho_hat_)
: number_of_iterations(number_of_iterations_)
, sin_theta(sin_theta_)
, rho_hat(rho_hat_)
{}
virtual ~NoRhoConvergenceError() {}
virtual std::string what() const {
std::stringstream message;
message << "NoRhoConvergenceError: no convergence"
<< " after " << number_of_iterations << " iterations "
<< " (sin(theta)=" << sin_theta << ", rho-hat=" << rho_hat
<< ")";
return message.str();
}
unsigned get_number_of_iterations() const { return number_of_iterations; }
double get_sin_theta() const { return sin_theta; }
double get_rho_hat() const { return rho_hat; }
private:
unsigned number_of_iterations;
double sin_theta, rho_hat;
};
/**
* @class NonPerturbativeRunningError
* @brief Non-perturbative RG running
*/
class NonPerturbativeRunningError : public Error {
public:
/**
* Constructor.
*
* @param scale_ target renormalization scale
* @param parameter_index_ index of parameter that becomes non-perturbative
* @param value_ parameter value at scale_
*
* The parameter index can be set to -1 (default) to indicate that
* something is wrong with the target renormalization scale.
*/
explicit NonPerturbativeRunningError(double scale_, int parameter_index_ = -1, double value_ = 0)
: scale(scale_)
, value(value_)
, parameter_index(parameter_index_)
{}
virtual ~NonPerturbativeRunningError() {}
virtual std::string what() const {
std::stringstream message;
message << "NonPerturbativeRunningError: non-perturbative running"
" of parameter " << parameter_index << " to scale " << scale;
return message.str();
}
std::string what(const std::string& parameter_name) const {
std::stringstream message;
message << "NonPerturbativeRunningError: non-perturbative running"
" of " << parameter_name << " = " << value << " to scale " << scale;
return message.str();
}
int get_parameter_index() const { return parameter_index; }
double get_parameter_value() const { return value; }
double get_scale() const { return scale; }
private:
double scale; ///< renormalization scale
double value; ///< value of parameter that becomes non-perturbative
int parameter_index; ///< index of parameter that becomes non-perturbative
};
class NonPerturbativeRunningQedQcdError : public Error {
public:
explicit NonPerturbativeRunningQedQcdError(std::string msg_)
: msg(msg_)
{}
virtual ~NonPerturbativeRunningQedQcdError() {}
virtual std::string what() const { return msg; }
private:
std::string msg;
};
/**
* @class OutOfMemoryError
* @brief Not enough memory
*/
class OutOfMemoryError : public Error {
public:
explicit OutOfMemoryError(std::string msg_)
: msg(msg_)
{}
virtual ~OutOfMemoryError() {}
virtual std::string what() const {
std::stringstream message;
message << "OutOfMemoryError: Not enought memory: " << msg;
return message.str();
}
private:
std::string msg;
};
/**
* @class OutOfBoundsError
* @brief Out of bounds access
*/
class OutOfBoundsError : public Error {
public:
explicit OutOfBoundsError(std::string msg_)
: msg(msg_)
{}
virtual ~OutOfBoundsError() {}
virtual std::string what() const { return msg; }
private:
std::string msg;
};
/**
* @class DiagonalizationError
* @brief Diagonalization failed
*/
class DiagonalizationError : public Error {
public:
explicit DiagonalizationError(const std::string& message_) : message(message_) {}
virtual ~DiagonalizationError() {}
virtual std::string what() const { return message; }
private:
std::string message;
};
class ReadError : public Error {
public:
ReadError(const std::string& message_) : message(message_) {}
virtual ~ReadError() {}
virtual std::string what() const { return message; }
private:
std::string message;
};
}
#endif