Skip to content
This repository was archived by the owner on Aug 28, 2024. It is now read-only.

Commit

Permalink
Fixed potential issues with underflow and NaN values for degenerate o…
Browse files Browse the repository at this point in the history
…rbits
  • Loading branch information
daminton committed Jan 12, 2023
1 parent 600c1b0 commit acb580e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/swiftest/swiftest_gr.f90
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,10 @@ pure module subroutine swiftest_gr_vel2pseudovel(param, mu, rh, vh, pv)
pv(1:NDIM) = vh(1:NDIM) ! Initial guess
rterm = 3 * mu / norm2(rh(:))
v2 = dot_product(vh(:), vh(:))
if (v2 < TINY(1.0_DP)) then
pv(:) = 0.0_DP
return
end if
do n = 1, MAXITER
pv2 = dot_product(pv(:), pv(:))
G = 1.0_DP - inv_c2 * (0.5_DP * pv2 + rterm)
Expand Down
5 changes: 5 additions & 0 deletions src/swiftest/swiftest_orbel.f90
Original file line number Diff line number Diff line change
Expand Up @@ -939,6 +939,11 @@ pure module subroutine swiftest_orbel_xv2el(mu, px, py, pz, vx, vy, vz, a, e, in
capom = 0.0_DP
omega = 0.0_DP
capm = 0.0_DP
varpi = 0.0_DP
lam = 0.0_DP
f = 0.0_DP
cape = 0.0_DP
capf = 0.0_DP
x = [px, py, pz]
v = [vx, vy, vz]
r = .mag. x(:)
Expand Down

0 comments on commit acb580e

Please sign in to comment.