flexiblesusy is hosted by Hepforge, IPPP Durham
FlexibleSUSY
two_scale_solver.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 "two_scale_solver.hpp"
20
22#include "error.hpp"
23#include "initial_guesser.hpp"
24#include "logger.hpp"
25#include "model.hpp"
29
30#include <algorithm>
31
37namespace flexiblesusy {
38
46{
47 if (!c) throw SetupError("constraint pointer is NULL");
48 if (!m) throw SetupError("model pointer is NULL");
49 sliders.push_back(std::make_shared<Constraint_slider>(m, c));
50}
51
62{
63 if (!mc) throw SetupError("matching condition pointer is NULL");
64 if (!m1) throw SetupError("model pointer 1 is NULL");
65 if (!m2) throw SetupError("model pointer 2 is NULL");
66 mc->set_models(m1, m2);
67 sliders.push_back(std::make_shared<Matching_slider>(m1, m2, mc));
68}
69
80{
81 check_setup();
82
83 const int max_iterations = get_max_iterations();
84 if (sliders.empty() || max_iterations == 0)
85 return;
86
87 initial_guess();
88
89 iteration = 0;
90 bool accuracy_reached = false;
91
92 while (iteration < max_iterations && !accuracy_reached) {
93 update_running_precision();
94 clear_problems();
95 run_sliders();
96 accuracy_reached = accuracy_goal_reached();
97 ++iteration;
98 }
99
100 if (!accuracy_reached)
101 throw NoConvergenceError(max_iterations);
102
103 VERBOSE_MSG("convergence reached after " << iteration << " iterations");
104}
105
110{
111 if (!convergence_tester) {
112 throw SetupError("RGFlow<Two_scale>::Error: convergence tester must "
113 "not be NULL");
114 }
115}
116
118{
119 VERBOSE_MSG("> clearing problems ...");
120
121 for (auto& s: sliders)
122 s->clear_problems();
123}
124
130{
131 if (initial_guesser)
132 initial_guesser->guess();
133}
134
136{
137 VERBOSE_MSG("> running all models (iteration " << iteration << ") ...");
138
139 for (auto& s: sliders) {
140 s->set_precision(get_precision());
141 s->slide();
142 }
143
144 VERBOSE_MSG("> running sliders finished");
145}
146
153{
154 return running_precision;
155}
156
162{
163 if (running_precision_calculator)
164 running_precision = running_precision_calculator->get_precision(iteration);
165}
166
172{
173 return convergence_tester->accuracy_goal_reached();
174}
175
182{
183 convergence_tester = convergence_tester_;
184}
185
187{
188 initial_guesser = ig;
189}
190
197{
198 running_precision_calculator = rp;
199}
200
206{
207 return iteration;
208}
209
215{
216 return convergence_tester->max_iterations();
217}
218
226{
227 const auto sorted_sliders = sort_sliders();
228
229 auto it = std::lower_bound(sorted_sliders.begin(), sorted_sliders.end(),
230 scale,
231 [](const std::shared_ptr<Slider>& s, double scale)
232 { return s->get_scale() < scale; });
233
234 if (it == sorted_sliders.end())
235 return nullptr;
236
237 return (*it)->get_model();
238}
239
245{
246 return get_model(scale);
247}
248
257{
258 sliders.clear();
259
260 iteration = 0;
261 convergence_tester = nullptr;
262 initial_guesser = nullptr;
263 running_precision_calculator = nullptr;
264 running_precision = 1.0e-3;
265 scale = 0;
266}
267
273std::vector<std::shared_ptr<RGFlow<Two_scale>::Slider> > RGFlow<Two_scale>::sort_sliders() const
274{
275 std::vector<std::shared_ptr<Slider> > sorted_sliders(sliders);
276
277 std::sort(sorted_sliders.begin(), sorted_sliders.end(),
278 [](const std::shared_ptr<Slider>& s1, const std::shared_ptr<Slider>& s2)
279 { return s1->get_scale() < s2->get_scale(); });
280
281 return sorted_sliders;
282}
283
289void RGFlow<Two_scale>::run_to(double scale_)
290{
291 scale = scale_;
292
293 Model* model = get_model(scale_);
294
295 if (model)
296 model->run_to(scale_);
297}
298
299/* Implementation of sliders */
300
302 model->clear_problems();
303}
304
306 return model;
307}
308
310 return constraint->get_scale();
311}
312
314 VERBOSE_MSG("> \trunning " << model->name() << " to scale " << constraint->get_scale() << " GeV");
315 model->run_to(constraint->get_scale());
316 VERBOSE_MSG("> \tapplying " << constraint->name());
317 constraint->apply();
318}
319
321 model->set_precision(p);
322}
323
325 m1->clear_problems();
326 m2->clear_problems();
327}
328
330 return m1;
331}
332
334 return matching->get_scale();
335}
336
338 VERBOSE_MSG("> \trunning " << m1->name() << " to scale " << matching->get_scale() << " GeV");
339 m1->run_to(matching->get_scale());
340 VERBOSE_MSG("> \trunning " << m2->name() << " to scale " << matching->get_scale() << " GeV");
341 m2->run_to(matching->get_scale());
342 VERBOSE_MSG("> \tmatching " << m1->name() << " -> " << m2->name());
343 matching->match();
344}
345
347 m1->set_precision(p);
348 m2->set_precision(p);
349}
350
351} // namespace flexiblesusy
virtual void run_to(double, double eps=-1.0)=0
No convergence while solving the RGEs.
Definition: error.hpp:57
Spectrum generator was not setup correctly.
Definition: error.hpp:46
#define VERBOSE_MSG(msg)
Definition: logger.hpp:57
const double mc
Definition: consts.hpp:104
contains the definition of the RGFlow<Two_scale> class