BubbleProfiler  0.3.0
by Peter Athron, Csaba Balazs, Michael Bardsley, Andrew Fowlie, Dylan Harries & Graham White
thin_wall_potential.cpp
Go to the documentation of this file.
1 /*
2  * This file is part of BubbleProfiler.
3  *
4  * BubbleProfiler is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation, either version 3 of the License, or
7  * (at your option) any later version.
8  *
9  * BubbleProfiler is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with BubbleProfiler. If not, see <http://www.gnu.org/licenses/>.
16  */
17 
18 #include "thin_wall_potential.hpp"
19 #include "error.hpp"
20 #include "math_wrappers.hpp"
21 
22 namespace BubbleProfiler {
23 
25  double a_, double epsilon_)
26  : lambda(lambda_)
27  , a(a_)
28  , epsilon(epsilon_)
29 {
30  if (lambda <= 0.) {
31  throw Setup_error("Thin_wall_potential: lambda must be positive");
32  }
33 
34  const bool can_tunnel =
35  Abs(epsilon) < 2. * lambda * a * a * a * a/ (3. * Sqrt(3));
36  if (!can_tunnel) {
37  throw Setup_error(
38  "Thin_wall_potential: no barrier exists between minima");
39  }
40 }
41 
43  const Eigen::VectorXd& coords) const
44 {
45  if (coords.size() != 1) {
46  throw Setup_error("Thin_wall_potential::partial: "
47  "number of coordinates must be one");
48  }
49 
50  return operator()(coords(0));
51 }
52 
54  const Eigen::VectorXd& coords, int i) const
55 {
56  if (coords.size() != 1) {
57  throw Setup_error("Thin_wall_potential::partial: "
58  "number of coordinates must be one");
59  }
60 
61  if (i != 0) {
62  throw Out_of_bounds_error(
63  i, "Thin_wall_potential::partial: invalid field index "
64  + std::to_string(i));
65  }
66 
67  return first_deriv(coords(0));
68 }
69 
71  const Eigen::VectorXd& coords, int i, int j) const
72 {
73  if (coords.size() != 1) {
74  throw Setup_error("Thin_wall_potential::partial: "
75  "number of coordinates must be one");
76  }
77 
78  if (i != 0) {
79  throw Out_of_bounds_error(
80  i, "Thin_wall_potential::partial: invalid field index "
81  + std::to_string(i));
82  }
83 
84  if (j != 0) {
85  throw Out_of_bounds_error(
86  j, "Thin_wall_potential::partial: invalid field index "
87  + std::to_string(j));
88  }
89 
90  return second_deriv(coords(0));
91 }
92 
93 double Thin_wall_potential::operator()(double coords) const
94 {
95  const double phip = scale * coords + origin;
96 
97  return 0.125 * lambda * (phip * phip - a * a) * (phip * phip - a * a)
98  + 0.5 * epsilon * (phip - a) / a;
99 }
100 
101 double Thin_wall_potential::first_deriv(double coords) const
102 {
103  const double phip = scale * coords + origin;
104 
105  return 0.5 * lambda * phip * phip * phip - 0.5 * lambda * a * a * phip
106  + 0.5 * epsilon / a;
107 }
108 
109 double Thin_wall_potential::second_deriv(double coords) const
110 {
111  const double phip = scale * coords + origin;
112 
113  return 0.5 * lambda * (3. * phip * phip - a * a);
114 }
115 
125 {
126  const double x = 1.5 * Sqrt(3.) * epsilon / (lambda * a * a * a * Abs(a));
127  const double theta = ArcSin(x) / 3.;
128 
129  const double phip1 = 2. * Abs(a) * Sin(theta + 2. * Pi / 3.)
130  / Sqrt(3);
131  const double phip2 = 2. * Abs(a) * Sin(theta + 4. * Pi / 3.)
132  / Sqrt(3);
133 
134  const double phi1 = (phip1 - origin) / scale;
135  const double phi2 = (phip2 - origin) / scale;
136 
137  return (operator()(phi1) > operator()(phi2) ? phi1 : phi2);
138 }
139 
149 {
150  const double x = 1.5 * Sqrt(3.) * epsilon / (lambda * a * a * a * Abs(a));
151  const double theta = ArcSin(x) / 3.;
152 
153  const double phip = 2. * Abs(a) * Sin(theta) / Sqrt(3);
154 
155  return (phip - origin) / scale;
156 }
157 
167 {
168  const double x = 1.5 * Sqrt(3.) * epsilon / (lambda * a * a * a * Abs(a));
169  const double theta = ArcSin(x) / 3.;
170 
171  const double phip1 = 2. * Abs(a) * Sin(theta + 2. * Pi / 3.)
172  / Sqrt(3);
173  const double phip2 = 2. * Abs(a) * Sin(theta + 4. * Pi / 3.)
174  / Sqrt(3);
175 
176  const double phi1 = (phip1 - origin) / scale;
177  const double phi2 = (phip2 - origin) / scale;
178 
179  return (operator()(phi1) <= operator()(phi2) ? phi1 : phi2);
180 }
181 
191 {
192  constexpr double pisq = boost::math::double_constants::pi
193  * boost::math::double_constants::pi;
194 
195  return 8. * pisq * lambda * lambda * std::pow(a, 12) /
196  (3. * epsilon * epsilon * epsilon);
197 }
198 
199 } // namespace BubbleProfiler
double get_local_minimum_location() const
returns the location of the local minimum
T Abs(T x) noexcept
virtual double partial(const Eigen::VectorXd &, int) const override
Partial derivative WRT coordinate i at a point.
T Sqrt(T x) noexcept
T Sin(T x) noexcept
double first_deriv(double) const
evaluates the first derivative of the potential
T ArcSin(T x) noexcept
virtual double operator()(const Eigen::VectorXd &) const override
Evaluate potential at point.
Exception indicating out of bounds access error.
Definition: error.hpp:75
double get_thin_wall_action() const
returns the approximate action in the thin-wall approximation
double second_deriv(double) const
evaluates the second derivative of the potential
Exception indicating general setup error.
Definition: error.hpp:32
double get_local_maximum_location() const
returns the location of the local maximum
double get_global_minimum_location() const
returns the location of the global minimum