Skip to content

Add energy bounds functions for ICRU and PSTAR data - #306

Open
witNie wants to merge 1 commit into
masterfrom
bugfix/stopping-power-data-accessors
Open

witNie wants to merge 1 commit into
masterfrom
bugfix/stopping-power-data-accessors

Conversation

@witNie

@witNie witNie commented Oct 16, 2026

Copy link
Copy Markdown
Contributor

No description provided.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Changes recommended

The PSTAR function derives its maximum from number_of_data_points, a field that actually stores the material enum value, so it returns an incorrect (near-minimum) upper bound for every material.

5 open issues
What changed in this PR

This PR adds two new public helper functions, AT_PSTAR_energy_bounds and AT_ICRU_energy_bounds, that report the minimum and maximum tabulated energies available in the PSTAR and ICRU stopping-power datasets for a given material (and, for ICRU, particle). These are intended as lookup utilities alongside the existing AT_PSTAR_wrapper/AT_ICRU_wrapper interpolation routines in the stopping-power data modules.

Changes:

  • Added AT_PSTAR_energy_bounds (material bounds) in the PSTAR source/header.
  • Added AT_ICRU_energy_bounds (material + particle bounds, with a special 250 MeV/u cap for helium) in the ICRU source/header.
  • The PSTAR implementation derives the upper bound from number_of_data_points, which does not actually contain the point count.
File Description
src/​AT_StoppingPowerDataPSTAR.c Implements AT_PSTAR_energy_bounds; incorrectly uses number_of_data_points (holds the material id, not the count) for the max index.
src/​AT_StoppingPowerDataICRU.c Implements AT_ICRU_energy_bounds with material/particle validation and He upper-bound cap.
include/​AT_StoppingPowerDataPSTAR.h Declares AT_PSTAR_energy_bounds (no Doxygen).
include/​AT_StoppingPowerDataICRU.h Declares AT_ICRU_energy_bounds (no Doxygen).

Review effort: Balanced

Comment on lines +1353 to +1358
if (table == NULL || table->number_of_data_points <= 0) {
return -1;
}
*minimum = table->energy_and_stopping_power[0][0];
*maximum = table->energy_and_stopping_power[
table->number_of_data_points - 1][0];
Comment on lines +54 to +57
int AT_ICRU_energy_bounds( long material_no,
long particle_no,
double *minimum,
double *maximum);
Comment on lines +70 to +72
int AT_PSTAR_energy_bounds( long material_no,
double *minimum,
double *maximum);
double *maximum) {
if (material_no != Water_Liquid &&
material_no != Aluminum_Oxide) {
return -1;
double *minimum,
double *maximum) {
if (material_no < 0 || material_no >= N_PSTAR_MATERIALS) {
return -1;
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.

2 participants