@@ -510,8 +510,8 @@ pub fn calculate_binary_collision(particle_1: &particle::Particle, particle_2: &
510510 _ => x0* a* ( theta/2. ) . sin ( )
511511 } ;
512512
513- let psi = theta. sin ( ) . atan2 ( Ma /Mb + theta. cos ( ) ) ; //.abs();
514- let psi_recoil = theta. sin ( ) . atan2 ( 1. - theta. cos ( ) ) ; //.abs();
513+ let psi = theta. sin ( ) . atan2 ( Ma /Mb + theta. cos ( ) ) ;
514+ let psi_recoil = theta. sin ( ) . atan2 ( 1. - theta. cos ( ) ) ;
515515 let recoil_energy = 4. * ( Ma * Mb ) /( Ma + Mb ) . powi ( 2 ) * E0 * ( theta/2. ) . sin ( ) . powi ( 2 ) ;
516516
517517 Ok ( BinaryCollisionResult :: new ( theta, psi, psi_recoil, recoil_energy, asymptotic_deflection, x0) )
@@ -583,18 +583,6 @@ pub fn polynomial_rootfinder(Za: f64, Zb: f64, Ma: f64, Mb: f64, E0: f64, impact
583583 let coefficients = interactions:: polynomial_coefficients ( relative_energy, impact_parameter, interaction_potential) ;
584584 let roots = real_polynomial_roots ( coefficients. clone ( ) , polynom_complex_threshold) . unwrap ( ) ;
585585
586- /*
587- println!("p={}", impact_parameter/ANGSTROM);
588-
589- for coefficient in &coefficients {
590- println!("{}", {coefficient});
591- }
592-
593- for root in &roots {
594- println!("{} A", {root});
595- }
596- */
597-
598586 let max_root = roots. iter ( ) . cloned ( ) . fold ( f64:: NAN , f64:: max) ;
599587
600588 let inverse_transformed_root = interactions:: inverse_transform ( max_root, interaction_potential) ;
@@ -642,8 +630,6 @@ pub fn cpr_rootfinder(Za: f64, Zb: f64, Ma: f64, Mb: f64, E0: f64, impact_parame
642630 let g = |r : f64 | -> f64 { interactions:: distance_of_closest_approach_function_singularity_free ( r, a, Za , Zb , relative_energy, impact_parameter, interaction_potential) *
643631 interactions:: scaling_function ( r, impact_parameter, interaction_potential) } ;
644632
645- //Using upper bound const, ~10, construct upper bound as a plateau near 0 and linear increase away from that
646- //let upper_bound = f64::max(upper_bound_const*p, upper_bound_const*a);
647633 let upper_bound = impact_parameter + interactions:: crossing_point_doca ( interaction_potential) ;
648634
649635 let roots = match derivative_free {
@@ -683,14 +669,16 @@ pub fn newton_rootfinder(Za: f64, Zb: f64, Ma: f64, Mb: f64, E0: f64, impact_par
683669 let f = |r : f64 | -> f64 { interactions:: distance_of_closest_approach_function ( r, a, Za , Zb , relative_energy, impact_parameter, interaction_potential) } ;
684670 let df = |r : f64 | -> f64 { interactions:: diff_distance_of_closest_approach_function ( r, a, Za , Zb , relative_energy, impact_parameter, interaction_potential) } ;
685671
686- //Guess for large reduced energy from Mendenhall and Weller 1991
687- //For small energies, use pure Newton-Raphson with arbitrary guess of 1
688- let mut x0 = beta;
689672 let mut xn: f64 ;
690- if reduced_energy > 5. {
673+
674+ //Guess for large reduced energy from Mendenhall and Weller 1991
675+ //For small energies, use pure Newton-Raphson with arbitrary guess of beta
676+ let mut x0 = if reduced_energy > 5. {
691677 let inv_er_2 = 0.5 /reduced_energy;
692- x0 = inv_er_2 + ( inv_er_2* inv_er_2 + beta* beta) . sqrt ( ) ;
693- }
678+ inv_er_2 + ( inv_er_2* inv_er_2 + beta* beta) . sqrt ( )
679+ } else {
680+ beta
681+ } ;
694682
695683 //Newton-Raphson to determine distance of closest approach
696684 let mut err: f64 = tolerance + 1. ;
0 commit comments