예제 #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)))
예제 #2
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
예제 #3
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