コード例 #1
0
ファイル: directnbody.py プロジェクト: viveikjha/galpy
def _external_force(x,t,pot):
    dim= len(x)
    if dim == 3:
        #x is rectangular so calculate R and phi
        R= nu.sqrt(x[0]**2.+x[1]**2.)
        phi= nu.arccos(x[0]/R)
        sinphi= x[1]/R
        cosphi= x[0]/R
        if x[1] < 0.: phi= 2.*nu.pi-phi
        #calculate forces
        Rforce= evaluateRforces(R,x[2],pot,phi=phi,t=t)
        phiforce= evaluatephiforces(R,x[2],pot,phi=phi,t=t)
        return nu.array([cosphi*Rforce-1./R*sinphi*phiforce,
                     sinphi*Rforce+1./R*cosphi*phiforce,
                     evaluatezforces(R,x[2],pot,phi=phi,t=t)])
    elif dim == 2:
        #x is rectangular so calculate R and phi
        R= nu.sqrt(x[0]**2.+x[1]**2.)
        phi= nu.arccos(x[0]/R)
        sinphi= x[1]/R
        cosphi= x[0]/R
        if x[1] < 0.: phi= 2.*nu.pi-phi
        #calculate forces
        Rforce= evaluateplanarRforces(R,pot,phi=phi,t=t)
        phiforce= evaluateplanarphiforces(R,pot,phi=phi,t=t)
        return nu.array([cosphi*Rforce-1./R*sinphi*phiforce,
                         sinphi*Rforce+1./R*cosphi*phiforce])
    elif dim == 1:
        return evaluatelinearForces(x,pot,t=t)
コード例 #2
0
def _linearEOM(y,t,pot):
    """
    NAME:
       linearEOM
    PURPOSE:
       the one-dimensional equation-of-motion
    INPUT:
       y - current phase-space position
       t - current time
       pot - (list of) linearPotential instance(s)
    OUTPUT:
       dy/dt
    HISTORY:
       2010-07-13 - Bovy (NYU)
    """
    return [y[1],evaluatelinearForces(y[0],pot,t=t)]
コード例 #3
0
ファイル: isothermdf.py プロジェクト: derkal/galpy
def _ars_hpx_1d(x,args):
    """Internal function that evaluates h'(x) for ARS"""
    pot,sigma2= args
    return evaluatelinearForces(x,pot)/sigma2
コード例 #4
0
def _ars_hpx_1d(x, args):
    """Internal function that evaluates h'(x) for ARS"""
    pot, sigma2 = args
    return evaluatelinearForces(x, pot) / sigma2