Skip to content

RustBCA version 3.0 - #328

Merged
drobnyjt merged 100 commits into
mainfrom
dev
Aug 11, 2026
Merged

drobnyjt merged 100 commits into
mainfrom
dev

Conversation

@drobnyjt

@drobnyjt drobnyjt commented Aug 10, 2026 •

Copy link
Copy Markdown
Collaborator

This PR will bump RustBCA to v3.0.0. The increment in major version is due to different behavior caused by implementing a seeded RNG; however, all input files should be backwards-compatible and produce results within expected Monte Carlo error, with the exception of correctness fixes noted in the list below.

Correctness

  • Fixed Biersack-Varelas stopping power for ck!=1.0; split electronic stopping powers into their own functions and implemented testing of electronic stopping functions.
  • Added additional assertions on Ed, Eb values (must be >0)
  • Implemented recoil generation and particle advance routines using Duff et al.'s orthonormal basis instead of ad hoc switching between two cartesian bases - this should significantly increase the robustness and decrease the errors (when ux ~ 1) involved in the calculation of recoil locations and particle deflection. Additionally, this is slightly faster, as it requires fewer floating point operations.

Optimizations

  • Implemented LazyLock initialized Lookup Tables (LUTs) for functions of (Za, Zb); this offers speedups of up to ~30%, with some new constraints: Za, Zb must be integers, and Z_MAX is currently hardcoded at 120.
  • Changed all unnecessary invocations of powf to powi, sqrt, or cbrt. This change offered a ~5% speedup.
  • Removed some redundant function calls - ~5% speedup.

New features

  • New seeded PRNG; I've implemented a streaming PRNG, ChaCha8, that the user can seed manually. This makes RustBCA deterministic for all functions except some C/Fortran API functions where implementing it would be troublesome to the function calling.
  • New INTERPOLATEDPLUS electronic stopping mode - this mode allows mild adjustments of the Bragg peak magnitude with a new parameter, c_i, in BiersackVarelas stopping, S_BV = ((S_LS)^(-ci) + (S_BB)^(-ci))^(-1/ci).
  • added generalized RustBCA function wrappers; these allow one to call a complete RustBCA simulation from an input file dictionary, with the option to directly output lists of particles to memory or to print files as in the standalone code.

Other changes

  • deprecated HDF5 input
  • minor code cleanup/optimizations throughout
  • added many more integration tests, tightened epsilon on some pre-existing unit tests

drobnyjt and others added 30 commits June 23, 2026 10:21
…NG values; fixed simple_bca PRNG so that it gets a new rng with each particle.
…ers switched to thread-level seeds from prngs.
… algorithm for residue-preserving floating point addition
…a the LIBRUSTBCA_SEED environment variable. Added an option to Options to let the user set the PRNG seed in the standalone code; it defaults to 0.
… variable seeding with default 0 to all library functions.
drobnyjt and others added 25 commits July 31, 2026 14:41
…values - is fp mult associative? Guess we will find out
* Updated pyo3 API to latest version.

* Fixes and improvements to Python library using newest version of pyo3.

* Cargo.toml updates.

* Update non-physics packages.

* Updates to non-physics packages required some minor code changes

* Add inlining type hints
* Experimental triangular lookup tables for screening lengths and Coulomb constant

* Added cfg to swap between 'reasonable' Z and full periodic table

* Add tests for Z1 > Z2 to test_rustbca.py

* Add Python function to compute screened coulomb scattering integrals and test

* cleanup of lib.rs

* Added scattering integral tests to workflow

* Add different option test script to tests

* Final version of triangular LUTs.
* Swapped out sin, cos with sin_cos where possible

* Fixed bbe call - was calling average instead of actual, ignoring input option

* Fixed incorrect bulk binding model in tests.

* removed unnecessary invocations of screening_length

* Put DEFAULTNEWTON back to 1e-6

* replace costly heap allocations in gauss-mehler with iterator solution

* Don't need lazylock for GL points, can just make them consts

* Removed further unnecessary heap allocations.
* Draft of generalized RustBCA python wrapper(s)

* Added tests of rustbca_py to test_different_options.py

* Implemented better python error handling

* Add different interaction potentials to scattering_integrals()

* used macros to streamline both lib.rs geometry types and main.rs geometry types

* Attempt to fix module imports across lib, main
* Update to edition 2024. Fix no_mangle configuration flags to unsafe

* Remove unnecessary nan-checking

* Upgrade version number to 3.0

* Removed redundant screening length calls; wrapped into scattering integral calls.

* Fixed tests.

* add .gitignore

* Remove HDF5

* Fix workflows.
* Add improved Python error handling

* Add pyresult outputs to remaining python functions.

* Make new get_seed function from env vars
Comment thread src/interactions.rs
-0.2912948318493851,
-2.096765499656263,
19.16045452701010,
19.160_454_527_010_1,

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume these literals are from clippy fix

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep: https://help.klocwork.com/2026.1/en-us/reference/rs.clippy.lossy_float_literal.htm

Presumably the new written value in the highlighted case above (there are several others throughout the code) represents the actual float that the previous value would have represented.

@drobnyjt
drobnyjt merged commit 673bd3f into main Aug 11, 2026
4 checks passed
@drobnyjt
drobnyjt deleted the dev branch August 11, 2026 00:29
@drobnyjt
drobnyjt restored the dev branch August 11, 2026 00:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant