Skip to content

Commit

Permalink
use multiple angle formula for sin/cos in sneut
Browse files Browse the repository at this point in the history
  • Loading branch information
zingale committed Oct 29, 2023
1 parent ba6dce4 commit b95912d
Showing 1 changed file with 22 additions and 15 deletions.
37 changes: 22 additions & 15 deletions neutrinos/sneut5.H
Original file line number Diff line number Diff line change
Expand Up @@ -824,21 +824,28 @@ void nu_photo(const sneutf_t& sf,

Real taudt = nu_constants::iln10 * sf.tempi;

// equation 3.7, compute the expensive trig functions only one time

Real cos1 = std::cos(nu_constants::fac1 * tau);
Real cos2 = std::cos(nu_constants::fac1 * 2.0e0_rt * tau);
Real cos3 = std::cos(nu_constants::fac1 * 3.0e0_rt * tau);
Real cos4 = std::cos(nu_constants::fac1 * 4.0e0_rt * tau);
Real cos5 = std::cos(nu_constants::fac1 * 5.0e0_rt * tau);
Real last = std::cos(nu_constants::fac2 * tau);

Real sin1 = std::sin(nu_constants::fac1*tau);
Real sin2 = std::sin(nu_constants::fac1*2.0e0_rt*tau);
Real sin3 = std::sin(nu_constants::fac1*3.0e0_rt*tau);
Real sin4 = std::sin(nu_constants::fac1*4.0e0_rt*tau);
Real sin5 = std::sin(nu_constants::fac1*5.0e0_rt*tau);
Real xast = std::sin(nu_constants::fac2*tau);
// equation 3.7

const Real [cos1, sin1] = amrex::sincos(nu_constants::fac1 * tau);

// double, triple, etc. angle formulas
// sin/cos (2 fac1 tau)
const Real sin2 = 2.0_rt * sin1 * cos1;
const Real cos2 = 2.0_rt * cos1 * cos1 - 1.0_rt;

// sin/cos (3 fac1 tau)
const Real sin3 = 3.0_rt * sin1 - 4.0_rt * sin1 * sin1 * sin1;
const Real cos3 = 4.0_rt * cos1 * cos1 - cos1 - 3.0_rt * cos1;

// sin/cos (4 fac1 tau) -- use double angle on sin2/cos2
const Real sin4 = 2.0_rt * sin2 * cos2;
const Real cos4 = 2.0_rt * cos2 * cos2 - 1.0_rt;

// sin/cos (5 fac1 tau)
const Real sin5 = 5.0_rt * sin1 - 20.0_rt * sin1 * sin1 * sin1 + 16.0_rt * sin1 * sin1 * sin1 * sin1 * sin;
const Real cos5 = 16.0_rt * cos1 * cos1 * cos1 * cos1 * cos1 - 20.0_rt * cos1 * cos1 * cos1 + 5.0_rt * cos1;

const Real [xast, last] = amrex::sincos(fac2 * tau);

Real a0 = 0.5e0_rt * c00
+ c01 * cos1 + dd01 * sin1 + c02 * cos2 + dd02 * sin2
Expand Down

0 comments on commit b95912d

Please sign in to comment.