tavoid NaN values from harmonic mean computation - Granular.jl - Julia package for granular dynamics simulation
(HTM) git clone git://src.adamsgaard.dk/Granular.jl
(DIR) Log
(DIR) Files
(DIR) Refs
(DIR) README
(DIR) LICENSE
---
(DIR) commit 4ef34d5d68a9760142cecc7e851a72bb298201c4
(DIR) parent e6423e746bc3d5ee39a065427f18b4be7a8021b3
(HTM) Author: Anders Damsgaard <andersd@riseup.net>
Date: Fri, 12 May 2017 10:51:10 -0400
avoid NaN values from harmonic mean computation
Diffstat:
M src/interaction.jl | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
---
(DIR) diff --git a/src/interaction.jl b/src/interaction.jl
t@@ -159,9 +159,9 @@ function interactIceFloes!(simulation::Simulation, i::Int, j::Int, ic::Int)
end
function harmonicMean(a::Any, b::Any)
- hm = 2.*a*b/(a + b)
- if isnan(hm)
+ if a ≈ 0. && b ≈ 0
return 0.
+ else
+ return 2.*a*b/(a + b)
end
- return hm
end