diff --git a/.github/workflows/cmake-format-linter.yml b/.github/workflows/cmake-format-linter.yml index ee9073ae..fc88b643 100644 --- a/.github/workflows/cmake-format-linter.yml +++ b/.github/workflows/cmake-format-linter.yml @@ -2,7 +2,14 @@ name: Run cmake-format linter on: pull_request: - branches: [ master, develop ] + branches: + - master + - develop + types: + - opened + - reopened + - synchronize + - ready_for_review concurrency: group: ${{ github.workflow }}-${{ github.ref }} @@ -10,11 +17,14 @@ concurrency: jobs: build: + if: github.event_name == 'pull_request' && github.event.pull_request.draft == false runs-on: ubuntu-latest steps: - name: Checkout repository uses: actions/checkout@v4 + with: + ssh-key: ${{secrets.DEPLOY_KEY}} - name: Format CMake files id: cmake-format diff --git a/.github/workflows/conan.yml b/.github/workflows/conan.yml new file mode 100644 index 00000000..201c7d3c --- /dev/null +++ b/.github/workflows/conan.yml @@ -0,0 +1,42 @@ +name: Run conan + +on: + push: + branches: + - master + - main + pull_request: + branches: + - master + - main + workflow_dispatch: + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + + +jobs: + conan: + strategy: + fail-fast: false + matrix: + os: [ ubuntu-latest, macos-latest, windows-latest] + runs-on: ${{matrix.os}} + if: "!contains(github.event.head_commit.message, 'skip-ci')" + + steps: + - uses: actions/checkout@v4 + with: + persist-credentials: false + - uses: actions/setup-python@v5 + with: + python-version: '3.x' # Version range or exact version of a Python version to use, using SemVer's version range syntax + architecture: 'x64' # optional x64 or x86. Defaults to x64 if not specified + - name: Install conan + run: pip install conan>2 + + - name: Build without cmaes + run: python3 Setup.py --create --build-missing --options UseLibCMAES=False + + - run: python3 Setup.py --create --build-missing diff --git a/.github/workflows/cpp-linter.yml b/.github/workflows/cpp-linter.yml index 50b092f2..243812dc 100644 --- a/.github/workflows/cpp-linter.yml +++ b/.github/workflows/cpp-linter.yml @@ -2,7 +2,13 @@ name: cpp-linter on: pull_request: - branches: [master] + branches: + - master + types: + - opened + - reopened + - synchronize + - ready_for_review concurrency: group: ${{ github.workflow }}-${{ github.ref }} @@ -10,12 +16,14 @@ concurrency: jobs: cpp-linter: + if: github.event_name == 'pull_request' && github.event.pull_request.draft == false runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 with: fetch-depth: 0 ref: ${{ github.head_ref }} + ssh-key: ${{secrets.DEPLOY_KEY}} - name: Install clang-format if: inputs.apply_clang_format diff --git a/.gitignore b/.gitignore index f102b91a..24f1272a 100644 --- a/.gitignore +++ b/.gitignore @@ -17,3 +17,8 @@ analyze*.py CMakeUserPresets.json __pycache__/* + +test_package/build/ +CMakeLists.txt.user +CMakeCache.txt +CMakeFiles/cmake.check_cache diff --git a/Build.py b/Build.py index ec3a902a..ca06ec28 100644 --- a/Build.py +++ b/Build.py @@ -2,6 +2,7 @@ import subprocess import sys + def get_preset(): preset = "conan-" os = sys.platform @@ -11,7 +12,7 @@ def get_preset(): preset += "linux" elif os == "darwin": preset += "macos" - + preset += "-" preset += Setup.get_arch() @@ -19,11 +20,12 @@ def get_preset(): return preset + def build(preset): cmd=f"cmake --preset {preset} --fresh".split() subprocess.check_call(cmd) - cmd=f"cmake --build --preset {preset}".split() + cmd = f"cmake --build --preset {preset}".split() subprocess.check_call(cmd) @@ -37,6 +39,6 @@ def main(): ) build(get_preset()) + if __name__ == "__main__": main() - \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt index 6cd0def3..1294ebbc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,14 +4,18 @@ # SPDX-License-Identifier: GPL-3.0-or-later cmake_minimum_required(VERSION 3.23) +set(BSMPT_VERSION 3.0.6) project( BSMPT - VERSION 3.0.6 + VERSION ${BSMPT_VERSION} LANGUAGES C CXX DESCRIPTION "BSMPT - Beyond the Standard Model Phase Transitions : A C++ package for the computation of the EWPT in BSM models" ) +set(CMAKE_CXX_FLAGS "-g") + + # -------------------------------- options -------------------------------- option(UseLibCMAES "Use libcmaes to minimize the potential" ON) @@ -21,6 +25,7 @@ option(MakeAdditionalTesting "Build the executables used for further testing" option(BSMPTCompileBaryo "Compile Baryogenesis" OFF) option(EnableCoverage "Enable code coverage" OFF) option(BSMPTUseVectorization "Disable vectorization" ON) +option(BSMPTBuildExecutables "Build the executables" ON) set(BSMPT_IS_TOPLEVEL NO) if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME) @@ -53,7 +58,7 @@ if(NOT CMAKE_BUILD_TYPE) set(CMAKE_BUILD_TYPE "Release") endif(NOT CMAKE_BUILD_TYPE) -set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/bin") +# set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/bin") include(LTO) @@ -69,6 +74,9 @@ if(NOT Boost_FOUND) set(BSMPTCompileBaryo OFF) endif() +# add_compile_options(-fsanitize=address) +# add_link_options(-fsanitize=address) + set(CodeCoverageExcludesFromOtherPkgs "") if(NOT "${EIGEN3_ROOT_DIR}" STREQUAL "") list(APPEND CodeCoverageExcludesFromOtherPkgs "${EIGEN3_ROOT_DIR}/*") @@ -114,12 +122,10 @@ if(UseNLopt) endif(UseNLopt) -if(NOT libcmaes_FOUND AND NOT NLopt_FOUND) +if(NOT cmaes_FOUND AND NOT NLopt_FOUND) message(FATAL_ERROR "You need at least libcmaes or NLopt.") endif() -configure_file(include/BSMPT/config.h.in include/BSMPT/config.h) - # -------------------- Coverage # -------------------------------------------------- @@ -156,43 +162,11 @@ if(EnableCoverage) GenericTests) endif(EnableCoverage) -find_lto(CXX) +# find_lto(CXX) add_subdirectory(src) add_subdirectory(standalone) -# -------------------------- export as cmake package -------------------------- -if(PROJECT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR) - include(CMakePackageConfigHelpers) - write_basic_package_version_file( - BSMPTConfigVersion.cmake - VERSION ${PACKAGE_VERSION} - COMPATIBILITY AnyNewerVersion) - - set(ExportList Models Minimizer ThermalFunctions Utility Spline ASCIIPlotter) - - if(BSMPTCompileBaryo) - set(ExportList ${ExportList} Baryo LibWallThickness Kfactors) - endif(BSMPTCompileBaryo) - - export( - TARGETS ${ExportList} - NAMESPACE BSMPT:: - FILE BSMPTTargets.cmake) - - if(EXPORT_CMAES) - export( - TARGETS cmaes - NAMESPACE libcmaes:: - APPEND - FILE BSMPTTargets.cmake) - endif(EXPORT_CMAES) - - configure_file(tools/cmake/BSMPTConfig.cmake.in BSMPTConfig.cmake @ONLY) - - export(PACKAGE BSMPT) -endif() - # ------------------------ Doxygen -------------------------------------------- if(BSMPT_IS_TOPLEVEL) find_package(Doxygen) diff --git a/Setup.py b/Setup.py index d84fc202..3ce555ce 100644 --- a/Setup.py +++ b/Setup.py @@ -26,23 +26,31 @@ class BuildMode(ArgTypeEnum, Enum): debug = 2 -def get_compiler(): - compiler = "" +class Compiler(ArgTypeEnum, Enum): + gcc = (0,) + clang = 1 + + +def get_compiler(compiler: Compiler): + compilerString = "" if sys.platform != "linux" and sys.platform != "darwin": - return compiler + return compilerString - if (sys.platform == "linux"): - compiler += "-gcc-" + if sys.platform == "linux": + if compiler == Compiler.gcc or compiler is None: + compilerString += "-gcc-" + else: + compilerString += "-clang-" - if (sys.platform == "darwin"): - compiler += "-clang-" - compiler += get_compiler_version() + if sys.platform == "darwin": + compilerString += "-clang-" + compilerString += get_compiler_version(compiler) - return compiler + return compilerString -def get_profile(os: str, arch: str, build_type: BuildMode): +def get_profile(os: str, arch: str, build_type: BuildMode, compiler: Compiler): profile = "" if os == "win32": profile += "windows" @@ -61,31 +69,44 @@ def get_profile(os: str, arch: str, build_type: BuildMode): profile += "-" profile += arch - profile += get_compiler() + profile += get_compiler(compiler) return profile + def set_setting(file, setting, value): for line in fileinput.input([file], inplace=True): if line.strip().startswith(setting): line = setting + "=" + value + "\n" sys.stdout.write(line) + def check_profile(profile): path = os.path.join("profiles", "BSMPT", profile) if not os.path.isfile(path): - conan_home = subprocess.check_output("conan config home".split(), encoding="UTF-8").split("\n")[0] - print(f"Profile does not exist in BSMPT/profiles.\nUsing profile {profile} created from the default profile. Change it accordingly.") + conan_home = subprocess.check_output( + "conan config home".split(), encoding="UTF-8" + ).split("\n")[0] + print( + f"Profile does not exist in BSMPT/profiles.\nUsing profile {profile} created from the default profile. Change it accordingly." + ) if not os.path.isfile(conan_home + "/profiles/default"): cmd = "conan profile detect".split() subprocess.check_output(cmd) - if (sys.platform != "win32"): - cmd = "cp " + conan_home + "/profiles/default profiles/BSMPT/" + str(profile) + if sys.platform != "win32": + cmd = ( + "cp " + conan_home + "/profiles/default profiles/BSMPT/" + str(profile) + ) subprocess.check_call(cmd, shell=True) set_setting(path, "compiler.cppstd", "gnu17") - + else: - cmd = "copy " + conan_home + "\\profiles\\default profiles\\BSMPT\\" + str(profile) + cmd = ( + "copy " + + conan_home + + "\\profiles\\default profiles\\BSMPT\\" + + str(profile) + ) subprocess.check_call(cmd, shell=True) set_setting(path, "compiler.cppstd", "17") @@ -93,14 +114,14 @@ def check_profile(profile): check_profile(profile) -def get_compiler_version(): - if (sys.platform == "linux"): +def get_compiler_version(compiler: Compiler): + if sys.platform == "linux" and compiler != Compiler.clang: version_response = subprocess.check_output( "gcc --version".split(), encoding="UTF-8" ).partition("\n")[0] semver_string = version_response[version_response.rfind(" ") + 1 :] return semver_string.partition(".")[0] - if (sys.platform == "darwin"): + elif sys.platform == "darwin" or compiler == Compiler.clang: version_response = subprocess.check_output( "clang --version".split(), encoding="UTF-8" ).partition("\n")[0] @@ -125,12 +146,14 @@ def setup_profiles(): shutil.copytree("profiles/BSMPT", profile_dir) -def conan_install(profile, additional_options=[], build_missing=False): +def conan_install( + profile, additional_options=[], build_missing=False, compiler: Compiler = None +): config_settings = [ "tools.cmake.cmake_layout:build_folder_vars=['settings.os','settings.arch','settings.build_type']" ] - build_profile = get_profile(sys.platform, get_arch(), BuildMode.release) + build_profile = get_profile(sys.platform, get_arch(), BuildMode.release, compiler) cmd = f"conan install . -pr:h BSMPT/{profile} -pr:b BSMPT/{build_profile} ".split() @@ -143,36 +166,58 @@ def conan_install(profile, additional_options=[], build_missing=False): if build_missing: cmd += ["--build=missing"] + print(f"Executing command {cmd}") + subprocess.check_call(cmd) def conan_install_all( - mode: BuildMode, options=[], build_missing=False, custom_profile="" + mode: BuildMode, + options=[], + build_missing=False, + custom_profile="", + compiler: Compiler = None, ): if mode == BuildMode.all or mode == BuildMode.release: profile = ( custom_profile if custom_profile != "" - else get_profile(sys.platform, get_arch(), BuildMode.release) + else get_profile(sys.platform, get_arch(), BuildMode.release, compiler) ) check_profile(profile) - conan_install( - profile, - options, - build_missing, - ) + conan_install(profile, options, build_missing, compiler) if mode == BuildMode.all or mode == BuildMode.debug: profile = ( custom_profile if custom_profile != "" - else get_profile(sys.platform, get_arch(), BuildMode.debug) + else get_profile(sys.platform, get_arch(), BuildMode.debug, compiler) ) check_profile(profile) - conan_install( - profile, - options, - build_missing, - ) + conan_install(profile, options, build_missing, compiler) + + +def create(build_missing=False, compiler: Compiler = None, additional_options=[]): + + config_settings = [ + "tools.cmake.cmake_layout:build_folder_vars=['settings.os','settings.arch','settings.build_type']" + ] + + profile = get_profile(sys.platform, get_arch(), BuildMode.release, compiler) + cmd = f"conan create . -pr:h BSMPT/{profile} -pr:b BSMPT/{profile}".split() + + for conf in config_settings: + cmd += ["-c", conf] + + if build_missing: + cmd += ["--build=missing"] + + for option in additional_options: + cmd += ["--options", option] + + # cmd += ["--options", "EnableTests=False"] + cmd += ["--options", "BuildExecutables=False"] + + subprocess.check_call(cmd) class ArgTypeEnum(Enum): @@ -216,6 +261,19 @@ def parse_arguments(): default="", ) + parser.add_argument( + "-c", "--create", action="store_true", help="create the local conan package" + ) + + parser.add_argument( + "-co", + "--compiler", + default=None, + type=Compiler.argtype, + choices=Compiler, + help="Force a certain compiler", + ) + return parser.parse_args() @@ -223,9 +281,19 @@ def parse_arguments(): opts = parse_arguments() setup_profiles() - conan_install_all( - opts.mode, - opts.options if opts.options is not None else [], - opts.build_missing, - opts.profile, - ) + + if opts.create: + create( + build_missing=opts.build_missing, + compiler=opts.compiler, + additional_options=opts.options if opts.options is not None else [], + ) + else: + + conan_install_all( + opts.mode, + opts.options if opts.options is not None else [], + opts.build_missing, + opts.profile, + opts.compiler, + ) diff --git a/conanfile.py b/conanfile.py index de5d6969..64495f59 100644 --- a/conanfile.py +++ b/conanfile.py @@ -1,7 +1,11 @@ from conan import ConanFile, tools -from conan.tools.cmake import cmake_layout, CMakeToolchain from conan.tools.system.package_manager import Apt from conan.errors import ConanInvalidConfiguration +from conan.tools.cmake import CMakeToolchain, CMake, cmake_layout +from conan.tools.files import load +from conan.tools.scm import Git +import os, re +from conan.tools.env import Environment required_conan_version = ">=2.0.0 <3" @@ -10,7 +14,19 @@ class BSMPT(ConanFile): settings = "os", "compiler", "build_type", "arch" generators = "CMakeDeps" + name = "bsmpt" + + exports_sources = ( + "CMakeLists.txt", + "src/*", + "include/*", + "tools/*", + "tests/*", + "standalone/*", + ) + options = { + "fPIC": [True, False], "EnableTests": [True, False], # enables the unit tests "UseLibCMAES": [ True, @@ -23,28 +39,31 @@ class BSMPT(ConanFile): False, ], # compile the electroweak baryogenesis for the C2HDM "EnableCoverage": [True, False], # enable code coverage - "UseVectorization": [True, False], # use vectorization for the build + "UseVectorization": [True, False], # use vectorization for the build, + "BuildExecutables": [True, False], } default_options = { + "fPIC": True, "EnableTests": True, "UseLibCMAES": True, "UseNLopt": True, "MakeAdditionalTesting": False, "CompileBaryo": False, "EnableCoverage": False, - "UseVectorization": True, + "UseVectorization": False, + "BuildExecutables": True, } def requirements(self): - self.requires("eigen/3.4.0") - self.requires("gsl/2.7.1") - self.requires("nlohmann_json/3.11.3") + self.requires("eigen/3.4.0", transitive_headers=True, transitive_libs=True) + self.requires("gsl/2.7.1", transitive_headers=True, transitive_libs=True) + self.requires("nlohmann_json/3.11.3", transitive_headers=True) if self.options.CompileBaryo: - self.requires("boost/1.84.0") + self.requires("boost/1.84.0", transitive_headers=True, transitive_libs=True) if self.options.UseNLopt: - self.requires("nlopt/2.7.1") + self.requires("nlopt/2.7.1", transitive_headers=True, transitive_libs=True) def build_requirements(self): self.tool_requires("cmake/3.29.0") @@ -58,6 +77,26 @@ def system_requirements(self): apt = Apt(self) apt.install(["lcov"], update=True, check=True) + def set_version(self): + content = load(self, os.path.join(self.recipe_folder, "CMakeLists.txt")) + value = re.search(r"set\(BSMPT_VERSION (.*)\)", content) + extracted_version = value.group(1).strip() + + is_git_tag = False + git = Git(self, folder=self.recipe_folder) + try: + git.run("describe --exact-match --tags") + is_git_tag = True + except Exception: + is_git_tag = False + + if is_git_tag: + self.version = extracted_version + else: + # if not tag -> pre-release version + commit_hash = git.get_commit()[:8] + self.version = f"{extracted_version}.{commit_hash}" + def layout(self): cmake_layout(self) @@ -71,6 +110,7 @@ def generate(self): tc.variables["BSMPTCompileBaryo"] = self.options.CompileBaryo tc.variables["EnableCoverage"] = self.options.EnableCoverage tc.variables["BSMPTUseVectorization"] = self.options.UseVectorization + tc.variables["BSMPTBuildExecutables"] = self.options.BuildExecutables tc.generate() @@ -82,5 +122,158 @@ def validate(self): if self.settings.os != "Linux" and self.options.EnableCoverage: raise ConanInvalidConfiguration("We depend on lcov for coverage.") - + tools.build.check_min_cppstd(self, "17") + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + environment = Environment() + environment.define("CTEST_OUTPUT_ON_FAILURE", "1") + envvars = environment.vars(self) + + if self.options.get_safe("EnableTests"): + with envvars.apply(): + cmake.test() + + def package(self): + cmake = CMake(self) + cmake.install() + + def package_id(self): + del self.info.options.EnableTests + + def package_info(self): + self.cpp_info.components["ASCIIPlotter"].libs = ["ASCIIPlotter"] + self.cpp_info.components["ASCIIPlotter"].requires = [ + "nlohmann_json::nlohmann_json", + ] + self.cpp_info.components["ASCIIPlotter"].set_property( + "cmake_target_name", "BSMPT::ASCIIPlotter" + ) + + if self.options.CompileBaryo: + self.cpp_info.components["ASCIIPlotter"].requires.append( + "boost::boost", + ) + + self.cpp_info.components["Spline"].libs = ["Spline"] + self.cpp_info.components["Spline"].requires = [ + "nlohmann_json::nlohmann_json", + ] + self.cpp_info.components["Spline"].set_property( + "cmake_target_name", "BSMPT::Spline" + ) + + if self.options.CompileBaryo: + self.cpp_info.components["Spline"].requires.append( + "boost::boost", + ) + + self.cpp_info.components["Utility"].libs = ["Utility"] + self.cpp_info.components["Utility"].requires = [ + "gsl::gsl", + "nlohmann_json::nlohmann_json", + "ASCIIPlotter", + "Spline", + ] + self.cpp_info.components["Utility"].set_property( + "cmake_target_name", "BSMPT::Utility" + ) + + if self.options.CompileBaryo: + self.cpp_info.components["Utility"].requires.append( + "boost::boost", + ) + + self.cpp_info.components["BounceSolution"].libs = ["BounceSolution"] + self.cpp_info.components["BounceSolution"].requires = [ + "eigen::eigen", + "gsl::gsl", + "Minimizer", + "Utility", + "MinimumTracer", + ] + self.cpp_info.components["BounceSolution"].set_property( + "cmake_target_name", "BSMPT::BounceSolution" + ) + + self.cpp_info.components["GW"].libs = ["GW"] + self.cpp_info.components["GW"].requires = [ + "eigen::eigen", + "gsl::gsl", + "Minimizer", + "Utility", + "BounceSolution", + ] + self.cpp_info.components["GW"].set_property("cmake_target_name", "BSMPT::GW") + + self.cpp_info.components["Minimizer"].libs = ["Minimizer"] + self.cpp_info.components["Minimizer"].requires = [ + "eigen::eigen", + "gsl::gsl", + # "Threads::Threads", + "Utility", + # "Models", + # "Minimizer_CMAES" + ] + self.cpp_info.components["Minimizer"].set_property( + "cmake_target_name", "BSMPT::Minimizer" + ) + + if self.options.UseNLopt: + + self.cpp_info.components["Minimizer"].requires.append("nlopt::nlopt") + + if self.options.UseLibCMAES: + self.cpp_info.components["cmaes"].libs = ["cmaes"] + self.cpp_info.components["cmaes"].set_property( + "cmake_target_name", "libcmaes::cmaes" + ) + self.cpp_info.components["Minimizer"].requires.append("cmaes") + + + self.cpp_info.components["MinimumTracer"].libs = ["MinimumTracer"] + self.cpp_info.components["MinimumTracer"].requires = [ + "eigen::eigen", + "gsl::gsl", + "Minimizer", + "Utility", + ] + self.cpp_info.components["MinimumTracer"].set_property( + "cmake_target_name", "BSMPT::MinimumTracer" + ) + + self.cpp_info.components["Models"].libs = ["Models"] + self.cpp_info.components["Models"].requires = [ + "gsl::gsl", + "eigen::eigen", + "Minimizer", + "ThermalFunctions", + "Utility", + ] + self.cpp_info.components["Models"].set_property( + "cmake_target_name", "BSMPT::Models" + ) + + self.cpp_info.components["ThermalFunctions"].libs = ["ThermalFunctions"] + self.cpp_info.components["ThermalFunctions"].requires = ["gsl::gsl", "Utility"] + self.cpp_info.components["ThermalFunctions"].set_property( + "cmake_target_name", "BSMPT::ThermalFunctions" + ) + + self.cpp_info.components["TransitionTracer"].libs = ["TransitionTracer"] + self.cpp_info.components["TransitionTracer"].requires = [ + "BounceSolution", + "MinimumTracer", + "GW", + ] + self.cpp_info.components["TransitionTracer"].set_property( + "cmake_target_name", "BSMPT::TransitionTracer" + ) diff --git a/include/BSMPT/config.h.in b/include/BSMPT/config.h.in index 71fd83d2..807ded9e 100644 --- a/include/BSMPT/config.h.in +++ b/include/BSMPT/config.h.in @@ -1,6 +1,6 @@ #pragma once -#cmakedefine libcmaes_FOUND +#cmakedefine cmaes_FOUND #cmakedefine NLopt_FOUND #cmakedefine Boost_FOUND #cmakedefine nlohmann_json_FOUND diff --git a/include/BSMPT/minimizer/Minimizer.h b/include/BSMPT/minimizer/Minimizer.h index a9c1dbec..d00ecf43 100644 --- a/include/BSMPT/minimizer/Minimizer.h +++ b/include/BSMPT/minimizer/Minimizer.h @@ -33,7 +33,7 @@ const bool UseGSLDefault = true; /** * @brief UseLibCMAESDefault Use the Libcmaes minimizer in the default settings */ -#ifdef libcmaes_FOUND +#ifdef cmaes_FOUND const bool UseLibCMAESDefault = true; #else const bool UseLibCMAESDefault = false; diff --git a/include/BSMPT/models/ClassPotentialOrigin.h b/include/BSMPT/models/ClassPotentialOrigin.h index 4c791f3f..9d0bcba0 100644 --- a/include/BSMPT/models/ClassPotentialOrigin.h +++ b/include/BSMPT/models/ClassPotentialOrigin.h @@ -15,17 +15,13 @@ #include #include #include +#include #include #include namespace BSMPT { -/** - * @brief C_UseParwani Use the Parwani Method instead of Arnold-Espinosa - */ -const bool C_UseParwani = false; - /** * @brief C_PT Lower threshold to stop the EWPT calculation */ diff --git a/include/BSMPT/models/IncludeAllModels.h b/include/BSMPT/models/IncludeAllModels.h index 3b72adf1..0ce09a3c 100644 --- a/include/BSMPT/models/IncludeAllModels.h +++ b/include/BSMPT/models/IncludeAllModels.h @@ -9,6 +9,7 @@ #pragma once +#include #include // for max #include #include // for string @@ -25,46 +26,6 @@ class Class_Potential_Origin; namespace ModelID { -/** - * @brief The ModelIDs enum containing all IDs for identifying the Models - */ -enum class ModelIDs -{ - NotSet, - C2HDM, - R2HDM, - N2HDM, - CXSM, - CPINTHEDARK, - SM, - - // Here you start adding your models - TEMPLATE, - - // DO NOT EDIT the part below - stop -}; - -/** - * @brief Mapping between the model name which is given as the first argument to - * the binary and the ModelIDs element - */ -const std::unordered_map ModelNames{ - {"c2hdm", ModelIDs::C2HDM}, - {"r2hdm", ModelIDs::R2HDM}, - {"n2hdm", ModelIDs::N2HDM}, - {"cxsm", ModelIDs::CXSM}, - {"sm", ModelIDs::SM}, - {"cpinthedark", ModelIDs::CPINTHEDARK}, - {"template", ModelIDs::TEMPLATE}, -}; - -/** - * @brief InvertModelNames - * @return The switched map to ModelNames - */ -std::unordered_map InvertModelNames(); - /** * @param choice ModelIDs for the Model under investigation * @return smart pointer to the instance of the class matching the ModelIDs @@ -98,11 +59,6 @@ FChoose(ModelIDs choice, const ISMConstants &smConstants); ModelIDs getModel(const std::string &s); } // namespace ModelID -/** - * @brief ShowInputError shows all the available models in the terminal - */ -void ShowInputError(); - } // namespace BSMPT // #endif /* INCLUDEALLMODELS_H_ */ diff --git a/include/BSMPT/utility/ModelIDs.h b/include/BSMPT/utility/ModelIDs.h new file mode 100644 index 00000000..5e6ab228 --- /dev/null +++ b/include/BSMPT/utility/ModelIDs.h @@ -0,0 +1,63 @@ +#pragma once + +#include +#include + +namespace BSMPT +{ +namespace ModelID +{ + +/** + * @brief The ModelIDs enum containing all IDs for identifying the Models + */ +enum class ModelIDs +{ + NotSet, + C2HDM, + R2HDM, + N2HDM, + CXSM, + CPINTHEDARK, + SM, + + // Here you start adding your models + TEMPLATE, + + // DO NOT EDIT the part below + stop +}; + +/** + * @brief Mapping between the model name which is given as the first argument to + * the binary and the ModelIDs element + */ +const std::unordered_map ModelNames{ + {"c2hdm", ModelIDs::C2HDM}, + {"r2hdm", ModelIDs::R2HDM}, + {"n2hdm", ModelIDs::N2HDM}, + {"cxsm", ModelIDs::CXSM}, + {"sm", ModelIDs::SM}, + {"cpinthedark", ModelIDs::CPINTHEDARK}, + {"template", ModelIDs::TEMPLATE}, +}; + +/** + * @brief InvertModelNames + * @return The switched map to ModelNames + */ +std::unordered_map InvertModelNames(); +} // namespace ModelID + +/** + * @brief ShowInputError shows all the available models in the terminal + */ +void ShowInputError(); + +/** + * @brief operator << overload for the model parameter + */ +std::ostream &operator<<(std::ostream &os, const ModelID::ModelIDs &Model); +std::string ModelIDToString(const ModelID::ModelIDs &Model); + +} // namespace BSMPT \ No newline at end of file diff --git a/include/BSMPT/utility/settings.h b/include/BSMPT/utility/settings.h new file mode 100644 index 00000000..c6113f38 --- /dev/null +++ b/include/BSMPT/utility/settings.h @@ -0,0 +1,9 @@ +#pragma once + +namespace BSMPT +{ +/** + * @brief C_UseParwani Use the Parwani Method instead of Arnold-Espinosa + */ +const bool C_UseParwani = false; +} // namespace BSMPT diff --git a/include/BSMPT/utility/utility.h b/include/BSMPT/utility/utility.h index 8d06ce5b..75a25be2 100644 --- a/include/BSMPT/utility/utility.h +++ b/include/BSMPT/utility/utility.h @@ -284,16 +284,6 @@ double Li2(const double &x); */ double EllipIntSecond(const double &x); -/** - * @brief operator << overload for the model parameter - */ -namespace ModelID -{ -enum class ModelIDs; -} -std::ostream &operator<<(std::ostream &os, const ModelID::ModelIDs &Model); -std::string ModelIDToString(const ModelID::ModelIDs &Model); - #ifdef Boost_FOUND #if BOOST_VERSION >= 107200 template diff --git a/profiles/BSMPT/linux-debug-x86_64-clang-14 b/profiles/BSMPT/linux-debug-x86_64-clang-14 new file mode 100644 index 00000000..8239ce4d --- /dev/null +++ b/profiles/BSMPT/linux-debug-x86_64-clang-14 @@ -0,0 +1,9 @@ +[settings] +arch=x86_64 +build_type=Debug +compiler=clang +compiler.cppstd=gnu17 +compiler.libcxx=libstdc++11 +compiler.version=14 +os=Linux + diff --git a/profiles/BSMPT/linux-release-x86_64-clang-14 b/profiles/BSMPT/linux-release-x86_64-clang-14 new file mode 100644 index 00000000..5220f8c4 --- /dev/null +++ b/profiles/BSMPT/linux-release-x86_64-clang-14 @@ -0,0 +1,9 @@ +[settings] +arch=x86_64 +build_type=Release +compiler=clang +compiler.cppstd=gnu17 +compiler.libcxx=libstdc++11 +compiler.version=14 +os=Linux + diff --git a/run_clang.sh b/run_clang.sh new file mode 100644 index 00000000..232c58ed --- /dev/null +++ b/run_clang.sh @@ -0,0 +1,3 @@ +CC=clang +CXX=clang++ +python3 Setup.py -p linux-release-x86_64-clang-14 --compiler clang -m release -b --create diff --git a/sh/prepareData_C2HDM.py b/sh/prepareData_C2HDM.py index b24f2744..7aeaf773 100755 --- a/sh/prepareData_C2HDM.py +++ b/sh/prepareData_C2HDM.py @@ -7,36 +7,48 @@ import sys ####### The parameters Type, Lambda1 to Lambda4, re_Lambda5, im_Lambda5, tanbeta and re_m12squared should have the label -####### of the corresponding parameter. With Seperator you have to tell which seperator your data file +####### of the corresponding parameter. With Seperator you have to tell which seperator your data file ####### is using (e.g. , \t or space). Your InputFILE will then be saved to OutputFILE. + def convert(InputFile, OutputFile): - print(f'Reading {InputFile}.') - print(f'Output is saved to {OutputFile}.') - - HasIndexCol=False - Separator='\t' - Type='yuktype' - Lambda1='L1' - Lambda2='L2' - Lambda3='L3' - Lambda4='L4' - re_Lambda5='re_L5' - im_Lambda5='im_L5' - tanbeta='tbeta' - re_m12squared='re_m12sq' - - with open(InputFile, 'r') as file: - df = pd.read_csv(file,index_col=HasIndexCol,sep=Separator) - - frontcol=[Type,Lambda1,Lambda2,Lambda3,Lambda4,re_Lambda5,im_Lambda5,re_m12squared,tanbeta] + print(f"Reading {InputFile}.") + print(f"Output is saved to {OutputFile}.") + + HasIndexCol = False + Separator = "\t" + Type = "yuktype" + Lambda1 = "L1" + Lambda2 = "L2" + Lambda3 = "L3" + Lambda4 = "L4" + re_Lambda5 = "re_L5" + im_Lambda5 = "im_L5" + tanbeta = "tbeta" + re_m12squared = "re_m12sq" + + with open(InputFile, "r") as file: + df = pd.read_csv(file, index_col=HasIndexCol, sep=Separator) + + frontcol = [ + Type, + Lambda1, + Lambda2, + Lambda3, + Lambda4, + re_Lambda5, + im_Lambda5, + re_m12squared, + tanbeta, + ] Col = [c for c in frontcol if c in df] + [c for c in df if c not in frontcol] df = df[Col] - with open(OutputFile, 'w') as file: - df.to_csv(file, index=False, sep='\t') + with open(OutputFile, "w") as file: + df.to_csv(file, index=False, sep="\t") + if __name__ == "__main__": convert(sys.argv[1], sys.argv[2]) diff --git a/sh/prepareData_CxSM.py b/sh/prepareData_CxSM.py index 2d22d770..2214e802 100755 --- a/sh/prepareData_CxSM.py +++ b/sh/prepareData_CxSM.py @@ -6,55 +6,57 @@ import pandas as pd import sys + def convert(InputFile, OutputFile): - print(f'Reading {InputFile}.') - print(f'Output is saved to {OutputFile}.') - - with open(InputFile, 'r') as file: - df = pd.read_csv(file,index_col=False,sep='\t') - - v = 'v' - vs = 'vs' - va = 'va' - msq = 'msq' - lamb = 'lambda' - delta2 = 'delta2' - b2 = 'b2' - d2 = 'd2' - Reb1 = 'Reb1' - Imb1 = 'Imb1' - Rea1 = 'Rea1' - Ima1 = 'Ima1' - - NoImb1 = False - NoIma1 = False - - if Imb1 not in df: - Reb1 = 'b1' - print(f'Reb1 changed to {Reb1}.') - NoImb1 = True - if Ima1 not in df: - Rea1 = 'a1' - print(f'Rea1 changed to {Rea1}.') - NoIma1 = True - - frontcol=[v, vs, va, msq, lamb, delta2, b2, d2, Reb1, Imb1, Rea1, Ima1] - - for c in frontcol: - if c not in df: - df[c] = 0 - - Col = [c for c in frontcol if c in df] + [c for c in df if c not in frontcol] - - df = df[Col] - - if NoImb1: - df.rename(columns={Reb1:'Reb1'}, inplace=True) - if NoIma1: - df.rename(columns={Rea1:'Rea1'}, inplace=True) - - with open(OutputFile, 'w') as file: - df.to_csv(file, index=True, sep='\t')\ + print(f"Reading {InputFile}.") + print(f"Output is saved to {OutputFile}.") + + with open(InputFile, "r") as file: + df = pd.read_csv(file, index_col=False, sep="\t") + + v = "v" + vs = "vs" + va = "va" + msq = "msq" + lamb = "lambda" + delta2 = "delta2" + b2 = "b2" + d2 = "d2" + Reb1 = "Reb1" + Imb1 = "Imb1" + Rea1 = "Rea1" + Ima1 = "Ima1" + + NoImb1 = False + NoIma1 = False + + if Imb1 not in df: + Reb1 = "b1" + print(f"Reb1 changed to {Reb1}.") + NoImb1 = True + if Ima1 not in df: + Rea1 = "a1" + print(f"Rea1 changed to {Rea1}.") + NoIma1 = True + + frontcol = [v, vs, va, msq, lamb, delta2, b2, d2, Reb1, Imb1, Rea1, Ima1] + + for c in frontcol: + if c not in df: + df[c] = 0 + + Col = [c for c in frontcol if c in df] + [c for c in df if c not in frontcol] + + df = df[Col] + + if NoImb1: + df.rename(columns={Reb1: "Reb1"}, inplace=True) + if NoIma1: + df.rename(columns={Rea1: "Rea1"}, inplace=True) + + with open(OutputFile, "w") as file: + df.to_csv(file, index=True, sep="\t") + if __name__ == "__main__": convert(sys.argv[1], sys.argv[2]) diff --git a/sh/prepareData_N2HDM.py b/sh/prepareData_N2HDM.py index 307b7be7..0f4a3fd5 100644 --- a/sh/prepareData_N2HDM.py +++ b/sh/prepareData_N2HDM.py @@ -5,43 +5,63 @@ import pandas as pd import argparse -####### The parameters Type,Lambda1 to Lambda8, tanbeta, m12squared and v_s should have the label of the +####### The parameters Type,Lambda1 to Lambda8, tanbeta, m12squared and v_s should have the label of the ####### corresponding parameter. With Seperator you have to tell which seperator your data file ####### is using (e.g. , \t or space). Your InputFILE will then be saved to OutputFILE. -Seperator='\t' -InputFILE='../example/N2HDM_Input.dat' -OutputFILE='N2HDM_Ordered.dat' -Type='p_THDMtype' -Lambda1='p_L1' -Lambda2='p_L2' -Lambda3='p_L3' -Lambda4='p_L4' -Lambda5='p_L5' -Lambda6='p_L6' -Lambda7='p_L7' -Lambda8='p_L8' -tanbeta='p_tbeta' -m12squared='p_m12sq' -vs='p_vs' +Seperator = "\t" +InputFILE = "../example/N2HDM_Input.dat" +OutputFILE = "N2HDM_Ordered.dat" +Type = "p_THDMtype" +Lambda1 = "p_L1" +Lambda2 = "p_L2" +Lambda3 = "p_L3" +Lambda4 = "p_L4" +Lambda5 = "p_L5" +Lambda6 = "p_L6" +Lambda7 = "p_L7" +Lambda8 = "p_L8" +tanbeta = "p_tbeta" +m12squared = "p_m12sq" +vs = "p_vs" + def convert(IndexCol): - df=pd.DataFrame() - if IndexCol == 'False': - df=pd.read_table(InputFILE,index_col=False,sep=Seperator) - else: - df=pd.read_table(InputFILE,index_col=int(IndexCol),sep=Seperator) + df = pd.DataFrame() + if IndexCol == "False": + df = pd.read_table(InputFILE, index_col=False, sep=Seperator) + else: + df = pd.read_table(InputFILE, index_col=int(IndexCol), sep=Seperator) + + frontcol = [ + Type, + Lambda1, + Lambda2, + Lambda3, + Lambda4, + Lambda5, + Lambda6, + Lambda7, + Lambda8, + vs, + tanbeta, + m12squared, + ] - frontcol=[Type,Lambda1,Lambda2,Lambda3,Lambda4,Lambda5,Lambda6,Lambda7,Lambda8,vs,tanbeta,m12squared] + Col = [c for c in frontcol if c in df] + [c for c in df if c not in frontcol] + df = df[Col] - Col = [c for c in frontcol if c in df] + [c for c in df if c not in frontcol] - df=df[Col] + df.to_csv(OutputFILE, index=False, sep="\t") - df.to_csv(OutputFILE,index=False,sep='\t') parser = argparse.ArgumentParser() -parser.add_argument('-i','--indexcol',help='Column which stores the index of your data', default='False') +parser.add_argument( + "-i", + "--indexcol", + help="Column which stores the index of your data", + default="False", +) if __name__ == "__main__": - args = parser.parse_args() - convert(args.indexcol) \ No newline at end of file + args = parser.parse_args() + convert(args.indexcol) diff --git a/sh/prepareData_R2HDM.py b/sh/prepareData_R2HDM.py index ff08ed6e..3db06c67 100755 --- a/sh/prepareData_R2HDM.py +++ b/sh/prepareData_R2HDM.py @@ -6,35 +6,37 @@ import pandas as pd import sys -####### The parameters Type, Lambda1 to Lambda5, tanbeta and m12squared should have the label of the corresponding +####### The parameters Type, Lambda1 to Lambda5, tanbeta and m12squared should have the label of the corresponding ####### parameter. With Seperator you have to tell which seperator your data file ####### is using (e.g. , \t or space). Your InputFILE will then be saved to OutputFILE + def convert(InputFile, OutputFile): - print(f'Reading {InputFile}.') - print(f'Output is saved to {OutputFile}.') + print(f"Reading {InputFile}.") + print(f"Output is saved to {OutputFile}.") - HasIndexCol=False - Separator='\t' - Type='yuktype' - Lambda1='L1' - Lambda2='L2' - Lambda3='L3' - Lambda4='L4' - Lambda5='L5' - tanbeta='tbeta' - m12squared='m12sq' + HasIndexCol = False + Separator = "\t" + Type = "yuktype" + Lambda1 = "L1" + Lambda2 = "L2" + Lambda3 = "L3" + Lambda4 = "L4" + Lambda5 = "L5" + tanbeta = "tbeta" + m12squared = "m12sq" - with open(InputFile, 'r') as file: - df = pd.read_csv(file,index_col=HasIndexCol,sep=Separator) + with open(InputFile, "r") as file: + df = pd.read_csv(file, index_col=HasIndexCol, sep=Separator) - frontcol=[Type,Lambda1,Lambda2,Lambda3,Lambda4,Lambda5,m12squared,tanbeta] + frontcol = [Type, Lambda1, Lambda2, Lambda3, Lambda4, Lambda5, m12squared, tanbeta] Col = [c for c in frontcol if c in df] + [c for c in df if c not in frontcol] df = df[Col] - with open(OutputFile, 'w') as file: - df.to_csv(file, index=False, sep='\t') + with open(OutputFile, "w") as file: + df.to_csv(file, index=False, sep="\t") + if __name__ == "__main__": convert(sys.argv[1], sys.argv[2]) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 259d250a..0bccee9e 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -3,6 +3,21 @@ # # SPDX-License-Identifier: GPL-3.0-or-later +configure_file(${BSMPT_SOURCE_DIR}/include/BSMPT/config.h.in + ${BSMPT_BINARY_DIR}/include/BSMPT/config.h) + +add_library(BSMPT_Config INTERFACE) +set(header_path ${BSMPT_BINARY_DIR}/include/BSMPT) +target_include_directories( + BSMPT_Config + INTERFACE $ + $ + $) +set(header ${header_path}/config.h) +set_property(TARGET BSMPT_Config PROPERTY PUBLIC_HEADER ${header}) + +install(TARGETS BSMPT_Config PUBLIC_HEADER DESTINATION include/BSMPT) + add_subdirectory(minimizer) add_subdirectory(models) if(BSMPTCompileBaryo) @@ -25,90 +40,94 @@ add_subdirectory(utility/spline) # ==============================EXE====================================== -add_executable(BSMPT prog/BSMPT.cpp) -target_link_libraries(BSMPT Minimizer Models Utility) -target_compile_features(BSMPT PUBLIC cxx_std_17) - -add_executable(VEVEVO prog/VEVEVO.cpp) -target_link_libraries(VEVEVO Minimizer Models Utility) -target_compile_features(VEVEVO PUBLIC cxx_std_17) - -add_executable(NLOVEV prog/NLOVEV.cpp) -target_link_libraries(NLOVEV Minimizer Models Utility) -target_compile_features(NLOVEV PUBLIC cxx_std_17) +if(BSMPTBuildExecutables) -add_executable(CalcCT prog/CalcCT.cpp) -target_link_libraries(CalcCT Models Utility) -target_compile_features(CalcCT PUBLIC cxx_std_17) + add_executable(BSMPT prog/BSMPT.cpp) + target_link_libraries(BSMPT Minimizer Models Utility) + target_compile_features(BSMPT PUBLIC cxx_std_17) -add_executable(TripleHiggsCouplingsNLO prog/TripleHiggsNLO.cpp) -target_link_libraries(TripleHiggsCouplingsNLO Models Utility) -target_compile_features(TripleHiggsCouplingsNLO PUBLIC cxx_std_17) + add_executable(VEVEVO prog/VEVEVO.cpp) + target_link_libraries(VEVEVO Minimizer Models Utility) + target_compile_features(VEVEVO PUBLIC cxx_std_17) -add_executable(Test prog/Test.cpp) -target_link_libraries(Test Minimizer Models Utility) -target_compile_features(Test PUBLIC cxx_std_17) + add_executable(NLOVEV prog/NLOVEV.cpp) + target_link_libraries(NLOVEV Minimizer Models Utility) + target_compile_features(NLOVEV PUBLIC cxx_std_17) -add_executable(CalcGW prog/CalcGW.cpp) -target_link_libraries(CalcGW Utility GW MinimumTracer TransitionTracer) -target_compile_features(CalcGW PUBLIC cxx_std_14) + add_executable(CalcCT prog/CalcCT.cpp) + target_link_libraries(CalcCT Models Utility) + target_compile_features(CalcCT PUBLIC cxx_std_17) -add_executable(CalcTemps prog/CalcTemps.cpp) -target_link_libraries(CalcTemps Utility GW MinimumTracer TransitionTracer) -target_compile_features(CalcTemps PUBLIC cxx_std_14) + add_executable(TripleHiggsCouplingsNLO prog/TripleHiggsNLO.cpp) + target_link_libraries(TripleHiggsCouplingsNLO Models Utility) + target_compile_features(TripleHiggsCouplingsNLO PUBLIC cxx_std_17) -add_executable(MinimaTracer prog/MinimaTracer.cpp) -target_link_libraries(MinimaTracer Minimizer Models Utility MinimumTracer - TransitionTracer) -target_compile_features(MinimaTracer PUBLIC cxx_std_14) + add_executable(Test prog/Test.cpp) + target_link_libraries(Test Minimizer Models Utility) + target_compile_features(Test PUBLIC cxx_std_17) -add_executable(PotPlotter prog/PotPlotter.cpp) -target_link_libraries(PotPlotter Models Utility Minimizer MinimumTracer) -target_compile_features(PotPlotter PUBLIC cxx_std_14) + add_executable(CalcGW prog/CalcGW.cpp) + target_link_libraries(CalcGW Utility GW MinimumTracer TransitionTracer) + target_compile_features(CalcGW PUBLIC cxx_std_14) -if(BSMPTCompileBaryo) - add_executable(CalculateEWBG prog/CalculateEWBG.cpp) - target_link_libraries(CalculateEWBG Minimizer Models Baryo Utility) - target_compile_features(CalculateEWBG PUBLIC cxx_std_17) -else(BSMPTCompileBaryo) - message("CalculateEWBG will not compile as Boost is missing") -endif(BSMPTCompileBaryo) - -if(BSMPTCompileBaryo) - add_executable(PlotEWBG_vw prog/PlotEWBG_vw.cpp) - target_link_libraries(PlotEWBG_vw Minimizer Models Baryo Utility) - target_compile_features(PlotEWBG_vw PUBLIC cxx_std_17) -else(BSMPTCompileBaryo) - message("PlotEWBG_vw will not compile as Boost is missing") -endif(BSMPTCompileBaryo) + add_executable(CalcTemps prog/CalcTemps.cpp) + target_link_libraries(CalcTemps Utility GW MinimumTracer TransitionTracer) + target_compile_features(CalcTemps PUBLIC cxx_std_14) -if(BSMPTCompileBaryo) - add_executable(PlotEWBG_nL prog/PlotEWBG_nL.cpp) - target_link_libraries(PlotEWBG_nL Minimizer Models Baryo Utility) - target_compile_features(PlotEWBG_nL PUBLIC cxx_std_17) -else(BSMPTCompileBaryo) - message("PlotEWBG_nL will not compile as Boost is missing") -endif(BSMPTCompileBaryo) + add_executable(MinimaTracer prog/MinimaTracer.cpp) + target_link_libraries(MinimaTracer Minimizer Models Utility MinimumTracer + TransitionTracer) + target_compile_features(MinimaTracer PUBLIC cxx_std_14) -# ======================= Additional testing -# ==================================== + add_executable(PotPlotter prog/PotPlotter.cpp) + target_link_libraries(PotPlotter Models Utility Minimizer MinimumTracer) + target_compile_features(PotPlotter PUBLIC cxx_std_14) -if(MakeAdditionalTesting) + if(BSMPTCompileBaryo) + add_executable(CalculateEWBG prog/CalculateEWBG.cpp) + target_link_libraries(CalculateEWBG Minimizer Models Baryo Utility) + target_compile_features(CalculateEWBG PUBLIC cxx_std_17) + else(BSMPTCompileBaryo) + message("CalculateEWBG will not compile as Boost is missing") + endif(BSMPTCompileBaryo) if(BSMPTCompileBaryo) - add_executable(CreateMuGrid prog/CreateMuGrid.cpp) - target_link_libraries(CreateMuGrid Minimizer Models Baryo Utility) - target_compile_features(CreateMuGrid PUBLIC cxx_std_17) + add_executable(PlotEWBG_vw prog/PlotEWBG_vw.cpp) + target_link_libraries(PlotEWBG_vw Minimizer Models Baryo Utility) + target_compile_features(PlotEWBG_vw PUBLIC cxx_std_17) else(BSMPTCompileBaryo) - message("CreateMuGrid will not compile as Boost is missing") + message("PlotEWBG_vw will not compile as Boost is missing") endif(BSMPTCompileBaryo) if(BSMPTCompileBaryo) - add_executable(Kfactor_grid prog/Kfactor_grid.cpp) - target_link_libraries(Kfactor_grid Minimizer Models Kfactors Utility) - target_compile_features(Kfactor_grid PUBLIC cxx_std_17) + add_executable(PlotEWBG_nL prog/PlotEWBG_nL.cpp) + target_link_libraries(PlotEWBG_nL Minimizer Models Baryo Utility) + target_compile_features(PlotEWBG_nL PUBLIC cxx_std_17) else(BSMPTCompileBaryo) - message("Kfactor_grid will not compile as Boost is missing") + message("PlotEWBG_nL will not compile as Boost is missing") endif(BSMPTCompileBaryo) -endif(MakeAdditionalTesting) + # ======================= Additional testing + # ==================================== + + if(MakeAdditionalTesting) + + if(BSMPTCompileBaryo) + add_executable(CreateMuGrid prog/CreateMuGrid.cpp) + target_link_libraries(CreateMuGrid Minimizer Models Baryo Utility) + target_compile_features(CreateMuGrid PUBLIC cxx_std_17) + else(BSMPTCompileBaryo) + message("CreateMuGrid will not compile as Boost is missing") + endif(BSMPTCompileBaryo) + + if(BSMPTCompileBaryo) + add_executable(Kfactor_grid prog/Kfactor_grid.cpp) + target_link_libraries(Kfactor_grid Minimizer Models Kfactors Utility) + target_compile_features(Kfactor_grid PUBLIC cxx_std_17) + else(BSMPTCompileBaryo) + message("Kfactor_grid will not compile as Boost is missing") + endif(BSMPTCompileBaryo) + + endif(MakeAdditionalTesting) + +endif(BSMPTBuildExecutables) diff --git a/src/Kfactors/CMakeLists.txt b/src/Kfactors/CMakeLists.txt index 6d62483a..7ce4ab41 100644 --- a/src/Kfactors/CMakeLists.txt +++ b/src/Kfactors/CMakeLists.txt @@ -16,8 +16,5 @@ add_library(Kfactors ${header} ${src}) target_link_libraries(Kfactors PUBLIC Eigen3::Eigen GSL::gsl Boost::boost Minimizer Utility) -if(OpenMP_FOUND) - target_link_libraries(Kfactors PUBLIC OpenMP::OpenMP_CXX) -endif() target_include_directories(Kfactors PUBLIC ${BSMPT_SOURCE_DIR}/include) target_compile_features(Kfactors PUBLIC cxx_std_17) diff --git a/src/ThermalFunctions/CMakeLists.txt b/src/ThermalFunctions/CMakeLists.txt index 20022f62..e6c52666 100644 --- a/src/ThermalFunctions/CMakeLists.txt +++ b/src/ThermalFunctions/CMakeLists.txt @@ -3,7 +3,9 @@ # # SPDX-License-Identifier: GPL-3.0-or-later -set(header_path "${BSMPT_SOURCE_DIR}/include/BSMPT/ThermalFunctions") +set(suffix "include/BSMPT/ThermalFunctions") +set(header_path "${BSMPT_SOURCE_DIR}/${suffix}") + set(header ${header_path}/ThermalFunctions.h ${header_path}/NegativeBosonSpline.h ${header_path}/thermalcoefficientcalculator.h) @@ -15,3 +17,7 @@ add_library(ThermalFunctions ${header} ${src}) target_link_libraries(ThermalFunctions PUBLIC GSL::gsl Utility) target_include_directories(ThermalFunctions PUBLIC ${BSMPT_SOURCE_DIR}/include) target_compile_features(ThermalFunctions PUBLIC cxx_std_17) + +set_property(TARGET ThermalFunctions PROPERTY PUBLIC_HEADER ${header}) + +install(TARGETS ThermalFunctions PUBLIC_HEADER DESTINATION ${suffix}) diff --git a/src/baryo_calculation/CMakeLists.txt b/src/baryo_calculation/CMakeLists.txt index 083a6bb6..93535d6a 100644 --- a/src/baryo_calculation/CMakeLists.txt +++ b/src/baryo_calculation/CMakeLists.txt @@ -32,6 +32,5 @@ target_link_libraries( LibWallThickness Utility Boost::boost) -# target_compile_options(Baryo PUBLIC ${OpenMP_CXX_FLAGS}) target_include_directories(Baryo PUBLIC ${BSMPT_SOURCE_DIR}/include) target_compile_features(Baryo PUBLIC cxx_std_17) diff --git a/src/bounce_solution/CMakeLists.txt b/src/bounce_solution/CMakeLists.txt index ed43c8f0..7efd17bc 100644 --- a/src/bounce_solution/CMakeLists.txt +++ b/src/bounce_solution/CMakeLists.txt @@ -2,8 +2,8 @@ # João Viana # # SPDX-License-Identifier: GPL-3.0-or-later - -set(header_path "${BSMPT_SOURCE_DIR}/include/BSMPT/bounce_solution") +set(suffix "include/BSMPT/bounce_solution") +set(header_path "${BSMPT_SOURCE_DIR}/${suffix}") set(header ${header_path}/bounce_solution.h ${header_path}/action_calculation.h) set(src bounce_solution.cpp action_calculation.cpp) @@ -13,3 +13,7 @@ target_link_libraries(BounceSolution PUBLIC Eigen3::Eigen GSL::gsl Minimizer Utility MinimumTracer) target_include_directories(BounceSolution PUBLIC ${BSMPT_SOURCE_DIR}/include) target_compile_features(BounceSolution PUBLIC cxx_std_14) + +set_property(TARGET BounceSolution PROPERTY PUBLIC_HEADER ${header}) + +install(TARGETS BounceSolution PUBLIC_HEADER DESTINATION ${suffix}) diff --git a/src/gravitational_waves/CMakeLists.txt b/src/gravitational_waves/CMakeLists.txt index 403b80a9..d4efe560 100644 --- a/src/gravitational_waves/CMakeLists.txt +++ b/src/gravitational_waves/CMakeLists.txt @@ -3,13 +3,18 @@ # # SPDX-License-Identifier: GPL-3.0-or-later -set(header_path "${BSMPT_SOURCE_DIR}/include/BSMPT/gravitational_waves") +set(suffix "include/BSMPT/gravitational_waves") +set(header_path "${BSMPT_SOURCE_DIR}/${suffix}") set(header ${header_path}/gw.h) set(src gw.cpp) -add_library(GW ${header} ${src}) +add_library(GW STATIC ${header} ${src}) target_link_libraries(GW PUBLIC Eigen3::Eigen GSL::gsl Minimizer Utility BounceSolution) target_include_directories(GW PUBLIC ${BSMPT_SOURCE_DIR}/include) -target_compile_features(GW PUBLIC cxx_std_14) +target_compile_features(GW PUBLIC cxx_std_17) + +set_property(TARGET GW PROPERTY PUBLIC_HEADER ${header}) + +install(TARGETS GW PUBLIC_HEADER DESTINATION ${suffix}) diff --git a/src/minimizer/CMakeLists.txt b/src/minimizer/CMakeLists.txt index 2d3712b1..74472bb8 100644 --- a/src/minimizer/CMakeLists.txt +++ b/src/minimizer/CMakeLists.txt @@ -3,42 +3,34 @@ # # SPDX-License-Identifier: GPL-3.0-or-later -set(header_path "${BSMPT_SOURCE_DIR}/include/BSMPT/minimizer") +set(suffix "include/BSMPT/minimizer") +set(header_path "${BSMPT_SOURCE_DIR}/${suffix}") set(header ${header_path}/Minimizer.h ${header_path}/MinimizePlane.h ${header_path}/MinimizeGSL.h) -set(src MinimizeGSL.cpp Minimizer.cpp MinimizePlane.cpp) - -if(libcmaes_FOUND) - set(header ${header} ${header_path}/LibCMAES/MinimizeLibCMAES.h) - set(src ${src} LibCMAES/MinimizeLibCMAES.cpp) -endif() - -if(NLopt_FOUND) - set(header ${header} ${header_path}/LibNLOPT/MinimizeNLOPT.h) - set(src ${src} LibNLOPT/MinimizeNLOPT.cpp) -endif() - -add_library(Minimizer ${header} ${src}) +add_library(Minimizer STATIC) target_link_libraries(Minimizer PUBLIC Eigen3::Eigen GSL::gsl Threads::Threads Utility Models) - -if(libcmaes_FOUND) - target_link_libraries(Minimizer PRIVATE libcmaes::cmaes) - if(OpenMP_FOUND) - target_link_libraries(Minimizer PRIVATE OpenMP::OpenMP_CXX) - endif() +target_sources( + Minimizer + PUBLIC MinimizeGSL.cpp Minimizer.cpp MinimizePlane.cpp + PUBLIC ${header}) + +if(cmaes_FOUND) + add_subdirectory(LibCMAES) + target_link_libraries(Minimizer PRIVATE Minimizer_CMAES) endif() if(NLopt_FOUND) - if(TARGET NLopt::nlopt) - target_link_libraries(Minimizer PUBLIC NLopt::nlopt) - else() - target_link_libraries(Minimizer PUBLIC NLopt::nlopt_cxx) - endif() + add_subdirectory(LibNLOPT) + target_link_libraries(Minimizer PUBLIC Minimizer_NLOPT) endif() target_include_directories(Minimizer PUBLIC ${BSMPT_SOURCE_DIR}/include ${BSMPT_BINARY_DIR}/include) target_include_directories(Minimizer PUBLIC ${BSMPT_SOURCE_DIR}/include) target_compile_features(Minimizer PUBLIC cxx_std_17) + +set_property(TARGET Minimizer PROPERTY PUBLIC_HEADER ${header}) + +install(TARGETS Minimizer PUBLIC_HEADER DESTINATION ${suffix}) diff --git a/src/minimizer/LibCMAES/CMakeLists.txt b/src/minimizer/LibCMAES/CMakeLists.txt new file mode 100644 index 00000000..57b509bf --- /dev/null +++ b/src/minimizer/LibCMAES/CMakeLists.txt @@ -0,0 +1,28 @@ +# SPDX-FileCopyrightText: 2021 Philipp Basler, Margarete Mühlleitner and Jonas +# Müller +# +# SPDX-License-Identifier: GPL-3.0-or-later + +include(CMAES) + +set(suffix "include/BSMPT/minimizer/LibCMAES") +set(header_path "${BSMPT_SOURCE_DIR}/${suffix}") +set(header ${header_path}/MinimizeLibCMAES.h) + +add_library(Minimizer_CMAES INTERFACE) +target_sources(Minimizer_CMAES INTERFACE MinimizeLibCMAES.cpp ${header}) +target_link_libraries(Minimizer_CMAES INTERFACE Minimizer) + +target_link_libraries(Minimizer_CMAES + INTERFACE libcmaes::cmaes) + +target_include_directories( + Minimizer_CMAES INTERFACE ${BSMPT_SOURCE_DIR}/include + ${BSMPT_BINARY_DIR}/include) +target_include_directories(Minimizer_CMAES + INTERFACE ${BSMPT_SOURCE_DIR}/include) +target_compile_features(Minimizer_CMAES INTERFACE cxx_std_17) + +set_property(TARGET Minimizer_CMAES PROPERTY PUBLIC_HEADER ${header}) + +install(TARGETS Minimizer_CMAES PUBLIC_HEADER DESTINATION ${suffix}) diff --git a/src/minimizer/LibNLOPT/CMakeLists.txt b/src/minimizer/LibNLOPT/CMakeLists.txt new file mode 100644 index 00000000..c5aec26e --- /dev/null +++ b/src/minimizer/LibNLOPT/CMakeLists.txt @@ -0,0 +1,31 @@ +# SPDX-FileCopyrightText: 2021 Philipp Basler, Margarete Mühlleitner and Jonas +# Müller +# +# SPDX-License-Identifier: GPL-3.0-or-later + +set(suffix "include/BSMPT/minimizer/LibNLOPT") +set(header_path "${BSMPT_SOURCE_DIR}/${suffix}") +set(header ${header_path}/MinimizeNLOPT.h) + +set(src MinimizeNLOPT.cpp) + +add_library(Minimizer_NLOPT INTERFACE) +target_sources(Minimizer_NLOPT INTERFACE ${header} ${src}) +target_link_libraries(Minimizer_NLOPT INTERFACE Minimizer) + +if(TARGET NLopt::nlopt) + target_link_libraries(Minimizer_NLOPT INTERFACE NLopt::nlopt) +else() + target_link_libraries(Minimizer_NLOPT INTERFACE NLopt::nlopt_cxx) +endif() + +target_include_directories( + Minimizer_NLOPT INTERFACE ${BSMPT_SOURCE_DIR}/include + ${BSMPT_BINARY_DIR}/include) +target_include_directories(Minimizer_NLOPT + INTERFACE ${BSMPT_SOURCE_DIR}/include) +target_compile_features(Minimizer_NLOPT INTERFACE cxx_std_17) + +set_property(TARGET Minimizer_NLOPT PROPERTY PUBLIC_HEADER ${header}) + +install(TARGETS Minimizer_NLOPT PUBLIC_HEADER DESTINATION ${suffix}) diff --git a/src/minimizer/MinimizePlane.cpp b/src/minimizer/MinimizePlane.cpp index f0969ceb..9b13e075 100644 --- a/src/minimizer/MinimizePlane.cpp +++ b/src/minimizer/MinimizePlane.cpp @@ -26,7 +26,7 @@ #include -#ifdef libcmaes_FOUND +#ifdef cmaes_FOUND #include #endif @@ -172,7 +172,7 @@ MinimizePlane(const std::vector &basepoint, Minima.push_back(GSLResult.Minimum); } -#ifdef libcmaes_FOUND +#ifdef cmaes_FOUND if (UseMinimizer.UseCMAES and modelPointer->get_nVEV() >= 3) { std::vector startCMAES(params.nVEV - 1); diff --git a/src/minimizer/Minimizer.cpp b/src/minimizer/Minimizer.cpp index 09989da6..cb40e188 100644 --- a/src/minimizer/Minimizer.cpp +++ b/src/minimizer/Minimizer.cpp @@ -24,7 +24,7 @@ #include -#ifdef libcmaes_FOUND +#ifdef cmaes_FOUND #include #endif @@ -69,7 +69,7 @@ MinimizersToUse GetMinimizers(int WhichMinimizer) WhichMinimizer /= 2; bool UseNLopt = (WhichMinimizer % 2 != 0); -#ifndef libcmaes_FOUND +#ifndef cmaes_FOUND UseCMAES = false; #endif @@ -153,7 +153,7 @@ Minimize_gen_all(const std::shared_ptr &modelPointer, } } } -#ifdef libcmaes_FOUND +#ifdef cmaes_FOUND std::thread thread_CMAES; LibCMAES::LibCMAESReturn LibCMAES; if (UseMinimizer.UseCMAES) @@ -210,7 +210,7 @@ Minimize_gen_all(const std::shared_ptr &modelPointer, } #endif -#ifdef libcmaes_FOUND +#ifdef cmaes_FOUND if (UseMultithreading and thread_CMAES.joinable()) { Logger::Write(LoggingLevel::MinimizerDetailed, "Waiting for CMAES Thread"); diff --git a/src/minimum_tracer/CMakeLists.txt b/src/minimum_tracer/CMakeLists.txt index fa45ce75..70fbcbe9 100644 --- a/src/minimum_tracer/CMakeLists.txt +++ b/src/minimum_tracer/CMakeLists.txt @@ -3,13 +3,19 @@ # # SPDX-License-Identifier: GPL-3.0-or-later -set(header_path "${BSMPT_SOURCE_DIR}/include/BSMPT/minimum_tracer") +set(suffix "include/BSMPT/minimum_tracer") +set(header_path "${BSMPT_SOURCE_DIR}/${suffix}") set(header ${header_path}/minimum_tracer.h) set(src minimum_tracer.cpp) -add_library(MinimumTracer ${header} ${src}) +add_library(MinimumTracer STATIC ${header} ${src}) target_link_libraries(MinimumTracer PUBLIC Eigen3::Eigen GSL::gsl Minimizer Utility) + target_include_directories(MinimumTracer PUBLIC ${BSMPT_SOURCE_DIR}/include) -target_compile_features(MinimumTracer PUBLIC cxx_std_14) +target_compile_features(MinimumTracer PUBLIC cxx_std_17) + +set_property(TARGET MinimumTracer PROPERTY PUBLIC_HEADER ${header}) + +install(TARGETS MinimumTracer PUBLIC_HEADER DESTINATION ${suffix}) diff --git a/src/models/CMakeLists.txt b/src/models/CMakeLists.txt index 26ab76f8..f70d1402 100644 --- a/src/models/CMakeLists.txt +++ b/src/models/CMakeLists.txt @@ -3,7 +3,9 @@ # # SPDX-License-Identifier: GPL-3.0-or-later -set(header_path "${BSMPT_SOURCE_DIR}/include/BSMPT/models") +set(suffix "include/BSMPT/models") +set(header_path "${BSMPT_SOURCE_DIR}/${suffix}") + set(header ${header_path}/SMparam.h ${header_path}/ModelTestfunctions.h @@ -33,7 +35,7 @@ set(src # Here you can add your new model ClassTemplate.cpp) -add_library(Models ${header} ${src}) +add_library(Models STATIC ${header} ${src}) target_link_libraries(Models PUBLIC GSL::gsl Eigen3::Eigen Minimizer ThermalFunctions Utility) target_include_directories(Models PUBLIC ${BSMPT_SOURCE_DIR}/include) @@ -41,3 +43,7 @@ target_compile_features(Models PUBLIC cxx_std_17) # Include code-coverage settings: target_link_libraries(Models PUBLIC # coverage_config) + +set_property(TARGET Models PROPERTY PUBLIC_HEADER ${header}) + +install(TARGETS Models PUBLIC_HEADER DESTINATION ${suffix}) diff --git a/src/models/IncludeAllModels.cpp b/src/models/IncludeAllModels.cpp index 0fd8dcb1..7ea1dcb6 100644 --- a/src/models/IncludeAllModels.cpp +++ b/src/models/IncludeAllModels.cpp @@ -75,37 +75,6 @@ ModelIDs getModel(const std::string &s) return ModelIDs::NotSet; } -std::unordered_map InvertModelNames() -{ - std::unordered_map IMN; - for (const auto &el : ModelNames) - { - auto success = IMN.emplace(el.second, el.first); - if (not success.second) - { - throw std::runtime_error( - "\nERROR: The same ModelID is assigned for two different models.\n"); - } - } - return IMN; -} - } // namespace ModelID -void ShowInputError() -{ - std::stringstream ss; - ss << "The chosen Method for the thermal mass corrections is "; - if (C_UseParwani) - ss << "Parwani "; - else - ss << "Arnold Espinosa\n"; - ss << "The implemented models are " << std::endl; - for (auto entry : ModelID::ModelNames) - { - ss << entry.first << std::endl; - } - Logger::Write(LoggingLevel::Default, ss.str()); -} - } // namespace BSMPT diff --git a/src/models/ModelTestfunctions.cpp b/src/models/ModelTestfunctions.cpp index ce975917..edca9bad 100644 --- a/src/models/ModelTestfunctions.cpp +++ b/src/models/ModelTestfunctions.cpp @@ -446,7 +446,8 @@ TestResults CheckTreeLevelMin(const Class_Potential_Origin &point, point.SMConstants, CheckVector, start, - WhichMinimizer); + WhichMinimizer, + false); std::string prsize_tline1 = "The given VEV configuration at tree-level is : "; std::string prsize_tline2 = "The calculated VEV configuration at tree-level is : "; diff --git a/src/transition_tracer/CMakeLists.txt b/src/transition_tracer/CMakeLists.txt index 34e0ce89..0317d3ec 100644 --- a/src/transition_tracer/CMakeLists.txt +++ b/src/transition_tracer/CMakeLists.txt @@ -3,7 +3,9 @@ # # SPDX-License-Identifier: GPL-3.0-or-later -set(header_path "${BSMPT_SOURCE_DIR}/include/BSMPT/transition_tracer") +set(suffix "include/BSMPT/transition_tracer") +set(header_path "${BSMPT_SOURCE_DIR}/${suffix}") + set(header ${header_path}/transition_tracer.h) set(src transition_tracer.cpp) @@ -12,3 +14,7 @@ add_library(TransitionTracer ${header} ${src}) target_link_libraries(TransitionTracer PUBLIC MinimumTracer BounceSolution GW) target_include_directories(TransitionTracer PUBLIC ${BSMPT_SOURCE_DIR}/include) target_compile_features(TransitionTracer PUBLIC cxx_std_14) + +set_property(TARGET TransitionTracer PROPERTY PUBLIC_HEADER ${header}) + +install(TARGETS TransitionTracer PUBLIC_HEADER DESTINATION ${suffix}) diff --git a/src/utility/CMakeLists.txt b/src/utility/CMakeLists.txt index 43b1036b..cebde8aa 100644 --- a/src/utility/CMakeLists.txt +++ b/src/utility/CMakeLists.txt @@ -3,13 +3,18 @@ # # SPDX-License-Identifier: GPL-3.0-or-later -set(header_path "${BSMPT_SOURCE_DIR}/include/BSMPT/utility") +set(suffix "include/BSMPT/utility") +set(header_path "${BSMPT_SOURCE_DIR}/${suffix}") set(header - ${header_path}/utility.h ${header_path}/Logger.h ${header_path}/parser.h + ${header_path}/utility.h + ${header_path}/Logger.h + ${header_path}/parser.h ${header_path}/const_velocity_spline.h - ${header_path}/NumericalDerivatives.h) + ${header_path}/NumericalDerivatives.h + ${header_path}/ModelIDs.h + ${header_path}/settings.h) set(src utility.cpp Logger.cpp parser.cpp const_velocity_spline.cpp - NumericalDerivatives.cpp) + NumericalDerivatives.cpp ModelIDs.cpp) add_library(Utility ${header} ${src}) target_include_directories(Utility PUBLIC ${BSMPT_SOURCE_DIR}/include ${BSMPT_BINARY_DIR}/include) @@ -22,4 +27,8 @@ if(nlohmann_json_FOUND) target_link_libraries(Utility PRIVATE nlohmann_json::nlohmann_json) endif() -target_link_libraries(Utility PUBLIC ASCIIPlotter Spline GSL::gsl) +target_link_libraries(Utility PUBLIC ASCIIPlotter Spline GSL::gsl BSMPT_Config) + +set_property(TARGET Utility PROPERTY PUBLIC_HEADER ${header}) + +install(TARGETS Utility PUBLIC_HEADER DESTINATION ${suffix}) diff --git a/src/utility/ModelIDs.cpp b/src/utility/ModelIDs.cpp new file mode 100644 index 00000000..3b1c925f --- /dev/null +++ b/src/utility/ModelIDs.cpp @@ -0,0 +1,60 @@ +#include +#include +#include +#include +#include +#include // for runtime_error + +namespace BSMPT +{ +namespace ModelID +{ + +std::unordered_map InvertModelNames() +{ + std::unordered_map IMN; + for (const auto &el : ModelNames) + { + auto success = IMN.emplace(el.second, el.first); + if (not success.second) + { + throw std::runtime_error( + "\nERROR: The same ModelID is assigned for two different models.\n"); + } + } + return IMN; +} + +} // namespace ModelID + +void ShowInputError() +{ + std::stringstream ss; + ss << "The chosen Method for the thermal mass corrections is "; + if (C_UseParwani) + ss << "Parwani "; + else + ss << "Arnold Espinosa\n"; + ss << "The implemented models are " << std::endl; + for (auto entry : ModelID::ModelNames) + { + ss << entry.first << std::endl; + } + Logger::Write(LoggingLevel::Default, ss.str()); +} + +std::ostream &operator<<(std::ostream &os, const ModelID::ModelIDs &Model) +{ + static auto IMN = BSMPT::ModelID::InvertModelNames(); + os << IMN.at(Model); + return os; +} + +std::string ModelIDToString(const ModelID::ModelIDs &Model) +{ + std::stringstream ss; + ss << Model; + return ss.str(); +} + +} // namespace BSMPT \ No newline at end of file diff --git a/src/utility/asciiplotter/CMakeLists.txt b/src/utility/asciiplotter/CMakeLists.txt index 9c295266..b675ace7 100644 --- a/src/utility/asciiplotter/CMakeLists.txt +++ b/src/utility/asciiplotter/CMakeLists.txt @@ -3,10 +3,12 @@ # # SPDX-License-Identifier: GPL-3.0-or-later -set(header_path "${BSMPT_SOURCE_DIR}/include/BSMPT/utility/asciiplotter") +set(suffix "include/BSMPT/utility/asciiplotter") +set(header_path "${BSMPT_SOURCE_DIR}/${suffix}") set(header ${header_path}/asciiplotter.h) set(src asciiplotter.cpp) add_library(ASCIIPlotter ${header} ${src}) +set_property(TARGET ASCIIPlotter PROPERTY PUBLIC_HEADER ${header}) target_include_directories(ASCIIPlotter PUBLIC ${BSMPT_SOURCE_DIR}/include ${BSMPT_BINARY_DIR}/include) if(Boost_FOUND) @@ -17,3 +19,5 @@ target_compile_features(ASCIIPlotter PUBLIC cxx_std_17) if(nlohmann_json_FOUND) target_link_libraries(ASCIIPlotter PRIVATE nlohmann_json::nlohmann_json) endif() + +install(TARGETS ASCIIPlotter PUBLIC_HEADER DESTINATION ${suffix}) diff --git a/src/utility/asciiplotter/asciiplotter.cpp b/src/utility/asciiplotter/asciiplotter.cpp index 10651315..50a71c0e 100644 --- a/src/utility/asciiplotter/asciiplotter.cpp +++ b/src/utility/asciiplotter/asciiplotter.cpp @@ -26,7 +26,9 @@ SOFTWARE. using namespace std; -int max(vector data) +namespace +{ +int max(const vector &data) { int xmax = data[0]; for (std::size_t i = 1; i < sizeof(data); i++) @@ -39,7 +41,7 @@ int max(vector data) return xmax; } -int min(vector data) +int min(const vector &data) { int xmin = data[0]; for (std::size_t i = 1; i < data.size(); i++) @@ -52,7 +54,7 @@ int min(vector data) return xmin; } -double max(vector data) +double max(const vector &data) { double xmax = data[0]; for (std::size_t i = 1; i < data.size(); i++) @@ -65,7 +67,7 @@ double max(vector data) return xmax; } -double min(vector data) +double min(const vector &data) { double xmin = data[0]; for (std::size_t i = 1; i < data.size(); i++) @@ -169,6 +171,7 @@ resample(vector xdata, vector ydata, int newlength) } } +} // namespace AsciiPlotter::AsciiPlotter() { _title = ""; diff --git a/src/utility/parser.cpp b/src/utility/parser.cpp index 2f838bb4..3ec6f5f1 100644 --- a/src/utility/parser.cpp +++ b/src/utility/parser.cpp @@ -5,6 +5,7 @@ #include #include +#include #include #include #include diff --git a/src/utility/spline/CMakeLists.txt b/src/utility/spline/CMakeLists.txt index 1b630dc8..a977c4af 100644 --- a/src/utility/spline/CMakeLists.txt +++ b/src/utility/spline/CMakeLists.txt @@ -3,7 +3,9 @@ # # SPDX-License-Identifier: GPL-3.0-or-later -set(header_path "${BSMPT_SOURCE_DIR}/include/BSMPT/utility/spline") +set(suffix "include/BSMPT/utility/spline") +set(header_path "${BSMPT_SOURCE_DIR}/${suffix}") + set(header ${header_path}/spline.h) set(src spline.cpp) add_library(Spline ${header} ${src}) @@ -19,3 +21,7 @@ if(nlohmann_json_FOUND) endif() target_compile_definitions(Spline PRIVATE _USE_MATH_DEFINES) + +set_property(TARGET Spline PROPERTY PUBLIC_HEADER ${header}) + +install(TARGETS Spline PUBLIC_HEADER DESTINATION ${suffix}) diff --git a/src/utility/utility.cpp b/src/utility/utility.cpp index 300066a8..402c09ba 100644 --- a/src/utility/utility.cpp +++ b/src/utility/utility.cpp @@ -16,13 +16,6 @@ namespace BSMPT { -std::ostream &operator<<(std::ostream &os, const ModelID::ModelIDs &Model) -{ - static auto IMN = BSMPT::ModelID::InvertModelNames(); - os << IMN.at(Model); - return os; -} - std::vector split(const std::string &str, char delimiter) { // Using str in a string stream @@ -36,13 +29,6 @@ std::vector split(const std::string &str, char delimiter) return res; } -std::string ModelIDToString(const ModelID::ModelIDs &Model) -{ - std::stringstream ss; - ss << Model; - return ss.str(); -} - bool StringStartsWith(const std::string &str, const std::string &prefix) { return str.size() >= prefix.size() and str.find(prefix) == 0; diff --git a/standalone/CMakeLists.txt b/standalone/CMakeLists.txt index 3f787f0b..ad87674f 100644 --- a/standalone/CMakeLists.txt +++ b/standalone/CMakeLists.txt @@ -3,27 +3,31 @@ # # SPDX-License-Identifier: GPL-3.0-or-later -set(STANDALONE_DIR ${CMAKE_CURRENT_SOURCE_DIR}) -file(GLOB SOURCE_FILES "*.cpp" CONFIURE_DEPENDS) +if(BSMPTBuildExecutables) -foreach(file_path ${SOURCE_FILES}) - get_filename_component(filename "${file_path}" NAME) - string(REPLACE ".cpp" "" filename "${filename}") - add_executable("${filename}" "${file_path}") - target_link_libraries( - "${filename}" - PRIVATE Minimizer - MinimumTracer - Models - Utility - TestCompares - ThermalFunctions - BounceSolution - TransitionTracer - GW) - set_target_properties( - "${filename}" PROPERTIES RUNTIME_OUTPUT_DIRECTORY - "${CMAKE_BINARY_DIR}/bin/standalone") + set(STANDALONE_DIR ${CMAKE_CURRENT_SOURCE_DIR}) + file(GLOB SOURCE_FILES "*.cpp" CONFIURE_DEPENDS) - target_compile_features("${filename}" PUBLIC cxx_std_14) -endforeach() + foreach(file_path ${SOURCE_FILES}) + get_filename_component(filename "${file_path}" NAME) + string(REPLACE ".cpp" "" filename "${filename}") + add_executable("${filename}" "${file_path}") + target_link_libraries( + "${filename}" + PRIVATE Minimizer + MinimumTracer + Models + Utility + TestCompares + ThermalFunctions + BounceSolution + TransitionTracer + GW) + set_target_properties( + "${filename}" PROPERTIES RUNTIME_OUTPUT_DIRECTORY + "${CMAKE_BINARY_DIR}/bin/standalone") + + target_compile_features("${filename}" PUBLIC cxx_std_14) + endforeach() + +endif(BSMPTBuildExecutables) diff --git a/test_package/.vscode/launch.json b/test_package/.vscode/launch.json new file mode 100644 index 00000000..b2fa92e2 --- /dev/null +++ b/test_package/.vscode/launch.json @@ -0,0 +1,33 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "name": "(gdb) Launch", + "type": "cppdbg", + "request": "launch", + "program": "${workspaceFolder}/build/linux-x86_64-release/example", + "args": [], + "stopAtEntry": false, + "cwd": "${fileDirname}", + "environment": [], + "externalConsole": false, + "MIMode": "gdb", + "setupCommands": [ + { + "description": "Enable pretty-printing for gdb", + "text": "-enable-pretty-printing", + "ignoreFailures": true + }, + { + "description": "Set Disassembly Flavor to Intel", + "text": "-gdb-set disassembly-flavor intel", + "ignoreFailures": true + } + ] + } + + ] +} \ No newline at end of file diff --git a/test_package/CMakeLists.txt b/test_package/CMakeLists.txt new file mode 100644 index 00000000..95d11b67 --- /dev/null +++ b/test_package/CMakeLists.txt @@ -0,0 +1,27 @@ +cmake_minimum_required(VERSION 3.23) +project(PackageTest CXX) + +find_package(BSMPT CONFIG REQUIRED) + +add_compile_options( + $<$:/permissive-> + $<$,$>:/bigobj> + $<$:/w44101> + $<$,$>:/Ox>) + +add_executable(example src/example.cpp) +target_link_libraries(example BSMPT::Utility BSMPT::BounceSolution + BSMPT::Models BSMPT::Minimizer) + +include(../tools/cmake/CompilerOptions.cmake) + +add_compile_options( + $<$:-DCOMPILEDEBUG=true> + $<$,$,$>:-pedantic> + $<$,$,$>:-Wall> + $<$,$,$>:-Wextra> + $<$,$,$>:-Wshadow> + $<$,$,$,$>>:-Wmissing-declarations> + $<$,$,$,$>>:-Wmissing-include-dirs> + $<$,$,$,$>>:-O3> +) \ No newline at end of file diff --git a/test_package/conanfile.py b/test_package/conanfile.py new file mode 100644 index 00000000..4c065a48 --- /dev/null +++ b/test_package/conanfile.py @@ -0,0 +1,29 @@ + + +import os + +from conan import ConanFile +from conan.tools.cmake import CMake, cmake_layout +from conan.tools.build import can_run + + +class helloTestConan(ConanFile): + settings = "os", "compiler", "build_type", "arch" + generators = "CMakeDeps", "CMakeToolchain" + + def requirements(self): + self.requires(self.tested_reference_str) + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def layout(self): + cmake_layout(self) + + def test(self): + if can_run(self): + cmd = os.path.join(self.cpp.build.bindir, "example") + self.run(cmd, env="conanrun") + diff --git a/test_package/src/example.cpp b/test_package/src/example.cpp new file mode 100644 index 00000000..6c1a093b --- /dev/null +++ b/test_package/src/example.cpp @@ -0,0 +1,36 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +int main() +{ + using namespace BSMPT; + Logger::Disable(); + std::shared_ptr testModel = + ModelID::FChoose(ModelID::ModelIDs::C2HDM, GetSMConstants()); + Minimizer::CalcWhichMinimizer(); + + const std::vector example_point_C2HDM{/* lambda_1 = */ 3.29771, + /* lambda_2 = */ 0.274365, + /* lambda_3 = */ 4.71019, + /* lambda_4 = */ -2.23056, + /* Re(lambda_5) = */ -2.43487, + /* Im(lambda_5) = */ 0.124948, + /* Re(m_{12}^2) = */ 2706.86, + /* tan(beta) = */ 4.64487, + /* Yukawa Type = */ 1}; + + testModel->initModel(example_point_C2HDM); + + std::vector check; + std::vector start(0, 8); + auto result = Minimizer::Minimize_gen_all(testModel, 0, check, start, BSMPT::Minimizer::WhichMinimizerDefault, false); + std::cout << "result = " << result << std::endl; +} diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index f0000eaa..3abe01ac 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -21,4 +21,4 @@ endif() add_subdirectory(catcheventlistener) add_subdirectory(GenerateTestCompares) add_subdirectory(unittests) -add_subdirectory(benchmarks) +# add_subdirectory(benchmarks) diff --git a/tests/unittests/CMakeLists.txt b/tests/unittests/CMakeLists.txt index 0b380fa1..12040f3f 100644 --- a/tests/unittests/CMakeLists.txt +++ b/tests/unittests/CMakeLists.txt @@ -5,7 +5,7 @@ set(TESTDIR ${CMAKE_CURRENT_SOURCE_DIR}) -file(GLOB SOURCE_FILES "Test-*.cpp" CONFIURE_DEPENDS) +file(GLOB SOURCE_FILES "Test-c2hdm.cpp" CONFIURE_DEPENDS) add_executable(GenericTests ${SOURCE_FILES}) target_link_libraries( GenericTests diff --git a/tools/ModelGeneration/sympy/General2HDM.py b/tools/ModelGeneration/sympy/General2HDM.py index 288da6ad..7dc14770 100644 --- a/tools/ModelGeneration/sympy/General2HDM.py +++ b/tools/ModelGeneration/sympy/General2HDM.py @@ -1,4 +1,4 @@ -from sympy import symbols, Matrix, simplify, I, sqrt, im , conjugate, expand +from sympy import symbols, Matrix, simplify, I, sqrt, im, conjugate, expand from sympy.physics.quantum import Dagger from enum import Enum @@ -7,165 +7,233 @@ class TwoHDMType(Enum): - TypeI=0, - TypeII=1, - Flipped=2, - LeptonSpecific=3 + TypeI = (0,) + TypeII = (1,) + Flipped = (2,) + LeptonSpecific = 3 + Chosen2HDMType = TwoHDMType.TypeI # SM paramters -Cg = symbols('C_g',real=True) -Cgs = symbols('C_gs',real=True) -sigma0 = Matrix([[1,0],[0,1]]) -sigma1 = Matrix([[0,1],[1,0]]) -sigma2 = Matrix([[0,-I],[I,0]]) -sigma3 = Matrix([[1,0],[0,-1]]) -m_electron = symbols('C_MassElectron',real=True) -m_mu = symbols('C_MassMu',real=True) -m_tau = symbols('C_MassTau',real=True) -m_up = symbols('C_MassUp',real=True) -m_charm = symbols('C_MassCharm',real=True) -m_top = symbols('C_MassTop',real=True) -m_down = symbols('C_MassDown',real=True) -m_strange = symbols('C_MassStrange',real=True) -m_bottom = symbols('C_MassBottom',real=True) - +Cg = symbols("C_g", real=True) +Cgs = symbols("C_gs", real=True) +sigma0 = Matrix([[1, 0], [0, 1]]) +sigma1 = Matrix([[0, 1], [1, 0]]) +sigma2 = Matrix([[0, -I], [I, 0]]) +sigma3 = Matrix([[1, 0], [0, -1]]) +m_electron = symbols("C_MassElectron", real=True) +m_mu = symbols("C_MassMu", real=True) +m_tau = symbols("C_MassTau", real=True) +m_up = symbols("C_MassUp", real=True) +m_charm = symbols("C_MassCharm", real=True) +m_top = symbols("C_MassTop", real=True) +m_down = symbols("C_MassDown", real=True) +m_strange = symbols("C_MassStrange", real=True) +m_bottom = symbols("C_MassBottom", real=True) # CKM Matrix -Vud,Vus,Vub,Vcd,Vcs,Vcb,Vtd,Vts,Vtb = symbols('Vud Vus Vub Vcd Vcs Vcb Vtd Vts Vtb') -VCKM = Matrix([[Vud,Vus,Vub],[Vcd,Vcs,Vcb],[Vtd,Vts,Vtb]]) - -#parameters -m11sq, m22sq, Rem12sq, Imm12sq = symbols('m11sq m22sq Rem12sq Imm12sq',real=True) -lambda1 = symbols('lambda1',real=True) -lambda2 = symbols('lambda2',real=True) -lambda3 = symbols('lambda3',real=True) -lambda4 = symbols('lambda4',real=True) -Relambda5 = symbols('Relambda5',real=True) -Imlambda5 = symbols('Imlambda5',real=True) -Relambda6 = symbols('Relambda6',real=True) -Imlambda6 = symbols('Imlambda6',real=True) -Relambda7 = symbols('Relambda7',real=True) -Imlambda7 = symbols('Imlambda7',real=True) - -m12sq = Rem12sq + I *Imm12sq -lambda5 = Relambda5 + I*Imlambda5 -lambda6 = Relambda6 + I*Imlambda6 -lambda7 = Relambda7 + I*Imlambda7 - -params=[lambda1,lambda2,lambda3,lambda4,Relambda5,Imlambda5,Relambda6,Imlambda6,Relambda7,Imlambda7,m11sq,m22sq,Rem12sq,Imm12sq] - -#CT params -dm11sq, dm22sq, dRem12sq, dImm12sq = symbols('dm11sq dm22sq dRem12sq dImm12sq',real=True) -dlambda1 = symbols('dlambda1',real=True) -dlambda2 = symbols('dlambda2',real=True) -dlambda3 = symbols('dlambda3',real=True) -dlambda4 = symbols('dlambda4',real=True) -dRelambda5 = symbols('dRelambda5',real=True) -dImlambda5 = symbols('dImlambda5',real=True) -dRelambda6 = symbols('dRelambda6',real=True) -dImlambda6 = symbols('dImlambda6',real=True) -dRelambda7 = symbols('dRelambda7',real=True) -dImlambda7 = symbols('dImlambda7',real=True) -dparams=[dlambda1,dlambda2,dlambda3,dlambda4,dRelambda5,dImlambda5,dRelambda6,dImlambda6,dRelambda7,dImlambda7,dm11sq,dm22sq,dRem12sq,dImm12sq] - -#VEVs -v1 = symbols('v1', real=True) -v2 = symbols('v2', real=True) -w1 = symbols('w1' , real=True) -w2 = symbols('w2' , real=True) -wCP = symbols('wCP',real=True) -wCB = symbols('wCB',real=True) - -#Higgsfields -rho1,eta1,zeta1,psi1 = symbols('rho1 eta1 zeta1 psi1', real=True) -rho2,eta2,zeta2,psi2 = symbols('rho2 eta2 zeta2 psi2', real=True) -Higgsfields=[rho1,eta1,rho2,eta2,zeta1,psi1,zeta2,psi2] -CTTadpoles = symbols('dT1:{}'.format(len(Higgsfields)+1),real=True) - -#doublets -phi1 = Matrix([[Higgsfields[0]+I*Higgsfields[1]], [Higgsfields[4]+I*Higgsfields[5]]]) * 1/sqrt(2) -phi2 = Matrix([[Higgsfields[2]+I*Higgsfields[3]], [Higgsfields[6]+I*Higgsfields[7]]]) * 1/sqrt(2) - -#replacements -higgsvevAtZeroTemp = [0,0,0,0,v1,0,v2,0] -higgsVEVAtFiniteTemp = [0,0,wCB, 0, w1, 0, w2, wCP] -zeroTempVEV = [(Higgsfields[i],higgsvevAtZeroTemp[i]) for i in range(len(Higgsfields)) ] -finiteTempVEV = [(Higgsfields[i],higgsVEVAtFiniteTemp[i]) for i in range(len(Higgsfields)) ] -fieldsZero = [(x,0) for x in Higgsfields] - -phi1Sq = simplify((Dagger(phi1)*phi1)[0]) -phi2Sq = simplify((Dagger(phi2)*phi2)[0]) -phi12 = simplify((Dagger(phi1)*phi2)[0]) -phi21 = simplify((Dagger(phi2)*phi1)[0]) +Vud, Vus, Vub, Vcd, Vcs, Vcb, Vtd, Vts, Vtb = symbols( + "Vud Vus Vub Vcd Vcs Vcb Vtd Vts Vtb" +) +VCKM = Matrix([[Vud, Vus, Vub], [Vcd, Vcs, Vcb], [Vtd, Vts, Vtb]]) + +# parameters +m11sq, m22sq, Rem12sq, Imm12sq = symbols("m11sq m22sq Rem12sq Imm12sq", real=True) +lambda1 = symbols("lambda1", real=True) +lambda2 = symbols("lambda2", real=True) +lambda3 = symbols("lambda3", real=True) +lambda4 = symbols("lambda4", real=True) +Relambda5 = symbols("Relambda5", real=True) +Imlambda5 = symbols("Imlambda5", real=True) +Relambda6 = symbols("Relambda6", real=True) +Imlambda6 = symbols("Imlambda6", real=True) +Relambda7 = symbols("Relambda7", real=True) +Imlambda7 = symbols("Imlambda7", real=True) + +m12sq = Rem12sq + I * Imm12sq +lambda5 = Relambda5 + I * Imlambda5 +lambda6 = Relambda6 + I * Imlambda6 +lambda7 = Relambda7 + I * Imlambda7 + +params = [ + lambda1, + lambda2, + lambda3, + lambda4, + Relambda5, + Imlambda5, + Relambda6, + Imlambda6, + Relambda7, + Imlambda7, + m11sq, + m22sq, + Rem12sq, + Imm12sq, +] + +# CT params +dm11sq, dm22sq, dRem12sq, dImm12sq = symbols( + "dm11sq dm22sq dRem12sq dImm12sq", real=True +) +dlambda1 = symbols("dlambda1", real=True) +dlambda2 = symbols("dlambda2", real=True) +dlambda3 = symbols("dlambda3", real=True) +dlambda4 = symbols("dlambda4", real=True) +dRelambda5 = symbols("dRelambda5", real=True) +dImlambda5 = symbols("dImlambda5", real=True) +dRelambda6 = symbols("dRelambda6", real=True) +dImlambda6 = symbols("dImlambda6", real=True) +dRelambda7 = symbols("dRelambda7", real=True) +dImlambda7 = symbols("dImlambda7", real=True) +dparams = [ + dlambda1, + dlambda2, + dlambda3, + dlambda4, + dRelambda5, + dImlambda5, + dRelambda6, + dImlambda6, + dRelambda7, + dImlambda7, + dm11sq, + dm22sq, + dRem12sq, + dImm12sq, +] + +# VEVs +v1 = symbols("v1", real=True) +v2 = symbols("v2", real=True) +w1 = symbols("w1", real=True) +w2 = symbols("w2", real=True) +wCP = symbols("wCP", real=True) +wCB = symbols("wCB", real=True) + +# Higgsfields +rho1, eta1, zeta1, psi1 = symbols("rho1 eta1 zeta1 psi1", real=True) +rho2, eta2, zeta2, psi2 = symbols("rho2 eta2 zeta2 psi2", real=True) +Higgsfields = [rho1, eta1, rho2, eta2, zeta1, psi1, zeta2, psi2] +CTTadpoles = symbols("dT1:{}".format(len(Higgsfields) + 1), real=True) + +# doublets +phi1 = ( + Matrix( + [[Higgsfields[0] + I * Higgsfields[1]], [Higgsfields[4] + I * Higgsfields[5]]] + ) + * 1 + / sqrt(2) +) +phi2 = ( + Matrix( + [[Higgsfields[2] + I * Higgsfields[3]], [Higgsfields[6] + I * Higgsfields[7]]] + ) + * 1 + / sqrt(2) +) + +# replacements +higgsvevAtZeroTemp = [0, 0, 0, 0, v1, 0, v2, 0] +higgsVEVAtFiniteTemp = [0, 0, wCB, 0, w1, 0, w2, wCP] +zeroTempVEV = [(Higgsfields[i], higgsvevAtZeroTemp[i]) for i in range(len(Higgsfields))] +finiteTempVEV = [ + (Higgsfields[i], higgsVEVAtFiniteTemp[i]) for i in range(len(Higgsfields)) +] +fieldsZero = [(x, 0) for x in Higgsfields] + +phi1Sq = simplify((Dagger(phi1) * phi1)[0]) +phi2Sq = simplify((Dagger(phi2) * phi2)[0]) +phi12 = simplify((Dagger(phi1) * phi2)[0]) +phi21 = simplify((Dagger(phi2) * phi1)[0]) phi12Sq = simplify(phi12**2) phi21Sq = simplify(phi21**2) -VHiggsNC = m11sq*phi1Sq+ m22sq * phi2Sq + lambda1/2 * phi1Sq**2 +lambda2/2 * phi2Sq**2 + lambda3*phi1Sq*phi2Sq + lambda4*phi12*phi21 +VHiggsNC = ( + m11sq * phi1Sq + + m22sq * phi2Sq + + lambda1 / 2 * phi1Sq**2 + + lambda2 / 2 * phi2Sq**2 + + lambda3 * phi1Sq * phi2Sq + + lambda4 * phi12 * phi21 +) # We need to expand here otherwise simplify cant handle the simplification well enough -VHiggsHC = expand(-m12sq*phi12 + lambda5/2 *phi12**2 + lambda6*phi1Sq*phi12 + lambda7*phi2Sq*phi12) +VHiggsHC = expand( + -m12sq * phi12 + + lambda5 / 2 * phi12**2 + + lambda6 * phi1Sq * phi12 + + lambda7 * phi2Sq * phi12 +) VHiggs = simplify(VHiggsNC + VHiggsHC + conjugate(VHiggsHC)) if im(VHiggs) != 0: raise Exception("Higgs potential has an imaginary part with " + str(im(VHiggs))) # Generate the model -G2HDM = ModelGenerator.ModelGenerator(params,dparams,CTTadpoles,Higgsfields,VHiggs,zeroTempVEV, finiteTempVEV) - - +G2HDM = ModelGenerator.ModelGenerator( + params, dparams, CTTadpoles, Higgsfields, VHiggs, zeroTempVEV, finiteTempVEV +) # Set Gauge fields -W1, W2, W3, B0 = symbols('W1 W2 W3 B0',real=True) +W1, W2, W3, B0 = symbols("W1 W2 W3 B0", real=True) -Dmu = -I*Cg/2 * (sigma1*W1 + sigma2 * W2 + sigma3*W3) -I*Cgs/2 * sigma0 * B0 -VGauge = simplify(Dagger(Dmu*phi1)*(Dmu*phi1))[0,0] + simplify(Dagger(Dmu*phi2)*(Dmu*phi2))[0,0] +Dmu = ( + -I * Cg / 2 * (sigma1 * W1 + sigma2 * W2 + sigma3 * W3) - I * Cgs / 2 * sigma0 * B0 +) +VGauge = ( + simplify(Dagger(Dmu * phi1) * (Dmu * phi1))[0, 0] + + simplify(Dagger(Dmu * phi2) * (Dmu * phi2))[0, 0] +) # Generate Lepton Potentials -NuL = symbols('veL vmuL vtauL',real=True) -ER = symbols('eR muR tauR', real=True) -EL = symbols('eL muL tauL', real=True) +NuL = symbols("veL vmuL vtauL", real=True) +ER = symbols("eR muR tauR", real=True) +EL = symbols("eL muL tauL", real=True) LepBase = NuL + ER + EL + + def TypeILeptons(): - ye = sqrt(2)*m_electron/v2 - ymu = sqrt(2)*m_mu/v2 - ytau = sqrt(2)*m_tau/v2 + ye = sqrt(2) * m_electron / v2 + ymu = sqrt(2) * m_mu / v2 + ytau = sqrt(2) * m_tau / v2 - PiLep = Matrix([[ye,0,0],[0,ymu,0],[0,0,ytau]]) + PiLep = Matrix([[ye, 0, 0], [0, ymu, 0], [0, 0, ytau]]) VFLep = 0 for i in range(len(NuL)): for j in range(len(ER)): - VFLep += (NuL[i] * PiLep[i,j] * ER[j])*phi2[0] + VFLep += (NuL[i] * PiLep[i, j] * ER[j]) * phi2[0] for i in range(len(EL)): for j in range(len(ER)): - VFLep += (EL[i] * PiLep[i,j] * ER[j])*phi2[1] + VFLep += (EL[i] * PiLep[i, j] * ER[j]) * phi2[1] VFLep = simplify(VFLep) - return VFLep + return VFLep + def TypeIILeptons(): - ye = sqrt(2)*m_electron/v1 - ymu = sqrt(2)*m_mu/v1 - ytau = sqrt(2)*m_tau/v1 + ye = sqrt(2) * m_electron / v1 + ymu = sqrt(2) * m_mu / v1 + ytau = sqrt(2) * m_tau / v1 - PiLep = Matrix([[ye,0,0],[0,ymu,0],[0,0,ytau]]) + PiLep = Matrix([[ye, 0, 0], [0, ymu, 0], [0, 0, ytau]]) VFLep = 0 for i in range(len(NuL)): for j in range(len(ER)): - VFLep += (NuL[i] * PiLep[i,j] * ER[j])*phi1[1] + VFLep += (NuL[i] * PiLep[i, j] * ER[j]) * phi1[1] for i in range(len(EL)): for j in range(len(ER)): - VFLep += (EL[i] * PiLep[i,j] * ER[j])*phi1[0] + VFLep += (EL[i] * PiLep[i, j] * ER[j]) * phi1[0] VFLep = simplify(VFLep) return VFLep @@ -177,91 +245,99 @@ def TypeIILeptons(): VFLep = TypeIILeptons() - - - - - # Generate Quark Potentials -UL = symbols('uL cL tL', real=True) -DL = symbols('dL sL bL', real=True) -UR = symbols('uR cR tR', real=True) -DR = symbols('dR sR bR', real=True) +UL = symbols("uL cL tL", real=True) +DL = symbols("dL sL bL", real=True) +UR = symbols("uR cR tR", real=True) +DR = symbols("dR sR bR", real=True) QuarkBase = UR + DR + UL + DL + def TypeIQuarks(): - yb = sqrt(2)*m_bottom/v2 - yc = sqrt(2)*m_charm/v2 - yd = sqrt(2)*m_down/v2 - ys = sqrt(2)*m_strange/v2 - yt = sqrt(2)*m_top/v2 - yu = sqrt(2)*m_up/v2 + yb = sqrt(2) * m_bottom / v2 + yc = sqrt(2) * m_charm / v2 + yd = sqrt(2) * m_down / v2 + ys = sqrt(2) * m_strange / v2 + yt = sqrt(2) * m_top / v2 + yu = sqrt(2) * m_up / v2 - DownCoupling = Matrix([[yd,0,0],[0,ys,0],[0,0,yb]]) - UpCoupling = Matrix([[yu,0,0],[0,yc,0],[0,0,yt]]) + DownCoupling = Matrix([[yd, 0, 0], [0, ys, 0], [0, 0, yb]]) + UpCoupling = Matrix([[yu, 0, 0], [0, yc, 0], [0, 0, yt]]) ULVector = Matrix([[x] for x in UL]) DLVector = Matrix([[x] for x in DL]) URVector = Matrix([[x] for x in UR]) DRVector = Matrix([[x] for x in DR]) - phiUp = phi2 + phiUp = phi2 phiDown = phi2 VQuark = ULVector.transpose() * VCKM * DownCoupling * DRVector * phiDown[0] - VQuark+= DLVector.transpose() * DownCoupling * DRVector * phiDown[1] + VQuark += DLVector.transpose() * DownCoupling * DRVector * phiDown[1] VQuark += ULVector.transpose() * UpCoupling * URVector * phiUp[1].conjugate() - VQuark+= -DLVector.transpose() * Dagger(VCKM)*UpCoupling*URVector*phiUp[0].conjugate() - VQuark = simplify(VQuark[0,0]) + VQuark += ( + -DLVector.transpose() + * Dagger(VCKM) + * UpCoupling + * URVector + * phiUp[0].conjugate() + ) + VQuark = simplify(VQuark[0, 0]) return VQuark + def TypeIIQuarks(): - yb = sqrt(2)*m_bottom/v1 - yd = sqrt(2)*m_down/v1 - ys = sqrt(2)*m_strange/v1 + yb = sqrt(2) * m_bottom / v1 + yd = sqrt(2) * m_down / v1 + ys = sqrt(2) * m_strange / v1 - yt = sqrt(2)*m_top/v2 - yu = sqrt(2)*m_up/v2 - yc = sqrt(2)*m_charm/v2 + yt = sqrt(2) * m_top / v2 + yu = sqrt(2) * m_up / v2 + yc = sqrt(2) * m_charm / v2 - DownCoupling = Matrix([[yd,0,0],[0,ys,0],[0,0,yb]]) - UpCoupling = Matrix([[yu,0,0],[0,yc,0],[0,0,yt]]) + DownCoupling = Matrix([[yd, 0, 0], [0, ys, 0], [0, 0, yb]]) + UpCoupling = Matrix([[yu, 0, 0], [0, yc, 0], [0, 0, yt]]) ULVector = Matrix([[x] for x in UL]) DLVector = Matrix([[x] for x in DL]) URVector = Matrix([[x] for x in UR]) DRVector = Matrix([[x] for x in DR]) - phiUp = phi2 + phiUp = phi2 phiDown = phi1 VQuark = ULVector.transpose() * VCKM * DownCoupling * DRVector * phiDown[0] - VQuark+= DLVector.transpose() * DownCoupling * DRVector * phiDown[1] + VQuark += DLVector.transpose() * DownCoupling * DRVector * phiDown[1] VQuark += ULVector.transpose() * UpCoupling * URVector * phiUp[1].conjugate() - VQuark+= -DLVector.transpose() * Dagger(VCKM)*UpCoupling*URVector*phiUp[0].conjugate() - VQuark = simplify(VQuark[0,0]) + VQuark += ( + -DLVector.transpose() + * Dagger(VCKM) + * UpCoupling + * URVector + * phiUp[0].conjugate() + ) + VQuark = simplify(VQuark[0, 0]) return VQuark + if Chosen2HDMType == TwoHDMType.TypeII or Chosen2HDMType == TwoHDMType.Flipped: VQuark = TypeIIQuarks() else: VQuark = TypeIQuarks() - - # Get the tesnors -G2HDM.setGauge([W1,W2,W3,B0],VGauge) +G2HDM.setGauge([W1, W2, W3, B0], VGauge) G2HDM.setLepton(LepBase, VFLep) G2HDM.setQuark(QuarkBase, VQuark) def setAdditionalCTEquations(): - # additional equations to define a unique CT solution point + # additional equations to define a unique CT solution point additionaEquations = [] additionaEquations.append(dlambda4) additionaEquations.append(dRelambda7) @@ -270,16 +346,21 @@ def setAdditionalCTEquations(): return additionaEquations - parser = argparse.ArgumentParser() -parser.add_argument('-s','--show',choices=['ct','tensor','treeSimpl','CTSimpl'],required=True,help='The part of the model to be printed') +parser.add_argument( + "-s", + "--show", + choices=["ct", "tensor", "treeSimpl", "CTSimpl"], + required=True, + help="The part of the model to be printed", +) if __name__ == "__main__": args = parser.parse_args() method = args.show - printCT = method == 'ct' - printTensors = method == 'tensor' + printCT = method == "ct" + printTensors = method == "tensor" if printCT: print("//Begin CT Calculation") @@ -293,8 +374,8 @@ def setAdditionalCTEquations(): if printTensors: G2HDM.printModelToCPP() - if method == 'treeSimpl': + if method == "treeSimpl": G2HDM.printTreeSimplified() - - if method == 'CTSimpl': - G2HDM.printVCTSimplified() \ No newline at end of file + + if method == "CTSimpl": + G2HDM.printVCTSimplified() diff --git a/tools/ModelGeneration/sympy/ModelGenerator.py b/tools/ModelGeneration/sympy/ModelGenerator.py index 9e5fbc39..9c5d8f2d 100644 --- a/tools/ModelGeneration/sympy/ModelGenerator.py +++ b/tools/ModelGeneration/sympy/ModelGenerator.py @@ -1,12 +1,24 @@ -from sympy import symbols, Matrix, diff, simplify, Symbol, linsolve, I, hessian, zeros, expand +from sympy import ( + symbols, + Matrix, + diff, + simplify, + Symbol, + linsolve, + I, + hessian, + zeros, + expand, +) from sympy.printing.cxx import cxxcode + class ModelGenerator: - _params =None - _dparams = None + _params = None + _dparams = None _CTTadpoles = None _HiggsFields = None - _VHiggs =None + _VHiggs = None _nHiggs = 0 _VCT = None _NablaVCW = None @@ -23,8 +35,18 @@ class ModelGenerator: _QuarkFields = [] _nQuarks = 0 _VQuarks = 0 - _CTParVectorOrder=[] - def __init__(self, params, dparams,CTTadpoles,HiggsFields,VHiggs,VEVAtZeroTemp,finiteTempVEV): + _CTParVectorOrder = [] + + def __init__( + self, + params, + dparams, + CTTadpoles, + HiggsFields, + VHiggs, + VEVAtZeroTemp, + finiteTempVEV, + ): self._params = params self._dparams = dparams self._CTTadpoles = CTTadpoles @@ -33,25 +55,46 @@ def __init__(self, params, dparams,CTTadpoles,HiggsFields,VHiggs,VEVAtZeroTemp,f self._nHiggs = len(HiggsFields) self._VEVAtZeroTemp = VEVAtZeroTemp self._calcVCT() - self._NablaVCW = Matrix([[Symbol("NCW[{},{}]".format(i,j),real=True) for j in range(1)] for i in range(self._nHiggs) ]) - self._HessianVCW = Matrix([[Symbol("HCW[{},{}]".format(i,j),real=True) for j in range(self._nHiggs)] for i in range(self._nHiggs) ]) + self._NablaVCW = Matrix( + [ + [Symbol("NCW[{},{}]".format(i, j), real=True) for j in range(1)] + for i in range(self._nHiggs) + ] + ) + self._HessianVCW = Matrix( + [ + [ + Symbol("HCW[{},{}]".format(i, j), real=True) + for j in range(self._nHiggs) + ] + for i in range(self._nHiggs) + ] + ) self._TreeLevelTadpoleReplacement = None self._calcTreeLevelMinimumConditions() self._VEVAtFiniteTemp = finiteTempVEV - counter=0 + counter = 0 for i in range(self._nHiggs): - self._replacementLists['NCW[' + str(i) + ']'] = 'NablaWeinberg(' + str(i) + ')' + self._replacementLists["NCW[" + str(i) + "]"] = ( + "NablaWeinberg(" + str(i) + ")" + ) for j in range(self._nHiggs): - self._replacementLists['HCW[' + str(counter) + ']'] = 'HesseWeinberg(' + str(i) + "," + str(j) + ")" + self._replacementLists["HCW[" + str(counter) + "]"] = ( + "HesseWeinberg(" + str(i) + "," + str(j) + ")" + ) counter += 1 - + for i in range(self._nHiggs): - self._replacementLists['NCW[' + str(i) + ',0]'] = 'NablaWeinberg(' + str(i) + ')' + self._replacementLists["NCW[" + str(i) + ",0]"] = ( + "NablaWeinberg(" + str(i) + ")" + ) for j in range(self._nHiggs): - self._replacementLists['HCW[' + str(i) + ',' + str(j) + "]"] = 'HesseWeinberg(' + str(i) + "," + str(j) + ")" + self._replacementLists["HCW[" + str(i) + "," + str(j) + "]"] = ( + "HesseWeinberg(" + str(i) + "," + str(j) + ")" + ) - def setGauge(self,gaugeFields, VGauge): + def setGauge(self, gaugeFields, VGauge): self._GaugeFields = gaugeFields self._VGauge = VGauge self._nGauge = len(gaugeFields) @@ -67,79 +110,136 @@ def setQuark(self, quarkFields, VQuarks): self._QuarkFields = quarkFields def printVEVOrder(self): - vevCounter=0 + vevCounter = 0 for i in range(self._nHiggs): val = self._VEVAtFiniteTemp[i][1] - if(val != 0): + if val != 0: print("VevOrder.at(" + str(vevCounter) + ") = " + str(i) + ";") - vevCounter+=1 + vevCounter += 1 def _calcTreeLevelMinimumConditions(self): gradient = lambda f, v: Matrix([f]).jacobian(v) - NablaV=simplify(gradient(self._VHiggs,self._HiggsFields).subs(self._VEVAtZeroTemp)) - n,m = NablaV.shape - Equations= [NablaV[i,j] for i in range(n) for j in range(m) if NablaV[i,j] != 0] - self._TreeLevelTadpoleReplacement = linsolve(Equations,self._params) + NablaV = simplify( + gradient(self._VHiggs, self._HiggsFields).subs(self._VEVAtZeroTemp) + ) + n, m = NablaV.shape + Equations = [ + NablaV[i, j] for i in range(n) for j in range(m) if NablaV[i, j] != 0 + ] + self._TreeLevelTadpoleReplacement = linsolve(Equations, self._params) self._TreeLevelTadpoleReplacement = self._TreeLevelTadpoleReplacement.args[0] - def printTreeLevelMinimumConditions(self): for i in range(len(self._params)): - print(self.convertToCPP(self._params[i]) + " = " + self.convertToCPP(self._TreeLevelTadpoleReplacement[i]) + ";") - - def _printTensorsBasic(self,potential,tensorNamePrefix): - fieldsZero = [(x,0) for x in self._HiggsFields] + print( + self.convertToCPP(self._params[i]) + + " = " + + self.convertToCPP(self._TreeLevelTadpoleReplacement[i]) + + ";" + ) + + def _printTensorsBasic(self, potential, tensorNamePrefix): + fieldsZero = [(x, 0) for x in self._HiggsFields] for i in range(self._nHiggs): - val = diff(potential,self._HiggsFields[i]) + val = diff(potential, self._HiggsFields[i]) val = val.subs(fieldsZero) val = simplify(val) if val != 0: - print(tensorNamePrefix+"_L1.at(" + str(i) + ") = " + self.convertToCPP(val) + ";") + print( + tensorNamePrefix + + "_L1.at(" + + str(i) + + ") = " + + self.convertToCPP(val) + + ";" + ) for i in range(self._nHiggs): for j in range(self._nHiggs): - val = diff(potential,self._HiggsFields[i],self._HiggsFields[j]) + val = diff(potential, self._HiggsFields[i], self._HiggsFields[j]) val = val.subs(fieldsZero) val = simplify(val) if val != 0: - print(tensorNamePrefix+"_L2.at(" + str(i) + ").at(" + str(j) + ") = " + self.convertToCPP(val) + ";" ) + print( + tensorNamePrefix + + "_L2.at(" + + str(i) + + ").at(" + + str(j) + + ") = " + + self.convertToCPP(val) + + ";" + ) for i in range(self._nHiggs): for j in range(self._nHiggs): for k in range(self._nHiggs): - val = diff(potential,self._HiggsFields[i],self._HiggsFields[j],self._HiggsFields[k]) + val = diff( + potential, + self._HiggsFields[i], + self._HiggsFields[j], + self._HiggsFields[k], + ) val = val.subs(fieldsZero) val = simplify(val) if val != 0: - print(tensorNamePrefix+"_L3.at(" + str(i) + ").at(" + str(j) + ").at("+ str(k) +") = " + self.convertToCPP(val) + ";" ) + print( + tensorNamePrefix + + "_L3.at(" + + str(i) + + ").at(" + + str(j) + + ").at(" + + str(k) + + ") = " + + self.convertToCPP(val) + + ";" + ) for i in range(self._nHiggs): for j in range(self._nHiggs): for k in range(self._nHiggs): for l in range(self._nHiggs): - val = diff(potential,self._HiggsFields[i],self._HiggsFields[j],self._HiggsFields[k],self._HiggsFields[l]) + val = diff( + potential, + self._HiggsFields[i], + self._HiggsFields[j], + self._HiggsFields[k], + self._HiggsFields[l], + ) val = val.subs(fieldsZero) val = simplify(val) if val != 0: - print(tensorNamePrefix+"_L4.at(" + str(i) + ").at(" + str(j) + ").at("+ str(k) +").at("+ str(l) +") = " + self.convertToCPP(val) + ";" ) - + print( + tensorNamePrefix + + "_L4.at(" + + str(i) + + ").at(" + + str(j) + + ").at(" + + str(k) + + ").at(" + + str(l) + + ") = " + + self.convertToCPP(val) + + ";" + ) def printTensors(self): - self._printTensorsBasic(self._VHiggs,"Curvature_Higgs") + self._printTensorsBasic(self._VHiggs, "Curvature_Higgs") def printCTTensors(self): - self._printTensorsBasic(self._VCT,"Curvature_Higgs_CT") - - - + self._printTensorsBasic(self._VCT, "Curvature_Higgs_CT") def _calcVCT(self): - self._VCT=0 + self._VCT = 0 for i in range(len(self._params)): - self._VCT = self._VCT + self._dparams[i]*diff(self._VHiggs,self._params[i]) + self._VCT = self._VCT + self._dparams[i] * diff( + self._VHiggs, self._params[i] + ) for i in range(len(self._HiggsFields)): - newTerm = self._CTTadpoles[i]*self._HiggsFields[i] + newTerm = self._CTTadpoles[i] * self._HiggsFields[i] self._VCT = self._VCT + newTerm self._VCT = simplify(self._VCT) @@ -147,56 +247,62 @@ def _calcVCT(self): def getVCT(self): return self._VCT - def _CTGetEquations(self): gradient = lambda f, v: Matrix([f]).jacobian(v) - NablaVCT=simplify(gradient(self._VCT,self._HiggsFields).subs(self._VEVAtZeroTemp)) - HessianVCT=simplify(hessian(self._VCT,self._HiggsFields).subs(self._VEVAtZeroTemp)) - - Equations=[] + NablaVCT = simplify( + gradient(self._VCT, self._HiggsFields).subs(self._VEVAtZeroTemp) + ) + HessianVCT = simplify( + hessian(self._VCT, self._HiggsFields).subs(self._VEVAtZeroTemp) + ) + + Equations = [] for i in range(self._nHiggs): val = NablaVCT[i] if val != 0: Equations.append(val + self._NablaVCW[i]) for i in range(self._nHiggs): - for j in range(i,self._nHiggs): - val = HessianVCT[i,j] + for j in range(i, self._nHiggs): + val = HessianVCT[i, j] if val != 0: - Equations.append(val+self._HessianVCW[i,j]) + Equations.append(val + self._HessianVCW[i, j]) return Equations def CTGetMatrixEquation(self): Equations = self._CTGetEquations() - dtParamsCombined=self._dparams+[x for x in self._CTTadpoles] - SysMatrix = zeros(len(Equations),len(dtParamsCombined)) - Target = zeros(len(Equations),1) + dtParamsCombined = self._dparams + [x for x in self._CTTadpoles] + SysMatrix = zeros(len(Equations), len(dtParamsCombined)) + Target = zeros(len(Equations), 1) for i in range(len(Equations)): - Target[i,0] = -Equations[i].subs([(x,0) for x in dtParamsCombined ]) + Target[i, 0] = -Equations[i].subs([(x, 0) for x in dtParamsCombined]) for j in range(len(dtParamsCombined)): - SysMatrix[i,j] = diff(Equations[i],dtParamsCombined[j]) - - + SysMatrix[i, j] = diff(Equations[i], dtParamsCombined[j]) - return SysMatrix,Target + return SysMatrix, Target - def calcCTParams(self,additionalEquations): + def calcCTParams(self, additionalEquations): EquationsFromSystem = self._CTGetEquations() Equations = EquationsFromSystem + additionalEquations - n,m = self._NablaVCW.shape - NVCWList = [self._NablaVCW[i,j] for i in range(n) for j in range(m)] - n,m = self._HessianVCW.shape - HVCWList = [self._HessianVCW[i,j] for i in range(n) for j in range(i,m)] - dtParamsCombined=self._dparams+[x for x in self._CTTadpoles] - extraArgs=NVCWList+HVCWList - combinedParams=dtParamsCombined+extraArgs - solution=linsolve(Equations,combinedParams) - solutionPairs = [(combinedParams[i], solution.args[0][i] ) for i in range(len(dtParamsCombined))] - identitiesPairs = [(combinedParams[i], solution.args[0][i] ) for i in range(len(dtParamsCombined),len(combinedParams))] - + n, m = self._NablaVCW.shape + NVCWList = [self._NablaVCW[i, j] for i in range(n) for j in range(m)] + n, m = self._HessianVCW.shape + HVCWList = [self._HessianVCW[i, j] for i in range(n) for j in range(i, m)] + dtParamsCombined = self._dparams + [x for x in self._CTTadpoles] + extraArgs = NVCWList + HVCWList + combinedParams = dtParamsCombined + extraArgs + solution = linsolve(Equations, combinedParams) + solutionPairs = [ + (combinedParams[i], solution.args[0][i]) + for i in range(len(dtParamsCombined)) + ] + identitiesPairs = [ + (combinedParams[i], solution.args[0][i]) + for i in range(len(dtParamsCombined), len(combinedParams)) + ] for eq in Equations: testedEquation = eq.subs(solutionPairs) @@ -205,11 +311,10 @@ def calcCTParams(self,additionalEquations): if testedEquation != 0: raise Exception("No solution for identities found") - uniqueSolutions = [] nonUniqueSolutions = [] for sol in solutionPairs: - isUnique = True + isUnique = True for par in self._dparams: if sol[1].diff(par) != 0: isUnique = False @@ -218,76 +323,130 @@ def calcCTParams(self,additionalEquations): uniqueSolutions.append(sol) else: nonUniqueSolutions.append(sol) - if len(nonUniqueSolutions) != 0: print("Non unique Solutions") - for lhs,rhs in nonUniqueSolutions: + for lhs, rhs in nonUniqueSolutions: print(str(lhs) + " = " + str(rhs)) - raise ValueError("You have non unique solutions in your system. Please define additional equations to choose among them.") + raise ValueError( + "You have non unique solutions in your system. Please define additional equations to choose among them." + ) - for par,val in solutionPairs: + for par, val in solutionPairs: self._CTParVectorOrder.append(par) return solutionPairs, identitiesPairs def convertToCPP(self, expr, assignTo=None): - II = symbols('II',real=True) + II = symbols("II", real=True) replExpr = "" try: - replExpr = expr.subs(I,II) + replExpr = expr.subs(I, II) except AttributeError: pass - custom_functions = { - 'conjugate': 'conj' - } + custom_functions = {"conjugate": "conj"} - code=cxxcode(replExpr, standard = 'C++17', user_functions = custom_functions, assign_to=assignTo) + code = cxxcode( + replExpr, + standard="C++17", + user_functions=custom_functions, + assign_to=assignTo, + ) strToPrint = str(code) - for key,value in self._replacementLists.items(): - strToPrint=strToPrint.replace(key,value) + for key, value in self._replacementLists.items(): + strToPrint = strToPrint.replace(key, value) return strToPrint - - - def printCTForCPP(self,additionalEquations=[]): + def printCTForCPP(self, additionalEquations=[]): CTPairs, identities = self.calcCTParams(additionalEquations) for par, val in CTPairs: - print("parCT.push_back("+ self.convertToCPP(val) + "); //" + self.convertToCPP(par)) - + print( + "parCT.push_back(" + + self.convertToCPP(val) + + "); //" + + self.convertToCPP(par) + ) def printCTOrder(self): for i in range(len(self._CTParVectorOrder)): par = self._CTParVectorOrder[i] - print(self.convertToCPP(par) + " = par.at(" + str(i) + ");" ) + print(self.convertToCPP(par) + " = par.at(" + str(i) + ");") def printGaugeTensors(self): for a in range(self._nGauge): for b in range(self._nGauge): for i in range(self._nHiggs): for j in range(self._nHiggs): - val = diff(self._VGauge,self._GaugeFields[a], self._GaugeFields[b], self._HiggsFields[i], self._HiggsFields[j] ) + val = diff( + self._VGauge, + self._GaugeFields[a], + self._GaugeFields[b], + self._HiggsFields[i], + self._HiggsFields[j], + ) if val != 0: - print("Curvature_Gauge_G2H2.at(" + str(a) + ").at(" + str(b) + ").at(" + str(i) + ").at(" + str(j) + ") = " + self.convertToCPP(val) + ";") + print( + "Curvature_Gauge_G2H2.at(" + + str(a) + + ").at(" + + str(b) + + ").at(" + + str(i) + + ").at(" + + str(j) + + ") = " + + self.convertToCPP(val) + + ";" + ) def printLeptons(self): for a in range(self._nLeptons): for b in range(self._nLeptons): for i in range(self._nHiggs): - val = diff(self._VLep, self._LeptonFields[a], self._LeptonFields[b], self._HiggsFields[i] ) - if(val != 0): - print("Curvature_Lepton_F2H1.at(" + str(a) + ").at(" + str(b) + ").at(" + str(i) + ") = " + self.convertToCPP(val) + ";") - + val = diff( + self._VLep, + self._LeptonFields[a], + self._LeptonFields[b], + self._HiggsFields[i], + ) + if val != 0: + print( + "Curvature_Lepton_F2H1.at(" + + str(a) + + ").at(" + + str(b) + + ").at(" + + str(i) + + ") = " + + self.convertToCPP(val) + + ";" + ) + def printQuarks(self): for a in range(self._nQuarks): for b in range(self._nQuarks): for i in range(self._nHiggs): - val = diff(self._VQuarks, self._QuarkFields[a], self._QuarkFields[b], self._HiggsFields[i]) + val = diff( + self._VQuarks, + self._QuarkFields[a], + self._QuarkFields[b], + self._HiggsFields[i], + ) if val != 0: - print("Curvature_Quark_F2H1.at(" + str(a) + ").at(" + str(b) + ").at(" + str(i) + ") = " + self.convertToCPP(val) + ";") + print( + "Curvature_Quark_F2H1.at(" + + str(a) + + ").at(" + + str(b) + + ").at(" + + str(i) + + ") = " + + self.convertToCPP(val) + + ";" + ) def printCtrInfo(self): nPar = len(self._params) @@ -297,7 +456,7 @@ def printCtrInfo(self): if lhs != rhs: nPar -= 1 - print("nPar = " + str(nPar) +";" ) + print("nPar = " + str(nPar) + ";") lenCT = len(self._dparams) + len(self._CTTadpoles) print("nParCT = " + str(lenCT) + ";") @@ -358,23 +517,23 @@ def printModelToCPP(self): print("") def printTreeSimplified(self): - vevCounter=0 + vevCounter = 0 for i in range(self._nHiggs): val = self._VEVAtFiniteTemp[i][1] - if(val != 0): + if val != 0: print("double " + self.convertToCPP(val) + " = v.at(" + str(i) + ");") - vevCounter+=1 + vevCounter += 1 VS = simplify(expand(self._VHiggs.subs(self._VEVAtFiniteTemp))) - print(self.convertToCPP(VS,"res")) + print(self.convertToCPP(VS, "res")) def printVCTSimplified(self): - vevCounter=0 + vevCounter = 0 for i in range(self._nHiggs): val = self._VEVAtFiniteTemp[i][1] - if(val != 0): + if val != 0: print("double " + self.convertToCPP(val) + " = v.at(" + str(i) + ");") - vevCounter+=1 + vevCounter += 1 VS = simplify(expand(self._VCT.subs(self._VEVAtFiniteTemp))) - print(self.convertToCPP(VS,"res")) \ No newline at end of file + print(self.convertToCPP(VS, "res")) diff --git a/tools/ModelGeneration/sympy/SM.py b/tools/ModelGeneration/sympy/SM.py index 7d57d262..055193c5 100644 --- a/tools/ModelGeneration/sympy/SM.py +++ b/tools/ModelGeneration/sympy/SM.py @@ -25,10 +25,11 @@ m_bottom = symbols('C_MassBottom',real=True) - # CKM Matrix -Vud,Vus,Vub,Vcd,Vcs,Vcb,Vtd,Vts,Vtb = symbols('Vud Vus Vub Vcd Vcs Vcb Vtd Vts Vtb') -VCKM = Matrix([[Vud,Vus,Vub],[Vcd,Vcs,Vcb],[Vtd,Vts,Vtb]]) +Vud, Vus, Vub, Vcd, Vcs, Vcb, Vtd, Vts, Vtb = symbols( + "Vud Vus Vub Vcd Vcs Vcb Vtd Vts Vtb" +) +VCKM = Matrix([[Vud, Vus, Vub], [Vcd, Vcs, Vcb], [Vtd, Vts, Vtb]]) #parameters muSq, lamb = symbols('muSq lambda', real=True) @@ -38,21 +39,21 @@ dmuSq, dlamb = symbols('dmuSq dlambda', real=True) dparams=[dmuSq,dlamb] -#VEVs -v = symbols('v', real=True) +# VEVs +v = symbols("v", real=True) -#Higgsfields -rho,eta,zeta,psi = symbols('rho eta zeta psi', real=True) -Higgsfields=[rho,eta,zeta,psi] -CTTadpoles = symbols('dT1:{}'.format(len(Higgsfields)+1),real=True) +# Higgsfields +rho, eta, zeta, psi = symbols("rho eta zeta psi", real=True) +Higgsfields = [rho, eta, zeta, psi] +CTTadpoles = symbols("dT1:{}".format(len(Higgsfields) + 1), real=True) -#doublets -phi = Matrix([[rho+I*eta], [zeta+I*psi]]) * 1/sqrt(2) +# doublets +phi = Matrix([[rho + I * eta], [zeta + I * psi]]) * 1 / sqrt(2) -#replacements -zeroTempVEV = [(rho,0),(eta,0),(zeta,v),(psi,0)] +# replacements +zeroTempVEV = [(rho, 0), (eta, 0), (zeta, v), (psi, 0)] finiteTempVEV = zeroTempVEV -fieldsZero = [(x,0) for x in Higgsfields] +fieldsZero = [(x, 0) for x in Higgsfields] phiSq = simplify((Dagger(phi)*phi)[0]) VHiggs = muSq * phiSq + lamb * phiSq**2 @@ -60,28 +61,30 @@ # Set Gauge fields W1, W2, W3, B0 = symbols('W1 W2 W3 B0',real=True) -Dmu = -I*Cg/2 * (sigma1*W1 + sigma2 * W2 + sigma3*W3) -I*Cgs/2 * sigma0 * B0 -VGauge = simplify(Dagger(Dmu*phi)*(Dmu*phi))[0,0] +Dmu = ( + -I * Cg / 2 * (sigma1 * W1 + sigma2 * W2 + sigma3 * W3) - I * Cgs / 2 * sigma0 * B0 +) +VGauge = simplify(Dagger(Dmu * phi) * (Dmu * phi))[0, 0] # Generate Lepton Potentials -NuL = symbols('veL vmuL vtauL',real=True) -ER = symbols('eR muR tauR', real=True) -EL = symbols('eL muL tauL', real=True) +NuL = symbols("veL vmuL vtauL", real=True) +ER = symbols("eR muR tauR", real=True) +EL = symbols("eL muL tauL", real=True) ye = sqrt(2)*m_electron/v ymu = sqrt(2)*m_mu/v ytau = sqrt(2)*m_tau/v -PiLep = Matrix([[ye,0,0],[0,ymu,0],[0,0,ytau]]) +PiLep = Matrix([[ye, 0, 0], [0, ymu, 0], [0, 0, ytau]]) VFLep = 0 for i in range(len(NuL)): for j in range(len(ER)): - VFLep += (NuL[i] * PiLep[i,j] * ER[j])*phi[0] + VFLep += (NuL[i] * PiLep[i, j] * ER[j]) * phi[0] for i in range(len(EL)): for j in range(len(ER)): - VFLep += (EL[i] * PiLep[i,j] * ER[j])*phi[1] + VFLep += (EL[i] * PiLep[i, j] * ER[j]) * phi[1] VFLep = simplify(VFLep) LepBase = symbols('eL eR muL muR tauL tauR veL vmuL vtauL', real=True) @@ -100,8 +103,8 @@ yt = sqrt(2)*m_top/v yu = sqrt(2)*m_up/v -DownCoupling = Matrix([[yd,0,0],[0,ys,0],[0,0,yb]]) -UpCoupling = Matrix([[yu,0,0],[0,yc,0],[0,0,yt]]) +DownCoupling = Matrix([[yd, 0, 0], [0, ys, 0], [0, 0, yb]]) +UpCoupling = Matrix([[yu, 0, 0], [0, yc, 0], [0, 0, yt]]) ULVector = Matrix([[x] for x in UL]) DLVector = Matrix([[x] for x in DL]) @@ -116,21 +119,29 @@ # Generate the model -toyModel = ModelGenerator.ModelGenerator(params,dparams,CTTadpoles,Higgsfields,VHiggs,zeroTempVEV,finiteTempVEV) -toyModel.setGauge([W1,W2,W3,B0],VGauge) +toyModel = ModelGenerator.ModelGenerator( + params, dparams, CTTadpoles, Higgsfields, VHiggs, zeroTempVEV, finiteTempVEV +) +toyModel.setGauge([W1, W2, W3, B0], VGauge) toyModel.setLepton(LepBase, VFLep) toyModel.setQuark(QuarkBase, VQuark) parser = argparse.ArgumentParser() -parser.add_argument('-s','--show',choices=['ct','tensor','treeSimpl','CTSimpl'],required=True,help='The part of the model to be printed') +parser.add_argument( + "-s", + "--show", + choices=["ct", "tensor", "treeSimpl", "CTSimpl"], + required=True, + help="The part of the model to be printed", +) if __name__ == "__main__": args = parser.parse_args() method = args.show - printCT = method == 'ct' - printTensors = method == 'tensor' + printCT = method == "ct" + printTensors = method == "tensor" if printCT: print("//Begin CT Calculation") @@ -144,8 +155,9 @@ if printTensors: toyModel.printModelToCPP() - if method == 'treeSimpl': + if method == "treeSimpl": toyModel.printTreeSimplified() + if method == 'CTSimpl': toyModel.printVCTSimplified() diff --git a/tools/cmake/BSMPTConfig.cmake.in b/tools/cmake/BSMPTConfig.cmake.in deleted file mode 100644 index 18bac8e9..00000000 --- a/tools/cmake/BSMPTConfig.cmake.in +++ /dev/null @@ -1,30 +0,0 @@ -# SPDX-FileCopyrightText: 2021 Philipp Basler, Margarete Mühlleitner and Jonas Müller -# -# SPDX-License-Identifier: GPL-3.0-or-later -include(CMakeFindDependencyMacro) - -list(APPEND CMAKE_MODULE_PATH "@BSMPT_SOURCE_DIR@/tools/cmake") -@CMAES_DEPENDENCY@ - -find_dependency(Eigen3 @EIGEN3_VERSION@) -find_dependency(Boost @Boost_VERSION_STRING@) - - -find_dependency(GSL @GSL_VERSION@) -find_dependency(OpenMP @OpenMP_CXX_VERSION@) -find_dependency(Threads @Threads_VERSION@) - -if(@libcmaes_FOUND@ AND NOT @EXPORT_CMAES@) - find_dependency(libcmaes) -endif(@libcmaes_FOUND@ AND NOT @EXPORT_CMAES@) - -if(@NLopt_FOUND@) - find_dependency(NLopt @NLopt_VERSION@) -endif(@NLopt_FOUND@) - -if(@nlohmann_json_FOUND@) - find_dependency(nlohmann_json @nlohmann_json_VERSION@) -endif() - -# Add the targets file -include("${CMAKE_CURRENT_LIST_DIR}/BSMPTTargets.cmake") diff --git a/tools/cmake/CMAES.cmake b/tools/cmake/CMAES.cmake index 99b34f8c..c820b73a 100644 --- a/tools/cmake/CMAES.cmake +++ b/tools/cmake/CMAES.cmake @@ -15,6 +15,7 @@ if(NOT libcmaes_FOUND) option(LIBCMAES_BUILD_PYTHON OFF) option(LIBCMAES_BUILD_EXAMPLES OFF) option(LIBCMAES_USE_OPENMP OpenMP_FOUND) + option(LIBCMAES_BUILD_SHARED_LIBS OFF) FetchContent_Populate(libcmaes) add_subdirectory(${libcmaes_SOURCE_DIR} ${libcmaes_BINARY_DIR}) include(GenerateExportHeader) @@ -31,3 +32,5 @@ else() set(CodeCoverageExcludesFromOtherPkgs ${CodeCoverageExcludesFromOtherPkgs} "${libcmaes_ROOT_DIR}/*") endif() + +set(cmaes_FOUND ${libcmaes_FOUND}) \ No newline at end of file diff --git a/tools/cmake/CompilerOptions.cmake b/tools/cmake/CompilerOptions.cmake index dd6822ce..112125f0 100644 --- a/tools/cmake/CompilerOptions.cmake +++ b/tools/cmake/CompilerOptions.cmake @@ -3,6 +3,10 @@ # # SPDX-License-Identifier: GPL-3.0-or-later +# add_compile_definitions( +# $<$,$,$>:_GLIBCXX_USE_CXX11_ABI=1> +# ) + add_compile_options( $<$:-DCOMPILEDEBUG=true> $<$,$,$>:-pedantic> @@ -15,6 +19,7 @@ add_compile_options( ) if(BSMPTUseVectorization) +message(FATAL_ERROR "DONT") include(CheckCXXCompilerFlag) check_cxx_compiler_flag("-march=native" _march_native_works)