Skip to content

Commit 5987950

Browse files
committed
Add new electronic stopping mode; BV with custom interp. weight - improves max error from ~20% to ~10%
1 parent b24e872 commit 5987950

5 files changed

Lines changed: 33 additions & 13 deletions

File tree

‎examples/test_electronic_stopping.py‎

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
Za = 1.0
77
Zb = 13.0
88
n_Al = 6.026e28
9+
ck = 1.4
10+
ci = 0.8171 # found via scipy.optimize minimization of SSE
911

1012
# load PSTAR data for H on Al
1113
# PSTAR data is in MeV cm^2/g
@@ -20,13 +22,15 @@
2022
lindhard_scharff = np.zeros(num_energies)
2123
bethe_bloch = np.zeros(num_energies)
2224
biersack_varelas = np.zeros(num_energies)
25+
bv_custom = np.zeros(num_energies)
2326

2427
for index, energy in enumerate(energies):
25-
lindhard_scharff[index], bethe_bloch[index], biersack_varelas[index] = electronic_stopping_cross_sections(Za, Zb, energy, Ma, 1.4)
28+
lindhard_scharff[index], bethe_bloch[index], biersack_varelas[index], bv_custom[index] = electronic_stopping_cross_sections(Za, Zb, energy, Ma, ck, ci)
2629

27-
plt.loglog(energies, lindhard_scharff*n_Al, label='Lindhard-Scharff (ck=1.4 [Eckstein 1991 Tab. 5.1])')
28-
plt.loglog(energies, bethe_bloch*n_Al, label='Bethe-Bloch (ck=1.4)')
29-
plt.loglog(energies, biersack_varelas*n_Al, label='Biersack-Varelas (ck=1.4)')
30+
plt.loglog(energies, lindhard_scharff*n_Al, label=f'Lindhard-Scharff (ck={ck}[Eckstein 1991 Tab. 5.1])')
31+
plt.loglog(energies, bethe_bloch*n_Al, label=f'Bethe-Bloch (ck={ck})')
32+
plt.loglog(energies, biersack_varelas*n_Al, label=f'Biersack-Varelas (ck={ck})')
33+
plt.loglog(energies, bv_custom*n_Al, label=f'Biersack-Varelas (ck={ck}, ci={ci})', linestyle='--')
3034

3135
plt.legend(loc='lower left')
3236
plt.title('Nonlocal Electronic Stopping Modes in RustBCA (H -> Al)')
@@ -38,12 +42,17 @@
3842
plt.figure()
3943
index_valid = np.argmax(energies > 1e9)
4044
residual = np.sqrt((biersack_varelas[:index_valid]*n_Al - S_PSTAR[:index_valid])**2)/S_PSTAR[:index_valid]
45+
residual_custom = np.sqrt((bv_custom[:index_valid]*n_Al - S_PSTAR[:index_valid])**2)/S_PSTAR[:index_valid]
4146
# Biersack-Varelas interpolation misses the peak with ~19.9% error, but has ~1% error in LS region and max 3% error in B-B region below 1e8 ev
4247
np.testing.assert_allclose(residual, 0.0, atol=0.2)
4348

4449

45-
plt.loglog(energies[:index_valid], residual)
46-
plt.title('Biersack-Varelas residual against PSTAR (H->Al, ck=1.4 [Eckstein 1991 Tab. 5.1])')
50+
plt.loglog(energies[:index_valid], residual, label='Original Biersack-Varelas')
51+
plt.loglog(energies[:index_valid], residual_custom, label=f'BV with custom interp. weight ci={ci}')
52+
plt.title(f'Biersack-Varelas residual against PSTAR (H->Al, ck={ck})')
4753
plt.xlabel('E [eV]')
4854
plt.ylabel('Error in BV vs PSTAR')
49-
plt.savefig('biersack_varelas_residual.png')
55+
plt.legend()
56+
plt.savefig('biersack_varelas_residual.png')
57+
58+
plt.show()

