def profile(eos, energy_center, number=200, initr=0.001, energy_0=1e7, rad_0=False): '''Calculate the enthalpy profile of a neutron star with equation of state eos and central energy density energy_center in g/cm^3 optional arguments: number: number of points initr: size of central seed energy_0: energy density at which to stop resolving crust. This doesn't need to be tiny (and may cause problems if it is). Integration still goes to surface. rad_0: Set true to calculate outer radius at energy_0 instead of at formal zero enthalpy limit of EOS ''' # set up a core with small initial radius and mass initm = 4.0 / 3.0 * np.pi * (initr)**3 * energy_center * Gcc init_rm = np.array([initr, initm]) # central enthalpy enth_c = eos.enthalpy(energy_center) # end the core spacing here enth_0 = eos.enthalpy(energy_center / 10) # resolve core with linear spacing in enthalpy linenths = np.linspace(enth_c, enth_0, number / 2)[:-1] # end the crust spacing here and jump to 0 enth_0 = eos.enthalpy(energy_0) # resolve crust with log spacing in enthalpy logenths = np.logspace(np.log10(linenths[-1]), np.log10(enth_0), number / 2 + 1)[1:] # set of enthalpies to calculate energy density, radius, and mass at if rad_0: enths = np.hstack((np.array(linenths), np.array(logenths))) else: enths = np.hstack( (np.array(linenths), np.array(logenths), np.array(0))) # enths = np.linspace(enth_c, 0, number) # boring way for debugging # integrate the TOV equations specified in deriv above rms = integrate.odeint(deriv, init_rm, enths, args=(eos, )) return np.vstack((enths, np.transpose(rms)))
def profile(eos, energy_center , number=200, initr=0.001, energy_0=1e7, rad_0=False): '''Calculate the enthalpy profile of a neutron star with equation of state eos and central energy density energy_center in g/cm^3 optional arguments: number: number of points initr: size of central seed energy_0: energy density at which to stop resolving crust. This doesn't need to be tiny (and may cause problems if it is). Integration still goes to surface. rad_0: Set true to calculate outer radius at energy_0 instead of at formal zero enthalpy limit of EOS ''' # set up a core with small initial radius and mass initm = 4.0/3.0*np.pi*(initr)**3 * energy_center * Gcc init_rm = np.array([initr,initm]) # central enthalpy enth_c = eos.enthalpy(energy_center) # end the core spacing here enth_0 = eos.enthalpy(energy_center/10) # resolve core with linear spacing in enthalpy linenths = np.linspace(enth_c, enth_0, number/2)[:-1] # end the crust spacing here and jump to 0 enth_0 = eos.enthalpy(energy_0) # resolve crust with log spacing in enthalpy logenths = np.logspace(np.log10(linenths[-1]),np.log10(enth_0), number/2+1)[1:] # set of enthalpies to calculate energy density, radius, and mass at if rad_0: enths = np.hstack((np.array(linenths),np.array(logenths))) else: enths = np.hstack((np.array(linenths),np.array(logenths),np.array(0))) # enths = np.linspace(enth_c, 0, number) # boring way for debugging # integrate the TOV equations specified in deriv above rms = integrate.odeint(deriv, init_rm, enths, args=(eos,)) return np.vstack((enths,np.transpose(rms)))
def rotprofile(eos, energy_center, number=100, initr=0.001, energy_0=1e7): '''Calculate the enthalpy profile of a slowly rotating neutron star with equation of state eos and central energy density energy_center in g/cm^3. optional arguments: number: number of points initr: size of central seed energy_0: energy density at which to stop resolving crust. This doesn't need to be tiny (and may cause problems if it is). Integration still goes to surface. ''' #TODO: consolodate the profile functions; this mostly just repeats #profile but with different initial conditions # central enthalpy and density enth_c = eos.enthalpy(energy_center) dens_c = eos.density(enth_c) # set up a core with small initial radius and mass initm = 4.0 / 3.0 * np.pi * (initr)**3 * energy_center * Gcc initma = 4.0 / 3.0 * np.pi * (initr)**3 * dens_c * Gcc init_rm = np.array([initr, initm, initma, 0.0, 1.0]) # resolve core with linear spacing linenths = np.linspace(enth_c, enth_c / 10, number)[:-1] # resolve crust with log enth spacing enth_0 = eos.enthalpy(energy_0) # end the crust spacing here and jump to 0 logenths = np.logspace(np.log10(linenths[-1]), np.log10(enth_0), number / 2 + 1) # set of enthalpies to calculate energy density, radius, and mass at enths = np.hstack( (np.array(linenths), np.array(logenths[1:]), np.array(0))) # enths = np.linspace(enth_c, 0, number) # boring way for debugging # integrate the TOV equations specified in deriv above rms = integrate.odeint(rotderiv, init_rm, enths, args=(eos, )) return np.vstack((enths, np.transpose(rms)))
def rotprofile(eos, energy_center , number=100, initr=0.001, energy_0=1e7): '''Calculate the enthalpy profile of a slowly rotating neutron star with equation of state eos and central energy density energy_center in g/cm^3. optional arguments: number: number of points initr: size of central seed energy_0: energy density at which to stop resolving crust. This doesn't need to be tiny (and may cause problems if it is). Integration still goes to surface. ''' #TODO: consolodate the profile functions; this mostly just repeats #profile but with different initial conditions # central enthalpy and density enth_c = eos.enthalpy(energy_center) dens_c = eos.density(enth_c) # set up a core with small initial radius and mass initm = 4.0/3.0*np.pi*(initr)**3 * energy_center * Gcc initma = 4.0/3.0*np.pi*(initr)**3 * dens_c * Gcc init_rm = np.array([initr,initm, initma, 0.0, 1.0]) # resolve core with linear spacing linenths = np.linspace(enth_c, enth_c/10, number)[:-1] # resolve crust with log enth spacing enth_0 = eos.enthalpy(energy_0) # end the crust spacing here and jump to 0 logenths = np.logspace(np.log10(linenths[-1]),np.log10(enth_0), number/2+1) # set of enthalpies to calculate energy density, radius, and mass at enths = np.hstack((np.array(linenths),np.array(logenths[1:]),np.array(0))) # enths = np.linspace(enth_c, 0, number) # boring way for debugging # integrate the TOV equations specified in deriv above rms = integrate.odeint(rotderiv, init_rm, enths, args=(eos,)) return np.vstack((enths,np.transpose(rms)))