Skip to content

Commit

Permalink
preserved the bool mask in gatti, chahl
Browse files Browse the repository at this point in the history
  • Loading branch information
Gorkowski committed Feb 7, 2025
1 parent 3849c5f commit 8047248
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 21 deletions.

Large diffs are not rendered by default.

9 changes: 6 additions & 3 deletions particula/dynamics/coagulation/transition_regime.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ def coulomb_dyachkov2007(
Journal of Chemical Physics, 126(12).
https://doi.org/10.1063/1.2713719
"""

coulomb_potential_ratio = np.maximum(
coulomb_potential_ratio, 1e-16
) # Avoid division by zero
Expand Down Expand Up @@ -141,6 +142,7 @@ def coulomb_gatti2008(
E - Statistical, Nonlinear, and Soft Matter Physics, 78(4).
https://doi.org/10.1103/PhysRevE.78.046402
"""
bool_mask = coulomb_potential_ratio >= 0
# Ensure no division by zero
coulomb_potential_ratio = np.maximum(coulomb_potential_ratio, 1e-16)

Expand All @@ -153,7 +155,7 @@ def coulomb_gatti2008(
factored_term = (pi_sqrt * continuum * coulomb_potential_ratio * 1.22) / (
2 * kinetic * diffusive_knudsen
)
exponential_decay = np.exp(-factored_term)
exponential_decay = safe_exp(-factored_term)

term1 = continuum_limit * (1 - (1 + factored_term) * exponential_decay)
term2 = (
Expand All @@ -174,7 +176,7 @@ def coulomb_gatti2008(
)
# coulomb_potential_ratio is below 0 returns hard sphere
return np.where(
coulomb_potential_ratio > 0,
bool_mask,
term1 + term2,
hard_sphere(diffusive_knudsen),
)
Expand Down Expand Up @@ -246,6 +248,7 @@ def coulomb_chahl2019(
Aerosol Science and Technology, 53(8), 933-957.
https://doi.org/10.1080/02786826.2019.1614522
"""
bool_mask = coulomb_potential_ratio > 0
# Ensure no division by zero
coulomb_potential_ratio = np.maximum(coulomb_potential_ratio, 1e-12)

Expand All @@ -270,7 +273,7 @@ def coulomb_chahl2019(
)
)
return np.where(
coulomb_potential_ratio > 0,
bool_mask,
safe_exp(correction_mu) * hard_sphere(diffusive_knudsen),
hard_sphere(diffusive_knudsen),
)

0 comments on commit 8047248

Please sign in to comment.