‎src/bca.rs‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -454,8 +454,8 @@ pub fn subtract_electronic_stopping_energy<T: Geometry>(particle_1: &mut particl
454454
let n = material.number_densities(x, y, z);
455455

456456
let delta_energy_electronic = match options.electronic_stopping_mode {
457-
ElectronicStoppingMode::INTERPOLATED => electronic_stopping_powers.iter().zip(n).map(|(se, number_density)| se*number_density).collect::<Vec<f64>>().iter().sum::<f64>()*distance_traveled,
458-
ElectronicStoppingMode::LOW_ENERGY_NONLOCAL => electronic_stopping_powers.iter().zip(n).map(|(se, number_density)| se*number_density).collect::<Vec<f64>>().iter().sum::<f64>()*distance_traveled,
457+
ElectronicStoppingMode::INTERPOLATED | ElectronicStoppingMode::LOW_ENERGY_NONLOCAL | ElectronicStoppingMode::INTERPOLATEDPLUS{..} => electronic_stopping_powers.iter().zip(n).map(|(se, number_density)| se*number_density).collect::<Vec<f64>>().iter().sum::<f64>()*distance_traveled,
458+
//ElectronicStoppingMode::LOW_ENERGY_NONLOCAL => electronic_stopping_powers.iter().zip(n).map(|(se, number_density)| se*number_density).collect::<Vec<f64>>().iter().sum::<f64>()*distance_traveled,
459459
ElectronicStoppingMode::LOW_ENERGY_LOCAL => oen_robinson_loss(particle_1.Z, strong_collision_Z, electronic_stopping_powers[strong_collision_index], x0, interaction_potential),
460460
ElectronicStoppingMode::LOW_ENERGY_EQUIPARTITION => {
461461

‎src/enums.rs‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ pub enum ElectronicStoppingMode {
4444
LOW_ENERGY_NONLOCAL,
4545
/// Equipartition between Oen-Robinson and Lindhard-Scharff electronic stopping formulas.
4646
LOW_ENERGY_EQUIPARTITION,
47+
/// Biersack-Varelas interpolated electronic stopping with custom interpolation weight. Valid for ~eV/nucleon to ~GeV/nucleon.
48+
INTERPOLATEDPLUS{ci: f64}
4749
}
4850

4951
impl fmt::Display for ElectronicStoppingMode {
@@ -53,6 +55,7 @@ impl fmt::Display for ElectronicStoppingMode {
5355
ElectronicStoppingMode::LOW_ENERGY_NONLOCAL => write!(f, "Lindhard-Scharff electronic stopping"),
5456
ElectronicStoppingMode::LOW_ENERGY_LOCAL => write!(f, "Oen-Robinson electronic stopping"),
5557
ElectronicStoppingMode::LOW_ENERGY_EQUIPARTITION => write!(f, "Equipartition with Lindhard-Scharff and Oen-Robinson"),
58+
ElectronicStoppingMode::INTERPOLATEDPLUS{ci} => write!(f, "Biersack-Varelas interpolation with custom weight ci={}.", ci)
5659
}
5760
}
5861
}

‎src/lib.rs‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -841,14 +841,15 @@ pub extern "C" fn simple_bca_c(x: f64, y: f64, z: f64, ux: f64, uy: f64, uz: f64
841841
/// E (f64): ion energy in eV
842842
/// Ma (f64): ion mass in AMU
843843
/// ck (f64): LS correction factor
844+
/// ci (f64): BV custom interp. weight
844845
/// Returns:
845-
/// (Lindhard-Scharff [eV m^2], Bethe-Bloch [eV m^2], Biersack-Varelas [eV m^2])
846-
pub fn electronic_stopping_cross_sections(Za: f64, Zb: f64, E: f64, Ma: f64, ck: f64) -> (f64, f64, f64) {
846+
/// (Lindhard-Scharff [eV m^2], Bethe-Bloch [eV m^2], Biersack-Varelas [eV m^2], Biersack-Varelas with custom interp. weight [eV m^2])
847+
pub fn electronic_stopping_cross_sections(Za: f64, Zb: f64, E: f64, Ma: f64, ck: f64, ci: f64) -> (f64, f64, f64, f64) {
847848

848849
let S_low = lindhard_scharff_stopping_power_cross_section(Za, Zb, E*EV, Ma*AMU);
849850
let S_high = bethe_bloch_stopping_power_cross_section(Za, Zb, E*EV, Ma*AMU);
850851

851-
(S_low*ck/EV, S_high/EV, 1./(1./(S_high) + 1./(S_low*ck))/EV)
852+
(S_low*ck/EV, S_high/EV, 1./(1./(S_high) + 1./(S_low*ck))/EV, (S_high.powf(-ci) + (S_low*ck).powf(-ci)).powf(-1./ci)/EV)
852853
}
853854

854855
#[cfg(feature = "python")]

‎src/material.rs‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ impl <T: Geometry> Material<T> {
180180
}
181181
}
182182

183-
/// Finds the concentration-dependent surface binding energy of the triangle that contains or is nearest to (x, y).
183+
/// Finds the concentration-dependent surface binding energy of the geometry element that contains or is nearest to (x, y, z).
184184
/// The surface binding energy is calculated using one of three methods:
185185
/// 1. INDIVIDUAL: the surface binding energies are set individually for each species, as Es.
186186
/// 2. TARGET: the surface binding energy is calculated as the local concentration-weighted average of the target surface binding energies, unless the particle has Es = 0, in which case it is 0.
@@ -285,6 +285,13 @@ impl <T: Geometry> Material<T> {
285285
ElectronicStoppingMode::LOW_ENERGY_LOCAL | ElectronicStoppingMode::LOW_ENERGY_NONLOCAL | ElectronicStoppingMode::LOW_ENERGY_EQUIPARTITION => {
286286
S_low*ck
287287
},
288+
ElectronicStoppingMode::INTERPOLATEDPLUS{ci} => {
289+
let S_high = bethe_bloch_stopping_power_cross_section(Za, *Zb, E, Ma);
290+
291+
// correction applied only to LS component
292+
(S_high.powf(-ci) + (S_low*ck).powf(-ci)).powf(-1./ci)
293+
},
294+
288295
};
289296
stopping_powers.push(stopping_power);
290297
}

0 commit comments

Comments
 (0)