예제 #1
0
def MWPotentialSCFbar_nogrow(mbar,Acos,Asin,rs=1.,normalize=False,pat_speed=40.,fin_phi_deg=27.,t_stream_age=5.):
    
    a=rs/ro
    omegaP=pat_speed*(ro/vo)
    
    fin_phi= np.radians(fin_phi_deg)
    #init_phi= fin_phi - o_p*(tpal5age*Gyr_to_s)
    
    init_phi= fin_phi - omegaP*t_stream_age/bovy_conversion.time_in_Gyr(vo,ro)
    
    mrat=mbar/10.**10. #10^10 mass of bar used to compute Acos and Asin
    
    static_bar=potential.SCFPotential(amp=mrat,Acos=Acos,Asin=Asin,a=a,normalize=normalize)
    
    #Note only m=0 terms are considered 
    static_axi_bar=potential.SCFPotential(amp=mrat,Acos=np.atleast_3d(Acos[:,:,0]),a=a)
    
    barrot=potential.SolidBodyRotationWrapperPotential(pot=static_bar,omega=omegaP,ro=ro,vo=vo,pa=init_phi)
    
    if mbar <= 5.*10**9. :
        MWP2014SCFbar=[MWPotential2014[0],MiyamotoNagaiPotential(amp=(6.8-mrat)*10.**10*u.Msun,a=3./8.,b=0.28/8.),MWPotential2014[2],barrot]
        turn_physical_off(MWP2014SCFbar)
        #setup the corresponding axisymmetric bar
        MWP2014SCFnobar= [MWPotential2014[0],MiyamotoNagaiPotential(amp=(6.8-mrat)*10.**10*u.Msun,a=3./8.,b=0.28/8.),MWPotential2014[2],static_axi_bar]
        turn_physical_off(MWP2014SCFnobar)
        
    else : 
        MWP2014SCFbar=[MiyamotoNagaiPotential(amp=(6.8+0.5-mrat)*10.**10*u.Msun,a=3./8.,b=0.28/8.),MWPotential2014[2],barrot]
        turn_physical_off(MWP2014SCFbar)
        
        MWP2014SCFnobar= [MiyamotoNagaiPotential(amp=(6.8+0.5-mrat)*10.**10*u.Msun,a=3./8.,b=0.28/8.),MWPotential2014[2],static_axi_bar]
        turn_physical_off(MWP2014SCFnobar)
        
    return (MWP2014SCFbar,MWP2014SCFnobar)
예제 #2
0
def MWPotentialSCFbar_grow(mbar,
                           Acos,
                           Asin,
                           rs=1.,
                           normalize=False,
                           pat_speed=40.,
                           fin_phi_deg=27.,
                           t_on=-2.,
                           tgrow=2,
                           tstream=5.):
    '''
    SCFbar starts growing at -x Gyr

    tstream : age of the stream/max stripping time
    t_on: time in Gyr in the past at which the bar acquired full strength
    tgrow: no of bar periods it took the bar to grow to full strength starting at tform
            
    '''

    #setup the full strength bar and axisymmetric "bar"
    a = rs / ro
    omegaP = pat_speed * (ro / vo)

    fin_phi = np.radians(fin_phi_deg)

    Tbar = 2. * np.pi / np.abs(omegaP)  #bar period in galpy units.
    t_on = t_on / bovy_conversion.time_in_Gyr(vo, ro)
    tsteady = tgrow * Tbar
    tform = t_on - tsteady  #- because past is negative

    mrat = mbar / 10.**10.  #10^10 mass of bar used to compute Acos and Asin

    static_bar = mySCFPotential(amp=mrat,
                                Acos=Acos,
                                Asin=Asin,
                                a=a,
                                normalize=normalize)

    #Note only m=0 terms are considered
    static_axi_bar = mySCFPotential(amp=mrat,
                                    Acos=np.atleast_3d(Acos[:, :, 0]),
                                    a=a)

    barrot = potential.SolidBodyRotationWrapperPotential(pot=static_bar,
                                                         omega=omegaP,
                                                         ro=ro,
                                                         vo=vo,
                                                         pa=fin_phi)

    if mbar <= 5. * 10**9.:
        MWP2014SCFbar = [
            MWPotential2014[0],
            MiyamotoNagaiPotential(amp=(6.8 - mrat) * 10.**10 * u.Msun,
                                   a=3. / 8.,
                                   b=0.28 / 8.), MWPotential2014[2], barrot
        ]
        turn_physical_off(MWP2014SCFbar)
        #setup the corresponding axisymmetric bar
        MWP2014SCFnobar = [
            MWPotential2014[0],
            MiyamotoNagaiPotential(amp=(6.8 - mrat) * 10.**10 * u.Msun,
                                   a=3. / 8.,
                                   b=0.28 / 8.), MWPotential2014[2],
            static_axi_bar
        ]
        turn_physical_off(MWP2014SCFnobar)

    else:
        MWP2014SCFbar = [
            MiyamotoNagaiPotential(amp=(6.8 + 0.5 - mrat) * 10.**10 * u.Msun,
                                   a=3. / 8.,
                                   b=0.28 / 8.), MWPotential2014[2], barrot
        ]
        turn_physical_off(MWP2014SCFbar)

        MWP2014SCFnobar = [
            MiyamotoNagaiPotential(amp=(6.8 + 0.5 - mrat) * 10.**10 * u.Msun,
                                   a=3. / 8.,
                                   b=0.28 / 8.), MWPotential2014[2],
            static_axi_bar
        ]
        turn_physical_off(MWP2014SCFnobar)

    #if t_on >= t_stream, then stream sees the bar as always on
    if np.abs(t_on) * bovy_conversion.time_in_Gyr(vo, ro) >= tstream:
        return (MWP2014SCFbar, MWP2014SCFnobar)

    elif np.abs(tform) * bovy_conversion.time_in_Gyr(vo, ro) >= tstream:
        print("tform > age of stream")

    elif np.abs(tform) * bovy_conversion.time_in_Gyr(vo, ro) < tstream:

        MWbar_grow = DehnenWrap(amp=1.,
                                pot=MWP2014SCFbar,
                                tform=tform,
                                tsteady=tsteady)
        MWaxibar_destroy = DehnenWrap(amp=-1.,
                                      pot=MWP2014SCFnobar,
                                      tform=tform,
                                      tsteady=tsteady)

        growbarpot = [MWbar_grow, MWP2014SCFnobar, MWaxibar_destroy]

        turn_physical_off(growbarpot)

        return (growbarpot, MWP2014SCFnobar)
