create_rates_grid.py
Go to the documentation of this file.
1 # Author: M. Reichert
2 import numpy as np
3 import matplotlib.pyplot as plt
4 from scipy.interpolate import interp1d
5 
6 # Script to create tabulated rates for WinNet
7 
8 # The default talys temperature grid as used in WinNet
9 talys_t = np.array([1.0e-4,5.0e-4,1.0e-3,5.0e-3,1.0e-2,5.0e-2,1.0e-1,1.5e-1,2.0e-1,2.5e-1,
10  3.0e-1,4.0e-1,5.0e-1,6.0e-1,7.0e-1,8.0e-1,9.0e-1,1.0e+0,1.5e+0,2.0e+0,
11  2.5e+0,3.0e+0,3.5e+0,4.0e+0,5.0e+0,6.0e+0,7.0e+0,8.0e+0,9.0e+0,1.0e+1 ])
12 
13 # Define the string that will contain the tabulated rates in correct format
14 # as defined by WinNet
15 rate_file = ""
16 
17 
18 
19 # Interpolate the tabulation from the paper on the talys grid
20 # Here its Ne22(a,g)Mg26
21 T9,adopt,exp = np.loadtxt("ne22amg26_angulo1999",unpack=True,skiprows=1,)
22 rate = adopt*10**exp
23 f = interp1d(np.log10(T9),np.log10(rate),fill_value=-99,bounds_error=False,kind="cubic")
24 rates = 10**f(np.log10(talys_t))
25 # If you want you can plot:
26 # plt.plot(talys_t,rates)
27 
28 # Write it into the string (first reaclib chapter, then rate)
29 rate_file += "4\n\n"
30 rate_file += " he4 ne22 mg26 an99 1.06148e+01 \n"
31 stringlist = ["{:.3e}".format(ytmp) for ytmp in rates ]
32 rate_file += " "+" ".join(stringlist)+"\n"
33 
34 # The next rate, O17(a,g)Ne21
35 # This rate is already in reaclib! However, they multiply it by 0.1 in Nishimura et al. 2017
36 T9,adopt,exp = np.loadtxt("o17agne21_cf88",unpack=True,skiprows=1,)
37 rate = adopt*10**exp
38 rate[rate==0]=1e-98
39 f = interp1d(np.log10(T9),np.log10(rate),fill_value=-98,bounds_error=False,kind="cubic")
40 rates = 10**f(np.log10(talys_t))
41 # If you want you can plot:
42 # plt.plot(talys_t,rates)
43 
44 # Write the rate into the string again
45 rate_file += " he4 o17 ne21 cf88n 7.35100e+00 \n"
46 stringlist = ["{:.3e}".format(ytmp*0.1) for ytmp in rates ]
47 rate_file += " "+" ".join(stringlist)+"\n"
48 
49 
50 # The Ne22(a,n)Mg25 is given in a slightly different format in Jaeger et al. 2001
51 a = np.array([4.04,2.302e-4,6900,1.881e7])
52 b = np.array([0,-0.6,3.19,0.358])
53 c = np.array([7.74,6.14,11.3,26.7])
54 func = lambda T: np.sum(a*T**b*np.exp(-c/T))
55 y = np.array([func(ttmp) for ttmp in talys_t])
56 y[y<1e-99]=1e-99
57 # If you want you can plot:
58 # plt.plot(talys_t,y)
59 
60 # Write the rate into the string again
61 rate_file += "5\n\n"
62 rate_file += " he4 ne22 n mg25 ja01 -4.78290e-01 \n"
63 stringlist = ["{:.3e}".format(ytmp) for ytmp in y ]
64 rate_file += " "+" ".join(stringlist)+"\n"
65 
66 
67 # The last rate: O17(a,n)Ne20
68 T9,adopt,exp = np.loadtxt("017anne20_angulo1999",unpack=True,skiprows=1,)
69 rate = adopt*10**exp
70 f = interp1d(np.log10(T9),np.log10(rate),fill_value=-99,bounds_error=False,kind="cubic")
71 rates = 10**f(np.log10(talys_t))
72 rates[rates<1e-99]=1e-99
73 # If you want you can plot:
74 # plt.plot(talys_t,rates)
75 
76 # Write again to the string
77 rate_file += " he4 o17 n ne20 an99 5.86000e-01 \n"
78 stringlist = ["{:.3e}".format(ytmp) for ytmp in rates ]
79 rate_file += " "+" ".join(stringlist)+"\n"
80 
81 # Write the string to the file
82 with open("tab_rates.dat","w") as f:
83  f.write(rate_file)
84 
85 
86 # In case you plotted one of the rates:
87 # plt.yscale("log")
88 # plt.xscale("log")
89 # plt.xlim(1e-2,1e1)
90 # plt.ylim(1e-50,1e11)
91 # plt.show()
create_rates_grid.func
func
Definition: create_rates_grid.py:54
inter_module::interp1d
subroutine, public interp1d(n, xp, xb, yp, res, flin, itype)
Interface for 1D interpolation routines.
Definition: inter_module.f90:99
create_rates_grid.f
f
Definition: create_rates_grid.py:23