Cold Neutron Star Structure

O2scl

The class nstar_cold computes the structure of non-rotating zero-temperature spherically-symmetric neutron stars, given a core hadronic equation of state (of type eos_had_base) It automatically tabulates the core EOS, adds a crust EOS (if necessary) and then uses tov_solve to compute the mass-radius curve. It also computes the adiabatic index, the speed of sound, and determines the possibility of the direct Urca process as a function of density or radius.

Cold neutron star example

/* Example: ex_nstar_cold.cpp
   -------------------------------------------------------------------
   This example solves the TOV equations using class nstar_cold using a
   relativistic mean-field EOS from class eos_had_rmf.
*/

#include <o2scl/nstar_cold.h>
#include <o2scl/eos_had_rmf.h>
#include <o2scl/hdf_file.h>
#include <o2scl/hdf_io.h>
#include <o2scl/test_mgr.h>

using namespace std;
using namespace o2scl;
using namespace o2scl_hdf;

// For hc_mev_fm
using namespace o2scl_const;

// A simple function to load the NL3 model
int load_nl3(eos_had_rmf &rmf);

int main(void) {

  cout.setf(ios::scientific);

  test_mgr t;
  t.set_output_level(1);

  nstar_cold nst;

  // Initialize EOS
  eos_had_rmf rmf;
  load_nl3(rmf);

  rmf.def_neutron.mu=5.0;
  rmf.def_proton.mu=5.0;
  rmf.set_fields(0.2,0.1,-0.05);
  
  rmf.err_nonconv=false;
  rmf.def_sat_mroot.err_nonconv=false;
  rmf.def_sat_mroot.def_jac.err_nonconv=false;
  rmf.def_mroot.err_nonconv=false;
  rmf.def_mroot.def_jac.err_nonconv=false;
  
  int sret=rmf.saturation();

  if (sret!=0) {
    
    rmf.set_fields(0.1,0.07,0.0);
    rmf.def_neutron.mu=5.0;
    rmf.def_proton.mu=5.0;

    rmf.err_nonconv=true;
    rmf.def_sat_mroot.err_nonconv=true;
    rmf.def_sat_mroot.def_jac.err_nonconv=true;
    rmf.def_mroot.err_nonconv=true;
    rmf.def_mroot.def_jac.err_nonconv=true;
    
    rmf.saturation();
    
  } else {
    
    rmf.err_nonconv=true;
    rmf.def_sat_mroot.err_nonconv=true;
    rmf.def_sat_mroot.def_jac.err_nonconv=true;
    rmf.def_mroot.err_nonconv=true;
    rmf.def_mroot.def_jac.err_nonconv=true;

  }
  
  cout << "Saturation density: " << rmf.n0 << endl;
  cout << "Binding energy: " << rmf.eoa*hc_mev_fm << endl;
  cout << "Effective mass: " << rmf.msom << endl;
  cout << "Symmetry energy: " << rmf.esym*hc_mev_fm << endl;
  cout << "Compressibility: " << rmf.comp*hc_mev_fm << endl;
  
  // Compute EOS, include muons
  nst.include_muons=true;
  nst.set_eos(rmf);
  nst.calc_eos();
  std::shared_ptr<table_units<> > te=nst.get_eos_results();

  // Compute mass vs. radius
  nst.calc_nstar();
  std::shared_ptr<table_units<> > tr=nst.get_tov_results();
  cout << "Maximum mass: " << tr->max("gm") << endl;
  cout << "Radius of maximum mass star: " 
       << tr->get("r",tr->lookup("gm",tr->max("gm"))) << endl;
  cout << "Central baryon density of maximum mass star: ";
  cout << tr->get("nb",tr->lookup("gm",tr->max("gm"))) << endl;

  // Output EOS and TOV results to files
  hdf_file hf;
  hf.open_or_create("ex_nstar_cold_eos.o2");
  hdf_output(hf,*te,"eos");
  hf.close();
  hf.open_or_create("ex_nstar_cold_tov.o2");
  hdf_output(hf,*tr,"tov");
  hf.close();

  t.report();
  return 0;
}
// End of example

