Skip to content

Commit 8518652

Browse files
committed
First steps to make a LUT for LS stopping; this *might* break seeded values - is fp mult associative? Guess we will find out
1 parent d3c8777 commit 8518652

1 file changed

Lines changed: 18 additions & 1 deletion

File tree

‎src/material.rs‎

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
use super::*;
22
use rand::RngExt;
3+
use std::sync::LazyLock;
34

45
///This helper function is a workaround to issue #368 in serde
56
fn default_surface_binding_model() -> SurfaceBindingModel {
@@ -299,8 +300,24 @@ impl <T: Geometry> Material<T> {
299300
}
300301
}
301302

303+
const Z_MAX: usize = 120;
304+
static LS_STOPPING_CONSTANT_TABLE: LazyLock<[f64; Z_MAX*Z_MAX]> = LazyLock::new(
305+
||
306+
std::array::from_fn(
307+
|i| {
308+
let Za = i / Z_MAX;
309+
let Zb = i % Z_MAX;
310+
lindhard_scharff_stopping_power_constant(Za as f64, Zb as f64)
311+
}
312+
)
313+
);
314+
315+
fn lindhard_scharff_stopping_power_constant(Za: f64, Zb: f64) -> f64 {
316+
LINDHARD_SCHARFF_PREFACTOR*(Za*Za.cbrt().sqrt()*Zb)/(Za.cbrt().powi(2) + Zb.cbrt().powi(2)).powi(3).sqrt()*(AMU/Q).sqrt()
317+
}
318+
302319
pub fn lindhard_scharff_stopping_power_cross_section(Za: f64, Zb: f64, E: f64, Ma: f64) -> f64 {
303-
LINDHARD_SCHARFF_PREFACTOR*(Za*Za.cbrt().sqrt()*Zb)/(Za.cbrt().powi(2) + Zb.cbrt().powi(2)).powi(3).sqrt()*(E/Q/Ma*AMU).sqrt()
320+
lindhard_scharff_stopping_power_constant(Za, Zb)*(E/Ma).sqrt()
304321
}
305322

306323
pub fn bethe_bloch_stopping_power_cross_section(Za: f64, Zb: f64, E: f64, Ma: f64) -> f64 {

0 commit comments

Comments
 (0)