/// The repulsive part of the potential.
The repulsive part of the potential.
The repulsive part of the potential .
fn scaled_repulsive_part(params: &Params, distsq: f64, rdata: RData, r: V3) -> (f64, V3, M33) {
    // the sum factor
    let RData { dist, dist_d_r, dist_dd_r_r } = rdata;
    let (rep, rep_d_r, rep_dd_r_r) = unscaled_repulsive_part(params, distsq, r);
    // the exponential scaling factor
    let (scale, scale_d_r, scale_dd_r_r);
    {
        scale = f64::exp(-params.lambda * (dist - params.z0));
        let scale_d_dist = -params.lambda * scale;
        let scale_dd_dist_dist = -params.lambda * scale_d_dist;
        // ...in terms of r
        scale_d_r = scale_d_dist * dist_d_r;
        scale_dd_r_r = scale_d_dist * dist_dd_r_r + scale_dd_dist_dist * outer(dist_d_r, dist_d_r);
    }
    dbg!("scale: {:.9}", scale);
    let value = scale * rep;
    let d_r = scale_d_r * rep + scale * rep_d_r;
    let dd_r_r = scale_dd_r_r * rep + scale * rep_dd_r_r + plus_t(outer(scale_d_r, rep_d_r));
    (value, d_r, dd_r_r)
}
fn scaled_repulsive_part ( params : & Params , distsq : f64 , rdata : RData , r : V3 ) -> ( f64 , V3 , M33 ) { // the sum factor let RData { dist , dist_d_r , dist_dd_r_r } = rdata ; let ( rep , rep_d_r , rep_dd_r_r ) = unscaled_repulsive_part ( params , distsq , r ) ; // the exponential scaling factor let ( scale , scale_d_r , scale_dd_r_r ) ; { scale = f64 :: exp ( - params . lambda * ( dist - params . z0 ) ) ; let scale_d_dist = - params . lambda * scale ; let scale_dd_dist_dist = - params . lambda * scale_d_dist ; // ...in terms of r scale_d_r = scale_d_dist * dist_d_r ; scale_dd_r_r = scale_d_dist * dist_dd_r_r + scale_dd_dist_dist * outer ( dist_d_r , dist_d_r ) ; } dbg ! ( " " scale ) ; let value = scale * rep ; let d_r = scale_d_r * rep + scale * rep_d_r ; let dd_r_r = scale_dd_r_r * rep + scale * rep_dd_r_r + plus_t ( outer ( scale_d_r , rep_d_r ) ) ; ( value , d_r , dd_r_r ) }
The repulsive part of the potential.
The repulsive part of the potential .
params
&Params
distsq
f64
rdata
RData
r
V3