Skip to content

Commit

Permalink
fix: don't normalize flux if it sums to zero
Browse files Browse the repository at this point in the history
  • Loading branch information
fjebaker committed Jun 23, 2024
1 parent 39bf3ff commit a88f10a
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/transfer-functions/utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,9 @@ function _normalize!(flux::AbstractVector{T}, grid) where {T}
flux[i] = flux[i] /
Σflux += flux[i]
end
@. flux = flux / Σflux
if Σflux > 0
@. flux = flux / Σflux
end
flux
end

Expand All @@ -143,6 +145,8 @@ function _normalize!(flux::AbstractMatrix{T}, grid) where {T}
@. flux[i, :] = flux[i, :] /
Σflux += sum(flux[i, :])
end
@. flux = flux / Σflux
if Σflux > 0
@. flux = flux / Σflux
end
flux
end

0 comments on commit a88f10a

Please sign in to comment.