Skip to content

Commit

Permalink
added missing 1000 multiple
Browse files Browse the repository at this point in the history
  • Loading branch information
shimwell committed Oct 26, 2024
1 parent 085ba08 commit 1449890
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
9 changes: 4 additions & 5 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,17 @@ fn neutron_energy_mean_and_std_dev(
) -> PyResult<(f64, f64)> {
// values from Ballabio paper
let (a_1, a_2, a_3, a_4, mean) = match reaction {
Some("D+D=n+He3") => (4.69515, -0.040729, 0.47, 0.81844, 2.4495e6),
Some("D+T=n+a") => (5.30509, 2.4736e-3, 1.84, 1.3818, 14.021e6),
Some("D+D=n+He3") => (4.69515, -0.040729, 0.47, 0.81844, 2.4486858678216934e6),
Some("D+T=n+a") => (5.30509, 0.0024736, 1.84, 1.3818, 14028394.744466662),
_ => return Err(PyErr::new::<pyo3::exceptions::PyValueError, _>("reaction must be either 'D+D=n+He3' or 'D+T=n+a'")),
};

let ion_temperature_kev: f64 = scale_temperature_units_to_kev(ion_temperature, temperature_units); // Ballabio equation accepts KeV units

// units of mean_delta are in ev
let mean_delta = a_1 * ion_temperature_kev.powf(2.0 / 3.0) / (1.0 + a_2 * ion_temperature_kev.powf(a_3)) + a_4 * ion_temperature_kev;
// units of mean_delta are in put into ev with the 1000 multiplication
let mean_delta = 1000.0 *( a_1 * ion_temperature_kev.powf(0.66666666) / (1.0 + a_2 * ion_temperature_kev.powf(a_3)) + a_4 * ion_temperature_kev);

let mean_adjusted = mean + mean_delta;
print!("{}", mean);

let mean_scaled = scale_energy_in_kev_to_requested_units(mean_adjusted/1e3, neutron_energy_units);

Expand Down
8 changes: 4 additions & 4 deletions tests/test_average_neutron_energy.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ def test_mean_energy_with_nesst():
temperature_units='eV',
neutron_energy_units='eV'
)
# assert nesst_dt_mean == fnu_dt_mean
assert nesst_dd_mean == fnu_dd_mean
assert nest_dt_std_dev == fnu_dt_std_dev
assert nest_dd_std_dev == fnu_dd_std_dev
assert nesst_dt_mean == approx(fnu_dt_mean, rel=1e-6)
assert nesst_dd_mean == approx(fnu_dd_mean, rel=1e-6)
assert nest_dt_std_dev == approx(fnu_dt_std_dev, rel=1e-6)
assert nest_dd_std_dev == approx(fnu_dd_std_dev, rel=1e-6)

def test_mean_energy():
mean, std_dev = neutron_energy_mean_and_std_dev(
Expand Down

0 comments on commit 1449890

Please sign in to comment.