|
1 | 1 | use super::*; |
2 | | -use cached::macros::cached; |
| 2 | +use std::sync::LazyLock; |
3 | 3 |
|
4 | 4 | /// Analytic solutions to outermost root of the interaction potential. |
5 | 5 | pub fn crossing_point_doca(interaction_potential: InteractionPotential) -> f64 { |
@@ -274,24 +274,39 @@ pub fn screening_length(Za: f64, Zb: f64, interaction_potential: InteractionPote |
274 | 274 | //ZBL screening length, Eckstein (4.1.8) |
275 | 275 | InteractionPotential::ZBL => zbl_screening_length(Za as u64, Zb as u64), |
276 | 276 | //Lindhard/Firsov screening length, Eckstein (4.1.5) |
277 | | - InteractionPotential::MOLIERE | InteractionPotential::KR_C | InteractionPotential::LENZ_JENSEN | InteractionPotential::TRIDYN | InteractionPotential::WW => lindhard_screening_length(Za as u64, Zb as u64), |
278 | | - InteractionPotential::LENNARD_JONES_12_6{..} | InteractionPotential::LENNARD_JONES_65_6{..} => lindhard_screening_length(Za as u64, Zb as u64), |
| 277 | + InteractionPotential::MOLIERE | InteractionPotential::KR_C | InteractionPotential::LENZ_JENSEN | InteractionPotential::TRIDYN | InteractionPotential::WW => lindhard_screening_length_lookup(Za as u64, Zb as u64), |
| 278 | + InteractionPotential::LENNARD_JONES_12_6{..} | InteractionPotential::LENNARD_JONES_65_6{..} => lindhard_screening_length_lookup(Za as u64, Zb as u64), |
279 | 279 | InteractionPotential::MORSE{D, alpha, r0} => alpha, |
280 | 280 | InteractionPotential::COULOMB{Za: Z1, Zb: Z2} => zbl_screening_length(Za as u64, Zb as u64), |
281 | | - InteractionPotential::KRC_MORSE{..} => 0.8853*A0*(Za.sqrt() + Zb.sqrt()).powf(-2./3.), |
282 | | - InteractionPotential::FOUR_EIGHT{..} =>0.8853*A0*(Za.sqrt() + Zb.sqrt()).powf(-2./3.), |
| 281 | + InteractionPotential::KRC_MORSE{..} => lindhard_screening_length_lookup(Za as u64, Zb as u64), |
| 282 | + InteractionPotential::FOUR_EIGHT{..} => lindhard_screening_length_lookup(Za as u64, Zb as u64), |
283 | 283 | } |
284 | 284 | } |
285 | 285 |
|
286 | | -#[cached] |
287 | | -fn zbl_screening_length(Za: u64, Zb: u64) -> f64{ |
| 286 | +const Z_MAX: usize = 120; |
| 287 | +static LINDHARD_SCREENING_LENGTH_TABLE: LazyLock<[f64; Z_MAX*Z_MAX]> = LazyLock::new( |
| 288 | + || |
| 289 | + std::array::from_fn( |
| 290 | + |i| { |
| 291 | + let Za = i / Z_MAX; |
| 292 | + let Zb = i % Z_MAX; |
| 293 | + lindhard_screening_length(Za as u64, Zb as u64) |
| 294 | + } |
| 295 | + ) |
| 296 | +); |
| 297 | + |
| 298 | +pub fn zbl_screening_length(Za: u64, Zb: u64) -> f64{ |
288 | 299 | 0.88534*A0/((Za as f64).powf(0.23) + (Zb as f64).powf(0.23)) |
289 | 300 | } |
290 | | -#[cached] |
291 | | -fn lindhard_screening_length(Za: u64, Zb: u64) -> f64 { |
| 301 | + |
| 302 | +pub fn lindhard_screening_length(Za: u64, Zb: u64) -> f64 { |
292 | 303 | 0.8853*A0*((Za as f64).sqrt() + (Zb as f64).sqrt()).powf(-2./3.) |
293 | 304 | } |
294 | 305 |
|
| 306 | +pub fn lindhard_screening_length_lookup(Za: u64, Zb: u64) -> f64 { |
| 307 | + LINDHARD_SCREENING_LENGTH_TABLE[Za as usize * Z_MAX + Zb as usize] |
| 308 | +} |
| 309 | + |
295 | 310 | /// Coefficients of inverse-polynomial interaction potentials. |
296 | 311 | /// Note: these go in order of decreasing orders of r, e.g., [r^n, r^n-1, r^n-2, ... r, 1]. |
297 | 312 | pub fn polynomial_coefficients(relative_energy: f64, impact_parameter: f64, interaction_potential: InteractionPotential) -> Vec<f64> { |
|
0 commit comments