pyrfl 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (113) hide show
  1. pyrfl-0.1.0/BUILD +24 -0
  2. pyrfl-0.1.0/CMakeLists.txt +105 -0
  3. pyrfl-0.1.0/PKG-INFO +13 -0
  4. pyrfl-0.1.0/README.md +40 -0
  5. pyrfl-0.1.0/cmake/Armadillo.cmake +28 -0
  6. pyrfl-0.1.0/cmake/Ccache.cmake +5 -0
  7. pyrfl-0.1.0/cmake/Doxygen.cmake +51 -0
  8. pyrfl-0.1.0/cmake/GSL.cmake +33 -0
  9. pyrfl-0.1.0/cmake/GitRoot.cmake +6 -0
  10. pyrfl-0.1.0/cmake/LoadGoogleTest.cmake +13 -0
  11. pyrfl-0.1.0/cmake/Please.cmake +8 -0
  12. pyrfl-0.1.0/core/BUILD +41 -0
  13. pyrfl-0.1.0/core/BarrettGlaser/Action.cpp +30 -0
  14. pyrfl-0.1.0/core/BarrettGlaser/Action.hpp +96 -0
  15. pyrfl-0.1.0/core/BarrettGlaser/Hamiltonian.cpp +433 -0
  16. pyrfl-0.1.0/core/BarrettGlaser/Hamiltonian.hpp +136 -0
  17. pyrfl-0.1.0/core/BarrettGlaser/Metropolis.cpp +497 -0
  18. pyrfl-0.1.0/core/BarrettGlaser/Metropolis.hpp +105 -0
  19. pyrfl-0.1.0/core/CMakeLists.txt +48 -0
  20. pyrfl-0.1.0/core/Clifford.cpp +301 -0
  21. pyrfl-0.1.0/core/Clifford.hpp +151 -0
  22. pyrfl-0.1.0/core/DiracOperator.cpp +658 -0
  23. pyrfl-0.1.0/core/DiracOperator.hpp +206 -0
  24. pyrfl-0.1.0/core/GslRng.hpp +70 -0
  25. pyrfl-0.1.0/core/IAction.hpp +30 -0
  26. pyrfl-0.1.0/core/IAlgorithm.hpp +30 -0
  27. pyrfl-0.1.0/core/IDiracOperator.hpp +146 -0
  28. pyrfl-0.1.0/core/IDiracOperatorDerivatives.cpp +216 -0
  29. pyrfl-0.1.0/core/IDiracOperatorDerivatives.hpp +39 -0
  30. pyrfl-0.1.0/core/IRng.hpp +35 -0
  31. pyrfl-0.1.0/core/Simulation.cpp +8 -0
  32. pyrfl-0.1.0/core/Simulation.hpp +56 -0
  33. pyrfl-0.1.0/core/tests/BUILD +19 -0
  34. pyrfl-0.1.0/core/tests/CMakeLists.txt +9 -0
  35. pyrfl-0.1.0/core/tests/performance/CMakeLists.txt +7 -0
  36. pyrfl-0.1.0/core/tests/performance/tBenchmark.cpp +90 -0
  37. pyrfl-0.1.0/core/tests/tAction.cpp +89 -0
  38. pyrfl-0.1.0/core/tests/tClifford.cpp +257 -0
  39. pyrfl-0.1.0/core/tests/tDiracOperator.cpp +181 -0
  40. pyrfl-0.1.0/core/tests/tGslRng.cpp +35 -0
  41. pyrfl-0.1.0/core/tests/tHamiltonian.cpp +56 -0
  42. pyrfl-0.1.0/core/tests/tMetropolis.cpp +37 -0
  43. pyrfl-0.1.0/core/tests/tSimulation.cpp +49 -0
  44. pyrfl-0.1.0/examples/CMakeLists.txt +2 -0
  45. pyrfl-0.1.0/examples/README.md +29 -0
  46. pyrfl-0.1.0/examples/case_studies/BUILD +11 -0
  47. pyrfl-0.1.0/examples/case_studies/CMakeLists.txt +9 -0
  48. pyrfl-0.1.0/examples/case_studies/README.md +12 -0
  49. pyrfl-0.1.0/examples/case_studies/hmc_tuning.cpp +41 -0
  50. pyrfl-0.1.0/examples/case_studies/mauro_thesis_mmc.cpp +33 -0
  51. pyrfl-0.1.0/examples/case_studies/type_13_simulation/BUILD +14 -0
  52. pyrfl-0.1.0/examples/case_studies/type_13_simulation/CMakeLists.txt +8 -0
  53. pyrfl-0.1.0/examples/case_studies/type_13_simulation/EigenvalueRecorder.cpp +107 -0
  54. pyrfl-0.1.0/examples/case_studies/type_13_simulation/EigenvalueRecorder.hpp +42 -0
  55. pyrfl-0.1.0/examples/case_studies/type_13_simulation/Type13Metropolis.cpp +53 -0
  56. pyrfl-0.1.0/examples/cpp/BUILD +8 -0
  57. pyrfl-0.1.0/examples/cpp/CMakeLists.txt +3 -0
  58. pyrfl-0.1.0/examples/cpp/main.cpp +70 -0
  59. pyrfl-0.1.0/examples/python/BUILD +38 -0
  60. pyrfl-0.1.0/examples/python/main.py +58 -0
  61. pyrfl-0.1.0/examples/python/rfl_playground.ipynb +82 -0
  62. pyrfl-0.1.0/legacy/BUILD +18 -0
  63. pyrfl-0.1.0/legacy/include/Cliff.hpp +66 -0
  64. pyrfl-0.1.0/legacy/include/Geom24.hpp +202 -0
  65. pyrfl-0.1.0/legacy/source/CMakeLists.txt +27 -0
  66. pyrfl-0.1.0/legacy/source/HMC.cpp +122 -0
  67. pyrfl-0.1.0/legacy/source/HMC_core.cpp +235 -0
  68. pyrfl-0.1.0/legacy/source/MMC.cpp +90 -0
  69. pyrfl-0.1.0/legacy/source/MMC_core.cpp +140 -0
  70. pyrfl-0.1.0/legacy/source/action.cpp +205 -0
  71. pyrfl-0.1.0/legacy/source/cliff.cpp +275 -0
  72. pyrfl-0.1.0/legacy/source/derivative.cpp +193 -0
  73. pyrfl-0.1.0/legacy/source/hamiltonian.cpp +42 -0
  74. pyrfl-0.1.0/legacy/source/leapfrog.cpp +47 -0
  75. pyrfl-0.1.0/legacy/source/metropolis.cpp +247 -0
  76. pyrfl-0.1.0/legacy/source/misc.cpp +395 -0
  77. pyrfl-0.1.0/legacy/tests/BUILD +18 -0
  78. pyrfl-0.1.0/legacy/tests/CMakeLists.txt +8 -0
  79. pyrfl-0.1.0/legacy/tests/OldCode/HMC/Makefile +106 -0
  80. pyrfl-0.1.0/legacy/tests/OldCode/HMC/duav.cpp +32 -0
  81. pyrfl-0.1.0/legacy/tests/OldCode/HMC/main.cpp +44 -0
  82. pyrfl-0.1.0/legacy/tests/OldCode/action/Makefile +106 -0
  83. pyrfl-0.1.0/legacy/tests/OldCode/action/main.cpp +38 -0
  84. pyrfl-0.1.0/legacy/tests/OldCode/compilation/Makefile +106 -0
  85. pyrfl-0.1.0/legacy/tests/OldCode/compilation/main.cpp +16 -0
  86. pyrfl-0.1.0/legacy/tests/OldCode/delta/Makefile +106 -0
  87. pyrfl-0.1.0/legacy/tests/OldCode/delta/main.cpp +63 -0
  88. pyrfl-0.1.0/legacy/tests/OldCode/derivative/Makefile +106 -0
  89. pyrfl-0.1.0/legacy/tests/OldCode/derivative/in.txt +4 -0
  90. pyrfl-0.1.0/legacy/tests/OldCode/derivative/main.cpp +31 -0
  91. pyrfl-0.1.0/legacy/tests/OldCode/leapfrog/GLOB.log +1000 -0
  92. pyrfl-0.1.0/legacy/tests/OldCode/leapfrog/GLOB.txt +10 -0
  93. pyrfl-0.1.0/legacy/tests/OldCode/leapfrog/Makefile +106 -0
  94. pyrfl-0.1.0/legacy/tests/OldCode/leapfrog/fit.log +36 -0
  95. pyrfl-0.1.0/legacy/tests/OldCode/leapfrog/global.cpp +62 -0
  96. pyrfl-0.1.0/legacy/tests/OldCode/leapfrog/reversibility.cpp +41 -0
  97. pyrfl-0.1.0/legacy/tests/OldCode/omega/Makefile +106 -0
  98. pyrfl-0.1.0/legacy/tests/OldCode/omega/main.cpp +40 -0
  99. pyrfl-0.1.0/legacy/tests/OldCode/optimal/Makefile +106 -0
  100. pyrfl-0.1.0/legacy/tests/OldCode/optimal/main.cpp +44 -0
  101. pyrfl-0.1.0/legacy/tests/action_tests.cpp +75 -0
  102. pyrfl-0.1.0/legacy/tests/clifford.test.cpp +90 -0
  103. pyrfl-0.1.0/legacy/tests/compilation_tests.cpp +113 -0
  104. pyrfl-0.1.0/legacy/tests/delta_tests.cpp +145 -0
  105. pyrfl-0.1.0/legacy/tests/derivative_data.txt +4 -0
  106. pyrfl-0.1.0/legacy/tests/derivative_tests.cpp +114 -0
  107. pyrfl-0.1.0/legacy/tests/geometry.test.cpp +105 -0
  108. pyrfl-0.1.0/pyproject.toml +43 -0
  109. pyrfl-0.1.0/python_bindings/CMakeLists.txt +20 -0
  110. pyrfl-0.1.0/python_bindings/bindings.cpp +48 -0
  111. pyrfl-0.1.0/python_bindings/tests/BUILD +31 -0
  112. pyrfl-0.1.0/python_bindings/tests/integration/test_boundary_safety.py +55 -0
  113. pyrfl-0.1.0/python_bindings/tests/unit/test_core_api.py +54 -0
