Esempio n. 1
0
def test_mildnonaxi_meanvt_hierarchgrid_tlist():
    # Test that for a close to axisymmetric potential, the mean vt is close to that of the initial DF
    idf = dehnendf(beta=0.)
    pot = [
        LogarithmicHaloPotential(normalize=1.),
        SteadyLogSpiralPotential(A=-0.005, omegas=0.2)
    ]  #very mild non-axi
    edf = evolveddiskdf(idf, pot=pot, to=-10.)
    mvt, grid = edf.meanvT(0.9,
                           t=[0., -2.5, -5., -7.5, -10.],
                           phi=0.2,
                           integrate_method='rk6_c',
                           grid=True,
                           hierarchgrid=True,
                           returnGrid=True,
                           gridpoints=_GRIDPOINTS)
    assert numpy.all(
        numpy.fabs(mvt - idf.meanvT(0.9)) < 0.005
    ), 'meanvT of evolveddiskdf for axisymmetric potential is not equal to that of the initial dehnendf when using hierarchgrid and tlist'
    mvt = edf.meanvT(0.9,
                     t=[0., -2.5, -5., -7.5, -10.],
                     phi=0.2,
                     integrate_method='rk6_c',
                     grid=grid,
                     gridpoints=_GRIDPOINTS)
    assert numpy.all(
        numpy.fabs(mvt - idf.meanvT(0.9)) < 0.005
    ), 'meanvT of evolveddiskdf for axisymmetric potential is not equal to that of the initial dehnendf when calculated with pre-computed grid when using hierarchgrid and tlist'
    return None
Esempio n. 2
0
def test_plot_hierarchgrid():
    idf = dehnendf(beta=0.)
    pot = [
        LogarithmicHaloPotential(normalize=1.),
        SteadyLogSpiralPotential(A=-0.005, omegas=0.2)
    ]  #very mild non-axi
    edf = evolveddiskdf(idf, pot=pot, to=-10.)
    mvr, grid = edf.meanvR(0.9,
                           phi=0.2,
                           integrate_method='rk6_c',
                           grid=True,
                           hierarchgrid=True,
                           returnGrid=True,
                           gridpoints=_GRIDPOINTS)
    grid.plot()
    #w/ list of tiems
    mvr, grid = edf.meanvR(0.9,
                           t=[0., -2.5, -5., -7.5, -10.],
                           phi=0.2,
                           integrate_method='rk6_c',
                           grid=True,
                           hierarchgrid=True,
                           returnGrid=True,
                           gridpoints=_GRIDPOINTS)
    grid.plot(1)
    return None
Esempio n. 3
0
def test_mildnonaxi_meanvr_grid():
    # Test that for a close to axisymmetric potential, the mean vr is close to zero
    idf = dehnendf(beta=0.)
    pot = [
        LogarithmicHaloPotential(normalize=1.),
        SteadyLogSpiralPotential(A=-0.005, omegas=0.2)
    ]  #very mild non-axi
    edf = evolveddiskdf(idf, pot=pot, to=-10.)
    mvr, grid = edf.meanvR(0.9,
                           phi=0.2,
                           integrate_method='rk6_c',
                           grid=True,
                           returnGrid=True,
                           gridpoints=_GRIDPOINTS)
    assert numpy.fabs(
        mvr
    ) < 0.001, 'meanvR of evolveddiskdf for axisymmetric potential is not equal to zero'
    mvr = edf.meanvR(0.9, phi=0.2, integrate_method='rk6_c', grid=grid)
    assert numpy.fabs(
        mvr
    ) < 0.001, 'meanvR of evolveddiskdf for axisymmetric potential is not equal to zero when calculated with pre-computed grid'
    #Pre-compute surfmass and use it, first test that grid is properly returned when given
    smass, ngrid = edf.vmomentsurfacemass(0.9,
                                          0,
                                          0,
                                          phi=0.2,
                                          integrate_method='rk6_c',
                                          grid=grid,
                                          gridpoints=_GRIDPOINTS,
                                          returnGrid=True)
    assert ngrid == grid, 'grid returned by vmomentsurfacemass w/ grid input is not the same as the input'
    #Pre-compute surfmass and use it
    nsmass = edf.vmomentsurfacemass(0.9,
                                    0,
                                    0,
                                    phi=0.2,
                                    integrate_method='rk6_c',
                                    grid=True,
                                    gridpoints=_GRIDPOINTS)
    assert numpy.fabs(
        smass - nsmass
    ) < 0.001, 'surfacemass computed w/ and w/o returnGrid are not the same'
    mvr = edf.meanvR(0.9,
                     phi=0.2,
                     integrate_method='rk6_c',
                     grid=grid,
                     surfacemass=smass)
    assert numpy.fabs(
        mvr
    ) < 0.001, 'meanvR of evolveddiskdf for axisymmetric potential is not equal to zero when calculated with pre-computed grid and surfacemass'
    global _maxi_meanvr
    _maxi_meanvr = mvr
    global _maxi_surfacemass
    _maxi_surfacemass = smass
    return None