예제 #3
0
def MWPotentialSCFbar_invert(mbar,
                             Acos,
                             Asin,
                             rs=1.,
                             normalize=False,
                             pat_speed=40.,
                             fin_phi_deg=27.,
                             t_stream_age=5.,
                             t_on=2.,
                             tgrow=2):
    '''
    t_stream_age : age of the stream/max stripping time
    tform: time in Gyr in the past at which the bar started to form
    tgrow: no of bar periods it took the bar to grow to full strength starting at tform
    
        
    '''

    #setup the full strength bar and axisymmetric "bar"
    a = rs / ro
    omegaP = pat_speed * (ro / vo)

    fin_phi = np.radians(fin_phi_deg)

    mrat = mbar / 10.**10.  #10^10 mass of bar used to compute Acos and Asin

    static_bar = potential.SCFPotential(amp=mrat,
                                        Acos=Acos,
                                        Asin=Asin,
                                        a=a,
                                        normalize=normalize)

    #Note only m=0 terms are considered
    static_axi_bar = potential.SCFPotential(amp=mrat,
                                            Acos=np.atleast_3d(Acos[:, :, 0]),
                                            a=a)

    #pa = final phi and omega is negative since we are going back in time
    barrot = potential.SolidBodyRotationWrapperPotential(pot=static_bar,
                                                         omega=-omegaP,
                                                         ro=ro,
                                                         vo=vo,
                                                         pa=fin_phi)

    if mbar <= 5. * 10**9.:
        MWP2014SCFbar = [
            MWPotential2014[0],
            MiyamotoNagaiPotential(amp=(6.8 - mrat) * 10.**10 * u.Msun,
                                   a=3. / 8.,
                                   b=0.28 / 8.), MWPotential2014[2], barrot
        ]
        turn_physical_off(MWP2014SCFbar)
        #setup the corresponding axisymmetric bar
        MWP2014SCFnobar = [
            MWPotential2014[0],
            MiyamotoNagaiPotential(amp=(6.8 - mrat) * 10.**10 * u.Msun,
                                   a=3. / 8.,
                                   b=0.28 / 8.), MWPotential2014[2],
            static_axi_bar
        ]
        turn_physical_off(MWP2014SCFnobar)

    else:
        MWP2014SCFbar = [
            MiyamotoNagaiPotential(amp=(6.8 + 0.5 - mrat) * 10.**10 * u.Msun,
                                   a=3. / 8.,
                                   b=0.28 / 8.), MWPotential2014[2], barrot
        ]
        turn_physical_off(MWP2014SCFbar)

        MWP2014SCFnobar = [
            MiyamotoNagaiPotential(amp=(6.8 + 0.5 - mrat) * 10.**10 * u.Msun,
                                   a=3. / 8.,
                                   b=0.28 / 8.), MWPotential2014[2],
            static_axi_bar
        ]
        turn_physical_off(MWP2014SCFnobar)

    #setup Dehnen smooth growth wrapper for the bar

    #while going back, t_on = tform, then deconstruct the bar to no bar during tsteady
    tform = t_on / bovy_conversion.time_in_Gyr(vo, ro)

    Tbar = 2. * np.pi / omegaP
    tsteady = tgrow * Tbar

    MWaxibar_grow = DehnenWrap(amp=1.,
                               pot=MWP2014SCFnobar,
                               tform=tform,
                               tsteady=tsteady)
    MWbar_destroy = DehnenWrap(amp=-1.,
                               pot=MWP2014SCFbar,
                               tform=tform,
                               tsteady=tsteady)

    growbarpot_invert = [MWP2014SCFbar, MWaxibar_grow, MWbar_destroy]
    turn_physical_off(growbarpot_invert)

    return growbarpot_invert
