alphanso 1.0.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 (42) hide show
  1. alphanso-1.0.0/LICENSE +28 -0
  2. alphanso-1.0.0/MANIFEST.in +2 -0
  3. alphanso-1.0.0/PKG-INFO +396 -0
  4. alphanso-1.0.0/README.md +373 -0
  5. alphanso-1.0.0/alphanso/__init__.py +9 -0
  6. alphanso-1.0.0/alphanso/__main__.py +366 -0
  7. alphanso-1.0.0/alphanso/atomic_data_loader.py +390 -0
  8. alphanso-1.0.0/alphanso/constants.py +11 -0
  9. alphanso-1.0.0/alphanso/data/atomic_data/atomic_data.json +38472 -0
  10. alphanso-1.0.0/alphanso/data/atomic_data/atomic_data_loader.py +536 -0
  11. alphanso-1.0.0/alphanso/data/atomic_data/element_symbols.json +14 -0
  12. alphanso-1.0.0/alphanso/data/atomic_data/metadata.json +15 -0
  13. alphanso-1.0.0/alphanso/data/atomic_data/natural_abundances.json +1581 -0
  14. alphanso-1.0.0/alphanso/data/sources_overrides.yaml +19 -0
  15. alphanso-1.0.0/alphanso/data_manager.py +206 -0
  16. alphanso-1.0.0/alphanso/parsers.py +1861 -0
  17. alphanso-1.0.0/alphanso/sources_parsers.py +681 -0
  18. alphanso-1.0.0/alphanso/transport.py +2150 -0
  19. alphanso-1.0.0/alphanso/utils.py +215 -0
  20. alphanso-1.0.0/alphanso.egg-info/PKG-INFO +396 -0
  21. alphanso-1.0.0/alphanso.egg-info/SOURCES.txt +40 -0
  22. alphanso-1.0.0/alphanso.egg-info/dependency_links.txt +1 -0
  23. alphanso-1.0.0/alphanso.egg-info/entry_points.txt +2 -0
  24. alphanso-1.0.0/alphanso.egg-info/requires.txt +5 -0
  25. alphanso-1.0.0/alphanso.egg-info/top_level.txt +3 -0
  26. alphanso-1.0.0/example_usage/example_script.py +105 -0
  27. alphanso-1.0.0/pyproject.toml +45 -0
  28. alphanso-1.0.0/setup.cfg +4 -0
  29. alphanso-1.0.0/tests/__init__.py +1 -0
  30. alphanso-1.0.0/tests/conftest.py +62 -0
  31. alphanso-1.0.0/tests/ground_truth/__init__.py +1 -0
  32. alphanso-1.0.0/tests/ground_truth/generate_ground_truth.py +143 -0
  33. alphanso-1.0.0/tests/integration/__init__.py +1 -0
  34. alphanso-1.0.0/tests/integration/configs.py +336 -0
  35. alphanso-1.0.0/tests/integration/test_beam.py +48 -0
  36. alphanso-1.0.0/tests/integration/test_data_dir.py +205 -0
  37. alphanso-1.0.0/tests/integration/test_homogeneous.py +52 -0
  38. alphanso-1.0.0/tests/integration/test_interface.py +48 -0
  39. alphanso-1.0.0/tests/integration/test_sandwich.py +50 -0
  40. alphanso-1.0.0/tests/integration/test_sandwich_interface_equivalence.py +122 -0
  41. alphanso-1.0.0/tests/utils/__init__.py +1 -0
  42. alphanso-1.0.0/tests/utils/comparison.py +186 -0