pyrfl-0.1.0/BUILD ADDED
@@ -0,0 +1,24 @@
1
+ genrule(
2
+ name = "rfl_wheel",
3
+ srcs = [
4
+ "pyproject.toml",
5
+ "CMakeLists.txt",
6
+ "python_bindings/bindings.cpp",
7
+ "python_bindings/CMakeLists.txt",
8
+ # Sub-package source files (exported via wheel_srcs filegroups)
9
+ "//src/RFL/core:wheel_srcs",
10
+ "//src/RFL/legacy:wheel_srcs",
11
+ ] + glob(["cmake/*.cmake"]),
12
+ outs = ["dist"],
13
+ cmd = [
14
+ # Set up build tools in a venv
15
+ "python3 -m venv _venv",
16
+ "source _venv/bin/activate",
17
+ "pip install --quiet --cache-dir /tmp/pip_cache --upgrade pip",
18
+ "pip install --quiet --cache-dir /tmp/pip_cache build scikit-build-core pybind11 cmake ninja",
19
+ # Build the wheel directly into the output directory
20
+ "python -m build --wheel --outdir $OUTS $PKG_DIR",
21
+ ],
22
+ timeout = 1800, # 30 minutes to allow for C++ compilation
23
+ visibility = ["PUBLIC"],
24
+ )
@@ -0,0 +1,105 @@
1
+ cmake_minimum_required(VERSION 3.20...3.31)
2
+
3
+
4
+ project(
5
+ RFL
6
+ VERSION 0.1.0
7
+ DESCRIPTION
8
+ "Random Fuzzy Library (RFL) - A library for Markov Chain Monte Carlo simulations of Finite Random Non-commutative geometries."
9
+ LANGUAGES CXX)
10
+
11
+ set(CMAKE_POSITION_INDEPENDENT_CODE ON)
12
+
13
+ if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME)
14
+ set(CMAKE_CXX_STANDARD 17)
15
+ set(CMAKE_CXX_STANDARD_REQUIRED ON)
16
+ set(CMAKE_CXX_EXTENSIONS OFF)
17
+
18
+ # Nicely supports folders in IDEs
19
+ set_property(GLOBAL PROPERTY USE_FOLDERS ON)
20
+ enable_testing()
21
+
22
+ add_compile_options(-Wall -Wextra -Wpedantic)
23
+ if(NOT SKBUILD)
24
+ add_compile_options(-fsanitize=address)
25
+ add_link_options(-fsanitize=address)
26
+ endif()
27
+ endif()
28
+
29
+ set(CPACK_PROJECT_NAME ${PROJECT_NAME})
30
+ set(CPACK_PROJECT_VERSION ${PROJECT_VERSION})
31
+ include(CPack)
32
+
33
+ # Include ccache to speed up rebuild times.
34
+ list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
35
+ include(Ccache)
36
+
37
+ option(${PROJECT_NAME}_ENABLE_CODE_COVERAGE "Enable code coverage through GCC." ON)
38
+
39
+ # Include Please's output directory
40
+ include(GitRoot)
41
+
42
+ if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME AND NOT SKBUILD)
43
+ include(Doxygen)
44
+ if(DOXYGEN_FOUND)
45
+ doxygen_add_docs(doxygen
46
+ ${PROJECT_SOURCE_DIR}/README.md
47
+ ${PROJECT_SOURCE_DIR}/core
48
+ ${PROJECT_SOURCE_DIR}/examples
49
+ COMMENT "Generate documentation for entire project")
50
+ endif()
51
+ endif()
52
+
53
+ # GSL is included with Armadillo above, but we need more.
54
+ include(Armadillo)
55
+ include(GSL)
56
+ if(NOT SKBUILD)
57
+ include(LoadGoogleTest)
58
+ endif()
59
+
60
+ # Build legacy RFL library
61
+ set(legacy_RFL_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/legacy")
62
+ set(legacy_RFL_INCLUDE_DIR "${legacy_RFL_SOURCE_DIR}/include")
63
+ add_subdirectory(${legacy_RFL_SOURCE_DIR}/source)
64
+
65
+ # Add core RFL library
66
+ set(core_RFL_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/core")
67
+ set(core_RFL_INCLUDE_DIR "${core_RFL_SOURCE_DIR}")
68
+ add_subdirectory(${core_RFL_SOURCE_DIR})
69
+
70
+ # Add aliases for consumers
71
+ add_library(RFL::core ALIAS rfl_core)
72
+ add_library(RFL::rfl ALIAS rfl_core)
73
+ add_library(RFL::legacy ALIAS rfl_legacy)
74
+
75
+ # Add tests if building tests.
76
+ if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME AND NOT SKBUILD)
77
+ add_subdirectory(${legacy_RFL_SOURCE_DIR}/tests)
78
+ endif()
79
+
80
+ if(SKBUILD)
81
+ set(BUILD_PYTHON_BINDINGS_DEFAULT ON)
82
+ else()
83
+ set(BUILD_PYTHON_BINDINGS_DEFAULT OFF)
84
+ endif()
85
+ option(BUILD_PYTHON_BINDINGS "Build Python bindings via pybind11" ${BUILD_PYTHON_BINDINGS_DEFAULT})
86
+ if(BUILD_PYTHON_BINDINGS)
87
+ include(FetchContent)
88
+
89
+ # Fetch carma (NumPy/Armadillo bridge)
90
+ FetchContent_Declare(
91
+ carma
92
+ GIT_REPOSITORY https://github.com/RUrlus/carma.git
93
+ GIT_TAG v0.8.0
94
+ )
95
+
96
+ # Fetch pybind11
97
+ FetchContent_Declare(
98
+ pybind11
99
+ GIT_REPOSITORY https://github.com/pybind/pybind11.git
100
+ GIT_TAG v2.13.1
101
+ )
102
+ FetchContent_MakeAvailable(carma pybind11)
103
+
104
+ add_subdirectory(python_bindings)
105
+ endif()
pyrfl-0.1.0/PKG-INFO ADDED
@@ -0,0 +1,13 @@
1
+ Metadata-Version: 2.2
2
+ Name: pyrfl
3
+ Version: 0.1.0
4
+ Summary: Random Fuzzy Library (RFL) - MCMC simulations of Finite Random Non-commutative geometries
5
+ Author: Paul Druce, Mauro D'Arcangelo
6
+ Requires-Python: >=3.8
7
+ Requires-Dist: numpy>=1.20
8
+ Provides-Extra: test
9
+ Requires-Dist: pytest; extra == "test"
10
+ Provides-Extra: dev
11
+ Requires-Dist: jupyter; extra == "dev"
12
+ Requires-Dist: nbformat; extra == "dev"
13
+
pyrfl-0.1.0/README.md ADDED
@@ -0,0 +1,40 @@
1
+ # RFL Documentation
2
+
3
+ This directory contains the source code for the original RFL library created by Mauro D'arcangelo and its modern
4
+ implementation.
5
+
6
+ The aim is to deprecate Mauro's implementation (Original RFL) for version 1.0 of this project.
7
+ The code will be preserved under a protected branch on this repository.
8
+
9
+ ## Original RFL
10
+
11
+ The source code for the original library is in `./legacy`.
12
+ The library defines two classes: `Cliff` and `Geom24`, defined in `legacy/include/Cliff.hpp` and `legacy/include/Geom24.hpp`,
13
+ respectively.
14
+
15
+ - `Cliff` is responsible for creating the 'gamma matrices' for a specific Clifford module.
16
+ The general way to specify a Clifford module is by setting two positive integers $p$ and $q$.
17
+ - `Geom24` is the main Class for this library. It is responsible for setting up and running the simulation.
18
+
19
+ The original RFL code inherently uses an action of the form:
20
+
21
+ $$S(D) = g_2 \text{Tr}(D^2) + g_4 \text{Tr}(D^4)$$
22
+
23
+ where $g_2$ and $g_4$ are real numbers. This action is the origin of the name of the class `Geom24` as the action
24
+ contains the quadratic ($D^2$) and quartic ($D^4$) traces of the Dirac operator.
25
+
26
+ ## Core RFL
27
+
28
+ The modern implementation of RFL refactors the original RFL source code to make it modular and extensible without compromising
29
+ performance.
30
+ The modern source code is found in `./core`.
31
+
32
+ This refactoring allows for better testing and more flexibility for library users.
33
+ It is constantly being developed, and any improvements or enhancements are welcome. Please leave an issue on the GitHub
34
+ repo.
35
+
36
+ The high performance that Mauro's original implementation strived to develop has been preserved.
37
+ To ensure that this performance does not degrade, a unit test that captures the difference between the original and new
38
+ implementations.
39
+ This test requires that the new implementation is no more than 5% slower to run the same simulation in each
40
+ implementation.
@@ -0,0 +1,28 @@
1
+ # The purpose of this Cmake module is to find the Armadillo library.
2
+ # This library may be installed by the system/user in the standard install
3
+ # location, or it might be installed to a custom location by the build system
4
+ # Please.
5
+ set(LOCAL_ARMADILLO_INSTALL_DIR "${GIT_PROJECT_ROOT}/plz-out/gen/vendors/armadillo-12.6.6/install")
6
+
7
+ # Create local variable which stores the files to search for
8
+ message(DEBUG "Checking for local Armadillo library at ${LOCAL_ARMADILLO_INSTALL_DIR}")
9
+
10
+ if(EXISTS "${LOCAL_ARMADILLO_INSTALL_DIR}/lib/libarmadillo${CMAKE_SHARED_LIBRARY_SUFFIX}"
11
+ OR EXISTS "${LOCAL_ARMADILLO_INSTALL_DIR}/lib/libarmadillo${CMAKE_STATIC_LIBRARY_SUFFIX}")
12
+ message(STATUS "Using local Armadillo library at ${LOCAL_ARMADILLO_INSTALL_DIR}")
13
+ set(ARMADILLO_LIBRARIES "${LOCAL_ARMADILLO_INSTALL_DIR}/lib/libarmadillo${CMAKE_SHARED_LIBRARY_SUFFIX}")
14
+ set(ARMADILLO_INCLUDE_DIRS "${LOCAL_ARMADILLO_INSTALL_DIR}/include")
15
+
16
+ set(ARMADILLO_FOUND TRUE)
17
+ include_directories(${ARMADILLO_INCLUDE_DIRS})
18
+ link_directories(${ARMADILLO_LIBRARIES})
19
+ else()
20
+ message(STATUS "Using system Armadillo library")
21
+ find_package(Armadillo REQUIRED)
22
+ include_directories(${ARMADILLO_INCLUDE_DIRS})
23
+ endif()
24
+
25
+ # If the GSL package is not found, stop with an error
26
+ if(NOT ARMADILLO_FOUND)
27
+ message(FATAL_ERROR "Armadillo library not found")
28
+ endif()
@@ -0,0 +1,5 @@
1
+ find_program(CCACHE_PROGRAM ccache)
2
+ if(CCACHE_PROGRAM)
3
+ set(CMAKE_CXX_COMPILER_LAUNCHER "${CCACHE_PROGRAM}")
4
+ set(CMAKE_CUDA_COMPILER_LAUNCHER "${CCACHE_PROGRAM}") # CMake 3.9+
5
+ endif()
@@ -0,0 +1,51 @@
1
+ find_package(Doxygen OPTIONAL_COMPONENTS dot)
2
+
3
+ if(DOXYGEN_FOUND)
4
+ set(DOXYGEN_GENERATE_HTML YES)
5
+ set(DOXYGEN_HTML_OUTPUT
6
+ ${PROJECT_SOURCE_DIR}/RFL_docs)
7
+ set(DOXYGEN_USE_MDFILE_AS_MAINPAGE
8
+ "${CMAKE_CURRENT_SOURCE_DIR}/README.md")
9
+
10
+ # Settings for Inheritance Diagram etc.
11
+ set(DOXYGEN_EXTRACT_ALL YES)
12
+ set(DOXYGEN_CLASS_DIAGRAMS YES)
13
+ set(DOXYGEN_HIDE_UNDOC_RELATIONS NO)
14
+ set(DOXYGEN_CALL_GRAPH YES)
15
+ set(DOXYGEN_CALLER_GRAPH YES)
16
+ if(DOXYGEN_DOT_FOUND)
17
+ set(DOXYGEN_HAVE_DOT YES)
18
+ endif()
19
+ set(DOXYGEN_CLASS_GRAPH YES)
20
+ set(DOXYGEN_COLLABORATION_GRAPH NO)
21
+ set(DOXYGEN_UML_LOOK YES)
22
+ set(DOXYGEN_UML_LIMIT_NUM_FIELDS 50)
23
+ set(DOXYGEN_TEMPLATE_RELATIONS YES)
24
+ set(DOXYGEN_DOT_GRAPH_MAX_NODES 100)
25
+ set(DOXYGEN_MAX_DOT_GRAPH_DEPTH 0)
26
+ set(DOXYGEN_DOT_TRANSPARENT YES)
27
+ set(DOXYGEN_INTERACTIVE_SVG YES)
28
+ set(DOXYGEN_USE_MATHJAX YES)
29
+ set(DOXYGEN_SOURCE_BROWSER YES)
30
+
31
+ # Exclude tests from documentation
32
+ set(DOXYGEN_EXCLUDE_PATTERNS */tests/*)
33
+ endif()
34
+
35
+
36
+ function(Doxygen input output)
37
+ if (NOT DOXYGEN_FOUND)
38
+ add_custom_target(doxygen COMMAND false
39
+ COMMENT "Doxygen not found")
40
+ return()
41
+ endif()
42
+ set(DOXYGEN_GENERATE_HTML YES)
43
+ set(DOXYGEN_HTML_OUTPUT
44
+ ${PROJECT_BINARY_DIR}/${output})
45
+
46
+
47
+ doxygen_add_docs(${output}
48
+ ${input}
49
+ COMMENT "Generate HTML documentation"
50
+ )
51
+ endfunction()
@@ -0,0 +1,33 @@
1
+ # Set the path to the local GSL installation
2
+ set(LOCAL_GSL_PATH "${GIT_PROJECT_ROOT}/plz-out/gen/vendors/gsl-2.8/install")
3
+
4
+ # Check if the GSL library is available in the local installation path
5
+ message(DEBUG "Checking for local GSL library at ${LOCAL_GSL_PATH}")
6
+
7
+ if(EXISTS "${LOCAL_GSL_PATH}/lib/libgsl${CMAKE_STATIC_LIBRARY_SUFFIX}"
8
+ OR EXISTS "${LOCAL_GSL_PATH}/lib/libgsl${CMAKE_SHARED_LIBRARY_SUFFIX}")
9
+ message(STATUS "Using local GSL library at ${LOCAL_GSL_PATH}")
10
+
11
+ # Set GSL include and library paths
12
+ set(GSL_INCLUDE_DIR "${LOCAL_GSL_PATH}/include")
13
+ set(GSL_LIBRARIES "${LOCAL_GSL_PATH}/lib/libgsl${CMAKE_STATIC_LIBRARY_SUFFIX}")
14
+
15
+ # Set GSL_FOUND to true as the library is locally found
16
+ set(GSL_FOUND TRUE)
17
+
18
+ # Add the GSL include directory to the include path
19
+ include_directories(${GSL_INCLUDE_DIR})
20
+
21
+ # Link the local GSL library
22
+ link_directories(${GSL_LIBRARIES})
23
+ else()
24
+ # Fallback to system GSL library using find_package
25
+ message(STATUS "Using system GSL library")
26
+ find_package(GSL REQUIRED)
27
+ include_directories(${GSL_INCLUDE_DIRS})
28
+ endif()
29
+
30
+ # If the GSL package is not found, stop with an error
31
+ if(NOT GSL_FOUND)
32
+ message(FATAL_ERROR "GSL library not found")
33
+ endif()
@@ -0,0 +1,6 @@
1
+ execute_process(
2
+ COMMAND git rev-parse --show-toplevel
3
+ WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
4
+ OUTPUT_VARIABLE GIT_PROJECT_ROOT
5
+ OUTPUT_STRIP_TRAILING_WHITESPACE
6
+ )
@@ -0,0 +1,13 @@
1
+ # Get GoogleTest
2
+ include(FetchContent)
3
+ FetchContent_Declare(
4
+ googletest
5
+ GIT_REPOSITORY https://github.com/google/googletest.git
6
+ GIT_TAG release-1.12.0)
7
+
8
+ # For Windows: Prevent overriding the parent project's compiler/linker settings
9
+ set(gtest_force_shared_crt
10
+ ON
11
+ CACHE BOOL "" FORCE)
12
+ FetchContent_MakeAvailable(googletest)
13
+ include(GoogleTest)
@@ -0,0 +1,8 @@
1
+ # Set the output directory for vendors
2
+ set(VENDOR_OUTPUT_DIR "${GIT_PROJECT_ROOT}/plz-out/gen/vendors/")
3
+
4
+ # Add the vendor output directory to the CMake prefix path
5
+ list(INSERT CMAKE_PREFIX_PATH 0 "${VENDOR_OUTPUT_DIR}")
6
+
7
+ # Print the CMake prefix path for debugging
8
+ message(STATUS "CMAKE_PREFIX_PATH: ${CMAKE_PREFIX_PATH}")
pyrfl-0.1.0/core/BUILD ADDED
@@ -0,0 +1,41 @@
1
+ cc_library(
2
+ name = "rfl",
3
+ srcs = [
4
+ "BarrettGlaser/Action.cpp",
5
+ "BarrettGlaser/Hamiltonian.cpp",
6
+ "BarrettGlaser/Metropolis.cpp",
7
+ "Clifford.cpp",
8
+ "DiracOperator.cpp",
9
+ "IDiracOperatorDerivatives.cpp",
10
+ "Simulation.cpp",
11
+ ],
12
+ hdrs = [
13
+ "BarrettGlaser/Action.hpp",
14
+ "BarrettGlaser/Hamiltonian.hpp",
15
+ "BarrettGlaser/Metropolis.hpp",
16
+ "Clifford.hpp",
17
+ "DiracOperator.hpp",
18
+ "GslRng.hpp",
19
+ "IAction.hpp",
20
+ "IAlgorithm.hpp",
21
+ "IDiracOperator.hpp",
22
+ "IDiracOperatorDerivatives.hpp",
23
+ "IRng.hpp",
24
+ "Simulation.hpp",
25
+ ],
26
+ includes = [
27
+ "./", # TODO: This is not ideal, I should keep my header files in an include directory which matches what the output will be.
28
+ ],
29
+ linker_flags = [
30
+ "-larmadillo", # Depends on armadillo
31
+ "-lgsl", # Depends on GSL
32
+ ],
33
+ visibility = ["PUBLIC"],
34
+ )
35
+
36
+ # Export source files for the wheel build
37
+ filegroup(
38
+ name = "wheel_srcs",
39
+ srcs = glob(["**/*.cpp", "**/*.hpp", "**/*.h", "**/CMakeLists.txt"]),
40
+ visibility = ["//src/RFL:rfl_wheel"],
41
+ )
@@ -0,0 +1,30 @@
1
+ //
2
+ // Created by Paul Druce on 12/11/2022.
3
+ //
4
+ #include "./Action.hpp"
5
+
6
+ using namespace std;
7
+ using namespace arma;
8
+
9
+ Action::Action(const double g_2) : m_g_2(g_2), m_g_4(1.0) {}
10
+
11
+ Action::Action(const double g_2, const double g_4) : m_g_2(g_2), m_g_4(g_4) {}
12
+
13
+ double Action::calculateSFromDirac(const IDiracOperator& dirac) const {
14
+ const cx_mat dirac_mat = dirac.getDiracMatrix();
15
+ const cx_mat dirac_squared = dirac_mat * dirac_mat;
16
+ const double trace_dirac_squared = trace(dirac_squared).real();
17
+ const double trace_dirac_4 = trace(dirac_squared * dirac_squared).real();
18
+ return m_g_2 * trace_dirac_squared + m_g_4 * trace_dirac_4;
19
+ }
20
+
21
+ double Action::calculateS(const IDiracOperator& dirac) const {
22
+ return m_g_2 * dirac.traceOfDiracSquared() + m_g_4 * dirac.traceOfDirac4();
23
+ }
24
+
25
+ void Action::setParams(const double g_2, const double g_4) {
26
+ this->m_g_2 = g_2;
27
+ this->m_g_4 = g_4;
28
+ }
29
+ void Action::setG4(const double value) { this->m_g_4 = value; }
30
+ void Action::setG2(const double value) { this->m_g_2 = value; }
@@ -0,0 +1,96 @@
1
+ //
2
+ // Created by Paul Druce on 12/11/2022.
3
+ //
4
+
5
+ #ifndef RFL_ACTION_HPP
6
+ #define RFL_ACTION_HPP
7
+ #include "../IAction.hpp"
8
+ #include "../IDiracOperator.hpp"
9
+
10
+ /**
11
+ * @class Action
12
+ *
13
+ * @brief Implements the Barrett-Glaser action \f$ S(D) = g_2\text{Tr}(D^2) + g_4 \text{Tr}(D^4) \f$.
14
+ */
15
+ class Action : public IAction {
16
+ public:
17
+ /**
18
+ * Constructs a Barrett-Glaser action with quadratic and quartic coupling constants.
19
+ *
20
+ * @param g_2 Quadratic coupling constant.
21
+ * @param g_4 Quartic coupling constant.
22
+ */
23
+ Action(double g_2, double g_4);
24
+
25
+ /**
26
+ * Constructs a Barrett-Glaser action with quartic coupling constant equal to 1.0.
27
+ *
28
+ * @param g_2 Quadratic coupling constant.
29
+ */
30
+ explicit Action(double g_2);
31
+
32
+ /**
33
+ * Constructs a Barrett-Glaser action with coupling constants set to 0.0.
34
+ */
35
+ Action() : m_g_2(0.0), m_g_4(0.0){};
36
+
37
+ ~Action() override = default;
38
+
39
+ /**
40
+ * Sets the quadratic coupling constant \f$g_2\f$.
41
+ *
42
+ * @param value Quadratic coupling constant.
43
+ */
44
+ void setG2(double value);
45
+
46
+ /**
47
+ * Sets the quartic coupling constant \f$g_4\f$.
48
+ *
49
+ * @param value Quartic coupling constant.
50
+ */
51
+ void setG4(double value);
52
+
53
+ /**
54
+ * Sets the quadratic and quartic coupling constants.
55
+ *
56
+ * @param g_2 Quadratic coupling constant.
57
+ * @param g_4 Quartic coupling constant.
58
+ */
59
+ void setParams(double g_2, double g_4);
60
+
61
+ /**
62
+ * Returns the current quadratic coupling constant \f$g_2\f$.
63
+ *
64
+ * @return Quadratic coupling constant.
65
+ */
66
+ double getG2() const { return m_g_2; }
67
+
68
+ /**
69
+ * Returns the current quartic coupling constant \f$g_4\f$.
70
+ *
71
+ * @return Quartic coupling constant.
72
+ */
73
+ double getG4() const { return m_g_4; }
74
+
75
+ /**
76
+ * Calculates the Barrett-Glaser action using component matrix traces.
77
+ *
78
+ * @param dirac Dirac operator reference.
79
+ * @return Action value.
80
+ */
81
+ double calculateS(const IDiracOperator& dirac) const override;
82
+
83
+ /**
84
+ * Calculates the Barrett-Glaser action from the assembled Dirac operator matrix.
85
+ *
86
+ * Use calculateS() for faster performance.
87
+ *
88
+ * @param dirac Dirac operator reference.
89
+ * @return Action value.
90
+ */
91
+ double calculateSFromDirac(const IDiracOperator& dirac) const;
92
+
93
+ private:
94
+ double m_g_2, m_g_4;
95
+ };
96
+ #endif// RFL_ACTION_HPP