Esempio n. 1
0
    def Er(self,R,z,vR,vz,E,Lz,sinh2u0,u0):
        """
        NAME:
           Er
        PURPOSE:
           calculate the 'radial energy'
        INPUT:
           R, z, vR, vz - coordinates
           E - energy
           Lz - angular momentum
           sinh2u0, u0 - sinh^2 and u0
        OUTPUT:
           Er
        HISTORY:
           2012-11-29 - Written - Bovy (IAS)
        """                           
        u,v= bovy_coords.Rz_to_uv(R,z,self._delta)
        pu= (vR*numpy.cosh(u)*numpy.sin(v)
             +vz*numpy.sinh(u)*numpy.cos(v)) #no delta, bc we will divide it out
        out= (pu**2./2.+Lz**2./2./self._delta**2.*(1./numpy.sinh(u)**2.-1./sinh2u0)
              -E*(numpy.sinh(u)**2.-sinh2u0)
              +(numpy.sinh(u)**2.+1.)*actionAngleStaeckel.potentialStaeckel(u,numpy.pi/2.,self._pot,self._delta)
              -(sinh2u0+1.)*actionAngleStaeckel.potentialStaeckel(u0,numpy.pi/2.,self._pot,self._delta))
#              +(numpy.sinh(u)**2.+numpy.sin(v)**2.)*actionAngleStaeckel.potentialStaeckel(u,v,self._pot,self._delta)
#              -(sinh2u0+numpy.sin(v)**2.)*actionAngleStaeckel.potentialStaeckel(u0,v,self._pot,self._delta))
        return out
Esempio n. 2
0
def _u0Eq(logu,delta,pot,E,Lz22):
    """The equation that needs to be minimized to find u0"""
    u= numpy.exp(logu)
    sinh2u= numpy.sinh(u)**2.
    cosh2u= numpy.cosh(u)**2.
    dU= cosh2u*actionAngleStaeckel.potentialStaeckel(u,numpy.pi/2.,pot,delta)
    return -(E*sinh2u-dU-Lz22/delta**2./sinh2u)
Esempio n. 3
0
 def vatu0(self,E,Lz,u0,R,retv2=False):
     """
     NAME:
        vatu0
     PURPOSE:
        calculate the velocity at u0
     INPUT:
        E - energy
        Lz - angular momentum
        u0 - u0
        R - radius corresponding to u0,pi/2.
        retv2= (False), if True return v^2
     OUTPUT:
        velocity
     HISTORY:
        2012-11-29 - Written - Bovy (IAS)
     """                        
     v2= (2.*(E-actionAngleStaeckel.potentialStaeckel(u0,numpy.pi/2.,
                                                      self._pot,
                                                      self._delta))
          -Lz**2./R**2.)
     if retv2: return v2
     if isinstance(E,float) and v2 < 0. and v2 > -10.**-7.: 
         return 0. #rounding errors
     elif isinstance(E,float):
         return numpy.sqrt(v2)
     elif isinstance(v2,numpy.ndarray):
         v2[(v2 < 0.)*(v2 > -10.**-7.)]= 0.
         return numpy.sqrt(v2)