Creating an NSE table#
We can tabulate the NSE state on a grid \((\rho, T, Y_e)\), giving:
\(\bar{A}\) : the mean molecular weight
\(\langle B/A \rangle\) : the average binding energy per nucleon of the NSE state [MeV]
\(dY_e/dt\) : the time-evolution of \(Y_e\) due to weak reactions [1/s]
\(d\bar{A}/dt\) : the time-evolution of \(\bar{A}\) due to weak reactions [1/s]
\(d\langle B/A\rangle/dt\) : the time-evolution of the binding energy per nucleon due to weak reactions [MeV/s]
\(\epsilon_\nu\) : 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 \(Y_e\) 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 \((\rho, T, Y_e)\). To help accelerate the convergence, it will start at the highest temperature and loop over \(\rho\) and \(Y_e\) 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.6.0.post23+g476e8dbc7
# 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.2051965167 8.6280555771 -4.3798684e-05 1.7079991e-17 2.3285948e-06 7.4765875e+13
7.0000000000 9.6000000000 0.4650000000 55.7461181560 8.7870631885 -5.5253373e-09 -9.2881961e-22 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.2148721368 1.6682000987 0.084056593 9.4050686e-58 5.7350248e-41 7.8635828e+17
7.0000000000 10.0000000000 0.4650000000 1.2129154977 1.6556759493 0.10066493 1.0499774e-55 3.5220152e-41 8.3544455e+17
7.0000000000 10.0000000000 0.4300000000 1.2071216016 1.6183519865 0.1178642 1.5367417e-55 5.9197765e-42 8.8944343e+17
7.0000000000 10.4000000000 0.5000000000 1.0000000000 0.0000000002 5.7463273 7.8561884e-219 6.744271e-203 2.3050257e+20
7.0000000000 10.4000000000 0.4650000000 1.0000000000 0.0000000002 7.2542055 -3.4372499e-218 5.8190855e-203 2.360043e+20
7.0000000000 10.4000000000 0.4300000000 1.0000000000 0.0000000002 8.7650901 -1.1470818e-218 3.8278045e-203 2.4155562e+20
8.0000000000 9.6000000000 0.5000000000 54.3190287662 8.6383977879 -0.00084867596 3.1990002e-16 4.3696922e-05 1.4741939e+15
8.0000000000 9.6000000000 0.4650000000 55.8970086078 8.7873938438 -4.9038114e-08 1.8253071e-20 4.195729e-09 1.2981616e+11
8.0000000000 9.6000000000 0.4300000000 11.0638264094 8.1412220464 9.2047376e-06 -3.3885397e-29 -5.6069146e-13 1.1254068e+13
8.0000000000 10.0000000000 0.5000000000 2.5712548608 5.7636834391 -0.019589285 -2.5863906e-34 1.7213902e-19 1.6310989e+17
8.0000000000 10.0000000000 0.4650000000 2.5124367565 5.6778079210 -0.0041256863 1.5552568e-33 2.1068176e-19 1.5065028e+17
8.0000000000 10.0000000000 0.4300000000 2.3664071228 5.4461458125 0.0093041571 -4.6131074e-34 1.1443317e-19 1.616981e+17
8.0000000000 10.4000000000 0.5000000000 1.0000000215 0.0000002024 1.213841 1.991458e-165 9.8468142e-150 2.1894106e+20
8.0000000000 10.4000000000 0.4650000000 1.0000000212 0.0000002004 2.8346072 -1.4128967e-165 8.4165829e-150 2.2127881e+20
8.0000000000 10.4000000000 0.4300000000 1.0000000206 0.0000001945 4.4726034 2.4421366e-165 5.4823209e-150 2.2397331e+20
9.0000000000 9.6000000000 0.5000000000 55.5133155461 8.6413416287 -0.060150514 -0 0.0031209543 1.5551546e+17
9.0000000000 9.6000000000 0.4650000000 55.9133553778 8.7874269700 -3.9837589e-06 -2.8963396e-19 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.3121776451 7.1515970038 -0.10742171 4.0163705e-19 2.9758632e-05 4.7264474e+17
9.0000000000 10.0000000000 0.4650000000 5.1247512774 7.3995936852 -0.019430688 -7.0908138e-20 3.3567893e-06 8.738192e+16
9.0000000000 10.0000000000 0.4300000000 4.4162917436 7.0777667298 -0.0059568646 2.1719087e-21 5.1854462e-07 3.2607547e+16
9.0000000000 10.4000000000 0.5000000000 1.0000214754 0.0002025496 -17.715251 -3.2893139e-112 3.7269578e-96 2.77358e+20
9.0000000000 10.4000000000 0.4650000000 1.0000212646 0.0002005606 -15.005795 -1.2481114e-111 3.0828704e-96 2.5962746e+20
9.0000000000 10.4000000000 0.4300000000 1.0000206400 0.0001946701 -12.327314 -5.1370063e-113 1.9401534e-96 2.4324141e+20
10.0000000000 9.6000000000 0.5000000000 55.8690710156 8.6423241378 -5.2274435 -0 0.27200888 2.9375322e+19
10.0000000000 9.6000000000 0.4650000000 55.9152992533 8.7874248629 -0.00092936032 -1.8273036e-16 8.53828e-05 4.3024741e+15
10.0000000000 9.6000000000 0.4300000000 11.0638297827 8.1412222607 5.0971987e-15 -9.3106432e-42 -6.8646472e-21 5801.4456
10.0000000000 10.0000000000 0.5000000000 13.9373408169 8.2743569660 -5.5783268 2.1566023e-14 0.10960359 3.9379731e+19
10.0000000000 10.0000000000 0.4650000000 28.2439837438 8.6492581227 -0.075077755 5.7214672e-16 0.00050735877 5.2201547e+17
10.0000000000 10.0000000000 0.4300000000 10.2419481655 8.0844804259 -0.0025107086 -7.7994308e-20 1.107337e-06 1.7236325e+16
10.0000000000 10.4000000000 0.5000000000 1.0197762664 0.1829102375 -196.64449 2.4436705e-57 3.9060715e-42 2.3555843e+21
10.0000000000 10.4000000000 0.4650000000 1.0195859199 0.1811835464 -167.5422 2.8981879e-58 3.0444336e-42 1.9968627e+21
10.0000000000 10.4000000000 0.4300000000 1.0190251346 0.1760927406 -140.99607 2.6882149e-58 1.8184629e-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.