alphanso-1.0.0/LICENSE ADDED
@@ -0,0 +1,28 @@
1
+ BSD 3-Clause License
2
+
3
+ Copyright (c) 2026, Divit Rawal, Anthony J. Nelson, William Zywiec, Daniel Siefman
4
+
5
+ Redistribution and use in source and binary forms, with or without
6
+ modification, are permitted provided that the following conditions are met:
7
+
8
+ 1. Redistributions of source code must retain the above copyright notice, this
9
+ list of conditions and the following disclaimer.
10
+
11
+ 2. Redistributions in binary form must reproduce the above copyright notice,
12
+ this list of conditions and the following disclaimer in the documentation
13
+ and/or other materials provided with the distribution.
14
+
15
+ 3. Neither the name of the copyright holder nor the names of its
16
+ contributors may be used to endorse or promote products derived from
17
+ this software without specific prior written permission.
18
+
19
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
23
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
25
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
26
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
27
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
@@ -0,0 +1,2 @@
1
+ recursive-include alphanso/data/atomic_data *
2
+ include alphanso/data/sources_overrides.yaml
@@ -0,0 +1,396 @@
1
+ Metadata-Version: 2.4
2
+ Name: alphanso
3
+ Version: 1.0.0
4
+ Summary: Alpha-neutron source calculation package
5
+ Author-email: Divit Rawal <divit.rawal@berkeley.edu>, "Anthony J. Nelson" <nelson254@llnl.gov>, William Zywiec <zywiec1@llnl.gov>, Daniel Siefman <daniel.siefman@berkeley.edu>
6
+ License: BSD-3-Clause
7
+ Project-URL: Repository, https://github.com/alphanso-org/alphanso
8
+ Project-URL: Issues, https://github.com/alphanso-org/alphanso/issues
9
+ Keywords: alpha-neutron,nuclear,neutron-source,physics
10
+ Classifier: Development Status :: 4 - Beta
11
+ Classifier: License :: OSI Approved :: BSD License
12
+ Classifier: Programming Language :: Python :: 3
13
+ Classifier: Topic :: Scientific/Engineering :: Physics
14
+ Requires-Python: >=3.10
15
+ Description-Content-Type: text/markdown
16
+ License-File: LICENSE
17
+ Requires-Dist: numpy>=2.0
18
+ Requires-Dist: pandas
19
+ Requires-Dist: scipy
20
+ Requires-Dist: PyYAML>=6.0.2
21
+ Requires-Dist: platformdirs>=3.0
22
+ Dynamic: license-file
23
+
24
+ # ALPHANSO: ALPHa Neutron SOurces
25
+
26
+ Open-source Python package for modeling ($\alpha$,n) neutron source terms.
27
+
28
+ ![Python >= 3.10](https://img.shields.io/badge/python-%3E%3D3.10-blue)
29
+ ![License: BSD-3-Clause](https://img.shields.io/badge/license-BSD--3--Clause-green)
30
+ ![PyPI](https://img.shields.io/pypi/v/alphanso)
31
+
32
+ ## Motivation
33
+
34
+ Legacy ($\alpha$,n) codes such as SOURCES-4C are written in FORTRAN 77 with nuclear data from the 1980s and have not been maintained since 2002. ALPHANSO provides a modern, open-source replacement built on up-to-date evaluated nuclear data libraries stored in the GNDS format. It covers all naturally occurring target nuclides and agrees well with experimental data.
35
+
36
+ Applications include nuclear safeguards, radioactive waste management, nuclear astrophysics, and dark matter detection experiments.
37
+
38
+ ## Key Features
39
+
40
+ - **Multiple Geometry Types**: Beam, homogeneous, interface, and sandwich configurations
41
+ - **Accurate Physics**: Up-to-date nuclear data with customizable data sources
42
+ - **Complete Output**: Neutron yields and energy spectra
43
+ - **Command-Line & Python API**: Use via CLI or integrate into Python workflows
44
+
45
+ ## Installation
46
+
47
+ ### From PyPI
48
+
49
+ ```bash
50
+ pip install alphanso
51
+ ```
52
+
53
+ On first use, ALPHANSO automatically downloads ~1.1 GB of nuclear data files and caches them locally (e.g., `~/.local/share/alphanso/` on Linux). To pre-download the data:
54
+
55
+ ```bash
56
+ alphanso download-data
57
+ ```
58
+
59
+ ### From Source
60
+
61
+ ```bash
62
+ git clone https://github.com/alphanso-org/alphanso.git
63
+ cd alphanso
64
+ pip install -e .
65
+ ```
66
+
67
+ When installed from source, ALPHANSO uses the bundled `alphanso/data/` directory directly (no download needed).
68
+
69
+ ### Custom Data Location
70
+
71
+ Set the `ALPHANSO_DATA_DIR` environment variable to override the data directory:
72
+
73
+ ```bash
74
+ export ALPHANSO_DATA_DIR=/path/to/nuclear/data
75
+ ```
76
+
77
+ Use `alphanso data-info` to check the current data paths and status.
78
+
79
+ ## Quick Start
80
+
81
+ ### Command-Line Interface
82
+
83
+ Run ALPHANSO with a YAML configuration file:
84
+
85
+ ```bash
86
+ alphanso path/to/config.yaml
87
+ ```
88
+
89
+ Or equivalently:
90
+
91
+ ```bash
92
+ python3 -m alphanso path/to/config.yaml
93
+ ```
94
+
95
+ Results are saved to `alphanso_output/<config_name>/`. You can specify a custom output directory as a second CLI argument: `alphanso config.yaml my_output/`.
96
+
97
+ #### Example YAML Configurations
98
+
99
+ **Beam** — monoenergetic alpha beam on a thick target:
100
+
101
+ ```yaml
102
+ name: "Be-9 Beam Calculation"
103
+ calc_type: "beam"
104
+ matdef:
105
+ Be-9: 1.0
106
+ beam_energy: 5.0
107
+ ```
108
+
109
+ **Homogeneous** — uniform mixture of alpha emitters and targets:
110
+
111
+ ```yaml
112
+ name: "Homogeneous Source"
113
+ calc_type: "homogeneous"
114
+ matdef:
115
+ Pu-239: 0.3
116
+ Pu-238: 0.2
117
+ Be-9: 0.5
118
+ ```
119
+
120
+ **Interface** — planar interface between source and target regions:
121
+
122
+ ```yaml
123
+ name: "Interface Geometry"
124
+ calc_type: "interface"
125
+ source_matdef:
126
+ Pu-238: 1.0
127
+ source_density: 19.8
128
+ target_matdef:
129
+ Be-9: 1.0
130
+ ```
131
+
132
+ **Sandwich** — multi-layer geometry with intermediate layers:
133
+
134
+ ```yaml
135
+ name: "Multi-Layer Sandwich"
136
+ calc_type: "sandwich"
137
+ source_matdef:
138
+ Pu-238: 1.0
139
+ source_density: 19.8
140
+ target_matdef:
141
+ Be-9: 1.0
142
+ intermediate_layers:
143
+ - matdef: { C-13: 1.0 }
144
+ density: 2.26
145
+ thickness: 1.0e-4
146
+ - matdef: { Al-27: 1.0 }
147
+ density: 2.70
148
+ thickness: 1.0e-4
149
+ ```
150
+
151
+ ### Python API
152
+
153
+ ```python
154
+ from alphanso.transport import Transport
155
+
156
+ config = {
157
+ "calc_type": "beam",
158
+ "matdef": {"Be-9": 1.0},
159
+ "beam_energy": 5.0
160
+ }
161
+
162
+ results = Transport.calculate(config)
163
+ print(f"Neutron yield: {results['an_yield']:.3e} n/alpha")
164
+ ```
165
+
166
+ `Transport.calculate()` accepts optional keys in the config dict:
167
+
168
+ - `name` (str): Label for identification in CLI output
169
+ - `output_dir` (str): Directory to save output files. When specified, saves `output.yaml` (full config + results) and `results.yaml` (results only).
170
+ - `save_data_files` (bool, default: `True`): Whether to save output files when `output_dir` is specified. Set to `False` to skip file saving.
171
+
172
+ ## Running Tests
173
+
174
+ ```bash
175
+ pytest
176
+ ```
177
+
178
+ ## Calculation Types
179
+
180
+ ALPHANSO supports four calculation geometries, each designed for specific physical scenarios.
181
+
182
+ ### 1. Beam Calculations (`calc_type: "beam"`)
183
+
184
+ Monoenergetic or polyenergetic alpha beam incident on a thick target.
185
+
186
+ **Required Parameters**:
187
+
188
+ - `matdef` (dict): Target material composition (ZAID or element names with mass fractions)
189
+ - `beam_energy` (float): Alpha beam energy in MeV (monoenergetic)
190
+ - `beam_intensities` (list, optional): List of [energy, intensity] pairs for polyenergetic beams (use instead of `beam_energy`)
191
+
192
+ **Optional Parameters**:
193
+
194
+ - `num_alpha_groups` (int, default: `15000`): Number of alpha energy groups
195
+ - `min_alpha_energy` (float, default: `1e-11`): Minimum alpha energy in MeV
196
+ - `max_alpha_energy` (float, default: `15`): Maximum alpha energy in MeV
197
+ - `neutron_energy_bins` (list): Custom neutron energy bins in MeV (default: 0→15 MeV, 101 points). Accepts a 3-element shorthand `[start, stop, num_points]` which is expanded via `np.linspace`.
198
+ - `an_xs_data_dir` (str): Path to ($\alpha$,n) cross-section data directory
199
+ - `stopping_power_data_dir` (str): Path to stopping power data directory
200
+
201
+ **Results**:
202
+
203
+ - `an_yield`: Neutron production rate (n/$\alpha$)
204
+ - `an_spectrum`: Normalized neutron energy spectrum
205
+ - `an_spectrum_absolute`: Absolute neutron spectrum
206
+ - `neutron_energy_bins`: Energy bins for spectrum (MeV)
207
+
208
+ ---
209
+
210
+ ### 2. Homogeneous Calculations (`calc_type: "homogeneous"`)
211
+
212
+ Uniform mixture of alpha-emitting isotopes and target materials.
213
+
214
+ **Required Parameters**:
215
+
216
+ - `matdef` (dict): Material composition including both alpha emitters and targets
217
+
218
+ **Optional Parameters**:
219
+
220
+ - `num_alpha_groups` (int, default: `15000`): Number of alpha energy groups
221
+ - `min_alpha_energy` (float, default: `1e-11`): Minimum alpha energy in MeV
222
+ - `max_alpha_energy` (float, default: `15`): Maximum alpha energy in MeV
223
+ - `neutron_energy_bins` (list): Custom neutron energy bins in MeV (default: 0→15 MeV, 101 points). Accepts a 3-element shorthand `[start, stop, num_points]`.
224
+ - `an_xs_data_dir` (str): Path to cross-section data
225
+ - `stopping_power_data_dir` (str): Path to stopping power data
226
+ - `decay_data_dir` (str): Path to decay/branching data
227
+
228
+ **Results**:
229
+
230
+ - `an_yield`: Alpha-n neutron yield (n/s/g)
231
+ - `sf_yield`: Spontaneous fission neutron yield (n/s/g)
232
+ - `combined_yield`: Combined (alpha-n + SF) yield (n/s/g) - default output
233
+ - `an_spectrum`: Normalized alpha-n neutron spectrum
234
+ - `sf_spectrum`: Normalized spontaneous fission neutron spectrum
235
+ - `combined_spectrum`: Combined normalized neutron spectrum
236
+ - `neutron_energy_bins`: Energy bins (MeV)
237
+
238
+ ---
239
+
240
+ ### 3. Interface Calculations (`calc_type: "interface"`)
241
+
242
+ Planar interface between an alpha-emitting source region and a target region.
243
+
244
+ **Required Parameters**:
245
+
246
+ - `source_matdef` (dict): Alpha source material composition
247
+ - `source_density` (float): Source density in g/cm^3
248
+ - `target_matdef` (dict): Target material composition
249
+
250
+ **Optional Parameters**:
251
+
252
+ - `num_alpha_groups` (int, default: `15000`): Number of alpha energy groups
253
+ - `min_alpha_energy` (float, default: `1e-11`): Minimum alpha energy in MeV
254
+ - `max_alpha_energy` (float, default: `15`): Maximum alpha energy in MeV
255
+ - `neutron_energy_bins` (list): Custom neutron energy bins in MeV (default: 0→15 MeV, 101 points). Accepts a 3-element shorthand `[start, stop, num_points]`.
256
+ - `an_xs_data_dir` (str): Cross-section data path
257
+ - `stopping_power_data_dir` (str): Stopping power data path
258
+ - `decay_data_dir` (str): Decay data path
259
+
260
+ **Results**:
261
+
262
+ - `an_yield`: Neutron yield per cm^2 of interface (n/s/cm^2)
263
+ - `an_spectrum`: Normalized spectrum
264
+ - `an_spectrum_absolute`: Absolute spectrum (n/s/cm^2/MeV)
265
+ - `neutron_energy_bins`: Energy bins (MeV)
266
+
267
+ ---
268
+
269
+ ### 4. Sandwich Calculations (`calc_type: "sandwich"`)
270
+
271
+ Multi-layer sandwich geometry with volumetric formulation. Alpha source (Region A) -> Intermediate layers (Region B1, B2, ..., Bn) -> Target (Region C).
272
+
273
+ **Required Parameters**:
274
+
275
+ - `source_matdef` (dict): Alpha source material composition (Region A)
276
+ - `source_density` (float): Source density in g/cm^3
277
+ - `target_matdef` (dict): Target material composition (Region C)
278
+ - `intermediate_layers` (list of dicts): One or more intermediate layers, each containing:
279
+ - `matdef` (dict): Layer material composition
280
+ - `density` (float): Layer density in g/cm^3
281
+ - `thickness` (float): Layer thickness in cm
282
+
283
+ **Optional Parameters**:
284
+
285
+ - `n_angular_bins` (int, default: `40`): Angular bins for integration
286
+ - `num_alpha_groups` (int, default: `15000`): Number of alpha energy groups
287
+ - `min_alpha_energy` (float, default: `1e-11`): Minimum alpha energy in MeV
288
+ - `max_alpha_energy` (float, default: `15`): Maximum alpha energy in MeV
289
+ - `neutron_energy_bins` (list): Custom neutron energy bins in MeV (default: 0→15 MeV, 101 points). Accepts a 3-element shorthand `[start, stop, num_points]`.
290
+ - `an_xs_data_dir` (str): Cross-section data path
291
+ - `stopping_power_data_dir` (str): Stopping power data path
292
+ - `decay_data_dir` (str): Decay data path
293
+
294
+ **Results**:
295
+
296
+ - `an_yield`: Total neutron yield (n/s/cm^2)
297
+ - `yield_target`: Yield in target region (n/s/cm^2)
298
+ - `yield_layers`: Per-layer yield breakdown (list of n/s/cm^2)
299
+ - `yield_ab_b`: Yield at AB interface in first layer material
300
+ - `yield_bc_b`: Yield at BC interface in last layer material
301
+ - `yield_bc_c`: Yield at BC interface in target material
302
+ - `an_spectrum`: Normalized total spectrum
303
+ - `an_spectrum_absolute`: Absolute total spectrum
304
+ - `spectrum_layers`: Per-layer spectrum contributions
305
+ - `neutron_energy_bins`: Energy bins (MeV)
306
+
307
+ ## Material Definition Format
308
+
309
+ Materials are defined using dictionaries with isotope/element identifiers as keys and mass fractions as values.
310
+
311
+ **Supported Formats**:
312
+
313
+ - Element-mass names: `"Be-9"`, `"C-13"`, `"Al-27"`, `"Pu-238"`
314
+ - Natural element symbols: `"C"`, `"O"` (auto-expands to natural isotopes using abundance data)
315
+ - ZAID integers: `4009` (Be-9), `6013` (C-13), `94238` (Pu-238)
316
+ - Natural element ZAIDs: `6000` (natural C), `8000` (natural O) — AAA=000 convention
317
+
318
+ > **Note**: ZAID keys in Python dicts must be integers, not strings. Using string keys like `"92235"` will cause entries to be silently dropped.
319
+
320
+ **Example**:
321
+
322
+ ```yaml
323
+ matdef:
324
+ Pu-238: 0.90
325
+ Pu-239: 0.05
326
+ Pu-240: 0.05
327
+ ```
328
+
329
+ Or in Python:
330
+
331
+ ```python
332
+ matdef = {94238: 0.90, 94239: 0.05, 94240: 0.05}
333
+ ```
334
+
335
+ Mass fractions should sum to 1.0 for single-phase materials, but can exceed 1.0 for compounds.
336
+
337
+ ## Output Files
338
+
339
+ When using the CLI, results are saved to `alphanso_output/<config_name>/`:
340
+
341
+ - **`output.yaml`**: Complete input configuration and full results (for reproducibility)
342
+ - **`results.yaml`**: Clean results-only output (for easy parsing)
343
+
344
+ ## Custom Data Sources
345
+
346
+ ALPHANSO allows you to use custom nuclear data:
347
+
348
+ ```yaml
349
+ an_xs_data_dir: "/path/to/cross_sections"
350
+ stopping_power_data_dir: "/path/to/stopping_data"
351
+ decay_data_dir: "/path/to/decay_data"
352
+ ```
353
+
354
+ Paths can be absolute or relative to the project root. If not specified, ALPHANSO uses built-in default data.
355
+
356
+ To integrate new data formats, extend the parsers in `alphanso/parsers.py`.
357
+
358
+ ## Citation
359
+
360
+ If you use ALPHANSO in your research, please cite:
361
+
362
+ ```bibtex
363
+ @article{rawal2026alphanso,
364
+ title = {{ALPHANSO}: Open-Source Modeling of ($\alpha$,n) Neutron Source Terms},
365
+ author = {Rawal, Divit and Nelson, Anthony J. and Zywiec, William and Siefman, Daniel},
366
+ journal = {Nuclear Instruments and Methods in Physics Research Section A},
367
+ year = {2026},
368
+ note = {Preprint}
369
+ }
370
+ ```
371
+
372
+ ## Contributing
373
+
374
+ Contributions are welcome. To contribute:
375
+
376
+ 1. Fork the repository
377
+ 2. Create a feature branch (`git checkout -b feature/my-feature`)
378
+ 3. Commit your changes and push to your fork
379
+ 4. Open a pull request against `main`
380
+
381
+ Please open an issue first for bug reports or feature requests.
382
+
383
+ ## License
384
+
385
+ This project is licensed under the BSD-3-Clause License. See the [LICENSE](LICENSE) file for details.
386
+
387
+ ## Authors
388
+
389
+ - Divit Rawal - [divit.rawal@berkeley.edu](mailto:divit.rawal@berkeley.edu)
390
+ - Anthony J. Nelson - [nelson254@llnl.gov](mailto:nelson254@llnl.gov)
391
+ - William Zywiec - [zywiec1@llnl.gov](mailto:zywiec1@llnl.gov)
392
+ - Daniel Siefman - [daniel.siefman@berkeley.edu](mailto:daniel.siefman@berkeley.edu)
393
+
394
+ ## Support
395
+
396
+ For questions, issues, or feature requests, please [open an issue](https://github.com/alphanso-org/alphanso/issues) on GitHub or contact the authors.