flexiblesusy is hosted by Hepforge, IPPP Durham
FlexibleSUSY
problems_format_mathlink.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 PROBLEMS_FORMAT_MATHLINK_H
20#define PROBLEMS_FORMAT_MATHLINK_H
21
22#include "mathlink_utils.hpp"
23#include "problems.hpp"
24#include <vector>
25
26namespace flexiblesusy {
27
28namespace {
29
30template <class ParticleNameGetter>
31void put_masses(MLINK link, const std::vector<int>& flags,
32 const std::vector<std::string>& heads,
33 const ParticleNameGetter& particle_name)
34{
35 for (std::size_t i = 0; i < flags.size(); i++) {
36 if (flags[i]) {
37 MLPutHeads(link, heads);
38 MLPutSymbol(link, particle_name(i).c_str());
39 }
40 }
41}
42
43template <class ParticleNameGetter>
44void put_masses(MLINK link, const std::string& rule,
45 const std::vector<int>& flags,
46 const std::vector<std::string>& heads,
47 const ParticleNameGetter& particle_name)
48{
49 const auto n_masses = std::count(flags.cbegin(), flags.cend(), true);
50
51 MLPutRule(link, rule);
52 MLPutFunction(link, "List", n_masses);
53 put_masses(link, flags, heads, particle_name);
54}
55
56template <class ParticleNameGetter>
57void put_masses(MLINK link, const std::string& rule,
58 const std::vector<int>& flags1,
59 const std::vector<std::string>& heads1,
60 const std::vector<int>& flags2,
61 const std::vector<std::string>& heads2,
62 const ParticleNameGetter& particle_name)
63{
64 const auto n_masses = std::count(flags1.cbegin(), flags1.cend(), true)
65 + std::count(flags2.cbegin(), flags2.cend(), true);
66
67 MLPutRule(link, rule);
68 MLPutFunction(link, "List", n_masses);
69 put_masses(link, flags1, heads1, particle_name);
70 put_masses(link, flags2, heads2, particle_name);
71}
72
73} // anonymous namespace
74
76inline void mathlink_format_problems(MLINK link, const Problems& pr)
77{
78 const auto pn = [&pr] (int i) { return pr.get_particle_name(i); };
79
80 MLPutFunction(link, "List", pr.number_of_problems());
81
82 if (pr.have_tachyon()) {
83 put_masses(link, "Tachyons",
84 pr.get_running_tachyons(), {"M"},
85 pr.get_pole_tachyons(), {"Pole", "M"},
86 pn);
87 }
88 if (pr.no_ewsb()) {
89 MLPutRuleTo(link, "True", "NoEWSB");
90 }
92 MLPutRuleTo(link, "True", "NonPerturbative");
93 }
94 if (pr.no_sinThetaW_convergence()) {
95 MLPutRuleTo(link, "True", "NoSinThetaWConvergence");
96 }
97 if (pr.have_thrown()) {
98 MLPutRuleTo(link, "True", "Exceptions");
99 }
101 put_masses(link, "NoPoleMassConvergence",
102 pr.get_failed_pole_mass_convergence(), {"Pole", "M"},
103 pn);
104 }
105}
106
108inline void mathlink_format_warnings(MLINK link, const Problems& pr)
109{
110 const auto pn = [&pr] (int i) { return pr.get_particle_name(i); };
111
112 MLPutFunction(link, "List", pr.number_of_warnings());
113
114 if (pr.have_bad_mass()) {
115 put_masses(link, "ImpreciseMasses", pr.get_bad_masses(), {"M"}, pn);
116 }
117}
118
119} // namespace flexiblesusy
120
121#endif
stores problem flags for the spectrum generator
Definition: problems.hpp:35
bool have_thrown() const
Definition: problems.cpp:467
bool no_perturbative() const
Definition: problems.cpp:499
bool no_sinThetaW_convergence() const
Definition: problems.cpp:504
bool have_tachyon() const
Definition: problems.cpp:462
bool have_failed_pole_mass_convergence() const
Definition: problems.cpp:477
std::string get_particle_name(int) const
returns particle name
Definition: problems.cpp:146
std::vector< int > get_bad_masses() const
Definition: problems.cpp:519
bool have_bad_mass() const
Definition: problems.cpp:444
std::vector< int > get_failed_pole_mass_convergence() const
Definition: problems.cpp:534
bool no_ewsb() const
Definition: problems.cpp:484
unsigned number_of_warnings() const
returns number of warnings
Definition: problems.cpp:131
std::vector< int > get_pole_tachyons() const
Definition: problems.cpp:529
unsigned number_of_problems() const
returns number of problems
Definition: problems.cpp:110
std::vector< int > get_running_tachyons() const
Definition: problems.cpp:524
bool have_non_perturbative_parameter() const
Definition: problems.cpp:472
void mathlink_format_problems(MLINK link, const BVP_solver_problems &sp)
format BVP solver problems to MathLink output
void mathlink_format_warnings(MLINK link, const BVP_solver_problems &sp)
format BVP solver warnings to MathLink output