예제 #4
0
def MWPotentialSCFbar(mbar,
                      Acos,
                      Asin,
                      rs=1.,
                      normalize=False,
                      pat_speed=40.,
                      fin_phi_deg=27.,
                      t_stream_age=5.,
                      t_on=2.,
                      tgrow=2):
    '''
    t_stream_age : age of the stream/max stripping time
    t_on: time in Gyr in the past at which the bar acquired full strength
    tgrow: no of bar periods it took the bar to grow to full strength starting at tform
            
    '''

    #setup the full strength bar and axisymmetric "bar"
    a = rs / ro
    omegaP = pat_speed * (ro / vo)

    fin_phi = np.radians(fin_phi_deg)

    t_stream_age = t_stream_age / bovy_conversion.time_in_Gyr(vo, ro)

    Tbar = 2. * np.pi / omegaP  #bar period in galpy units.
    t_on = t_on / bovy_conversion.time_in_Gyr(vo, ro)
    tsteady = tgrow * Tbar
    tform = t_on + tsteady

    init_phi = fin_phi - omegaP * t_stream_age / bovy_conversion.time_in_Gyr(
        vo, ro)

    mrat = mbar / 10.**10.  #10^10 mass of bar used to compute Acos and Asin

    static_bar = SCFPotential(amp=mrat,
                              Acos=Acos,
                              Asin=Asin,
                              a=a,
                              normalize=normalize)

    #Note only m=0 terms are considered
    static_axi_bar = SCFPotential(amp=mrat,
                                  Acos=np.atleast_3d(Acos[:, :, 0]),
                                  a=a)

    barrot = potential.SolidBodyRotationWrapperPotential(pot=static_bar,
                                                         omega=omegaP,
                                                         ro=ro,
                                                         vo=vo,
                                                         pa=init_phi)

    if mbar <= 5. * 10**9.:
        MWP2014SCFbar = [
            MWPotential2014[0],
            MiyamotoNagaiPotential(amp=(6.8 - mrat) * 10.**10 * u.Msun,
                                   a=3. / 8.,
                                   b=0.28 / 8.), MWPotential2014[2], barrot
        ]
        turn_physical_off(MWP2014SCFbar)
        #setup the corresponding axisymmetric bar
        MWP2014SCFnobar = [
            MWPotential2014[0],
            MiyamotoNagaiPotential(amp=(6.8 - mrat) * 10.**10 * u.Msun,
                                   a=3. / 8.,
                                   b=0.28 / 8.), MWPotential2014[2],
            static_axi_bar
        ]
        turn_physical_off(MWP2014SCFnobar)

    else:
        MWP2014SCFbar = [
            MiyamotoNagaiPotential(amp=(6.8 + 0.5 - mrat) * 10.**10 * u.Msun,
                                   a=3. / 8.,
                                   b=0.28 / 8.), MWPotential2014[2], barrot
        ]
        turn_physical_off(MWP2014SCFbar)

        MWP2014SCFnobar = [
            MiyamotoNagaiPotential(amp=(6.8 + 0.5 - mrat) * 10.**10 * u.Msun,
                                   a=3. / 8.,
                                   b=0.28 / 8.), MWPotential2014[2],
            static_axi_bar
        ]
        turn_physical_off(MWP2014SCFnobar)

    #setup Dehnen smooth growth wrapper for the bar
    #convert to galpy units

    #if t_on >= t_pal5_age, then Pal 5 sees the bar as always on
    if t_on >= t_stream_age:
        return (MWP2014SCFbar, MWP2014SCFnobar)

    elif tform >= t_stream_age:
        print("tform > age of Pal 5 stream")

    elif tform < t_stream_age:

        #change tform in the past, i.e. instead of from today, to time in the future from 5 Gyr in the past
        tform = t_stream_age - tform
        MWbar_grow = DehnenWrap(amp=1.,
                                pot=MWP2014SCFbar,
                                tform=tform,
                                tsteady=tsteady)
        MWaxibar_destroy = DehnenWrap(amp=-1.,
                                      pot=MWP2014SCFnobar,
                                      tform=tform,
                                      tsteady=tsteady)

        growbarpot = [MWbar_grow, MWP2014SCFnobar, MWaxibar_destroy]

        turn_physical_off(growbarpot)

        return (growbarpot, MWP2014SCFnobar)