Skip to content

Commit

Permalink
Fix more derivatives in the templated networks (#1613)
Browse files Browse the repository at this point in the history
  • Loading branch information
yut23 authored Jul 17, 2024
1 parent 51019ac commit 80dffdc
Show file tree
Hide file tree
Showing 9 changed files with 36 additions and 26 deletions.
7 changes: 5 additions & 2 deletions networks/aprox19/actual_network.H
Original file line number Diff line number Diff line change
Expand Up @@ -1549,6 +1549,7 @@ namespace RHS {

if constexpr (rate == H1_H1_H1_to_He3) {
rates.fr = rates1.fr;
rates.frdt = rates1.frdt;
}

// Beta limit He3 + He4 by the B8 decay half-life
Expand Down Expand Up @@ -1674,7 +1675,8 @@ namespace RHS {

amrex::Real dtotdt = rates2.frdt + rates3.frdt;

rates.frdt = rates1.fr * (rates2.frdt * invtot - rates2.fr * invtot * invtot * dtotdt);
rates.frdt = rates1.fr * (rates2.frdt * invtot - rates2.fr * invtot * invtot * dtotdt)
+ rates1.frdt * (rates2.fr * invtot);
}

if constexpr (rate == N14_2H1_to_C12_He4)
Expand All @@ -1701,7 +1703,8 @@ namespace RHS {

amrex::Real dtotdt = rates2.frdt + rates3.frdt;

rates.frdt = rates1.fr * (rates3.frdt * invtot - rates3.fr * invtot * invtot * dtotdt);
rates.frdt = rates1.fr * (rates3.frdt * invtot - rates3.fr * invtot * invtot * dtotdt)
+ rates1.frdt * (rates3.fr * invtot);
}

if constexpr (rate == N14_He4_to_Ne20)
Expand Down
8 changes: 6 additions & 2 deletions networks/aprox21/actual_network.H
Original file line number Diff line number Diff line change
Expand Up @@ -1689,6 +1689,7 @@ namespace RHS {

if constexpr (rate == H1_H1_H1_to_He3) {
rates.fr = rates1.fr;
rates.frdt = rates1.frdt;
}

// Beta limit He3 + He4 by the B8 decay half-life
Expand Down Expand Up @@ -1814,7 +1815,8 @@ namespace RHS {

amrex::Real dtotdt = rates2.frdt + rates3.frdt;

rates.frdt = rates1.fr * (rates2.frdt * invtot - rates2.fr * invtot * invtot * dtotdt);
rates.frdt = rates1.fr * (rates2.frdt * invtot - rates2.fr * invtot * invtot * dtotdt)
+ rates1.frdt * (rates2.fr * invtot);
}

if constexpr (rate == N14_2H1_to_C12_He4)
Expand All @@ -1841,7 +1843,8 @@ namespace RHS {

amrex::Real dtotdt = rates2.frdt + rates3.frdt;

rates.frdt = rates1.fr * (rates3.frdt * invtot - rates3.fr * invtot * invtot * dtotdt);
rates.frdt = rates1.fr * (rates3.frdt * invtot - rates3.fr * invtot * invtot * dtotdt)
+ rates1.frdt * (rates3.fr * invtot);
}

if constexpr (rate == N14_He4_to_Ne20)
Expand Down Expand Up @@ -1975,6 +1978,7 @@ namespace RHS {
{
// Rate 1 == Ni56_to_Fe56
rates.fr = 1.0e-4 * rates1.fr;
rates.frdt = 1.0e-4 * rates1.frdt;
}

if constexpr (rate == Fe54_2N_to_Fe56)
Expand Down
4 changes: 2 additions & 2 deletions networks/iso7/actual_network.H
Original file line number Diff line number Diff line change
Expand Up @@ -374,15 +374,15 @@ namespace RHS {
amrex::Real denom = amrex::Math::powi<3>(state.rho * state.y(He4));

rates.fr = yeff_ca40 * denom * rates1.fr;
rates.frdt = (yeff_ca40dt * rates1.fr + yeff_ca40 * rates1.frdt) * denom * 1.0e-9_rt;
rates.frdt = (yeff_ca40dt * rates1.fr * 1.0e-9_rt + yeff_ca40 * rates1.frdt) * denom;

amrex::Real zz = 1.0_rt / denom;
rates.rr = amrex::min(1.0e10_rt, yeff_ti44 * rates1.rr * zz);

if (rates.rr == 1.0e10_rt) {
rates.rrdt = 0.0_rt;
} else {
rates.rrdt = (yeff_ti44dt * rates1.rr + yeff_ti44 * rates1.rrdt) * zz * 1.0e-9_rt;
rates.rrdt = (yeff_ti44dt * rates1.rr * 1.0e-9_rt + yeff_ti44 * rates1.rrdt) * zz;
}
}
}
Expand Down
2 changes: 2 additions & 0 deletions networks/rprox/actual_network.H
Original file line number Diff line number Diff line change
Expand Up @@ -732,6 +732,7 @@ namespace RHS {
else if constexpr (rate == O16_H1_to_F17) {
rate_p_o16_to_f17(state.tf, rates.fr, rates.frdt);
rate_f17_to_p_o16(state.tf, rates.rr, rates.rrdt);
rates.rrdt *= 1.0e-9_rt;
}
else if constexpr (rate == O16_He4_to_Ne20) {
rate_he4_o16_to_ne20(state.tf, rates.fr, rates.frdt);
Expand Down Expand Up @@ -760,6 +761,7 @@ namespace RHS {
else if constexpr (rate == Ti44_He4_to_V47_H1) {
rate_he4_ti44_to_p_v47(state.tf, rates.fr, rates.frdt);
}
rates.frdt *= 1.0e-9_rt;
}

template<int rate, typename dual_t>
Expand Down
1 change: 1 addition & 0 deletions rates/aprox_rates.H
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#define APROX_RATES_H

#include <aprox_rates_data.H>
#include <extern_parameters.H>
#include <tfactors.H>
#include <cmath>

Expand Down
6 changes: 3 additions & 3 deletions unit_test/test_rhs/ci-benchmarks/aprox19.out
Original file line number Diff line number Diff line change
Expand Up @@ -422,9 +422,9 @@
J_neutron_proton -3.1041941575e+11 0.01005978836
J_proton_proton -3.1047599221e+11 -2.3827182398e-87
J_E_proton -7.593501065e+15 4.237794952e+30
J_hydrogen-1_E 2.0563926691e-19 5.7718078776e-06
J_hydrogen-1_E 2.056391585e-19 5.7718078776e-06
J_helium-3_E -5.7716864292e-06 -2.0648367761e-19
J_helium-4_E 1.026556653e-19 2.885937043e-06
J_helium-4_E 1.0265571946e-19 2.885937043e-06
J_carbon-12_E -1.7761025826e-08 3.1733884044e-10
J_nitrogen-14_E -3.3419345218e-10 9.9166452811e-09
J_oxygen-16_E -4.8278139961e-11 2.1225767505e-12
Expand All @@ -441,5 +441,5 @@
J_nickel-56_E -1.41049225e-12 3.8177441789e-11
J_neutron_E 0 1.1761800714e-07
J_proton_E -5.6936091804e-14 1.1296574697e-07
J_E_E 2.092537071 3.5786987301e+13
J_E_E 2.0925380937 3.5786987301e+13

4 changes: 2 additions & 2 deletions unit_test/test_rhs/ci-benchmarks/aprox21.out
Original file line number Diff line number Diff line change
Expand Up @@ -510,7 +510,7 @@
J_E_proton -2.6108991385e+16 3.6817330507e+30
J_hydrogen-1_E -1.0006504976e-07 4.2872891104e-06
J_helium-3_E -4.2866803458e-06 -7.5769167747e-20
J_helium-4_E 3.7850094111e-20 2.1441607162e-06
J_helium-4_E 3.7852613992e-20 2.1441607162e-06
J_carbon-12_E -5.3556320773e-08 1.4041391721e-09
J_nitrogen-14_E -1.9393729314e-09 5.3556258717e-08
J_oxygen-16_E -3.4898941611e-13 6.2789315765e-12
Expand All @@ -529,5 +529,5 @@
J_nickel-56_E -1.3650886568e-12 2.7798205721e-11
J_neutron_E -4.0660804174e-09 5.9256825143e-08
J_proton_E -3.9082377477e-10 8.5866665712e-08
J_E_E 0.65500458025 2.6535626445e+13
J_E_E 0.65504112892 2.6535626445e+13

8 changes: 4 additions & 4 deletions unit_test/test_rhs/ci-benchmarks/iso7.out
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,12 @@
J_silicon-28_nickel-56 0 10000000000
J_nickel-56_nickel-56 -10000000000 0
J_E_nickel-56 -4.7656897776e+29 3.4603369325e+17
J_helium-4_E -5.2043289985e-09 1.0072596721e+20
J_helium-4_E -5.2043289985e-09 8.7939289725e+19
J_carbon-12_E -8.1026490435e-07 6.1135331864e-10
J_oxygen-16_E -1.0316135993e-08 2.5415462665e-08
J_neon-20_E -1.379618092e-08 3.5556715497e-07
J_magnesium-24_E -6.1614211527e-10 2.247549785e-08
J_silicon-28_E -5.4772628635e-09 1.4389423887e+19
J_nickel-56_E -1.4389423887e+19 0
J_E_E -6.8575530322e+38 1.9477832709e+12
J_silicon-28_E -5.4777796693e-09 1.2562755675e+19
J_nickel-56_E -1.2562755675e+19 0
J_E_E -5.9870196299e+38 1.9477832709e+12

22 changes: 11 additions & 11 deletions unit_test/test_rhs/ci-benchmarks/rprox.out
Original file line number Diff line number Diff line change
Expand Up @@ -134,15 +134,15 @@
J_helium-4_hydrogen-1 -189922474.35 927.47563176
J_hydrogen-1_hydrogen-1 -53877537415 -4.5403436538e-06
J_E_hydrogen-1 1.440700152e+13 1.7081017075e+29
J_carbon-12_E -63.63763642 0.9574584339
J_oxygen-14_E -16.885124406 63.634574488
J_oxygen-15_E -0.0078799579355 0.0012865310157
J_oxygen-16_E -0.09149619414 375.43326461
J_flourine-17_E -368.62408276 0.0050664564906
J_magnesium-22_E -16.81079726 0.25807275751
J_sulfur-30_E 0 15.814632043
J_nickel-56_E 0 1.0194733271
J_helium-4_E -57.069383443 9.1684880792e-05
J_hydrogen-1_E -127.2956735 383.90825786
J_E_E -1.0373910939e+20 4.0361993326e+20
J_carbon-12_E -4.9270631512e-08 1.2626274548e-09
J_oxygen-14_E -1.5651670231e-08 4.9270423429e-08
J_oxygen-15_E -6.7474909572e-12 1.4489725852e-12
J_oxygen-16_E -7.1070989692e-11 3.7544796794e-07
J_flourine-17_E -3.6920874683e-07 8.8724341682e-12
J_magnesium-22_E -1.5881316649e-08 1.9046704682e-10
J_sulfur-30_E 0 1.4942256036e-08
J_nickel-56_E 0 9.5914484828e-10
J_helium-4_E -5.3527159887e-08 7.3940758949e-14
J_hydrogen-1_E -9.8553411023e-08 3.8292554973e-07
J_E_E -1.0652292974e+11 3.1241232578e+11

0 comments on commit 80dffdc

Please sign in to comment.