示例#1
0
文件: tov.py 项目: jsread/nsstruc
def deriv(rm_vector, enthalpy, eos):
    ''' The TOV equations in terms of pseudoenthalpy. Derivatives of vector
    (radius, mass) as a function of enthalpy for given eos.'''
    (rad, mass) = rm_vector
    drdenth =  - rad * (rad - 2 * mass) \
              / (mass + 4 * np.pi * rad **3  * eos.pressure(enthalpy)*Gcc) 
    dmdenth = 4 * np.pi * eos.energy(enthalpy)*Gcc * rad **2 * drdenth
    return np.array([drdenth,dmdenth])
示例#2
0
def deriv(rm_vector, enthalpy, eos):
    ''' The TOV equations in terms of pseudoenthalpy. Derivatives of vector
    (radius, mass) as a function of enthalpy for given eos.'''
    (rad, mass) = rm_vector
    drdenth =  - rad * (rad - 2 * mass) \
              / (mass + 4 * np.pi * rad **3  * eos.pressure(enthalpy)*Gcc)
    dmdenth = 4 * np.pi * eos.energy(enthalpy) * Gcc * rad**2 * drdenth
    return np.array([drdenth, dmdenth])
示例#3
0
def rotderiv(rm_vector, enthalpy, eos):
    ''' The TOV equations augmented for a linearly perturbed, slowly
    rotating neutron star.  Also includes rest mass of star.'''
    (rad, mass, restmass, alpha, omega) = rm_vector

    pr = eos.pressure(enthalpy) * Gcc
    en = eos.energy(enthalpy) * Gcc
    rho = eos.density(enthalpy)**Gcc

    factor = rad - 2 * mass
    coef = 4.0 * np.pi

    drdenth = -rad * factor / (mass + coef * rad**3 * pr)
    dmdenth = coef * en * rad**2 * drdenth
    dmadenth = coef * rho * rad**2 * drdenth / (factor / rad)**0.5
    domega = alpha * drdenth
    dalpha = drdenth * (- 4.0 * alpha / rad \
      + coef * rad * (pr + en) * (4.0 * omega + rad * alpha ) / factor )

    return np.array([drdenth, dmdenth, dmadenth, dalpha, domega])
示例#4
0
文件: tov.py 项目: jsread/nsstruc
def rotderiv(rm_vector, enthalpy, eos):
    ''' The TOV equations augmented for a linearly perturbed, slowly
    rotating neutron star.  Also includes rest mass of star.'''
    (rad, mass, restmass, alpha, omega) = rm_vector
  
    pr = eos.pressure(enthalpy) * Gcc
    en = eos.energy(enthalpy) * Gcc
    rho = eos.density(enthalpy) ** Gcc
  
    factor = rad - 2 * mass
    coef = 4.0 * np.pi

    drdenth =  - rad * factor / (mass + coef * rad**3 * pr) 
    dmdenth = coef * en * rad**2 * drdenth
    dmadenth = coef * rho * rad**2 * drdenth / ( factor / rad )**0.5
    domega = alpha * drdenth
    dalpha = drdenth * (- 4.0 * alpha / rad \
      + coef * rad * (pr + en) * (4.0 * omega + rad * alpha ) / factor )

    return np.array([drdenth,dmdenth, dmadenth, dalpha, domega])
示例#5
0
文件: tov.py 项目: jsread/nsstruc
def energy_of_mass(eos, mass, lowenergy, highenergy=None):
    ''' for a given eos and a stellar mass in solar masses, calculate the
    central energy density in g/cm^3. Include a lower bound on the energy
    to avoid convergence problems especially with crusts.  About 10**14
    g/cm^3 works well for most neutron stars.

    Optional params: 

      highenergy = upper bound for search.  If this is not specified, use
      the limiting enthalpy range of the EOS. 
      '''
    if highenergy == None:
        highenergy = eos.energy(eos.enthrange[1])
    def massdiff(x, eos, mass):
        return profile(eos, x)[2,-1] - mass*Solarmass_km
    try:
        return optimize.brenth(massdiff, lowenergy, highenergy, (eos,mass))
    except RuntimeError:
        warnings.warn("Problem getting convergence in optimze.brenth")
        return 0
示例#6
0
def energy_maxmass(eos, lowenergy, highenergy=None):
    ''' Determine properties of the maximum mass star supported by the EOS.
    Returns (central energy density in g/cm^3, mass in Solar masses, and
    radius in km  for the star). 
    
    Include a lower bound on the energy to
    avoid convergence problems especially with crusts.  About 10**14 g/cm^3
    works well for most neutron stars.

    Optional params: 

      highenergy = upper bound for search. If this is not specified, use
      the limiting enthalpy range of the EOS. 
      '''
    if highenergy == None:
        highenergy = eos.energy(eos.enthrange[1])
    # Calculate the maximum mass energy density
    massen = lambda x: 10.0 - profile(eos, x)[2, -1]
    maxen = optimize.brent(massen, brack=(lowenergy, highenergy))
    # Calculate the maximum mass model
    maxprofile = profile(eos, maxen)[:, -1]
    return maxen, maxprofile[2] / Solarmass_km, maxprofile[1]
