src/SVPH/CompatibleFaceSpecificThermalEnergyPolicy.cc
// A strictly monotonic scheme that *will* pull the specific thermal energies
// together.
A strictly monotonic scheme that *will* pull the specific thermal energies
together.
A strictly monotonic scheme that * will * pull the specific thermal energies together .
inline
double monotonicWeighting(const double& ui,
                          const double& uj,
                          const double& mi,
                          const double& mj,
                          const double& DEij) {
  REQUIRE(mi > 0.0);
  REQUIRE(mj > 0.0);
  const double uji = uj - ui;
  const double miInv = 1.0/mi;
  const double mjInv = 1.0/mj;
  double result;
  if (uji*DEij >= 0.0) {
    const double A = min(1.0, max(0.0, uji*mi*safeInv(DEij, 1.0e-50)));
    const double B = min(1.0, max(0.0, mjInv/(miInv + mjInv)));
    CHECK(A >= 0.0 and A <= 1.0);
    CHECK(B >= 0.0 and B <= 1.0);
    result = A + B*(1.0 - A);
  } else {
    const double A = min(1.0, max(0.0, -uji*mj*safeInv(DEij, 1.0e-50)));
    const double B = min(1.0, max(0.0, miInv/(miInv + mjInv)));
    CHECK(A >= 0.0 and A <= 1.0);
    CHECK(B >= 0.0 and B <= 1.0);
    result = 1.0 - A - B*(1.0 - A);
  }
  ENSURE(result >= 0.0 and result <= 1.0);
  return result;
}
inline double monotonicWeighting ( const double & ui , const double & uj , const double & mi , const double & mj , const double & DEij ) { REQUIRE ( mi > 0.0 ) ; REQUIRE ( mj > 0.0 ) ; const double uji = uj - ui ; const double miInv = 1.0 / mi ; const double mjInv = 1.0 / mj ; double result ; if ( uji * DEij >= 0.0 ) { const double A = min ( 1.0 , max ( 0.0 , uji * mi * safeInv ( DEij , 1.0e-50 ) ) ) ; const double B = min ( 1.0 , max ( 0.0 , mjInv / ( miInv + mjInv ) ) ) ; CHECK ( A >= 0.0 and A <= 1.0 ) ; CHECK ( B >= 0.0 and B <= 1.0 ) ; result = A + B * ( 1.0 - A ) ; } else { const double A = min ( 1.0 , max ( 0.0 , - uji * mj * safeInv ( DEij , 1.0e-50 ) ) ) ; const double B = min ( 1.0 , max ( 0.0 , miInv / ( miInv + mjInv ) ) ) ; CHECK ( A >= 0.0 and A <= 1.0 ) ; CHECK ( B >= 0.0 and B <= 1.0 ) ; result = 1.0 - A - B * ( 1.0 - A ) ; } ENSURE ( result >= 0.0 and result <= 1.0 ) ; return result ; }
A strictly monotonic scheme that *will* pull the specific thermal energies
together.
A strictly monotonic scheme that * will * pull the specific thermal energies together .