23 #include "../macros.h"
24 subroutine chempot(temp,den,ye,etaele,etapos)
32 real(r_kind),
intent(in) :: temp
33 real(r_kind),
intent(in) :: den
34 real(r_kind),
intent(in) :: ye
35 real(r_kind),
intent(out) :: etaele
36 real(r_kind),
intent(out) :: etapos
41 parameter(imax = 271, jmax = 101)
44 real(r_kind) d(imax),t(jmax)
47 real(r_kind) ef(imax,jmax),efd(imax,jmax), &
48 eft(imax,jmax),efdt(imax,jmax)
51 real(r_kind) dt_sav(jmax), &
58 real(r_kind) tlo,thi,tstp,tstpi,dlo,dhi,dstp,dstpi, &
59 tsav,dsav,deni,tempi,kt,ktinv,beta,dbetadt
60 real(r_kind) dth,dti,dd,ddi,xt,xd,mxt,mxd, &
61 si0t,si1t,si0mt,si1mt, &
62 si0d,si1d,si0md,si1md, &
63 dsi0t,dsi1t,dsi0mt,dsi1mt, &
64 dsi0d,dsi1d,dsi0md,dsi1md, &
66 xpsi0,xdpsi0,xpsi1,xdpsi1,h3, &
67 w0t,w1t,w0mt,w1mt,w0d,w1d,w0md,w1md, &
68 detadd,detadt,detapdd,detapdt
71 real(r_kind) mecc,positron_start
76 integer :: chem_pot_unit
80 xpsi0(z) = z * z * (2.0d0*z - 3.0d0) + 1.d0
81 xdpsi0(z) = z * (6.0d0*z - 6.0d0)
84 xpsi1(z) = z * ( z * (z - 2.0d0) + 1.0d0)
85 xdpsi1(z) = z * (3.0d0*z - 4.0d0) + 1.0d0
89 h3(i,j,w0t,w1t,w0mt,w1mt,w0d,w1d,w0md,w1md) = &
90 fi(1) *w0d*w0t + fi(2) *w0md*w0t &
91 + fi(3) *w0d*w0mt + fi(4) *w0md*w0mt &
92 + fi(5) *w0d*w1t + fi(6) *w0md*w1t &
93 + fi(7) *w0d*w1mt + fi(8) *w0md*w1mt &
94 + fi(9) *w1d*w0t + fi(10) *w1md*w0t &
95 + fi(11) *w1d*w0mt + fi(12) *w1md*w0mt &
96 + fi(13) *w1d*w1t + fi(14) *w1md*w1t &
97 + fi(15) *w1d*w1mt + fi(16) *w1md*w1mt
101 mecc =
unit%mass_e*1.602176462d-6
102 positron_start = 0.02d0
105 if (ifirst .eq. 0)
then
111 tstp = (thi - tlo)/float(jmax-1)
115 dstp = (dhi - dlo)/float(imax-1)
119 tsav = tlo + (j-1)*tstp
120 t(j) = 10.0d0**(tsav)
122 dsav = dlo + (i-1)*dstp
123 d(i) = 10.0d0**(dsav)
124 read(chem_pot_unit,*) ef(i,j),efd(i,j),eft(i,j),efdt(i,j)
153 if (temp .gt. t(jmax))
then
155 ") was off the grid (hotter than "//
num_to_str(t(jmax))//
"K) "//new_line(
"A")//&
156 "when trying to interpolate electron and positron chemical potentials."//new_line(
"A")//&
157 "Check your conditions or consider to switch off theoretical weak rates (iwformat = 0).", &
164 if (temp .lt. t(1))
then
166 ") was off the grid (colder than "//
num_to_str(t(1))//
"K) "//new_line(
"A")//&
167 "when trying to interpolate electron and positron chemical potentials."//new_line(
"A")//&
168 "Check your conditions or consider to switch off theoretical weak rates (iwformat = 0).", &
175 if (din .gt. d(imax))
then
177 ") was off the grid (larger than "//
num_to_str(d(imax))//
") "//new_line(
"A")//&
178 "when trying to interpolate electron and positron chemical potentials."//new_line(
"A")//&
180 "Check your conditions or consider to switch off theoretical weak rates (iwformat = 0).", &
187 if (din .lt. d(1))
then
189 ") was off the grid (smaller than "//
num_to_str(d(1))//
") "//new_line(
"A")//&
190 "when trying to interpolate electron and positron chemical potentials."//new_line(
"A")//&
192 "Check your conditions or consider to switch off theoretical weak rates (iwformat = 0).", &
203 kt =
unit%kerg * temp
206 dbetadt =
unit%kerg/mecc
209 jat = int((log10(temp) - tlo)*tstpi) + 1
210 jat = max(1,min(jat,jmax-1))
211 iat = int((log10(din) - dlo)*dstpi) + 1
212 iat = max(1,min(iat,imax-1))
216 fi(2) = ef(iat+1,jat)
217 fi(3) = ef(iat,jat+1)
218 fi(4) = ef(iat+1,jat+1)
220 fi(6) = eft(iat+1,jat)
221 fi(7) = eft(iat,jat+1)
222 fi(8) = eft(iat+1,jat+1)
224 fi(10) = efd(iat+1,jat)
225 fi(11) = efd(iat,jat+1)
226 fi(12) = efd(iat+1,jat+1)
227 fi(13) = efdt(iat,jat)
228 fi(14) = efdt(iat+1,jat)
229 fi(15) = efdt(iat,jat+1)
230 fi(16) = efdt(iat+1,jat+1)
234 xt = max( (temp - t(jat))*dti_sav(jat), 0.0d0)
235 xd = max( (din - d(iat))*ddi_sav(iat), 0.0d0)
240 si1t = xpsi1(xt)*dt_sav(jat)
243 si1mt = -xpsi1(mxt)*dt_sav(jat)
246 si1d = xpsi1(xd)*dd_sav(iat)
249 si1md = -xpsi1(mxd)*dd_sav(iat)
252 dsi0t = xdpsi0(xt)*dti_sav(jat)
255 dsi0mt = -xdpsi0(mxt)*dti_sav(jat)
258 dsi0d = xdpsi0(xd)*ddi_sav(iat)
261 dsi0md = -xdpsi0(mxd)*ddi_sav(iat)
265 etaele = h3(iat,jat, &
266 si0t, si1t, si0mt, si1mt, &
267 si0d, si1d, si0md, si1md)
271 si0t, si1t, si0mt, si1mt, &
272 dsi0d, dsi1d, dsi0md, dsi1md)
276 detadt = h3(iat,jat, &
277 dsi0t, dsi1t, dsi0mt, dsi1mt, &
278 si0d, si1d, si0md, si1md)
285 if (beta .gt. positron_start)
then
286 etapos = -etaele - 2.0d0/beta
288 detapdt = -detadt + 2.0d0/beta**2 * dbetadt