Skip to content

Commit

Permalink
exit Kepler equation iteration if tolerance reach
Browse files Browse the repository at this point in the history
  • Loading branch information
Sceki committed Jul 9, 2024
1 parent 152df44 commit 49f1884
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
3 changes: 3 additions & 0 deletions dsgp4/sgp4.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,10 @@ def sgp4(satellite, tsince):
tem5 = (u - aynl * coseo1 + axnl * sineo1 - eo1) / tem5
tem5=torch.where(tem5>=0.95, 0.95, tem5)
tem5=torch.where(tem5<=-0.95, -0.95, tem5)
#we need to break if abs value of tem5 is less than 1e-12:
eo1 = eo1 + tem5
if torch.all(torch.abs(tem5) < 1e-12):
break

# short period preliminary quantities
ecose = axnl*coseo1 + aynl*sineo1
Expand Down
2 changes: 2 additions & 0 deletions dsgp4/sgp4_batched.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,8 @@ def sgp4_batched(satellite_batch, tsince):
tem5=torch.where(tem5>=0.95, 0.95, tem5)
tem5=torch.where(tem5<=-0.95, -0.95, tem5)
eo1 = eo1 + tem5
if torch.all(torch.abs(tem5) < 1e-12):
break

# short period preliminary quantities
ecose = axnl*coseo1 + aynl*sineo1
Expand Down

0 comments on commit 49f1884

Please sign in to comment.