beta-parameterization 4.0.0__tar.gz → 4.0.1__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.
- beta_parameterization-4.0.1/PKG-INFO +206 -0
- {beta_parameterization-4.0.0 → beta_parameterization-4.0.1}/pyproject.toml +6 -0
- beta_parameterization-4.0.0/PKG-INFO +0 -11
- {beta_parameterization-4.0.0 → beta_parameterization-4.0.1}/.gitignore +0 -0
- {beta_parameterization-4.0.0 → beta_parameterization-4.0.1}/CHANGELOG.md +0 -0
- {beta_parameterization-4.0.0 → beta_parameterization-4.0.1}/CMakeLists.txt +0 -0
- {beta_parameterization-4.0.0 → beta_parameterization-4.0.1}/LICENSE +0 -0
- {beta_parameterization-4.0.0 → beta_parameterization-4.0.1}/README.md +0 -0
- {beta_parameterization-4.0.0 → beta_parameterization-4.0.1}/ci/build-wheel.sh +0 -0
- {beta_parameterization-4.0.0 → beta_parameterization-4.0.1}/include/beta_parameterization.h +0 -0
- {beta_parameterization-4.0.0 → beta_parameterization-4.0.1}/include/beta_parameterization.hpp +0 -0
- {beta_parameterization-4.0.0 → beta_parameterization-4.0.1}/python/beta_parameterization/__init__.py +0 -0
- {beta_parameterization-4.0.0 → beta_parameterization-4.0.1}/python/beta_parameterization/_cdefs.py +0 -0
- {beta_parameterization-4.0.0 → beta_parameterization-4.0.1}/python/beta_parameterization/_libloader.py +0 -0
- {beta_parameterization-4.0.0 → beta_parameterization-4.0.1}/python/beta_parameterization/api.py +0 -0
- {beta_parameterization-4.0.0 → beta_parameterization-4.0.1}/python/tests/test_api.py +0 -0
- {beta_parameterization-4.0.0 → beta_parameterization-4.0.1}/src/beta_parameterization_c_api_mod.f08 +0 -0
- {beta_parameterization-4.0.0 → beta_parameterization-4.0.1}/src/beta_parameterization_mod.f08 +0 -0
- {beta_parameterization-4.0.0 → beta_parameterization-4.0.1}/src/beta_parameterization_workers_mod.f08 +0 -0
- {beta_parameterization-4.0.0 → beta_parameterization-4.0.1}/tests/beta_param_boundary_test.f08 +0 -0
- {beta_parameterization-4.0.0 → beta_parameterization-4.0.1}/tests/beta_param_equivalence_test.f08 +0 -0
- {beta_parameterization-4.0.0 → beta_parameterization-4.0.1}/tests/beta_param_golden_test.f08 +0 -0
- {beta_parameterization-4.0.0 → beta_parameterization-4.0.1}/tests/beta_param_lifecycle_test.f08 +0 -0
- {beta_parameterization-4.0.0 → beta_parameterization-4.0.1}/tests/beta_param_outputs_test.f08 +0 -0
- {beta_parameterization-4.0.0 → beta_parameterization-4.0.1}/tests/beta_param_property_test.f08 +0 -0
- {beta_parameterization-4.0.0 → beta_parameterization-4.0.1}/tests/beta_param_resolve_test.f08 +0 -0
- {beta_parameterization-4.0.0 → beta_parameterization-4.0.1}/tests/beta_param_standalone_test.f08 +0 -0
- {beta_parameterization-4.0.0 → beta_parameterization-4.0.1}/tests/beta_param_statelessness_test.f08 +0 -0
- {beta_parameterization-4.0.0 → beta_parameterization-4.0.1}/tests/beta_param_status_test.f08 +0 -0
- {beta_parameterization-4.0.0 → beta_parameterization-4.0.1}/tests/beta_pes_sweep.f08 +0 -0
- {beta_parameterization-4.0.0 → beta_parameterization-4.0.1}/tests/c_api_smoke_test.cpp +0 -0
- {beta_parameterization-4.0.0 → beta_parameterization-4.0.1}/tests/golden_capture.f08 +0 -0
- {beta_parameterization-4.0.0 → beta_parameterization-4.0.1}/tests/test_utils_mod.f08 +0 -0
- {beta_parameterization-4.0.0 → beta_parameterization-4.0.1}/tests/thread_stress_test.cpp +0 -0
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: beta-parameterization
|
|
3
|
+
Version: 4.0.1
|
|
4
|
+
Summary: Python bindings for the beta (Legendre) nuclear-shape parameterization library
|
|
5
|
+
License-Expression: MIT
|
|
6
|
+
License-File: LICENSE
|
|
7
|
+
Project-URL: Homepage, https://github.com/AleksanderAugustyn/beta-parameterization
|
|
8
|
+
Project-URL: Repository, https://github.com/AleksanderAugustyn/beta-parameterization
|
|
9
|
+
Project-URL: Changelog, https://github.com/AleksanderAugustyn/beta-parameterization/blob/master/CHANGELOG.md
|
|
10
|
+
Requires-Python: >=3.9
|
|
11
|
+
Requires-Dist: numpy>=1.21
|
|
12
|
+
Provides-Extra: test
|
|
13
|
+
Requires-Dist: pytest>=7; extra == "test"
|
|
14
|
+
Description-Content-Type: text/markdown
|
|
15
|
+
|
|
16
|
+
# beta-parameterization
|
|
17
|
+
|
|
18
|
+
Axially symmetric nuclear shapes in the spherical-harmonic (beta) expansion: a Fortran 2018 library with a C API, a C++20 wrapper and a Python wheel. It implements the two-tier shape parameterization contract shared with its sibling libraries.
|
|
19
|
+
|
|
20
|
+
## The shape
|
|
21
|
+
|
|
22
|
+
The surface radius, in units of the spherical radius R₀, is
|
|
23
|
+
|
|
24
|
+
R(θ) = c · [ 1 + Σ_{λ=1}^{n} β_λ · C_λ · P_λ(cos θ) ], C_λ = √((2λ+1) / 4π)
|
|
25
|
+
|
|
26
|
+
so that `C_λ · P_λ(cos θ)` is the spherical harmonic Y_λ0. `params(λ)` is β_λ0; position λ always means order λ. Up to 64 orders are supported.
|
|
27
|
+
|
|
28
|
+
Two per-call options change the shape:
|
|
29
|
+
|
|
30
|
+
- `apply_com` — β₁ is replaced by the value that puts the centre of mass at the origin (Newton iteration, tolerance 10⁻⁵ R₀).
|
|
31
|
+
- `conserve_volume` — the scale `c = (2 / ∫ R³ d cos θ)^(1/3)` restores the volume of the unit sphere. Without it, `c = 1`.
|
|
32
|
+
|
|
33
|
+
A shape is valid when R > 10⁻⁶ at both poles and on an internal 512-node Gauss-Legendre grid. An invalid shape returns a status code and zero-filled outputs.
|
|
34
|
+
|
|
35
|
+
## Two tiers
|
|
36
|
+
|
|
37
|
+
1. **One-shot.** One call computes one shape. All workspace is internal and discarded on return. For scripts and one-off plots.
|
|
38
|
+
2. **Read-only cache.** Build a cache once for a theta grid, then request any number of shapes against it. The cache holds only what does not depend on the parameters (Legendre tables, quadrature). It is immutable after creation and may be shared across threads. For loops and hot paths.
|
|
39
|
+
|
|
40
|
+
Both tiers return bitwise-identical results. Nothing parameter-dependent is stored: every call is independent of the calls before it.
|
|
41
|
+
|
|
42
|
+
Rules common to both tiers:
|
|
43
|
+
|
|
44
|
+
- A cache accepts `1 .. max_params` parameters per call; a one-shot call accepts `1 .. 64`.
|
|
45
|
+
- Missing trailing parameters are zero. A short vector and its zero-padded form give identical bits.
|
|
46
|
+
- Thetas are in radians, at least two, none at a pole (the open grid `θ_i = i·π/(n+1)` is the usual choice). Pole radii come from `resolve_shape`.
|
|
47
|
+
- Inputs must be finite and of physical magnitude. Release builds use fast-math and cannot detect NaN, and with `apply_com` the quadrature overflows for |β| beyond about 10⁷⁰.
|
|
48
|
+
- Every output is zero-filled on a nonzero status.
|
|
49
|
+
|
|
50
|
+
### Fortran
|
|
51
|
+
|
|
52
|
+
```fortran
|
|
53
|
+
program beta_example
|
|
54
|
+
use precision_utilities_mod, only: ik, rk
|
|
55
|
+
use beta_parameterization_mod, only: cache_t, cache_init_s, cache_free_s, &
|
|
56
|
+
cache_radius_grid_s, cache_resolve_shape_s, &
|
|
57
|
+
compute_radius_grid_standalone_s, SHAPE_VALID
|
|
58
|
+
implicit none
|
|
59
|
+
|
|
60
|
+
integer(kind = ik), parameter :: N = 180_ik
|
|
61
|
+
real(kind = rk), parameter :: PI = 3.141592653589793_rk
|
|
62
|
+
type(cache_t) :: cache
|
|
63
|
+
real(kind = rk) :: thetas(N), radii(N)
|
|
64
|
+
real(kind = rk) :: beta10, r_north, r_south, volume_factor
|
|
65
|
+
integer(kind = ik) :: i, status
|
|
66
|
+
|
|
67
|
+
do i = 1_ik, N
|
|
68
|
+
thetas(i) = real(i, rk) * PI / real(N + 1_ik, rk) ! open grid: no pole nodes
|
|
69
|
+
end do
|
|
70
|
+
|
|
71
|
+
! Tier 1: one-shot. params = (beta1, beta2), both options on.
|
|
72
|
+
call compute_radius_grid_standalone_s([0.0_rk, 0.25_rk], thetas, .true., .true., &
|
|
73
|
+
radii, status)
|
|
74
|
+
if (status /= SHAPE_VALID) error stop 'one-shot failed'
|
|
75
|
+
|
|
76
|
+
! Tier 2: build once, share, compute many.
|
|
77
|
+
call cache_init_s(cache, 8_ik, thetas, status) ! max_params = 8
|
|
78
|
+
call cache_radius_grid_s(cache, [0.0_rk, 0.25_rk], .true., .true., radii, status)
|
|
79
|
+
call cache_resolve_shape_s(cache, [0.0_rk, 0.25_rk], .true., .true., &
|
|
80
|
+
beta10, r_north, r_south, volume_factor, status)
|
|
81
|
+
call cache_free_s(cache)
|
|
82
|
+
end program beta_example
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
Cached outputs: `cache_radius_grid_s`, `cache_radius_and_derivative_s`, `cache_resolve_shape_s` (corrected β₁, pole radii, volume factor), `cache_node_radius_and_derivative_s` (radius and derivative at a `node_set_t`: extra thetas built from the cache with `node_set_build_s`), and `cache_radius_grid_unchecked_s` (no validity gate and no volume scaling: the outline of a shape the checked path rejects). To evaluate several theta grids in one call, build one node set over their concatenation.
|
|
86
|
+
|
|
87
|
+
### C
|
|
88
|
+
|
|
89
|
+
```c
|
|
90
|
+
#include "beta_parameterization.h"
|
|
91
|
+
#include <stdio.h>
|
|
92
|
+
|
|
93
|
+
int main(void) {
|
|
94
|
+
enum { N = 180 };
|
|
95
|
+
const double pi = 3.141592653589793;
|
|
96
|
+
double thetas[N], radii[N];
|
|
97
|
+
const double params[2] = {0.0, 0.25};
|
|
98
|
+
for (int i = 0; i < N; ++i) thetas[i] = (i + 1) * pi / (N + 1);
|
|
99
|
+
|
|
100
|
+
/* Tier 1: one-shot. */
|
|
101
|
+
int status = beta_param_radius_grid_standalone(params, 2, thetas, N, 1, 1, radii);
|
|
102
|
+
if (status != BETA_PARAM_VALID) {
|
|
103
|
+
printf("%s\n", beta_param_status_message(status));
|
|
104
|
+
return 1;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/* Tier 2: build once, share, compute many. */
|
|
108
|
+
beta_param_cache_t* cache = beta_param_cache_create(8, thetas, N, &status);
|
|
109
|
+
if (cache == NULL) {
|
|
110
|
+
printf("%s\n", beta_param_status_message(status));
|
|
111
|
+
return 1;
|
|
112
|
+
}
|
|
113
|
+
status = beta_param_cache_radius_grid(cache, params, 2, 1, 1, radii, N);
|
|
114
|
+
beta_param_cache_destroy(cache);
|
|
115
|
+
return status;
|
|
116
|
+
}
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
C++20 callers can use the RAII wrapper in `beta_parameterization.hpp` (`beta_param::Cache`, `beta_param::NodeSet`, `const` compute methods, `std::span` arguments).
|
|
120
|
+
|
|
121
|
+
### Python
|
|
122
|
+
|
|
123
|
+
```python
|
|
124
|
+
import beta_parameterization as bp
|
|
125
|
+
|
|
126
|
+
thetas = bp.theta_grid(180) # open grid, no pole nodes
|
|
127
|
+
|
|
128
|
+
# Tier 1: one-shot.
|
|
129
|
+
res = bp.radius_grid([0.0, 0.25], thetas, conserve_volume=True, apply_com=True)
|
|
130
|
+
assert res.ok, res.message
|
|
131
|
+
|
|
132
|
+
# Tier 2: build once, share, compute many.
|
|
133
|
+
with bp.Cache(8, thetas) as cache: # max_params = 8
|
|
134
|
+
res = cache.radius_and_derivative([0.0, 0.25], conserve_volume=True, apply_com=True)
|
|
135
|
+
shape = cache.resolve_shape([0.0, 0.25], conserve_volume=True, apply_com=True)
|
|
136
|
+
print(res.radii[:3], shape.volume_factor)
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
Shape-validation failures come back as results carrying a `Status`; `BetaParamError` is raised only for usage errors (failed create, closed handle, non-1-D input).
|
|
140
|
+
|
|
141
|
+
## Status codes
|
|
142
|
+
|
|
143
|
+
| Code | Name | Meaning |
|
|
144
|
+
|---|---|---|
|
|
145
|
+
| 0 | `SHAPE_VALID` | success |
|
|
146
|
+
| 1 | `SHAPE_ERROR_TOO_MANY_PARAMS` | `max_params` or a one-shot vector exceeds 64 |
|
|
147
|
+
| 2 | `SHAPE_ERROR_CACHE_NOT_INITIALIZED` | uninitialized cache (or NULL handle) |
|
|
148
|
+
| 3 | `SHAPE_ERROR_INVALID_GRID` | fewer than 2 thetas, or a table that cannot be allocated |
|
|
149
|
+
| 4 | `SHAPE_ERROR_WRONG_PARAM_COUNT` | vector length outside `1..max_params`, or an empty one-shot vector |
|
|
150
|
+
| 5 | `SHAPE_ERROR_INVALID_INIT` | `max_params < 1` |
|
|
151
|
+
| 100 | `BETA_PARAM_ERROR_NORTH_POLE` | radius not positive at θ = 0 |
|
|
152
|
+
| 101 | `BETA_PARAM_ERROR_SOUTH_POLE` | radius not positive at θ = π |
|
|
153
|
+
| 102 | `BETA_PARAM_ERROR_INTERIOR_NEGATIVE` | radius not positive in the interior |
|
|
154
|
+
| 103 | `BETA_PARAM_ERROR_COM_NOT_CONVERGED` | centre-of-mass correction did not converge |
|
|
155
|
+
| 104 | `BETA_PARAM_ERROR_INVALID_BUFFER_SIZE` | output buffer size does not match the theta or node count |
|
|
156
|
+
| 105 | `BETA_PARAM_ERROR_POLE_NODE` | a theta at or beyond a pole |
|
|
157
|
+
| 106 | `BETA_PARAM_ERROR_NODE_SET_MISMATCH` | node set unbuilt, or built for a smaller cache |
|
|
158
|
+
|
|
159
|
+
Codes 0–5 are shared by every shape parameterization library; the C header and the Python `Status` enum mirror all of them under `BETA_PARAM_*` names.
|
|
160
|
+
|
|
161
|
+
## Building
|
|
162
|
+
|
|
163
|
+
Requires GCC (gfortran, g++) and CMake ≥ 3.20. Dependencies are fetched by CMake.
|
|
164
|
+
|
|
165
|
+
```bash
|
|
166
|
+
cmake -S . -B build -DCMAKE_BUILD_TYPE=Release
|
|
167
|
+
cmake --build build -j
|
|
168
|
+
ctest --test-dir build --output-on-failure
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
As a CMake dependency:
|
|
172
|
+
|
|
173
|
+
```cmake
|
|
174
|
+
FetchContent_Declare(
|
|
175
|
+
beta-parameterization
|
|
176
|
+
GIT_REPOSITORY https://github.com/AleksanderAugustyn/beta-parameterization.git
|
|
177
|
+
GIT_TAG 4.0.0
|
|
178
|
+
)
|
|
179
|
+
FetchContent_MakeAvailable(beta-parameterization)
|
|
180
|
+
target_link_libraries(my_target PRIVATE BetaParameterization::beta_parameterization)
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
Targets: `BetaParameterization::beta_parameterization` (static, Fortran), `::beta_parameterization_shared` (shared, C API), `::beta_parameterization_cxx` (header-only C++ wrapper over the shared library).
|
|
184
|
+
|
|
185
|
+
Python:
|
|
186
|
+
|
|
187
|
+
```bash
|
|
188
|
+
pip install beta-parameterization==4.0.0
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
The wheel is self-contained (manylinux2014, x86-64). To run the Python tests against a local build instead: `BETA_PARAM_LIB=$PWD/build/libbeta_parameterization.so PYTHONPATH=python python -m pytest python/tests`.
|
|
192
|
+
|
|
193
|
+
## Dependencies
|
|
194
|
+
|
|
195
|
+
| Dependency | Version |
|
|
196
|
+
|---|---|
|
|
197
|
+
| [fortran-foundations](https://github.com/AleksanderAugustyn/fortran-foundations) | 3.0.0 |
|
|
198
|
+
| [gcc-compiler-options](https://github.com/AleksanderAugustyn/gcc-compiler-options) | 2.0.0 |
|
|
199
|
+
| numpy (wheel only) | ≥ 1.21 |
|
|
200
|
+
|
|
201
|
+
## Design
|
|
202
|
+
|
|
203
|
+
- **Stateless computes.** A cache holds only parameter-independent tables. Every compute takes it read-only and is `pure`; per-call scratch lives on the stack. One cache serves every thread and every option combination.
|
|
204
|
+
- **One pipeline.** A one-shot call builds a local cache and runs the cached routine, so the two tiers cannot drift apart.
|
|
205
|
+
- **Reproducible bits.** The library's own objects are compiled without link-time optimization. Under `-flto -ffast-math` a kernel inlined into two call sites may round differently in each; without LTO every caller executes the same machine code, and equal inputs give equal bits.
|
|
206
|
+
- **No stops.** Every failure is a status code; nothing in the library calls `error stop`.
|
|
@@ -5,6 +5,7 @@ build-backend = "scikit_build_core.build"
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "beta-parameterization"
|
|
7
7
|
description = "Python bindings for the beta (Legendre) nuclear-shape parameterization library"
|
|
8
|
+
readme = "README.md"
|
|
8
9
|
license = "MIT"
|
|
9
10
|
license-files = ["LICENSE"]
|
|
10
11
|
requires-python = ">=3.9"
|
|
@@ -14,6 +15,11 @@ dynamic = ["version"]
|
|
|
14
15
|
[project.optional-dependencies]
|
|
15
16
|
test = ["pytest>=7"]
|
|
16
17
|
|
|
18
|
+
[project.urls]
|
|
19
|
+
Homepage = "https://github.com/AleksanderAugustyn/beta-parameterization"
|
|
20
|
+
Repository = "https://github.com/AleksanderAugustyn/beta-parameterization"
|
|
21
|
+
Changelog = "https://github.com/AleksanderAugustyn/beta-parameterization/blob/master/CHANGELOG.md"
|
|
22
|
+
|
|
17
23
|
[tool.scikit-build]
|
|
18
24
|
cmake.source-dir = "."
|
|
19
25
|
cmake.define.BETA_PARAM_BUILD_TESTS = "OFF"
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 2.4
|
|
2
|
-
Name: beta-parameterization
|
|
3
|
-
Version: 4.0.0
|
|
4
|
-
Summary: Python bindings for the beta (Legendre) nuclear-shape parameterization library
|
|
5
|
-
License-Expression: MIT
|
|
6
|
-
License-File: LICENSE
|
|
7
|
-
Requires-Python: >=3.9
|
|
8
|
-
Requires-Dist: numpy>=1.21
|
|
9
|
-
Provides-Extra: test
|
|
10
|
-
Requires-Dist: pytest>=7; extra == "test"
|
|
11
|
-
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{beta_parameterization-4.0.0 → beta_parameterization-4.0.1}/include/beta_parameterization.hpp
RENAMED
|
File without changes
|
{beta_parameterization-4.0.0 → beta_parameterization-4.0.1}/python/beta_parameterization/__init__.py
RENAMED
|
File without changes
|
{beta_parameterization-4.0.0 → beta_parameterization-4.0.1}/python/beta_parameterization/_cdefs.py
RENAMED
|
File without changes
|
|
File without changes
|
{beta_parameterization-4.0.0 → beta_parameterization-4.0.1}/python/beta_parameterization/api.py
RENAMED
|
File without changes
|
|
File without changes
|
{beta_parameterization-4.0.0 → beta_parameterization-4.0.1}/src/beta_parameterization_c_api_mod.f08
RENAMED
|
File without changes
|
{beta_parameterization-4.0.0 → beta_parameterization-4.0.1}/src/beta_parameterization_mod.f08
RENAMED
|
File without changes
|
|
File without changes
|
{beta_parameterization-4.0.0 → beta_parameterization-4.0.1}/tests/beta_param_boundary_test.f08
RENAMED
|
File without changes
|
{beta_parameterization-4.0.0 → beta_parameterization-4.0.1}/tests/beta_param_equivalence_test.f08
RENAMED
|
File without changes
|
{beta_parameterization-4.0.0 → beta_parameterization-4.0.1}/tests/beta_param_golden_test.f08
RENAMED
|
File without changes
|
{beta_parameterization-4.0.0 → beta_parameterization-4.0.1}/tests/beta_param_lifecycle_test.f08
RENAMED
|
File without changes
|
{beta_parameterization-4.0.0 → beta_parameterization-4.0.1}/tests/beta_param_outputs_test.f08
RENAMED
|
File without changes
|
{beta_parameterization-4.0.0 → beta_parameterization-4.0.1}/tests/beta_param_property_test.f08
RENAMED
|
File without changes
|
{beta_parameterization-4.0.0 → beta_parameterization-4.0.1}/tests/beta_param_resolve_test.f08
RENAMED
|
File without changes
|
{beta_parameterization-4.0.0 → beta_parameterization-4.0.1}/tests/beta_param_standalone_test.f08
RENAMED
|
File without changes
|
{beta_parameterization-4.0.0 → beta_parameterization-4.0.1}/tests/beta_param_statelessness_test.f08
RENAMED
|
File without changes
|
{beta_parameterization-4.0.0 → beta_parameterization-4.0.1}/tests/beta_param_status_test.f08
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|