Esempio n. 4
0
def test_mildnonaxi_meanvr_grid_tlist():
    # Test that for a close to axisymmetric potential, the mean vr is close to zero
    idf= dehnendf(beta=0.)
    pot= [LogarithmicHaloPotential(normalize=1.),
          SteadyLogSpiralPotential(A=-0.005,omegas=0.2)] #very mild non-axi
    edf= evolveddiskdf(idf,pot=pot,to=-10.)
    mvr, grid= edf.meanvR(0.9,t=[0.,-2.5,-5.,-7.5,-10.],
                          phi=0.2,integrate_method='rk6_c',
                          grid=True,returnGrid=True,gridpoints=_GRIDPOINTS)
    assert numpy.all(numpy.fabs(mvr) < 0.003), 'meanvR of evolveddiskdf for axisymmetric potential is not equal to zero for list of times'
    mvr= edf.meanvR(0.9,t=[0.,-2.5,-5.,-7.5,-10.],
                    phi=0.2,integrate_method='rk6_c',grid=grid)
    assert numpy.all(numpy.fabs(mvr) < 0.003), 'meanvR of evolveddiskdf for axisymmetric potential is not equal to zero when calculated with pre-computed grid for list of times'
    return None
Esempio n. 5
0
def test_mildnonaxi_meanvt_hierarchgrid():
    # Test that for a close to axisymmetric potential, the mean vt is close to that of the initial DF
    idf = dehnendf(beta=0.)
    pot = [
        LogarithmicHaloPotential(normalize=1.),
        SteadyLogSpiralPotential(A=-0.005, omegas=0.2)
    ]  #very mild non-axi
    edf = evolveddiskdf(idf, pot=pot, to=-10.)
    mvt, grid = edf.meanvT(0.9,
                           phi=0.2,
                           integrate_method='rk6_c',
                           grid=True,
                           hierarchgrid=True,
                           returnGrid=True,
                           gridpoints=_GRIDPOINTS)
    assert numpy.fabs(
        mvt - idf.meanvT(0.9)
    ) < 0.005, 'meanvT of evolveddiskdf for axisymmetric potential is not equal to that of the initial dehnendf when using hierarchgrid'
    mvt = edf.meanvT(0.9,
                     phi=0.2,
                     integrate_method='rk6_c',
                     grid=grid,
                     gridpoints=_GRIDPOINTS)
    assert numpy.fabs(
        mvt - idf.meanvT(0.9)
    ) < 0.005, 'meanvT of evolveddiskdf for axisymmetric potential is not equal to that of the initial dehnendf when calculated with pre-computed grid when using hierarchgrid'
    #Also test that the hierarchgrid is properly returned
    smass, ngrid = edf.vmomentsurfacemass(0.9,
                                          0,
                                          0,
                                          phi=0.2,
                                          integrate_method='rk6_c',
                                          grid=grid,
                                          gridpoints=_GRIDPOINTS,
                                          returnGrid=True)
    assert ngrid == grid, 'hierarchical grid returned by vmomentsurfacemass w/ grid input is not the same as the input'
    nsmass = edf.vmomentsurfacemass(0.9,
                                    0,
                                    0,
                                    phi=0.2,
                                    integrate_method='rk6_c',
                                    grid=True,
                                    hierarchgrid=True,
                                    gridpoints=_GRIDPOINTS)
    assert numpy.fabs(
        smass - nsmass
    ) < 0.001, 'surfacemass computed w/ and w/o returnGrid are not the same'
    return None
