예제 #1
0
def test_osipkovmerritt_hernquist_meanvr_directint():
    pot= potential.HernquistPotential(amp=2.3,a=1.3)
    ras= [0.3,2.3,5.7]
    for ra in ras:
        dfh= osipkovmerrittHernquistdf(pot=pot,ra=ra)
        tol= 1e-8
        check_meanvr_directint(dfh,pot,tol,rmin=pot._scale/10.,
                               rmax=pot._scale*10.,bins=6)
    return None
예제 #2
0
def test_osipkovmerritt_hernquist_Qoutofbounds():
    pot= potential.HernquistPotential(amp=2.3,a=1.3)
    ras= [0.3,2.3,5.7]
    for ra in ras:
        dfh= osipkovmerrittHernquistdf(pot=pot,ra=ra)
        assert numpy.all(numpy.fabs(dfh((numpy.arange(0.1,10.,0.1),1.1))) < 1e-8), 'Evaluating the Osipkov-Merritt Hernquist DF at E > 0 does not give zero'
        # The next one is not actually a physical orbit...
        assert numpy.all(numpy.fabs(dfh((pot(0,0)-1e-1,0.1))) < 1e-8), 'Evaluating the Osipkov-Merritt Hernquist DF at E < -GM/a does not give zero'
        assert numpy.all(numpy.fabs(dfh((-1e-4,1.1))) < 1e-8), 'Evaluating the Osipkov-Merritt Hernquist DF at Q < 0 does not give zero'
    return None
예제 #3
0
def test_osipkovmerritt_hernquist_beta_directint():
    pot= potential.HernquistPotential(amp=2.3,a=1.3)
    ras= [0.3,2.3,5.7]
    for ra in ras:
        dfh= osipkovmerrittHernquistdf(pot=pot,ra=ra)
        tol= 1e-8
        check_beta_directint(dfh,tol,beta=lambda r: 1./(1.+ra**2./r**2.),
                             rmin=pot._scale/10.,
                             rmax=pot._scale*10.,
                             bins=6)
    return None
예제 #4
0
def test_osipkovmerritt_hernquist_dens_directint():
    pot= potential.HernquistPotential(amp=2.3,a=1.3)
    ras= [0.3,2.3,5.7]
    for ra in ras:
        dfh= osipkovmerrittHernquistdf(pot=pot,ra=ra)
        tol= 1e-5
        check_dens_directint(dfh,pot,tol,
                             lambda r: pot.dens(r,0)/(2.3/2.), # need to divide by mass
                             rmin=pot._scale/10.,
                             rmax=pot._scale*10.,bins=6)
    return None
예제 #5
0
def test_osipkovmerritt_hernquist_beta():
    pot= potential.HernquistPotential(amp=2.3,a=1.3)
    ras= [0.3,2.3,5.7]
    for ra in ras:
        dfh= osipkovmerrittHernquistdf(pot=pot,ra=ra)
        numpy.random.seed(10)
        samp= dfh.sample(n=1000000)
        tol= 0.06
        check_beta(samp,pot,tol,beta=lambda r: 1./(1.+ra**2./r**2.),
                   rmin=pot._scale/10.,rmax=pot._scale*10.,bins=31)
    return None
예제 #6
0
def test_osipkovmerritt_hernquist_dens_massprofile():
    pot= potential.HernquistPotential(amp=2.3,a=1.3)
    ras= [0.3,2.3,5.7]
    for ra in ras:
        dfh= osipkovmerrittHernquistdf(pot=pot,ra=ra)
        numpy.random.seed(10)
        samp= dfh.sample(n=100000)
        tol= 5*1e-3
        check_spherical_massprofile(samp,lambda r: pot.mass(r)\
                                    /pot.mass(numpy.amax(samp.r())),
                                    tol,skip=1000)
    return None
예제 #7
0
def test_osipkovmerritt_hernquist_diffcalls():
    from galpy.orbit import Orbit
    pot= potential.HernquistPotential(amp=2.3,a=1.3)
    ras= [0.3,2.3,5.7]
    for ra in ras:
        dfh= osipkovmerrittHernquistdf(pot=pot,ra=ra)
        # R,vR... vs. E
        R,vR,vT,z,vz,phi= 1.1,0.3,0.2,0.9,-0.2,2.4
        # Calculate E directly and L from Orbit
        assert numpy.fabs(dfh(R,vR,vT,z,vz,phi)-dfh((pot(R,z)+0.5*(vR**2.+vT**2.+vz**2.),numpy.sqrt(numpy.sum(Orbit([R,vR,vT,z,vz,phi]).L()**2.))))) < 1e-8, 'Calling the Osipkov-Merritt anisotropic Hernquist DF with R,vR,... or E[R,vR,...] does not give the same answer'
        # Also as orbit
        assert numpy.fabs(dfh(R,vR,vT,z,vz,phi)-dfh(Orbit([R,vR,vT,z,vz,phi]))) < 1e-8, 'Calling the Osipkov-Merritt isotropic Hernquist DF with R,vR,... or E[R,vR,...] does not give the same answer'   
    return None
예제 #8
0
def test_osipkovmerritt_hernquist_dens_spherically_symmetric():
    pot= potential.HernquistPotential(amp=2.3,a=1.3)
    ras= [0.3,2.3,5.7]
    for ra in ras:
        dfh= osipkovmerrittHernquistdf(pot=pot,ra=ra)
        numpy.random.seed(10)
        samp= dfh.sample(n=100000)
        # Check spherical symmetry for different harmonics l,m
        tol= 1e-2
        check_spherical_symmetry(samp,0,0,tol)
        check_spherical_symmetry(samp,1,0,tol)
        check_spherical_symmetry(samp,1,-1,tol)
        check_spherical_symmetry(samp,1,1,tol)
        check_spherical_symmetry(samp,2,0,tol)
        check_spherical_symmetry(samp,2,-1,tol)
        check_spherical_symmetry(samp,2,-2,tol)
        check_spherical_symmetry(samp,2,1,tol)
        check_spherical_symmetry(samp,2,2,tol)
        # and some higher order ones
        check_spherical_symmetry(samp,3,1,tol)
        check_spherical_symmetry(samp,9,-6,tol)
    return None