Beispiel #1
0
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)
Beispiel #2
0
def _rectForce(x,pot,t=0.):
    """
    NAME:
       _rectForce
    PURPOSE:
       returns the force in the rectangular frame
    INPUT:
       x - current position
       t - current time
       pot - (list of) Potential instance(s)
    OUTPUT:
       force
    HISTORY:
       2011-02-02 - Written - Bovy (NYU)
    """
    #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)])
Beispiel #3
0
def _rectForce(x,pot,t=0.):
    """
    NAME:
       _rectForce
    PURPOSE:
       returns the force in the rectangular frame
    INPUT:
       x - current position
       t - current time
       pot - (list of) Potential instance(s)
    OUTPUT:
       force
    HISTORY:
       2011-02-02 - Written - Bovy (NYU)
    """
    #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)])
Beispiel #4
0
def _RZEOM(y,t,pot,l2):
    """
    NAME:
       _RZEOM
    PURPOSE:
       implements the EOM, i.e., the right-hand side of the differential 
       equation
    INPUT:
       y - current phase-space position
       t - current time
       pot - (list of) Potential instance(s)
       l2 - angular momentum squared
    OUTPUT:
       dy/dt
    HISTORY:
       2010-04-16 - Written - Bovy (NYU)
    """
    return [y[1],
            l2/y[0]**3.+evaluateRforces(y[0],y[2],pot,t=t),
            y[3],
            evaluatezforces(y[0],y[2],pot,t=t)]
Beispiel #5
0
def _RZEOM(y, t, pot, l2):
    """
    NAME:
       _RZEOM
    PURPOSE:
       implements the EOM, i.e., the right-hand side of the differential 
       equation
    INPUT:
       y - current phase-space position
       t - current time
       pot - (list of) Potential instance(s)
       l2 - angular momentum squared
    OUTPUT:
       dy/dt
    HISTORY:
       2010-04-16 - Written - Bovy (NYU)
    """
    return [
        y[1], l2 / y[0]**3. + evaluateRforces(y[0], y[2], pot, t=t), y[3],
        evaluatezforces(y[0], y[2], pot, t=t)
    ]
Beispiel #6
0
def _FullEOM(y,t,pot):
    """
    NAME:
       _FullEOM
    PURPOSE:
       implements the EOM, i.e., the right-hand side of the differential 
       equation
    INPUT:
       y - current phase-space position
       t - current time
       pot - (list of) Potential instance(s)
    OUTPUT:
       dy/dt
    HISTORY:
       2010-04-16 - Written - Bovy (NYU)
    """
    l2= (y[0]**2.*y[3])**2.
    return [y[1],
            l2/y[0]**3.+evaluateRforces(y[0],y[4],pot,phi=y[2],t=t),
            y[3],
            1./y[0]**2.*(evaluatephiforces(y[0],y[4],pot,phi=y[2],t=t)-
                         2.*y[0]*y[1]*y[3]),
            y[5],
            evaluatezforces(y[0],y[4],pot,phi=y[2],t=t)]
Beispiel #7
0
def _FullEOM(y,t,pot):
    """
    NAME:
       _FullEOM
    PURPOSE:
       implements the EOM, i.e., the right-hand side of the differential 
       equation
    INPUT:
       y - current phase-space position
       t - current time
       pot - (list of) Potential instance(s)
    OUTPUT:
       dy/dt
    HISTORY:
       2010-04-16 - Written - Bovy (NYU)
    """
    l2= (y[0]**2.*y[3])**2.
    return [y[1],
            l2/y[0]**3.+evaluateRforces(y[0],y[4],pot,phi=y[2],t=t),
            y[3],
            1./y[0]**2.*(evaluatephiforces(y[0],y[4],pot,phi=y[2],t=t)-
                         2.*y[0]*y[1]*y[3]),
            y[5],
            evaluatezforces(y[0],y[4],pot,phi=y[2],t=t)]