int load_nl3(eos_had_rmf &rmf) {

  rmf.ms=508.194;
  rmf.mw=782.501;
  rmf.mr=763.0;
  rmf.mnuc=939.0;
  rmf.ms/=hc_mev_fm; 
  rmf.mw/=hc_mev_fm; 
  rmf.mr/=hc_mev_fm; 
  rmf.mnuc/=hc_mev_fm;
    
  double gs, gw, gr;
  gs=10.217;
  gw=12.868;
  gr=4.474;
  rmf.b=-10.431;
  rmf.c=-28.885;
  rmf.b/=-rmf.mnuc*pow(fabs(gs),3.0);
  rmf.c/=pow(gs,4.0);
  gr*=2.0;
  rmf.cs=gs/rmf.ms;
  rmf.cw=gw/rmf.mw;
  rmf.cr=gr/rmf.mr;
    
  rmf.xi=0.0; 
  rmf.zeta=0.0;
  rmf.a1=0.0;
  rmf.a2=0.0;
  rmf.a3=0.0;
  rmf.a4=0.0;
  rmf.a5=0.0;
  rmf.a6=0.0;
  rmf.b1=0.0;
  rmf.b2=0.0;
  rmf.b3=0.0;
    
  return 0;
}
Saturation density: 1.480066e-01
Binding energy: -1.621698e+01
Effective mass: 5.958939e-01
Symmetry energy: 3.734713e+01
Compressibility: 2.710301e+02
Mass versus radius mode.
Central P: 7.0000e-07 (Msun/km^3), M: 1.3093e-01 (Msun), R: 3.4255e+01 (km)
Central P: 7.7000e-07 (Msun/km^3), M: 1.4090e-01 (Msun), R: 2.9863e+01 (km)
Central P: 8.4700e-07 (Msun/km^3), M: 1.5179e-01 (Msun), R: 2.6749e+01 (km)
Central P: 9.3170e-07 (Msun/km^3), M: 1.6352e-01 (Msun), R: 2.4459e+01 (km)
Central P: 1.0249e-06 (Msun/km^3), M: 1.7605e-01 (Msun), R: 2.2725e+01 (km)
Central P: 1.1274e-06 (Msun/km^3), M: 1.8949e-01 (Msun), R: 2.1367e+01 (km)
Central P: 1.2401e-06 (Msun/km^3), M: 2.0392e-01 (Msun), R: 2.0282e+01 (km)
Central P: 1.3641e-06 (Msun/km^3), M: 2.1925e-01 (Msun), R: 1.9408e+01 (km)
Central P: 1.5005e-06 (Msun/km^3), M: 2.3558e-01 (Msun), R: 1.8691e+01 (km)
Central P: 1.6506e-06 (Msun/km^3), M: 2.5302e-01 (Msun), R: 1.8096e+01 (km)
Central P: 1.8156e-06 (Msun/km^3), M: 2.7149e-01 (Msun), R: 1.7601e+01 (km)
Central P: 1.9972e-06 (Msun/km^3), M: 2.9106e-01 (Msun), R: 1.7186e+01 (km)
Central P: 2.1969e-06 (Msun/km^3), M: 3.1174e-01 (Msun), R: 1.6836e+01 (km)
Central P: 2.4166e-06 (Msun/km^3), M: 3.3347e-01 (Msun), R: 1.6540e+01 (km)
Central P: 2.6582e-06 (Msun/km^3), M: 3.5639e-01 (Msun), R: 1.6287e+01 (km)
Central P: 2.9241e-06 (Msun/km^3), M: 3.8041e-01 (Msun), R: 1.6072e+01 (km)
Central P: 3.2165e-06 (Msun/km^3), M: 4.0568e-01 (Msun), R: 1.5887e+01 (km)
Central P: 3.5381e-06 (Msun/km^3), M: 4.3215e-01 (Msun), R: 1.5728e+01 (km)
Central P: 3.8919e-06 (Msun/km^3), M: 4.5995e-01 (Msun), R: 1.5591e+01 (km)
Central P: 4.2811e-06 (Msun/km^3), M: 4.8905e-01 (Msun), R: 1.5472e+01 (km)
Central P: 4.7092e-06 (Msun/km^3), M: 5.1960e-01 (Msun), R: 1.5369e+01 (km)
Central P: 5.1802e-06 (Msun/km^3), M: 5.5156e-01 (Msun), R: 1.5280e+01 (km)
Central P: 5.6982e-06 (Msun/km^3), M: 5.8511e-01 (Msun), R: 1.5203e+01 (km)
Central P: 6.2680e-06 (Msun/km^3), M: 6.2021e-01 (Msun), R: 1.5136e+01 (km)
Central P: 6.8948e-06 (Msun/km^3), M: 6.5703e-01 (Msun), R: 1.5078e+01 (km)
Central P: 7.5843e-06 (Msun/km^3), M: 6.9559e-01 (Msun), R: 1.5029e+01 (km)
Central P: 8.3427e-06 (Msun/km^3), M: 7.3598e-01 (Msun), R: 1.4986e+01 (km)
Central P: 9.1770e-06 (Msun/km^3), M: 7.7832e-01 (Msun), R: 1.4950e+01 (km)
Central P: 1.0095e-05 (Msun/km^3), M: 8.2262e-01 (Msun), R: 1.4920e+01 (km)
Central P: 1.1104e-05 (Msun/km^3), M: 8.6902e-01 (Msun), R: 1.4895e+01 (km)
Central P: 1.2215e-05 (Msun/km^3), M: 9.1757e-01 (Msun), R: 1.4875e+01 (km)
Central P: 1.3436e-05 (Msun/km^3), M: 9.6829e-01 (Msun), R: 1.4858e+01 (km)
Central P: 1.4780e-05 (Msun/km^3), M: 1.0213e+00 (Msun), R: 1.4846e+01 (km)
Central P: 1.6258e-05 (Msun/km^3), M: 1.0765e+00 (Msun), R: 1.4837e+01 (km)
Central P: 1.7883e-05 (Msun/km^3), M: 1.1340e+00 (Msun), R: 1.4830e+01 (km)
Central P: 1.9672e-05 (Msun/km^3), M: 1.1938e+00 (Msun), R: 1.4826e+01 (km)
Central P: 2.1639e-05 (Msun/km^3), M: 1.2557e+00 (Msun), R: 1.4824e+01 (km)
Central P: 2.3803e-05 (Msun/km^3), M: 1.3196e+00 (Msun), R: 1.4824e+01 (km)
Central P: 2.6183e-05 (Msun/km^3), M: 1.3855e+00 (Msun), R: 1.4824e+01 (km)
Central P: 2.8801e-05 (Msun/km^3), M: 1.4532e+00 (Msun), R: 1.4824e+01 (km)
Central P: 3.1681e-05 (Msun/km^3), M: 1.5224e+00 (Msun), R: 1.4825e+01 (km)
Central P: 3.4850e-05 (Msun/km^3), M: 1.5928e+00 (Msun), R: 1.4825e+01 (km)
Central P: 3.8335e-05 (Msun/km^3), M: 1.6643e+00 (Msun), R: 1.4823e+01 (km)
Central P: 4.2168e-05 (Msun/km^3), M: 1.7364e+00 (Msun), R: 1.4819e+01 (km)
Central P: 4.6385e-05 (Msun/km^3), M: 1.8088e+00 (Msun), R: 1.4813e+01 (km)
Central P: 5.1023e-05 (Msun/km^3), M: 1.8811e+00 (Msun), R: 1.4803e+01 (km)
Central P: 5.6126e-05 (Msun/km^3), M: 1.9528e+00 (Msun), R: 1.4790e+01 (km)
Central P: 6.1738e-05 (Msun/km^3), M: 2.0236e+00 (Msun), R: 1.4773e+01 (km)
Central P: 6.7912e-05 (Msun/km^3), M: 2.0931e+00 (Msun), R: 1.4751e+01 (km)
Central P: 7.4703e-05 (Msun/km^3), M: 2.1608e+00 (Msun), R: 1.4724e+01 (km)
Central P: 8.2174e-05 (Msun/km^3), M: 2.2262e+00 (Msun), R: 1.4692e+01 (km)
Central P: 9.0391e-05 (Msun/km^3), M: 2.2891e+00 (Msun), R: 1.4653e+01 (km)
Central P: 9.9430e-05 (Msun/km^3), M: 2.3491e+00 (Msun), R: 1.4609e+01 (km)
Central P: 1.0937e-04 (Msun/km^3), M: 2.4058e+00 (Msun), R: 1.4559e+01 (km)
Central P: 1.2031e-04 (Msun/km^3), M: 2.4589e+00 (Msun), R: 1.4503e+01 (km)
Central P: 1.3234e-04 (Msun/km^3), M: 2.5082e+00 (Msun), R: 1.4440e+01 (km)
Central P: 1.4558e-04 (Msun/km^3), M: 2.5535e+00 (Msun), R: 1.4371e+01 (km)
Central P: 1.6013e-04 (Msun/km^3), M: 2.5946e+00 (Msun), R: 1.4297e+01 (km)
Central P: 1.7615e-04 (Msun/km^3), M: 2.6314e+00 (Msun), R: 1.4216e+01 (km)
Central P: 1.9376e-04 (Msun/km^3), M: 2.6639e+00 (Msun), R: 1.4129e+01 (km)
Central P: 2.1314e-04 (Msun/km^3), M: 2.6920e+00 (Msun), R: 1.4038e+01 (km)
Central P: 2.3445e-04 (Msun/km^3), M: 2.7158e+00 (Msun), R: 1.3941e+01 (km)
Central P: 2.5790e-04 (Msun/km^3), M: 2.7352e+00 (Msun), R: 1.3839e+01 (km)
Central P: 2.8369e-04 (Msun/km^3), M: 2.7506e+00 (Msun), R: 1.3733e+01 (km)
Central P: 3.1205e-04 (Msun/km^3), M: 2.7618e+00 (Msun), R: 1.3623e+01 (km)
Central P: 3.4326e-04 (Msun/km^3), M: 2.7692e+00 (Msun), R: 1.3509e+01 (km)
Central P: 3.7759e-04 (Msun/km^3), M: 2.7728e+00 (Msun), R: 1.3393e+01 (km)
Central P: 4.1534e-04 (Msun/km^3), M: 2.7728e+00 (Msun), R: 1.3274e+01 (km)
Central P: 4.5688e-04 (Msun/km^3), M: 2.7696e+00 (Msun), R: 1.3153e+01 (km)
Central P: 5.0257e-04 (Msun/km^3), M: 2.7632e+00 (Msun), R: 1.3030e+01 (km)
Central P: 5.5282e-04 (Msun/km^3), M: 2.7539e+00 (Msun), R: 1.2906e+01 (km)
Central P: 6.0811e-04 (Msun/km^3), M: 2.7420e+00 (Msun), R: 1.2781e+01 (km)
Central P: 6.6892e-04 (Msun/km^3), M: 2.7277e+00 (Msun), R: 1.2656e+01 (km)
Central P: 7.3581e-04 (Msun/km^3), M: 2.7111e+00 (Msun), R: 1.2531e+01 (km)
Central P: 8.0939e-04 (Msun/km^3), M: 2.6925e+00 (Msun), R: 1.2407e+01 (km)
Central P: 8.9033e-04 (Msun/km^3), M: 2.6722e+00 (Msun), R: 1.2283e+01 (km)
Central P: 9.7936e-04 (Msun/km^3), M: 2.6504e+00 (Msun), R: 1.2162e+01 (km)
Central P: 1.0773e-03 (Msun/km^3), M: 2.6272e+00 (Msun), R: 1.2042e+01 (km)
Central P: 1.1850e-03 (Msun/km^3), M: 2.6029e+00 (Msun), R: 1.1924e+01 (km)
Central P: 1.3035e-03 (Msun/km^3), M: 2.5777e+00 (Msun), R: 1.1809e+01 (km)
Central P: 1.4339e-03 (Msun/km^3), M: 2.5517e+00 (Msun), R: 1.1696e+01 (km)
Central P: 1.5773e-03 (Msun/km^3), M: 2.5251e+00 (Msun), R: 1.1587e+01 (km)
Central P: 1.7350e-03 (Msun/km^3), M: 2.4981e+00 (Msun), R: 1.1482e+01 (km)
Central P: 1.9085e-03 (Msun/km^3), M: 2.4709e+00 (Msun), R: 1.1380e+01 (km)
Central P: 2.0993e-03 (Msun/km^3), M: 2.4435e+00 (Msun), R: 1.1282e+01 (km)
Central P: 2.3093e-03 (Msun/km^3), M: 2.4162e+00 (Msun), R: 1.1188e+01 (km)
Central P: 2.5402e-03 (Msun/km^3), M: 2.3890e+00 (Msun), R: 1.1099e+01 (km)
Central P: 2.7942e-03 (Msun/km^3), M: 2.3621e+00 (Msun), R: 1.1014e+01 (km)
Central P: 3.0736e-03 (Msun/km^3), M: 2.3356e+00 (Msun), R: 1.0934e+01 (km)
Central P: 3.3810e-03 (Msun/km^3), M: 2.3096e+00 (Msun), R: 1.0859e+01 (km)
Central P: 3.7191e-03 (Msun/km^3), M: 2.2842e+00 (Msun), R: 1.0789e+01 (km)
Central P: 4.0910e-03 (Msun/km^3), M: 2.2595e+00 (Msun), R: 1.0725e+01 (km)
Central P: 4.5001e-03 (Msun/km^3), M: 2.2355e+00 (Msun), R: 1.0665e+01 (km)
Central P: 4.9501e-03 (Msun/km^3), M: 2.2124e+00 (Msun), R: 1.0611e+01 (km)
Central P: 5.4452e-03 (Msun/km^3), M: 2.1903e+00 (Msun), R: 1.0563e+01 (km)
Central P: 5.9897e-03 (Msun/km^3), M: 2.1691e+00 (Msun), R: 1.0520e+01 (km)
Central P: 6.5886e-03 (Msun/km^3), M: 2.1490e+00 (Msun), R: 1.0482e+01 (km)
Central P: 7.2475e-03 (Msun/km^3), M: 2.1301e+00 (Msun), R: 1.0450e+01 (km)
Central P: 7.9723e-03 (Msun/km^3), M: 2.1122e+00 (Msun), R: 1.0423e+01 (km)
Maximum mass: 2.772836e+00
Radius of maximum mass star: 1.327385e+01
Central baryon density of maximum mass star: 6.818593e-01
0 tests performed.
All tests passed.