3 from winvn_class
import winvn
9 def __init__(self, path_winvn="winvne_v2.0.dat"):
11 Constructor for the class
31 Read the file containing the partition functions
35 df = w.get_dataframe()
36 pf = df[
"function"].values
39 spin = df[
"spin"].values
43 self.
__pf_Z_N = np.zeros((Z.max()+1,N.max()+1),dtype=object)
53 Calculate the neutron separation energy from the mass excess in the winvn
57 df = w.get_dataframe()
59 mexc_n = df.loc[
"n",
"mass excess"]
62 Zwinvn = df[
"Z"].values
63 Nwinvn = df[
"N"].values
64 mexc = df[
"mass excess"].values
77 self.
__A = df[
"A"].values
78 self.
__Z = df[
"Z"].values
79 self.
__N = df[
"N"].values
87 Helper function to calculate the path of the r-process. Necessary to use numba.
90 def helper_calc_ratio(Z, N, T, ndens, Sn_Z_N, pf_Z_N, spin_Z_N):
100 Snp1 = Sn_Z_N[Z, N + 1]
103 pf1 = pf_Z_N[Z, N + 1]
105 sp = 2 * spin_Z_N[Z, N] + 1
106 sp1 = 2 * spin_Z_N[Z, N + 1] + 1
108 a = np.log((A + 1) / A) * 3 / 2
110 c = np.log(pf * sp / (2 * pf1 * sp1))
112 d = np.log(2 * np.pi * hbar**2 / (hix * kbT)) * 1.5
113 e = np.log(ndens * NA)
115 ratio = a + b + c + d + e
121 Zmax = Sn_array.shape[0]-1
122 Nmax = Sn_array.shape[1]-1
123 logratios = np.zeros((Zmax+1, Nmax+1))*np.nan
127 for Z
in range(0,Zmax):
128 for N
in range(0,Nmax):
129 if np.isnan(Sn_array[Z,N]):
132 logratios[Z,N] = helper_calc_ratio(Z,N,temperature,ndens,Sn_array,pf,spin)
135 if np.all(np.isnan(logratios[Z,:])):
140 log_ratios = logratios[Z, :]
141 log_cumprod = np.nancumsum(log_ratios)
143 maxval = np.where(~np.isnan(Sn_array[Z,:]) & (Sn_array[Z,:]>0))[0][-1]
144 minval = np.where(~np.isnan(Sn_array[Z,:]))[0][0]
146 idx = np.minimum(np.maximum(np.argmax(log_cumprod)+1,minval),maxval)
151 path_N.append(path_N[-1]-1)
156 return path_Z, path_N
162 Get the path of the r-process
169 pf = np.empty((rows, cols))
170 def apply_callable(Z, N):
173 return func(temperature)
177 vectorized_calc = np.vectorize(apply_callable)
178 pf = vectorized_calc(np.arange(rows)[:,
None], np.arange(cols))
186 kbT = self.
__kb*T*1e9
196 a = np.log((A+1)/A)*3/2
200 c = np.log(pf*sp/(2*pf1*sp1))
202 d = np.log(2*np.pi*self.
__hbar**2 / (self.
__hix*kbT)) * 1.5
203 e = np.log(ndens*self.
__NA)
207 ratio = np.exp(a+b+c+d+e,dtype=np.float128)
211 if __name__ ==
"__main__":
214 ng =
ngamma_eq(
"/home/mreichert/data/Networks/comparison_winNet/WinNet-dev/data/winvne_v2.0.dat")
215 ng.calc_r_process_path(1e6,4,5e-1)