Creating an NSE table

Creating an NSE table#

We can tabulate the NSE state on a grid (ρ,T,Ye), giving:

  • A¯ : the mean molecular weight

  • B/A : the average binding energy per nucleon of the NSE state [MeV]

  • dYe/dt : the time-evolution of Ye due to weak reactions [1/s]

  • dA¯/dt : the time-evolution of A¯ due to weak reactions [1/s]

  • dB/A/dt : the time-evolution of the binding energy per nucleon due to weak reactions [MeV/s]

  • ϵν : the energy loss due to neutrinos [erg / g / s]

import pynucastro as pyna
from pynucastro import Nucleus

First we’ll create a simple NSE network with a few nuclei. We’ll include tabulated weak rates so we can compute the change in the state due to electron/positron captures and decays.

nucs = [Nucleus("p"), Nucleus("n"), Nucleus("he4"),
        Nucleus("fe52"), Nucleus("fe53"), Nucleus("fe54"),
        Nucleus("fe55"), Nucleus("fe56"),
        Nucleus("co54"), Nucleus("co55"), Nucleus("co56"),
        Nucleus("ni56"), Nucleus("ni57")]
tl = pyna.TabularLibrary().linking_nuclei(nucs)
rl = pyna.ReacLibLibrary().linking_nuclei(nucs)
all_lib = tl + rl
warning: He4 was not able to be linked
warning: Fe53 was not able to be linked
warning: Fe52 was not able to be linked
warning: Ni57 was not able to be linked
dupes = all_lib.find_duplicate_links()
rates_to_remove = []
for d in dupes:
    rates_to_remove += [r for r in d if isinstance(r, pyna.rates.ReacLibRate)]

for r in rates_to_remove:
    all_lib.remove_rate(r)
nse = pyna.NSENetwork(libraries=[all_lib])

Now we’ll create a grid of temperature, density, and Ye where we want to compute the NSE state

import numpy as np
Ts = np.logspace(9.6, 10.4, 3)
rhos = np.logspace(7, 10, 4)
yes = np.linspace(0.43, 0.5, 3)

Finally we can generate the table. This will compute the NSE state at each combination of (ρ,T,Ye). To help accelerate the convergence, it will start at the highest temperature and loop over ρ and Ye and cache the values of the proton and neutron chemical potentials for the next temperature.

nse.generate_table(rho_values=rhos,
                   T_values=Ts,
                   Ye_values=yes)

The table is stored as nse.tbl