Esempio n. 6
0
def test_mildnonaxi_meanvt_grid_tlist_onet():
    # Test that for a close to axisymmetric potential, the mean vt is close to that of the initial DF, for a list consisting of a single time
    idf= dehnendf(beta=0.)
    pot= [LogarithmicHaloPotential(normalize=1.),
          SteadyLogSpiralPotential(A=-0.005,omegas=0.2)] #very mild non-axi
    edf= evolveddiskdf(idf,pot=pot,to=-10.)
    mvt, grid= edf.meanvT(0.9,t=[0.],
                          phi=0.2,integrate_method='rk6_c',grid=True,
                          returnGrid=True,gridpoints=_GRIDPOINTS)
    assert numpy.fabs(mvt-idf.meanvT(0.9)) < 0.005, 'meanvT of evolveddiskdf for axisymmetric potential is not equal to that of the initial dehnendf'
    mvt= edf.meanvT(0.9,t=[0.],phi=0.2,integrate_method='rk6_c',grid=grid,
                    gridpoints=_GRIDPOINTS,)
    assert numpy.fabs(mvt-idf.meanvT(0.9)) < 0.005, 'meanvT of evolveddiskdf for axisymmetric potential is not equal to that of the initial dehnendf when calculated with pre-computed grid'
    global _maxi_meanvt
    _maxi_meanvt= mvt
    return None
Esempio n. 7
0
def test_mildnonaxi_vertexdev_grid():
    # Test that for a close to axisymmetric potential, the vertex deviation is close to zero
    idf= dehnendf(beta=0.)
    pot= [LogarithmicHaloPotential(normalize=1.),
          SteadyLogSpiralPotential(A=-0.005,omegas=0.2)] #very mild non-axi
    edf= evolveddiskdf(idf,pot=pot,to=-10.)
    vdev, grid= edf.vertexdev(0.9,phi=0.2,integrate_method='rk6_c',grid=True,
                              returnGrid=True,gridpoints=_GRIDPOINTS)
    assert numpy.fabs(vdev) < 2., 'vertexdev of evolveddiskdf for axisymmetric potential is not close to zero' #2 is pretty big, but the weak spiral creates that
    vdev= edf.vertexdev(0.9,phi=0.2,integrate_method='rk6_c',grid=grid,
                        gridpoints=_GRIDPOINTS)
    assert numpy.fabs(vdev) < 2., 'vertexdev of evolveddiskdf for axisymmetric potential is not equal zero when calculated with pre-computed grid'
    vdev= edf.vertexdev(0.9,phi=0.2,integrate_method='rk6_c',grid=grid,
                        sigmaR2=_maxi_sigmar2,sigmaT2=_maxi_sigmat2,
                        sigmaRT=_maxi_sigmart,gridpoints=_GRIDPOINTS)
    assert numpy.fabs(vdev) < 2., 'sigmart of evolveddiskdf for axisymmetric potential is not equal to zero when calculated with pre-computed sigmaR2,sigmaT2,sigmaRT'
    return None
Esempio n. 8
0
def test_mildnonaxi_meanvt_grid_rmEstimates():
    # Test vmomentsurfacemass w/o having the _estimateX functions in the intial DF
    class fakeDehnen(dehnendf): #class that removes the _estimate functions
        def __init__(self,*args,**kwargs):
            dehnendf.__init__(self,*args,**kwargs)
        _estimatemeanvR= property()
        _estimatemeanvT= property()
        _estimateSigmaR2= property()
        _estimateSigmaT2= property()
    idf= fakeDehnen(beta=0.)
    pot= [LogarithmicHaloPotential(normalize=1.),
          SteadyLogSpiralPotential(A=-0.005,omegas=0.2)] #very mild non-axi
    edf= evolveddiskdf(idf,pot=pot,to=-10.)
    mvt, grid= edf.meanvT(0.9,phi=0.2,integrate_method='rk6_c',grid=True,
                          returnGrid=True,gridpoints=_GRIDPOINTS)
    assert numpy.fabs(mvt-idf.meanvT(0.9)) < 0.005, 'meanvT of evolveddiskdf for axisymmetric potential is not equal to that of the initial dehnendf'
    return None
