@@ -2,6 +2,9 @@ use super::*;
22use rand:: RngExt ;
33use anyhow:: ensure;
44
5+ #[ cfg( feature = "cpr_rootfinder" ) ]
6+ const CPR_ROOTFINDER_LOWER_BOUND : f64 = 1e-4 ;
7+
58#[ cfg( feature = "cpr_rootfinder" ) ]
69use rcpr:: rootfinders:: {
710 find_roots,
@@ -635,11 +638,9 @@ pub fn cpr_rootfinder(Za: f64, Zb: f64, Ma: f64, Mb: f64, E0: f64, impact_parame
635638 interactions:: distance_of_closest_approach_function_singularity_free ( transform ( r) * a, a, Za , Zb , relative_energy, impact_parameter, interaction_potential) *
636639 interactions:: scaling_function ( transform ( r) * a, a, interaction_potential)
637640 } ;
638-
639- ensure ! ( 1.0 - inverse_transform( impact_parameter/a) > interval_limit, "Numerical error: impact parameter {} A smaller than interval limit." , impact_parameter/a) ;
640-
641- let upper_bound = 1.0 ;
642- let lower_bound = 1e-4 ;
641+
642+ let lower_bound = CPR_ROOTFINDER_LOWER_BOUND ;
643+ let upper_bound = 1.0_f64 ;
643644
644645 let delta = 1e-5 ;
645646 let config = Config :: new (
@@ -660,7 +661,7 @@ pub fn cpr_rootfinder(Za: f64, Zb: f64, Ma: f64, Mb: f64, E0: f64, impact_parame
660661 let max_root = roots. iter ( ) . map ( |& x| transform ( x) ) . max_by ( f64:: total_cmp) . expect ( "Numerical error: failed to find maximum root." ) ;
661662
662663 if roots. is_empty ( ) || max_root. is_nan ( ) {
663- return Err ( anyhow ! ( "Numerical error: CPR rootfinder failed to find root. x0: {}, F(a): {}, F(b): {};" , max_root, g( 0. ) , g( upper_bound) ) ) ;
664+ return Err ( anyhow ! ( "Numerical error: CPR rootfinder failed to find root. x0: {}, F(a): {}, F(b): {};" , max_root, g( lower_bound ) , g( upper_bound) ) ) ;
664665 } else {
665666 return Ok ( max_root) ;
666667 }
0 commit comments