Beispiel #1
0
def vesc(Pot,R):
    """

    NAME:

        vesc

    PURPOSE:

       calculate the escape velocity at R for potential Pot

    INPUT:

       Pot - Potential instances or list thereof

       R - Galactocentric radius (can be Quantity)

    OUTPUT:

       escape velocity

    HISTORY:

       2011-10-09 - Written - Bovy (IAS)

    """
    from galpy.potential import evaluateplanarPotentials
    from galpy.potential import PotentialError
    try:
        return nu.sqrt(2.*(evaluateplanarPotentials(Pot,_INF,use_physical=False)-evaluateplanarPotentials(Pot,R,use_physical=False)))
    except PotentialError:
        from galpy.potential import RZToplanarPotential
        Pot= RZToplanarPotential(Pot)
        return nu.sqrt(2.*(evaluateplanarPotentials(Pot,_INF,use_physical=False)-evaluateplanarPotentials(Pot,R,use_physical=False)))
Beispiel #2
0
def vcirc(Pot, R):
    """

    NAME:

       vcirc

    PURPOSE:

       calculate the circular velocity at R in potential Pot

    INPUT:

       Pot - Potential instance or list of such instances

       R - Galactocentric radius

    OUTPUT:

       circular rotation velocity

    HISTORY:

       2011-10-09 - Written - Bovy (IAS)

    """
    from galpy.potential import evaluateplanarRforces
    from galpy.potential import PotentialError
    try:
        return nu.sqrt(-R * evaluateplanarRforces(R, Pot))
    except PotentialError:
        from galpy.potential import RZToplanarPotential
        Pot = RZToplanarPotential(Pot)
        return nu.sqrt(-R * evaluateplanarRforces(R, Pot))
Beispiel #3
0
def dvcircdR(Pot, R, phi=None):
    """

    NAME:

       dvcircdR

    PURPOSE:

       calculate the derivative of the circular velocity wrt R at R in potential Pot

    INPUT:

       Pot - Potential instance or list of such instances

       R - Galactocentric radius (can be Quantity)

       phi= (None) azimuth to use for non-axisymmetric potentials

    OUTPUT:

       derivative of the circular rotation velocity wrt R

    HISTORY:

       2013-01-08 - Written - Bovy (IAS)

       2016-06-28 - Added phi= keyword for non-axisymmetric potential - Bovy (UofT)

    """
    from galpy.potential import evaluateplanarRforces, evaluateplanarR2derivs
    from galpy.potential import PotentialError
    tvc = vcirc(Pot, R, phi=phi, use_physical=False)
    try:
        return 0.5 * (
            -evaluateplanarRforces(Pot, R, phi=phi, use_physical=False) + R *
            evaluateplanarR2derivs(Pot, R, phi=phi, use_physical=False)) / tvc
    except PotentialError:
        from galpy.potential import RZToplanarPotential
        Pot = RZToplanarPotential(Pot)
        return 0.5 * (
            -evaluateplanarRforces(Pot, R, phi=phi, use_physical=False) + R *
            evaluateplanarR2derivs(Pot, R, phi=phi, use_physical=False)) / tvc
Beispiel #4
0
def calcEscapecurve(Pot, Rs):
    """
    NAME:
       calcEscapecurve
    PURPOSE:
       calculate the escape velocity curve for this potential (in the 
       z=0 plane for non-spherical potentials)
    INPUT:
       Pot - Potential or list of Potential instances

       Rs - (array of) radius(i)
    OUTPUT:
       array of v_esc
    HISTORY:
       2011-04-16 - Written - Bovy (NYU)
    """
    isList = isinstance(Pot, list)
    isNonAxi = ((isList and Pot[0].isNonAxi) or (not isList and Pot.isNonAxi))
    if isNonAxi:
        raise AttributeError(
            "Escape velocity curve plotting for non-axisymmetric potentials is not currently supported"
        )
    try:
        grid = len(Rs)
    except TypeError:
        grid = 1
        Rs = nu.array([Rs])
    esccurve = nu.zeros(grid)
    from galpy.potential import evaluateplanarPotentials
    from galpy.potential import PotentialError
    for ii in range(grid):
        try:
            esccurve[ii] = nu.sqrt(2. *
                                   (evaluateplanarPotentials(_INF, Pot) -
                                    evaluateplanarPotentials(Rs[ii], Pot)))
        except PotentialError:
            from galpy.potential import RZToplanarPotential
            Pot = RZToplanarPotential(Pot)
            esccurve[ii] = nu.sqrt(2. *
                                   (evaluateplanarPotentials(_INF, Pot) -
                                    evaluateplanarPotentials(Rs[ii], Pot)))
    return esccurve
Beispiel #5
0
def dvcircdR(Pot, R):
    """

    NAME:

       dvcircdR

    PURPOSE:

       calculate the derivative of the circular velocity wrt R at R in potential Pot

    INPUT:

       Pot - Potential instance or list of such instances

       R - Galactocentric radius

    OUTPUT:

       derivative of the circular rotation velocity wrt R

    HISTORY:

       2013-01-08 - Written - Bovy (IAS)

    """
    from galpy.potential import evaluateplanarRforces, evaluateplanarR2derivs
    from galpy.potential import PotentialError
    tvc = vcirc(Pot, R)
    try:
        return 0.5 * (-evaluateplanarRforces(R, Pot) +
                      R * evaluateplanarR2derivs(R, Pot)) / tvc
    except PotentialError:
        from galpy.potential import RZToplanarPotential
        Pot = RZToplanarPotential(Pot)
        return 0.5 * (-evaluateplanarRforces(R, Pot) +
                      R * evaluateplanarR2derivs(R, Pot)) / tvc