Skip to content

Commit 83ce77c

Browse files
authored
Fix some incorrect derivative terms in sneut5 (AMReX-Astro#1633)
1 parent b42f181 commit 83ce77c

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

neutrinos/sneut5.H

+8-5
Original file line numberDiff line numberDiff line change
@@ -686,20 +686,23 @@ void nu_photo(const sneutf_t& sf,
686686
// and table 2 written out for speed
687687

688688
amrex::Real tau;
689-
amrex::Real cc;
689+
amrex::Real cc, ccdt;
690690
amrex::Real c00, c01, c02, c03, c04, c05, c06;
691691
amrex::Real c10, c11, c12, c13, c14, c15, c16;
692692
amrex::Real c20, c21, c22, c23, c24, c25, c26;
693693
amrex::Real dd01, dd02, dd03, dd04, dd05;
694694
amrex::Real dd11, dd12, dd13, dd14, dd15;
695695
amrex::Real dd21, dd22, dd23, dd24, dd25;
696696

697+
amrex::Real taudt = nu_constants::iln10 * sf.tempi;
698+
697699
if (sf.temp < 1.0e8_rt) {
698700

699701
// note: we already bailed above for T < 1.e7, so this is really 1.e7 <= T < 1.e8
700702

701703
tau = std::log10(sf.temp * 1.0e-7_rt);
702704
cc = 0.5654e0_rt + tau;
705+
ccdt = taudt;
703706
c00 = 1.008e11_rt;
704707
c01 = 0.0e0_rt;
705708
c02 = 0.0e0_rt;
@@ -741,6 +744,7 @@ void nu_photo(const sneutf_t& sf,
741744

742745
tau = std::log10(sf.temp * 1.0e-8_rt);
743746
cc = 1.5654e0_rt;
747+
ccdt = 0.0e0_rt;
744748
c00 = 9.889e10_rt;
745749
c01 = -4.524e8_rt;
746750
c02 = -6.088e6_rt;
@@ -784,6 +788,7 @@ void nu_photo(const sneutf_t& sf,
784788

785789
tau = std::log10(sf.t9);
786790
cc = 1.5654e0_rt;
791+
ccdt = 0.0e0_rt;
787792
c00 = 9.581e10_rt;
788793
c01 = 4.107e8_rt;
789794
c02 = 2.305e8_rt;
@@ -823,8 +828,6 @@ void nu_photo(const sneutf_t& sf,
823828

824829
}
825830

826-
amrex::Real taudt = nu_constants::iln10 * sf.tempi;
827-
828831
// equation 3.7
829832

830833
const auto [sin1, cos1] = amrex::Math::sincos(nu_constants::fac1 * tau);
@@ -902,7 +905,7 @@ void nu_photo(const sneutf_t& sf,
902905
amrex::Real xnum = dum * z;
903906
amrex::Real xnumdt, xnumda, xnumdz;
904907
if constexpr (do_derivatives) {
905-
xnumdt = dumdt * z - dum * z * cc * sf.zetadt;
908+
xnumdt = dumdt * z - dum * z * (cc * sf.zetadt + sf.zeta * ccdt);
906909
xnumda = dumda * z - dum * z * cc * sf.zetada;
907910
xnumdz = dumdz * z - dum * z * cc * sf.zetadz;
908911
}
@@ -1383,7 +1386,7 @@ void nu_recomb(const sneutf_t& sf,
13831386
}
13841387

13851388
amrex::Real c00 = 1.0e0_rt / (1.0e0_rt + f1 * nu + f2 * nu2 + f3 * nu3);
1386-
amrex::Real c01 = f1 + f2 * 2.0e0_rt * nu + f3 * 3.0e0_rt * nu2;
1389+
amrex::Real c01 = -(f1 + f2 * 2.0e0_rt * nu + f3 * 3.0e0_rt * nu2) * c00 * c00;
13871390
amrex::Real dum = zeta * c00;
13881391
amrex::Real dumdt, dumda, dumdz;
13891392
if constexpr (do_derivatives) {

unit_test/test_rhs/ci-benchmarks/ecsn.out

+1-1
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@
157157
J_silicon-28_sulfur-32 0 0
158158
J_phosphorus-31_sulfur-32 0 0
159159
J_sulfur-32_sulfur-32 0 0
160-
J_E_sulfur-32 -1.2066886642e+15 7.8006383744e+14
160+
J_E_sulfur-32 -1.2066886642e+15 7.8006373177e+14
161161
J_hydrogen-1_E -0.12580793235 1.2089803642e+12
162162
J_helium-4_E -0.0078065301852 1.4905283338e+12
163163
J_oxygen-16_E -5.3990173959e+12 1.2739583515e-06

0 commit comments

Comments
 (0)