Skip to content

Commit 5b22775

Browse files
authored
Merge pull request #341 from lcpp-org/rcpr_with_relative_error
rcpr minor changes
2 parents 01e67ae + a4e6842 commit 5b22775

2 files changed

Lines changed: 7 additions & 6 deletions

File tree

‎src/bca.rs‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
use super::*;
22
use rand::RngExt;
33

4+
45
#[cfg(feature = "cpr_rootfinder")]
56
const CPR_ROOTFINDER_LOWER_BOUND: f64 = 1e-4;
67

@@ -17,6 +18,8 @@ use rcpr::rootfinders::{
1718
real_polynomial_roots,
1819
Config
1920
};
21+
#[cfg(feature = "cpr_rootfinder")]
22+
use rcpr::chebyshev::ErrorCalc;
2023

2124
/// Geometrical quantities of binary collision.
2225
pub struct BinaryCollisionGeometry {
@@ -606,8 +609,6 @@ fn transform(x: f64, l: f64) -> f64 {
606609
l/(x*PI/2.).tan().powi(2)
607610
}
608611

609-
610-
611612
#[cfg(feature = "cpr_rootfinder")]
612613
/// Computes the distance of closest approach of two particles with atomic numbers `Za`, `Zb` and masses `Ma`, `Mb` for an arbitrary interaction potential (e.g., Morse) for a given impact parameter and incident energy `E0` using the Chebyshev-Proxy Root-Finder method.
613614
///
@@ -655,7 +656,8 @@ pub fn cpr_rootfinder(Za: f64, Zb: f64, Ma: f64, Mb: f64, E0: f64, impact_parame
655656
nmax,
656657
complex_threshold,
657658
far_from_zero,
658-
interval_limit
659+
interval_limit,
660+
ErrorCalc::Relative,
659661
);
660662

661663
let roots = find_roots(&g, vec![(lower_bound, upper_bound)], config)?;

‎src/lib.rs‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2175,8 +2175,8 @@ fn scattering_integrals(Za: f64, Zb: f64, Ma: f64, Mb: f64, E0: f64, p: f64, n_g
21752175

21762176
#[cfg(feature = "python")]
21772177
#[pyfunction]
2178-
#[pyo3(signature = (Za, Zb, Ma, Mb, E0, p, d, alpha, r0, n0=2, nmax=64, epsilon=1e-6, complex_threshold=0.0, far_from_zero=1e22, interval_limit=1e-3, n_gl_points=100, interaction_potential="KR_C"))]
2179-
fn scattering_integral_morse(Za: f64, Zb: f64, Ma: f64, Mb: f64, E0: f64, p: f64, d: f64, alpha: f64, r0: f64, n0: usize, nmax: usize, epsilon: f64, complex_threshold: f64, far_from_zero: f64, interval_limit: f64, n_gl_points: usize, interaction_potential: &str) -> PyResult<(f64, f64, f64)> {
2178+
#[pyo3(signature = (Za, Zb, Ma, Mb, E0, p, d, alpha, r0, n0=2, nmax=64, epsilon=1e-6, complex_threshold=0.0, far_from_zero=1e22, interval_limit=1e-3, n_gl_points=100))]
2179+
fn scattering_integral_morse(Za: f64, Zb: f64, Ma: f64, Mb: f64, E0: f64, p: f64, d: f64, alpha: f64, r0: f64, n0: usize, nmax: usize, epsilon: f64, complex_threshold: f64, far_from_zero: f64, interval_limit: f64, n_gl_points: usize) -> PyResult<(f64, f64, f64)> {
21802180
let E0 = E0*EV;
21812181
let p = p*ANGSTROM;
21822182
let d = d*EV;
@@ -2199,7 +2199,6 @@ fn scattering_integral_morse(Za: f64, Zb: f64, Ma: f64, Mb: f64, E0: f64, p: f64
21992199
let theta_gm = bca::gauss_mehler(Za, Zb, Ma, Mb, E0, p, x0, screening_length, potential, n_gl_points);
22002200
let theta_gl = bca::gauss_legendre(Za, Zb, Ma, Mb, E0, p, x0, screening_length, potential);
22012201

2202-
22032202
Ok((x0, theta_gm, theta_gl))
22042203
}
22052204

0 commit comments

Comments
 (0)