Esempio n. 9
0
def test_mildnonaxi_sigmart_grid():
    # Test that for a close to axisymmetric potential, the sigmaR2 is close to zero
    idf= dehnendf(beta=0.)
    pot= [LogarithmicHaloPotential(normalize=1.),
          SteadyLogSpiralPotential(A=-0.005,omegas=0.2)] #very mild non-axi
    edf= evolveddiskdf(idf,pot=pot,to=-10.)
    srt, grid= edf.sigmaRT(0.9,phi=0.2,integrate_method='rk6_c',grid=True,
                           returnGrid=True,gridpoints=_GRIDPOINTS)
    assert numpy.fabs(srt) < 0.01, 'sigmart of evolveddiskdf for axisymmetric potential is not equal to zero'
    srt= edf.sigmaRT(0.9,phi=0.2,integrate_method='rk6_c',grid=grid,
                     gridpoints=_GRIDPOINTS)
    assert numpy.fabs(srt) < 0.01, 'sigmart of evolveddiskdf for axisymmetric potential is not equal zero when calculated with pre-computed grid'
    srt= edf.sigmaRT(0.9,phi=0.2,integrate_method='rk6_c',grid=grid,
                     meanvR=_maxi_meanvr,
                     meanvT=_maxi_meanvt,surfacemass=_maxi_surfacemass,
                     gridpoints=_GRIDPOINTS)
    assert numpy.fabs(srt) < 0.01, 'sigmart of evolveddiskdf for axisymmetric potential is not equal to zero when calculated with pre-computed grid and meanvR,surfacemass'
    global _maxi_sigmart
    _maxi_sigmart= srt
    return None
Esempio n. 10
0
def test_mildnonaxi_sigmat2_grid():
    # Test that for a close to axisymmetric potential, the sigmaR2 is close to the value of the initial DF
    idf= dehnendf(beta=0.)
    pot= [LogarithmicHaloPotential(normalize=1.),
          SteadyLogSpiralPotential(A=-0.005,omegas=0.2)] #very mild non-axi
    edf= evolveddiskdf(idf,pot=pot,to=-10.)
    st2, grid= edf.sigmaT2(0.9,phi=0.2,integrate_method='rk6_c',grid=True,
                           returnGrid=True,gridpoints=_GRIDPOINTS)
    ist2= idf.sigmaT2(0.9)
    assert numpy.fabs(numpy.log(st2)-numpy.log(ist2)) < 0.025, 'sigmat2 of evolveddiskdf for axisymmetric potential is not equal to that of initial DF'
    st2= edf.sigmaT2(0.9,phi=0.2,integrate_method='rk6_c',grid=grid,
                     gridpoints=_GRIDPOINTS)
    assert numpy.fabs(numpy.log(st2)-numpy.log(ist2)) < 0.025, 'sigmat2 of evolveddiskdf for axisymmetric potential is not equal to that of initial DF when calculated with pre-computed grid'
    st2= edf.sigmaT2(0.9,phi=0.2,integrate_method='rk6_c',grid=grid,
                     meanvT=_maxi_meanvt,surfacemass=_maxi_surfacemass,
                     gridpoints=_GRIDPOINTS)
    assert numpy.fabs(numpy.log(st2)-numpy.log(ist2)) < 0.025, 'sigmat2 of evolveddiskdf for axisymmetric potential is not equal to that of initial DF when calculated with pre-computed grid and meanvR,surfacemass'
    global _maxi_sigmat2
    _maxi_sigmat2= st2
    return None
Esempio n. 11
0
sp_a = -sp_m / tan(sp_i)
sp_gamma = sp_x_0 / sp_m
sp_fr_0 = 0.05  #0.05
ro = 8
vo = 220
sp_A = -(
    1
) * sp_fr_0  #*((ro*vo)**2) #not sure on this part but adding these makes it too big so leave them
#galpy natural units takes care of this stuff - so just leave it
#there was a lot of jumbling to get it to look the same as literature
#just believe it!!!

sp_component = SteadyLogSpiralPotential(amp=1,
                                        omegas=sp_spv,
                                        A=sp_A,
                                        alpha=sp_a,
                                        gamma=sp_gamma,
                                        ro=8,
                                        vo=220)
mwp_2D.append(sp_component)  # not yet

print("finally calculating distance from sun...")
for o in orbits_2D[2:]:
    o_2D = o.toPlanar()
    o_2D.integrate(ts, mwp_2D, method='odeint')
    delta_x = o_2D.x(ts) - sun_2D.x(ts)
    delta_y = o_2D.y(ts) - sun_2D.y(ts)
    delta = (delta_x**2 + delta_y**2)**0.5
    plt.semilogy(sun_2D.time(ts), delta * 1000)

plt.title("Solar Sibling Proximity")