@@ -54,13 +54,6 @@ struct DoCoalBuRe {
5454 DoBreakup<NFrags> bu; /* *< Instance of DoBreakup with specified no. of fragments calculation. */
5555 Flag coalbure_flag; /* *< Instance of CoalBuReFlag indicating the action to perform. */
5656
57- /*
58- rescale random number phi be in desired range of [0, 1] to account for fact that if a
59- collision occurs (i.e. if gamma != 0) then phi lies in range [0, prob - floor(prob)] rather than
60- [0, 1].
61- * _Note:_ This function is assumed to be consitent with collision_gamma(...) and must be.
62- */
63-
6457 /* *
6558 * @brief Rescales a random number phi to be in the desired range [0, 1].
6659 *
@@ -76,7 +69,12 @@ struct DoCoalBuRe {
7669 */
7770 KOKKOS_FUNCTION
7871 uint64_t rescale_phi (const double prob, const double phi) const {
79- return phi / (prob - Kokkos::floor (prob));
72+ const auto denom = prob - Kokkos::floor (prob);
73+ if (phi < denom) {
74+ return phi / (prob - Kokkos::floor (prob));
75+ } else {
76+ return (1.0 - phi) / (prob - Kokkos::floor (prob));
77+ }
8078 }
8179
8280 /* *
@@ -149,7 +147,7 @@ struct DoCoalBuRe {
149147 * @return True if the resulting superdroplet is null, otherwise false.
150148 */
151149 KOKKOS_INLINE_FUNCTION
152- bool operator ()(Superdrop & drop1, Superdrop & drop2, const double prob, const double phi) const ;
150+ bool operator ()(Superdrop& drop1, Superdrop& drop2, const double prob, const double phi) const ;
153151};
154152
155153/* *
@@ -198,7 +196,7 @@ inline MicrophysicalProcess auto CoalBuRe(const unsigned int interval,
198196 * @return True if the resulting superdroplet is null, otherwise false.
199197 */
200198template <NFragments NFrags, CoalBuReFlag Flag>
201- KOKKOS_FUNCTION bool DoCoalBuRe<NFrags, Flag>::operator ()(Superdrop & drop1, Superdrop & drop2,
199+ KOKKOS_FUNCTION bool DoCoalBuRe<NFrags, Flag>::operator ()(Superdrop& drop1, Superdrop& drop2,
202200 const double prob,
203201 const double phi) const {
204202 /* 1. calculate gamma factor for collision */
0 commit comments