示例#7
0
def energy_of_mass(eos, mass, lowenergy, highenergy=None):
    ''' for a given eos and a stellar mass in solar masses, calculate the
    central energy density in g/cm^3. Include a lower bound on the energy
    to avoid convergence problems especially with crusts.  About 10**14
    g/cm^3 works well for most neutron stars.

    Optional params: 

      highenergy = upper bound for search.  If this is not specified, use
      the limiting enthalpy range of the EOS. 
      '''
    if highenergy == None:
        highenergy = eos.energy(eos.enthrange[1])

    def massdiff(x, eos, mass):
        return profile(eos, x)[2, -1] - mass * Solarmass_km

    try:
        return optimize.brenth(massdiff, lowenergy, highenergy, (eos, mass))
    except RuntimeError:
        warnings.warn("Problem getting convergence in optimze.brenth")
        return 0
示例#8
0
文件: tov.py 项目: jsread/nsstruc
def energy_maxmass(eos, lowenergy, highenergy=None):
    ''' Determine properties of the maximum mass star supported by the EOS.
    Returns (central energy density in g/cm^3, mass in Solar masses, and
    radius in km  for the star). 
    
    Include a lower bound on the energy to
    avoid convergence problems especially with crusts.  About 10**14 g/cm^3
    works well for most neutron stars.

    Optional params: 

      highenergy = upper bound for search. If this is not specified, use
      the limiting enthalpy range of the EOS. 
      '''
    if highenergy == None:
        highenergy = eos.energy(eos.enthrange[1])
    # Calculate the maximum mass energy density
    massen = lambda x: 10.0 - profile(eos, x)[2,-1]
    maxen = optimize.brent(massen, brack=(lowenergy,highenergy))
    # Calculate the maximum mass model
    maxprofile = profile(eos,maxen)[:,-1]
    return maxen, maxprofile[2]/Solarmass_km, maxprofile[1]
示例#9
0
def tidederiv(rm_vector, enthalpy, eos):
    (rad, mass, restmass, beta, h) = rm_vector

    pr = eos.pressure(enthalpy) * Gcc
    en = eos.energy(enthalpy) * Gcc
    func = 1.0 / eos.dprden(enthalpy)

    factor = rad - 2 * mass
    coef = 4.0 * np.pi

    drdenth = -rad * factor / (mass + coef * rad**3 * pr)
    dmdenth = coef * en * rad**2 * drdenth
    dbeta = 2 * drdenth *\
        ( h * ( \
          (- 2. * np.pi * func * rad * (pr + en))/ factor + \
          (2. * mass**2 + \
            rad**2 * (3.0 + 2.0 * np.pi * rad**2 * \
              ( pr * (16.0 * np.pi * pr * rad**2 - 9.0 ) - 5. * en ))\
            + mass * ( - 6 * rad + 4 * np.pi * rad**3 * (13 *pr + 5*en) ) )\
          / rad**2 / factor**2 )
        + beta / rad / factor * ( mass - rad + 2 * np.pi * rad**3 * (en -
          pr)))
    dh = beta * drdenth
    return np.array([drdenth, dmdenth, dbeta, dh])
示例#10
0
文件: tov.py 项目: jsread/nsstruc
def tidederiv(rm_vector, enthalpy, eos):
    (rad, mass, restmass, beta, h) = rm_vector

    pr = eos.pressure(enthalpy) * Gcc
    en = eos.energy(enthalpy) * Gcc
    func = 1.0/eos.dprden(enthalpy)

    factor = rad - 2 * mass
    coef = 4.0*np.pi

    drdenth =  - rad * factor / (mass + coef * rad**3 * pr)
    dmdenth = coef * en * rad**2 * drdenth
    dbeta = 2 * drdenth *\
        ( h * ( \
          (- 2. * np.pi * func * rad * (pr + en))/ factor + \
          (2. * mass**2 + \
            rad**2 * (3.0 + 2.0 * np.pi * rad**2 * \
              ( pr * (16.0 * np.pi * pr * rad**2 - 9.0 ) - 5. * en ))\
            + mass * ( - 6 * rad + 4 * np.pi * rad**3 * (13 *pr + 5*en) ) )\
          / rad**2 / factor**2 )
        + beta / rad / factor * ( mass - rad + 2 * np.pi * rad**3 * (en -
          pr)))
    dh = beta * drdenth
    return np.array([drdenth,dmdenth, dbeta, dh])