Skip to content

Commit

Permalink
Set default atol equal to non-zero value for Python leapfrog integrat…
Browse files Browse the repository at this point in the history
…or and introduce maximum time step reduction like in C; fixes #336
  • Loading branch information
jobovy committed Jul 3, 2018
1 parent 19a1ddb commit 3c38e68
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions galpy/util/bovy_symplecticode.py
Expand Up @@ -31,7 +31,8 @@
#POSSIBILITY OF SUCH DAMAGE.
#############################################################################
import numpy as nu
def leapfrog(func,yo,t,args=(),rtol=1.49012e-8,atol=0.):
_MAX_DT_REDUCE= 10000.
def leapfrog(func,yo,t,args=(),rtol=1.49012e-12,atol=1.49012e-12):
"""
NAME:
leapfrog
Expand Down Expand Up @@ -84,12 +85,13 @@ def leapfrog_leapp(p,dt,force):
return p+dt*force

def _leapfrog_estimate_step(func,qo,po,dt,to,args,rtol,atol):
init_dt= dt
qmax= nu.amax(nu.fabs(qo))+nu.zeros(len(qo))
pmax= nu.amax(nu.fabs(po))+nu.zeros(len(po))
scale= atol+rtol*nu.array([qmax,pmax]).flatten()
err= 2.
dt*= 2.
while err > 1.:
while err > 1. and init_dt/dt < _MAX_DT_REDUCE:
#Do one leapfrog step with step dt and one with dt/2.
#dt
q12= leapfrog_leapq(qo,po,dt/2.)
Expand Down

0 comments on commit 3c38e68

Please sign in to comment.