Line data Source code
1 : ! ***********************************************************************
2 : !
3 : ! Copyright (C) 2010-2019 The MESA Team
4 : !
5 : ! This program is free software: you can redistribute it and/or modify
6 : ! it under the terms of the GNU Lesser General Public License
7 : ! as published by the Free Software Foundation,
8 : ! either version 3 of the License, or (at your option) any later version.
9 : !
10 : ! This program is distributed in the hope that it will be useful,
11 : ! but WITHOUT ANY WARRANTY; without even the implied warranty of
12 : ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13 : ! See the GNU Lesser General Public License for more details.
14 : !
15 : ! You should have received a copy of the GNU Lesser General Public License
16 : ! along with this program. If not, see <https://www.gnu.org/licenses/>.
17 : !
18 : ! ***********************************************************************
19 :
20 : module net_screen
21 :
22 : use const_def,only: dp, pi, ln10
23 : use math_lib
24 : use chem_def, only: chem_isos, ih1, num_chem_isos
25 : use net_def, only: Net_General_Info, Net_Info
26 : use rates_def
27 : use utils_lib, only: mesa_error
28 :
29 : implicit none
30 :
31 :
32 : contains
33 :
34 :
35 10 : subroutine make_screening_tables(n, ierr)
36 : type (Net_Info) :: n
37 : integer, intent(out) :: ierr
38 10 : real(dp) :: y(num_chem_isos)
39 78570 : y = 0
40 : call screen_net( &
41 : n% g, num_chem_isos, y, 1d0, 1d0, 0d0, 0d0, .true., &
42 : n% rate_raw, n% rate_raw_dT, n% rate_raw_dRho, &
43 : n% rate_screened, n% rate_screened_dT, n% rate_screened_dRho, &
44 : n% screening_mode, &
45 10 : 0d0, 0d0, 0d0, 1d0, ierr)
46 10 : end subroutine make_screening_tables
47 :
48 :
49 81813 : subroutine screen_net( &
50 81813 : g, num_isos, y, temp, den, logT, logRho, init, &
51 245439 : rate_raw, rate_raw_dT, rate_raw_dRho, &
52 245439 : rate_screened, rate_screened_dT, rate_screened_dRho, &
53 : screening_mode, &
54 : zbar, abar, z2bar, ye, ierr)
55 :
56 : use rates_def, only: Screen_Info, reaction_name
57 : use rates_lib, only: screen_set_context
58 :
59 : type (Net_General_Info), pointer :: g
60 : integer, intent(in) :: num_isos, screening_mode
61 : real(dp), intent(in) :: y(:), temp, den, logT, logRho, &
62 : zbar, abar, z2bar, ye
63 : real(dp), intent(inout), dimension(:) :: &
64 : rate_raw, rate_raw_dT, rate_raw_dRho, &
65 : rate_screened, rate_screened_dT, rate_screened_dRho
66 : logical, intent(in) :: init
67 : integer, intent(out) :: ierr
68 :
69 : type (Screen_Info) :: sc
70 : integer :: num_reactions, i, ir, j, op_err
71 : real(dp) :: Tfactor, dTfactordt
72 : logical :: all_okay
73 :
74 : include 'formats'
75 :
76 81813 : ierr = 0
77 :
78 81813 : if (.not. init) then
79 : call screen_set_context( &
80 : sc, temp, den, logT, logRho, zbar, abar, z2bar, &
81 81803 : screening_mode, num_isos, y, g% z158)
82 : end if
83 :
84 81813 : num_reactions = g% num_reactions
85 :
86 2896498 : do i = 1, num_reactions
87 2814685 : ir = g% reaction_id(i)
88 2814685 : if (ir == 0) then
89 0 : write(*,*) 'g% reaction_id(i) == 0', i, num_reactions
90 0 : call mesa_error(__FILE__,__LINE__,'screen_net')
91 : end if
92 2896498 : if (reaction_screening_info(3,ir) > 0) then
93 : call eval_screen_triple( &
94 : init, i, &
95 : reaction_screening_info(1,ir), &
96 : reaction_screening_info(2,ir), &
97 : reaction_screening_info(3,ir), &
98 81813 : i, sc, ir, ierr)
99 81813 : if (ierr /= 0) then
100 : write(*,*) 'screen_net failed in eval_screen_triple ' // &
101 0 : trim(reaction_name(ir))
102 10 : return
103 : end if
104 2732872 : else if (reaction_screening_info(2,ir) > 0) then
105 : call eval_screen_pair( &
106 : init, i, &
107 : reaction_screening_info(1,ir), &
108 : reaction_screening_info(2,ir), &
109 2093782 : i, sc, ir, ierr)
110 2093782 : if (ierr /= 0) then
111 : write(*,*) 'screen_net failed in eval_screen_pair ' // &
112 0 : trim(reaction_name(ir))
113 0 : return
114 : end if
115 : else
116 639090 : rate_screened(i) = rate_raw(i)
117 639090 : rate_screened_dT(i) = rate_raw_dT(i)
118 639090 : rate_screened_dRho(i) = rate_raw_dRho(i)
119 : end if
120 : end do
121 81813 : if (ierr /= 0) return
122 :
123 81813 : if(init) return
124 :
125 81803 : call set_combo_screen_rates(num_isos, y, sc, ierr)
126 81803 : if (ierr /= 0) then
127 0 : write(*,*) 'screen_net failed in set_combo_screen_rates'
128 0 : return
129 : end if
130 :
131 81803 : if (nrattab > 1 .and. (logT < g% logTcut_lim .or. logT <= g% logTcut_lo)) then
132 : ! strong rates cutoff smoothly for logT < logTcut_lim
133 1 : if (logT <= g% logTcut_lo) then
134 95 : do i = 1, num_reactions
135 94 : if (g% weak_reaction_index(i) > 0) cycle
136 90 : rate_screened(i) = 0
137 90 : rate_screened_dT(i) = 0
138 95 : rate_screened_dRho(i) = 0
139 : end do
140 : else
141 0 : Tfactor = (logT - g% logTcut_lo)/(g% logTcut_lim - g% logTcut_lo)
142 0 : Tfactor = 0.5d0*(1 - cospi(Tfactor*Tfactor))
143 : dTfactordt = 0.5d0 * pi * sinpi(Tfactor*Tfactor) * &
144 0 : 2.d0/((g% logTcut_lim - g% logTcut_lo) * temp * ln10)
145 0 : do i = 1, num_reactions
146 0 : if (g% weak_reaction_index(i) > 0) cycle
147 0 : rate_screened_dT(i) = Tfactor * rate_screened_dT(i) + dTfactordt * rate_screened(i)
148 0 : rate_screened_dRho(i) = Tfactor * rate_screened_dRho(i)
149 81802 : rate_screened(i) = Tfactor * rate_screened(i)
150 : end do
151 : end if
152 : end if
153 :
154 :
155 : contains
156 :
157 2257408 : subroutine screening_pair( &
158 : init, ir, jscr, sc, cid1, a1, z1, cid2, a2, z2, scor, scordt, scordd, ierr)
159 : use rates_lib, only: screen_init_AZ_info, screen_pair
160 : use rates_def, only: Screen_Info
161 : use chem_def, only: ih1, ih2, ihe4, ico55, ico57
162 : logical, intent(in) :: init
163 : integer, intent(in) :: ir, jscr
164 : type (Screen_Info) :: sc
165 : integer, intent(in) :: cid1, cid2
166 : real(dp), intent(in) :: a1, z1, a2, z2
167 : real(dp), intent(out) :: scor, scordt, scordd
168 : integer, intent(out) :: ierr
169 :
170 : integer :: i1, i2
171 : include 'formats'
172 2257408 : ierr = 0
173 2257408 : if (init) then
174 : call screen_init_AZ_info( &
175 : a1, z1, a2, z2, &
176 : g% zs13(jscr), g% zhat(jscr), g% zhat2(jscr), g% lzav(jscr), &
177 : g% aznut(jscr), g% zs13inv(jscr), &
178 435 : ierr)
179 435 : if (ierr /= 0) write(*,*) 'screen_init_AZ_info failed in screening_pair ' // &
180 0 : trim(reaction_name(ir))
181 : else
182 2256973 : if (cid1 > 0 .and. cid2 > 0) then
183 2175170 : i1 = g% net_iso(cid1)
184 2175170 : i2 = g% net_iso(cid2)
185 2175170 : if (i1 == 0 .or. i2 == 0) then ! not in current net
186 326137 : if (g% doing_approx21 .and. &
187 : .not. (cid1 == ico55 .or. cid1 == ico57 .or. &
188 : cid2 == ico55 .or. cid2 == ico57 .or. &
189 : cid2 == ih2 .or. cid2 == ih2)) then
190 : ! this skips screening things like al27 + p for approx21
191 76245 : scor = 1d0
192 76245 : scordt = 0d0
193 76245 : scordd = 0d0
194 76245 : return
195 : end if
196 : end if
197 : end if
198 : call screen_pair( &
199 : sc, a1, z1, a2, z2, screening_mode, &
200 : g% zs13(jscr), g% zhat(jscr), g% zhat2(jscr), g% lzav(jscr), &
201 : g% aznut(jscr), g% zs13inv(jscr), g% logTcut_lo, &
202 2180728 : scor, scordt, scordd, ierr)
203 2180728 : if (ierr /= 0) write(*,*) 'screen_pair failed in screening_pair ' // &
204 0 : trim(reaction_name(ir))
205 : end if
206 : end subroutine screening_pair
207 :
208 2175170 : subroutine set_rate_screening(i, sc1a, sc1adt, sc1add)
209 : integer, intent(in) :: i
210 : real(dp), intent(in) :: sc1a, sc1adt, sc1add
211 : include 'formats'
212 2175170 : if (i == 0) return
213 2175170 : rate_screened(i) = rate_raw(i)*sc1a
214 2175170 : rate_screened_dT(i) = rate_raw_dT(i)*sc1a + rate_raw(i)*sc1adt
215 2175170 : rate_screened_dRho(i) = rate_raw_dRho(i)*sc1a + rate_raw(i)*sc1add
216 : end subroutine set_rate_screening
217 :
218 2093782 : subroutine eval_screen_pair(init, jscr, i1, i2, i, sc, ir, ierr)
219 : use rates_def, only: Screen_Info
220 : logical, intent(in) :: init
221 : integer, intent(in) :: jscr
222 : type (Screen_Info) :: sc
223 : integer, intent(in) :: i1, i2 ! chem id's for the isotopes
224 : integer, intent(in) :: i ! rate number
225 : integer, intent(in) :: ir
226 : integer, intent(out) :: ierr
227 : real(dp) :: sc1a, sc1adt, sc1add, a1, z1, a2, z2
228 : include 'formats'
229 : ierr = 0
230 2093782 : a1 = chem_isos% Z_plus_N(i1)
231 2093782 : z1 = dble(chem_isos% Z(i1))
232 2093782 : a2 = chem_isos% Z_plus_N(i2)
233 2093782 : z2 = dble(chem_isos% Z(i2))
234 : !if (z1 == 0d0 .or. z2 == 0d0) return
235 : ! with this, get bad burn result, but okay for restart
236 : ! without it, reversed. get good burn, bad restart.
237 : ! bad restart max diff ~ 5e-15 in abundances of n17, n18, o14
238 : ! perhaps tiny difference in some screening factor?
239 : call screening_pair( &
240 2093782 : init, ir, jscr, sc, i1, a1, z1, i2, a2, z2, sc1a, sc1adt, sc1add, ierr)
241 2094197 : if (ierr /= 0) return
242 2093782 : if (init) return
243 2093367 : call set_rate_screening(i, sc1a, sc1adt, sc1add)
244 : end subroutine eval_screen_pair
245 :
246 245439 : subroutine eval_screen_triple(init, jscr, i1_in, i2_in, i3_in, i, sc, ir, ierr)
247 : use rates_def, only: Screen_Info
248 : logical, intent(in) :: init
249 : integer, intent(in) :: jscr
250 : type (Screen_Info) :: sc
251 : integer, intent(in) :: i1_in, i2_in, i3_in ! chem id's for the isotopes
252 : integer, intent(in) :: i ! rate number
253 : integer, intent(in) :: ir
254 : integer, intent(out) :: ierr
255 : integer :: i1, i2, i3, ii
256 : real(dp) :: sc1, sc1dt, sc1dd
257 : real(dp) :: sc2, sc2dt, sc2dd
258 : real(dp) :: scor, scordt, scordd
259 : real(dp) :: a1, z1, a2, z2, a3, z3
260 : include 'formats'
261 81813 : ierr = 0
262 81813 : i1 = i1_in; i2 = i2_in; i3 = i3_in
263 81813 : a1 = chem_isos% Z_plus_N(i1)
264 81813 : z1 = dble(chem_isos% Z(i1))
265 81813 : a2 = chem_isos% Z_plus_N(i2)
266 81813 : z2 = dble(chem_isos% Z(i2))
267 81813 : a3 = chem_isos% Z_plus_N(i3)
268 81813 : z3 = dble(chem_isos% Z(i3))
269 81813 : if (z2 == 0) then
270 10 : if (z1 == 0) return ! n + n + A
271 : ! have A + n + B
272 : ! swap 1 and 2 so have n + A + B
273 0 : ii = i2; i2 = i1; i1 = ii
274 0 : a1 = chem_isos% Z_plus_N(i1)
275 0 : z1 = dble(chem_isos% Z(i1))
276 0 : a2 = chem_isos% Z_plus_N(i2)
277 0 : z2 = dble(chem_isos% Z(i2))
278 : end if
279 81813 : if (z3 == 0) then ! have A + B + n
280 : ! swap 1 and 3 so have n + A + B
281 0 : ii = i1; i1 = i3; i3 = ii
282 0 : a1 = chem_isos% Z_plus_N(i1)
283 0 : z1 = dble(chem_isos% Z(i1))
284 0 : a3 = chem_isos% Z_plus_N(i3)
285 0 : z3 = dble(chem_isos% Z(i3))
286 : end if
287 : call screening_pair( &
288 81813 : init, ir, jscr, sc, i2, a2, z2, i3, a3, z3, sc2, sc2dt, sc2dd, ierr)
289 81813 : if (ierr /= 0) return
290 81813 : if (z1 == 0) then
291 0 : if (init) return
292 0 : call set_rate_screening(i, sc2, sc2dt, sc2dd)
293 0 : return ! n + (A + B)
294 : end if
295 81813 : i2 = 0 ! 0 for cid to disable caching
296 81813 : a2 = a2 + a3
297 81813 : z2 = z2 + z3
298 : call screening_pair( &
299 81813 : init, ir, jscr, sc, i1, a1, z1, i2, a2, z2, sc1, sc1dt, sc1dd, ierr)
300 81813 : if (init) return
301 81803 : scor = sc1*sc2
302 81803 : scordt = sc1*sc2dt + sc1dt*sc2
303 81803 : scordd = sc1*sc2dd + sc1dd*sc2
304 81803 : call set_rate_screening(i, scor, scordt, scordd)
305 :
306 : if (.false.) write(*,2) 'scr 3 ' // trim(reaction_Name(ir)) &
307 : // ' ' // trim(chem_isos% name(i1)) &
308 : // ' ' // trim(chem_isos% name(i2)) &
309 : // ' ' // trim(chem_isos% name(i3)), &
310 : ir, scor
311 :
312 : end subroutine eval_screen_triple
313 :
314 81803 : subroutine set_combo_screen_rates(num_isos, y, sc, ierr)
315 : use rates_def, only: Screen_Info
316 : integer, intent(in) :: num_isos
317 : real(dp), intent(in) :: y(:)
318 : type (Screen_Info) :: sc
319 : integer, intent(out) :: ierr
320 :
321 81803 : integer, pointer :: rtab(:)
322 : real(dp) :: rateII, rateIII, rsum, fII, fIII, rate34
323 : real(dp) :: d_rateII_dT, d_rateIII_dT, d_rateII_dRho, d_rateIII_dRho
324 : real(dp) :: d_fII_dT, d_fII_dRho
325 :
326 : include 'formats'
327 :
328 81803 : rtab => g% net_reaction
329 81803 : ierr = 0
330 :
331 77317 : if (rtab(ir34_pp2) /= 0 .and. rtab(ir34_pp3) /= 0) then
332 77317 : if (rate_screened(rtab(ir34_pp2)) /= &
333 : rate_screened(rtab(ir34_pp3))) then
334 0 : ierr = -1
335 0 : return
336 : end if
337 77317 : if (rtab(ir_be7_wk_li7) /= 0) then
338 0 : rateII = rate_screened(rtab(ir_be7_wk_li7))
339 0 : d_rateII_dT = rate_screened_dT(rtab(ir_be7_wk_li7))
340 0 : d_rateII_dRho = rate_screened_dRho(rtab(ir_be7_wk_li7))
341 77317 : else if (rtab(irbe7ec_li7_aux) /= 0) then
342 77317 : rateII = rate_screened(rtab(irbe7ec_li7_aux))
343 77317 : d_rateII_dT = rate_screened_dT(rtab(irbe7ec_li7_aux))
344 77317 : d_rateII_dRho = rate_screened_dRho(rtab(irbe7ec_li7_aux))
345 : else
346 0 : write(*,*) 'need either r_be7_wk_li7 or rbe7ec_li7_aux'
347 0 : call mesa_error(__FILE__,__LINE__,'set_combo_screen_rates')
348 : end if
349 77317 : if (rtab(ir_be7_pg_b8) /= 0) then
350 0 : rateIII = y(g% net_iso(ih1)) * rate_screened(rtab(ir_be7_pg_b8))
351 0 : d_rateIII_dT = y(g% net_iso(ih1)) * rate_screened_dT(rtab(ir_be7_pg_b8))
352 0 : d_rateIII_dRho = y(g% net_iso(ih1)) * rate_screened_dRho(rtab(ir_be7_pg_b8))
353 77317 : else if (rtab(irbe7pg_b8_aux) /= 0) then
354 77317 : rateIII = y(g% net_iso(ih1)) * rate_screened(rtab(irbe7pg_b8_aux))
355 77317 : d_rateIII_dT = y(g% net_iso(ih1)) * rate_screened_dT(rtab(irbe7pg_b8_aux))
356 77317 : d_rateIII_dRho = y(g% net_iso(ih1)) * rate_screened_dRho(rtab(irbe7pg_b8_aux))
357 : else
358 0 : write(*,*) 'need either r_be7_pg_b8 or rbe7pg_b8_aux'
359 0 : call mesa_error(__FILE__,__LINE__,'set_combo_screen_rates')
360 : end if
361 77317 : rsum = rateII + rateIII
362 77317 : if (rsum < 1d-50) then
363 : fII = 0.5d0
364 : d_fII_dT = 0d0
365 : d_fII_dRho = 0d0
366 : else
367 50359 : fII = rateII / rsum
368 50359 : d_fII_dT = (rateIII*d_rateII_dT - rateII*d_rateIII_dT)/(rsum*rsum)
369 50359 : d_fII_dRho = (rateIII*d_rateII_dRho - rateII*d_rateIII_dRho)/(rsum*rsum)
370 : end if
371 77317 : fIII = 1d0 - fII
372 77317 : rate34 = rate_screened(rtab(ir34_pp2))
373 :
374 : ! Include the response of the ppII and ppIII branching fractions.
375 77317 : rate_screened(rtab(ir34_pp2)) = fII*rate_screened(rtab(ir34_pp2))
376 77317 : rate_screened_dT(rtab(ir34_pp2)) = fII*rate_screened_dT(rtab(ir34_pp2)) + rate34*d_fII_dT
377 77317 : rate_screened_dRho(rtab(ir34_pp2)) = fII*rate_screened_dRho(rtab(ir34_pp2)) + rate34*d_fII_dRho
378 :
379 77317 : rate_screened(rtab(ir34_pp3)) = fIII*rate_screened(rtab(ir34_pp3))
380 77317 : rate_screened_dT(rtab(ir34_pp3)) = fIII*rate_screened_dT(rtab(ir34_pp3)) - rate34*d_fII_dT
381 77317 : rate_screened_dRho(rtab(ir34_pp3)) = fIII*rate_screened_dRho(rtab(ir34_pp3)) - rate34*d_fII_dRho
382 :
383 : end if
384 :
385 81803 : if (rtab(irn14_to_c12) /= 0) &
386 : call rate_for_pg_pa_branches( &
387 : rtab(irn14pg_aux), rtab(irn15pg_aux), rtab(irn15pa_aux), &
388 77317 : 0, rtab(irn14_to_c12))
389 :
390 81803 : if (rtab(irn14_to_o16) /= 0) &
391 : call rate_for_pg_pa_branches( &
392 : rtab(irn14pg_aux), rtab(irn15pg_aux), rtab(irn15pa_aux), &
393 77317 : rtab(irn14_to_o16), 0)
394 :
395 81803 : if (rtab(ir1616ppa) /= 0) &
396 : call rate_for_pg_pa_branches( &
397 : rtab(ir1616p_aux), rtab(irp31pg_aux), rtab(irp31pa_aux), &
398 0 : 0, rtab(ir1616ppa))
399 :
400 81803 : if (rtab(ir1616ppg) /= 0) &
401 : call rate_for_pg_pa_branches( &
402 : rtab(ir1616p_aux), rtab(irp31pg_aux), rtab(irp31pa_aux), &
403 0 : rtab(ir1616ppg), 0)
404 :
405 : call rate_for_alpha_ap( &
406 : irc12ap_aux, irn15pg_aux, irn15pa_aux, &
407 81803 : irc12ap_to_o16)
408 :
409 : call rate_for_alpha_gp( &
410 : iro16gp_aux, irn15pg_aux, irn15pa_aux, &
411 81803 : iro16gp_to_c12)
412 :
413 : call rate_for_alpha_ap( &
414 : iro16ap_aux, irf19pg_aux, irf19pa_aux, &
415 81803 : iro16ap_to_ne20)
416 :
417 : call rate_for_alpha_gp( &
418 : irne20gp_aux, irf19pg_aux, irf19pa_aux, &
419 81803 : irne20gp_to_o16)
420 :
421 : call rate_for_alpha_ap( &
422 : irne20ap_aux, irna23pg_aux, irna23pa_aux, &
423 81803 : irne20ap_to_mg24)
424 :
425 : call rate_for_alpha_gp( &
426 : irmg24gp_aux, irna23pg_aux, irna23pa_aux, &
427 81803 : irmg24gp_to_ne20)
428 :
429 : call rate_for_alpha_ap( &
430 : irmg24ap_aux, iral27pg_aux, iral27pa_aux, &
431 81803 : irmg24ap_to_si28)
432 :
433 : call rate_for_alpha_gp( &
434 : irsi28gp_aux, iral27pg_aux, iral27pa_aux, &
435 81803 : irsi28gp_to_mg24)
436 :
437 : call rate_for_alpha_ap( &
438 : irsi28ap_aux, irp31pg_aux, irp31pa_aux, &
439 81803 : irsi28ap_to_s32)
440 :
441 : call rate_for_alpha_gp( &
442 : irs32gp_aux, irp31pg_aux, irp31pa_aux, &
443 81803 : irs32gp_to_si28)
444 :
445 : call rate_for_alpha_ap( &
446 : irs32ap_aux, ircl35pg_aux, ircl35pa_aux, &
447 81803 : irs32ap_to_ar36)
448 :
449 : call rate_for_alpha_gp( &
450 : irar36gp_aux, ircl35pg_aux, ircl35pa_aux, &
451 81803 : irar36gp_to_s32)
452 :
453 : call rate_for_alpha_ap( &
454 : irar36ap_aux, irk39pg_aux, irk39pa_aux, &
455 81803 : irar36ap_to_ca40)
456 :
457 : call rate_for_alpha_gp( &
458 : irca40gp_aux, irk39pg_aux, irk39pa_aux, &
459 81803 : irca40gp_to_ar36)
460 :
461 : call rate_for_alpha_ap( &
462 : irca40ap_aux, irsc43pg_aux, irsc43pa_aux, &
463 81803 : irca40ap_to_ti44)
464 :
465 : call rate_for_alpha_gp( &
466 : irti44gp_aux, irsc43pg_aux, irsc43pa_aux, &
467 81803 : irti44gp_to_ca40)
468 :
469 : call rate_for_alpha_ap( &
470 : irti44ap_aux, irv47pg_aux, irv47pa_aux, &
471 81803 : irti44ap_to_cr48)
472 :
473 : call rate_for_alpha_gp( &
474 : ircr48gp_aux, irv47pg_aux, irv47pa_aux, &
475 81803 : ircr48gp_to_ti44)
476 :
477 : call rate_for_alpha_ap( &
478 : ircr48ap_aux, irmn51pg_aux, irmn51pa_aux, &
479 81803 : ircr48ap_to_fe52)
480 :
481 : call rate_for_alpha_gp( &
482 : irfe52gp_aux, irmn51pg_aux, irmn51pa_aux, &
483 81803 : irfe52gp_to_cr48)
484 :
485 :
486 81803 : end subroutine set_combo_screen_rates
487 :
488 818030 : subroutine rate_for_alpha_ap(ir_start, irpg, irpa, ir_with_pg)
489 : integer, intent(in) :: ir_start, irpg, irpa, ir_with_pg
490 818030 : integer, pointer :: rtab(:)
491 : include 'formats'
492 1636060 : if (ir_start == 0) return
493 818030 : rtab => g% net_reaction
494 818030 : if (rtab(ir_with_pg) == 0) return
495 : call rate_for_pg_pa_branches( &
496 231952 : rtab(ir_start), rtab(irpg), rtab(irpa), rtab(ir_with_pg), 0)
497 818030 : end subroutine rate_for_alpha_ap
498 :
499 818030 : subroutine rate_for_alpha_gp(ir_start, irpg, irpa, ir_with_pa)
500 : integer, intent(in) :: ir_start, irpg, irpa, ir_with_pa
501 818030 : integer, pointer :: rtab(:)
502 1636060 : if (ir_start == 0) return
503 818030 : rtab => g% net_reaction
504 818030 : if (rtab(ir_with_pa) == 0) return
505 : call rate_for_pg_pa_branches( &
506 0 : rtab(ir_start), rtab(irpg), rtab(irpa), 0, rtab(ir_with_pa))
507 818030 : end subroutine rate_for_alpha_gp
508 :
509 386586 : subroutine rate_for_pg_pa_branches(ir_start, irpg, irpa, ir_with_pg, ir_with_pa)
510 : integer, intent(in) :: ir_start, irpg, irpa, ir_with_pg, ir_with_pa
511 :
512 : real(dp) :: pg_raw_rate, pa_raw_rate, pg_frac, pa_frac
513 : real(dp) :: d_pg_frac_dT, d_pg_frac_dRho, d_pa_frac_dT, d_pa_frac_dRho
514 : real(dp) :: r, drdT, drdd, x
515 :
516 386586 : if (ir_start == 0) then
517 0 : write(*,*) 'ir_start', ir_start
518 0 : if (irpg /= 0) write(*,*) trim(reaction_Name(g% reaction_id(irpg))) // ' irpg'
519 0 : if (irpa /= 0) write(*,*) trim(reaction_Name(g% reaction_id(irpa))) // ' irpa'
520 0 : if (ir_with_pg /= 0) write(*,*) trim(reaction_Name(g% reaction_id(ir_with_pg))) // ' ir_with_pg'
521 0 : if (ir_with_pa /= 0) write(*,*) trim(reaction_Name(g% reaction_id(ir_with_pa))) // ' ir_with_pa'
522 0 : call mesa_error(__FILE__,__LINE__,'rate_for_pg_pa_branches')
523 : end if
524 :
525 386586 : if (irpg == 0) then
526 0 : write(*,*) 'irpg', irpg
527 0 : if (ir_with_pg /= 0) write(*,*) trim(reaction_Name(g% reaction_id(ir_with_pg))) // ' ir_with_pg'
528 0 : if (ir_with_pa /= 0) write(*,*) trim(reaction_Name(g% reaction_id(ir_with_pa))) // ' ir_with_pa'
529 0 : call mesa_error(__FILE__,__LINE__,'rate_for_pg_pa_branches')
530 : end if
531 :
532 386586 : if (irpa == 0) then
533 0 : write(*,*) 'irpg', irpg
534 0 : if (ir_with_pg /= 0) write(*,*) trim(reaction_Name(g% reaction_id(ir_with_pg))) // ' ir_with_pg'
535 0 : if (ir_with_pa /= 0) write(*,*) trim(reaction_Name(g% reaction_id(ir_with_pa))) // ' ir_with_pa'
536 0 : call mesa_error(__FILE__,__LINE__,'rate_for_pg_pa_branches')
537 : end if
538 :
539 386586 : pg_raw_rate = rate_raw(irpg)
540 386586 : pa_raw_rate = rate_raw(irpa)
541 :
542 386586 : if (pg_raw_rate + pa_raw_rate < 1d-99) then ! avoid divide by 0
543 238228 : pg_raw_rate = 1; pa_raw_rate = 1
544 : end if
545 :
546 386586 : pg_frac = pg_raw_rate / (pg_raw_rate + pa_raw_rate)
547 386586 : pa_frac = 1 - pg_frac
548 :
549 386586 : x = pg_raw_rate + pa_raw_rate
550 : d_pg_frac_dT = &
551 386586 : (pa_raw_rate*rate_raw_dT(irpg) - pg_raw_rate*rate_raw_dT(irpa)) / (x*x)
552 386586 : d_pa_frac_dT = -d_pg_frac_dT
553 :
554 : d_pg_frac_dRho = &
555 386586 : (pa_raw_rate*rate_raw_dRho(irpg) - pg_raw_rate*rate_raw_dRho(irpa)) / (x*x)
556 386586 : d_pa_frac_dRho = -d_pg_frac_dRho
557 :
558 386586 : r = rate_screened(ir_start)
559 386586 : drdT = rate_screened_dT(ir_start)
560 386586 : drdd = rate_screened_dRho(ir_start)
561 :
562 386586 : if (ir_with_pg /= 0) then
563 309269 : rate_screened(ir_with_pg) = r*pg_frac
564 309269 : rate_screened_dT(ir_with_pg) = r*d_pg_frac_dT + drdT*pg_frac
565 309269 : rate_screened_dRho(ir_with_pg) = r*d_pg_frac_dRho + drdd*pg_frac
566 : end if
567 :
568 386586 : if (ir_with_pa /= 0) then
569 77317 : rate_screened(ir_with_pa) = r*pa_frac
570 77317 : rate_screened_dT(ir_with_pa) = r*d_pa_frac_dT + drdT*pa_frac
571 77317 : rate_screened_dRho(ir_with_pa) = r*d_pa_frac_dRho + drdd*pa_frac
572 : end if
573 :
574 386586 : end subroutine rate_for_pg_pa_branches
575 :
576 :
577 : end subroutine screen_net
578 :
579 :
580 :
581 : end module net_screen
582 :
|