Skip to content

Commit

Permalink
Added testing for the O(4) symmetric potentials. (#144)
Browse files Browse the repository at this point in the history
* Implemented Dilogarithm/Spencer's funtion and unit tests for it.

* Espinosa-Konstandin - Example A

* Espinosa-Konstandin - Example B

* Correct typo

* Fix wrong sign in numerical derivative of analytical solution when d2Vdl < 0 and alpha = 3 (O(4)-symmetric solution)

* Fix recursive step that assumed l0 = 0.

* Protect against infinite recursion in "BounceActionInt::ExactSolutionLin()"

* Espinosa-Konstandin - Example D

* Include "gsl_sf_expint" in tests

* Espinosa-Konstandin - Example C

* Espinosa-Konstandin - Example E

* Espinosa-Konstandin - Example 2D

* Espinosa-Konstandin - Example 3D

* Delete test.txt (#142)

* Conan use default profile (#140)

* Use conan's default profile is no profile matches

* Check if default profile already exists.

* Windows support

* Force "compiler.cppstd" to gnu17/17

* Add additional c++ version check

---------

Co-authored-by: Philipp Basler <[email protected]>
Co-authored-by: Philipp Basler <[email protected]>

* Add GSL to CmakeLists.txt of GenericTests

* Add GSL to CMakeLists.txt of utility

* Changed "Li2()", instead of sum starting with sum=1e-100 and k = 1, it starts at sum = x and k = 2.

* Impose threshold instead of relying on numerical precision errors for checks.

* Update minor version

---------

Co-authored-by: Philipp Basler <[email protected]>
Co-authored-by: Philipp Basler <[email protected]>
  • Loading branch information
3 people authored May 19, 2024
1 parent 558aa79 commit d1d5687
Show file tree
Hide file tree
Showing 9 changed files with 1,766 additions and 8 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
cmake_minimum_required(VERSION 3.23)
project(
BSMPT
VERSION 3.0.0
VERSION 3.0.1
LANGUAGES C CXX
DESCRIPTION
"BSMPT - Beyond the Standard Model Phase Transitions : A C++ package for the computation of the EWPT in BSM models"
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ SPDX-FileCopyrightText: 2021 Philipp Basler, Margarete Mühlleitner and Jonas M
SPDX-License-Identifier: GPL-3.0-or-later
-->

Program: BSMPT version 3.0.0
Program: BSMPT version 3.0.1

Released by: Philipp Basler, Lisa Biermann, Margarete Mühlleitner, Jonas Müller, Rui Santos and João Viana

Expand Down
26 changes: 26 additions & 0 deletions include/BSMPT/utility/utility.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

#include <BSMPT/config.h>
#include <algorithm>
#include <gsl/gsl_integration.h>
#include <iostream>
#include <numeric>
#include <random>
Expand Down Expand Up @@ -257,6 +258,31 @@ double L2NormVector(const std::vector<double> &vec);
std::vector<std::vector<double>>
Transpose(const std::vector<std::vector<double>> &A);

/**
* @brief Dilogarithm of x
*
* https://en.wikipedia.org/wiki/Dilogarithm
*
* @param x real argument of from \f$ (-\infty, 1)\f$
* @return double
*/
double Li2(const double &x);

/**
* @brief Incomplete elliptic integral of the second kind of x with a different
* parameterization and k^2 = -2
*
* \f$ \text{EllipIntSecond}(x) = -i E(i \phi, 2) = \int_0^\phi
* \sqrt{1+2\sinh^2{\theta}}\,d\theta \f$
*
* https://en.wikipedia.org/wiki</Elliptic_integral#Incomplete_elliptic_integral_of_the_second_kind
* https://mathworld.wolfram.com/EllipticIntegraloftheSecondKind.html
*
* @param x real argument
* @return double
*/
double EllipIntSecond(const double &x);

/**
* @brief operator << overload for the model parameter
*/
Expand Down
17 changes: 14 additions & 3 deletions src/bounce_solution/action_calculation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,7 @@ std::vector<double> BounceActionInt::ExactSolutionLin(double l0,
// We used numerical derivative here because Bessel function J are not
// completely implemented
return (
(LinearSolution(rho_in + 0.001) - LinearSolution(rho_in - 0.001)) /
-(LinearSolution(rho_in + 0.001) - LinearSolution(rho_in - 0.001)) /
(0.002));
};
}
Expand Down Expand Up @@ -474,7 +474,14 @@ std::vector<double> BounceActionInt::ExactSolutionLin(double l0,
ss << rho_up << "\t" << l << "\t" << dVdl << "\t" << d2Vdl2 << "\n";
BSMPT::Logger::Write(BSMPT::LoggingLevel::BounceDetailed, ss.str());
ss.str(std::string());
return (ExactSolutionLin(l0, l / 10., dVdl, d2Vdl2));
if (abs((l - l0) / Spline.L) < 1e-10)
{
// Maximum numerical precision reached.
StateOfBounceActionInt = ActionStatus::Integration1DFailed;
// Abort calculation
return {0, 0, 0};
}
return (ExactSolutionLin(l0, l0 + (l - l0) / 10., dVdl, d2Vdl2));
}
}
else
Expand Down Expand Up @@ -578,8 +585,12 @@ std::vector<double> BounceActionInt::ExactSolution(double l0)
if (not ExactSolutionThreshold.has_value())
return ExactSolutionLin(l0, l, dVdl, d2Vdl2);

if (dVdl <= -1e-3)
if (dVdl <= 0)
{
// Assume negative grad is numerical error if close to the true minimum
if (l0_minus_lmin / Spline.L < 1e-2) return ExactSolutionFromMinimum(l);
// If we are not close to the minimum then probably l0 in not a solution as
// it will roll backwards
ss << " \n l = " << l0 << std::endl;
ss << " dVdl = " << dVdl << std::endl;
ss << " d2Vd2l = " << d2Vdl2 << std::endl;
Expand Down
2 changes: 1 addition & 1 deletion src/utility/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ if(nlohmann_json_FOUND)
target_link_libraries(Utility PRIVATE nlohmann_json::nlohmann_json)
endif()

target_link_libraries(Utility PUBLIC ASCIIPlotter Spline)
target_link_libraries(Utility PUBLIC ASCIIPlotter Spline GSL::gsl)
42 changes: 42 additions & 0 deletions src/utility/utility.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,52 @@ Transpose(const std::vector<std::vector<double>> &A)
return r;
}

double Li2(const double &x)
{
if (x == 0) return 0;
if (x == 1) return pow(M_PI, 2) / 6.;
if (x < -1) return -pow(M_PI, 2) / 6. - pow(log(-x), 2) / 2. - Li2(1. / x);
if (x < 0) return 1 / 2. * Li2(-x * -x) - Li2(-x);
if (x > 0.5) return pow(M_PI, 2) / 6. - log(x) * log(1 - x) - Li2(1 - x);
double sum = x; // k = 1 element of the sum
for (int k = 2; k <= 1e5; k++) // Sum starts at k = 2
{
if (abs((pow(x, k) / pow(k, 2.)) / sum) < 1e-10)
{
sum += pow(x, k) / pow(k, 2.);
return sum;
}
sum += pow(x, k) / pow(k, 2.);
}
return sum;
}

bool StringEndsWith(const std::string &str, const std::string &suffix)
{
return str.size() >= suffix.size() and
str.substr(str.size() - suffix.size(), str.size()) == suffix;
}

double EllipIntSecond(const double &x)
{
std::function<double(double)> integrand = [&](double x_int)
{ return sqrt(1 + 2 * pow(sinh(x_int), 2)); };

gsl_integration_workspace *w = gsl_integration_workspace_alloc(1000);

double result, error;

gsl_function F = {[](double d, void *vf) -> double
{
auto &f =
*static_cast<std::function<double(double)> *>(vf);
return f(d);
},
&integrand};

gsl_integration_qags(&F, 0, x, 0, 1e-7, 1000, w, &result, &error);
gsl_integration_workspace_free(w);
return result;
}

} // namespace BSMPT
3 changes: 2 additions & 1 deletion tests/unittests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ file(GLOB SOURCE_FILES "Test-*.cpp" CONFIURE_DEPENDS)
add_executable(GenericTests ${SOURCE_FILES})
target_link_libraries(
GenericTests
PRIVATE Catch2::Catch2WithMain
PRIVATE GSL::gsl
Catch2::Catch2WithMain
CatchEventListener
Minimizer
MinimumTracer
Expand Down
Loading

0 comments on commit d1d5687

Please sign in to comment.