%cat nse.tbl
# NSE table generated by pynucastro 2.5.0.post37+g50ff3873
# original NSENetwork had 13 nuclei
#
#   log10(rho)       log10(T)           Ye             Abar            <B/A>          dYe/dt         dAbar/dt        d<B/A>/dt         e_nu       
   7.0000000000    9.6000000000    0.5000000000   50.2051965063    8.6280555770  -4.3798684e-05              -0   2.3285948e-06   7.4765875e+13 
   7.0000000000    9.6000000000    0.4650000000   55.7461181554    8.7870631885  -5.5253373e-09   2.1689193e-21   3.9317237e-10   1.3980145e+10 
   7.0000000000    9.6000000000    0.4300000000   11.0637644863    8.1412181124   0.00017699678  -2.9553154e-26  -1.8453759e-12   2.7707299e+14 
   7.0000000000   10.0000000000    0.5000000000    1.2148721356    1.6682000908     0.084056593   1.1097981e-55   5.7350242e-41   7.8635828e+17 
   7.0000000000   10.0000000000    0.4650000000    1.2129154965    1.6556759416      0.10066493  -9.5154199e-56   3.5220148e-41   8.3544455e+17 
   7.0000000000   10.0000000000    0.4300000000    1.2071216004    1.6183519789       0.1178642  -1.8245905e-55   5.9197759e-42   8.8944343e+17 
   7.0000000000   10.4000000000    0.5000000000    1.0000000000    0.0000000002       5.7463273 -3.0282656e-218  6.7442697e-203   2.3050257e+20 
   7.0000000000   10.4000000000    0.4650000000    1.0000000000    0.0000000002       7.2542055 -1.4008643e-218  5.8190844e-203    2.360043e+20 
   7.0000000000   10.4000000000    0.4300000000    1.0000000000    0.0000000002       8.7650901  1.5660364e-218  3.8278038e-203   2.4155562e+20 
   8.0000000000    9.6000000000    0.5000000000   54.3190287633    8.6383977879  -0.00084867596              -0   4.3696922e-05   1.4741939e+15 
   8.0000000000    9.6000000000    0.4650000000   55.8970086077    8.7873938438  -4.9038114e-08   2.6652714e-20    4.195729e-09   1.2981616e+11 
   8.0000000000    9.6000000000    0.4300000000   11.0638264094    8.1412220464   9.2047376e-06  -3.3885398e-29  -5.6069146e-13   1.1254068e+13 
   8.0000000000   10.0000000000    0.5000000000    2.5712548585    5.7636834359    -0.019589285  -5.2722578e-34   1.7213901e-19   1.6310989e+17 
   8.0000000000   10.0000000000    0.4650000000    2.5124367545    5.6778079180   -0.0041256863  -3.8679592e-33   2.1068175e-19   1.5065028e+17 
   8.0000000000   10.0000000000    0.4300000000    2.3664071213    5.4461458099    0.0093041571   4.0022393e-35   1.1443316e-19    1.616981e+17 
   8.0000000000   10.4000000000    0.5000000000    1.0000000214    0.0000002024        1.213841 -1.9167604e-165  9.8468124e-150   2.1894106e+20 
   8.0000000000   10.4000000000    0.4650000000    1.0000000212    0.0000002004       2.8346072  1.4571224e-165  8.4165813e-150   2.2127881e+20 
   8.0000000000   10.4000000000    0.4300000000    1.0000000206    0.0000001945       4.4726034  2.0415049e-165  5.4823199e-150   2.2397331e+20 
   9.0000000000    9.6000000000    0.5000000000   55.5133155454    8.6413416287    -0.060150514              -0    0.0031209543   1.5551546e+17 
   9.0000000000    9.6000000000    0.4650000000   55.9133553778    8.7874269700  -3.9837589e-06   2.1308784e-18   3.6045209e-07   1.0369016e+13 
   9.0000000000    9.6000000000    0.4300000000   11.0638296395    8.1412222516   1.0225013e-08  -9.8140885e-34  -5.2463927e-15   1.1664591e+10 
   9.0000000000   10.0000000000    0.5000000000    4.3121776381    7.1515970010     -0.10742171  -8.6627599e-20   2.9758631e-05   4.7264474e+17 
   9.0000000000   10.0000000000    0.4650000000    5.1247512633    7.3995936810    -0.019430688   1.8465661e-19   3.3567893e-06   8.7381921e+16 
   9.0000000000   10.0000000000    0.4300000000    4.4162917338    7.0777667259   -0.0059568646  -9.8582877e-21   5.1854462e-07   3.2607547e+16 
   9.0000000000   10.4000000000    0.5000000000    1.0000214391    0.0002025496      -17.715252 -4.6659523e-112   3.7269644e-96   2.7735801e+20 
   9.0000000000   10.4000000000    0.4650000000    1.0000212299    0.0002005606      -15.005795 -5.0233078e-112   3.0828757e-96   2.5962747e+20 
   9.0000000000   10.4000000000    0.4300000000    1.0000206076    0.0001946701      -12.327315  9.4415328e-113   1.9401565e-96   2.4324142e+20 
  10.0000000000    9.6000000000    0.5000000000   55.8690710154    8.6423241378      -5.2274435              -0      0.27200888   2.9375322e+19 
  10.0000000000    9.6000000000    0.4650000000   55.9152992533    8.7874248629  -0.00092936032   -1.324133e-16     8.53828e-05   4.3024741e+15 
  10.0000000000    9.6000000000    0.4300000000   11.0638297820    8.1412222637   5.0971987e-15  -9.3106433e-42  -6.8646472e-21       5801.4456 
  10.0000000000   10.0000000000    0.5000000000   13.9373407965    8.2743569653      -5.5783268   2.1566023e-14      0.10960359   3.9379731e+19 
  10.0000000000   10.0000000000    0.4650000000   28.2439836979    8.6492581223    -0.075077755  -6.6877144e-16   0.00050735877   5.2201547e+17 
  10.0000000000   10.0000000000    0.4300000000   10.2419481623    8.0844804256   -0.0025107086  -3.0948296e-20    1.107337e-06   1.7236326e+16 
  10.0000000000   10.4000000000    0.5000000000    1.0197762662    0.1829102358      -196.64449  -9.9403547e-58   3.9060708e-42   2.3555843e+21 
  10.0000000000   10.4000000000    0.4650000000    1.0195859197    0.1811835447       -167.5422    -7.86651e-58    3.044433e-42   1.9968627e+21 
  10.0000000000   10.4000000000    0.4300000000    1.0190251344    0.1760927389      -140.99607  -1.6336075e-57   1.8184626e-42   1.6720802e+21 

There are other options to the NSE table writing, including storing the mass fractions or a reduced composition constructed by binning the nuclei into the closest nuclei in a smaller set.