Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
117 changes: 56 additions & 61 deletions EOS/helmholtz/actual_eos.H
Original file line number Diff line number Diff line change
Expand Up @@ -45,65 +45,65 @@ constexpr std::string_view eos_name = "helmholtz";
// quintic hermite polynomial functions
// psi0 and its derivatives
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
amrex::Real psi0 (amrex::Real z)
amrex::Real psi0 (amrex::Real z) noexcept
{
return z * z * z * (z * (-6.0e0_rt * z + 15.0e0_rt) -10.0e0_rt) + 1.0e0_rt;
}

AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
amrex::Real dpsi0 (amrex::Real z)
amrex::Real dpsi0 (amrex::Real z) noexcept
{
return z * z * (z * (-30.0e0_rt*z + 60.0e0_rt) - 30.0e0_rt);
}

AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
amrex::Real ddpsi0 (amrex::Real z)
amrex::Real ddpsi0 (amrex::Real z) noexcept
{
return z * (z * (-120.0e0_rt * z + 180.0e0_rt) - 60.0e0_rt);
}

// psi1 and its derivatives
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
amrex::Real psi1 (amrex::Real z)
amrex::Real psi1 (amrex::Real z) noexcept
{
return z * ( z * z * (z * (-3.0e0_rt * z + 8.0e0_rt) - 6.0e0_rt) + 1.0e0_rt);
}

AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
amrex::Real dpsi1 (amrex::Real z)
amrex::Real dpsi1 (amrex::Real z) noexcept
{
return z * z * ( z * (-15.0e0_rt * z + 32.0e0_rt) - 18.0e0_rt) + 1.0e0_rt;
}

AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
amrex::Real ddpsi1 (amrex::Real z)
amrex::Real ddpsi1 (amrex::Real z) noexcept
{
return z * (z * (-60.0e0_rt * z + 96.0e0_rt) - 36.0e0_rt);
}

// psi2 and its derivatives
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
amrex::Real psi2 (amrex::Real z)
amrex::Real psi2 (amrex::Real z) noexcept
{
return 0.5e0_rt * z * z * ( z * ( z * (-z + 3.0e0_rt) - 3.0e0_rt) + 1.0e0_rt);
}

AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
amrex::Real dpsi2 (amrex::Real z)
amrex::Real dpsi2 (amrex::Real z) noexcept
{
return 0.5e0_rt * z * (z * (z * (-5.0e0_rt * z + 12.0e0_rt) - 9.0e0_rt) + 2.0e0_rt);
}

AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
amrex::Real ddpsi2 (amrex::Real z)
amrex::Real ddpsi2 (amrex::Real z) noexcept
{
return 0.5e0_rt * (z * ( z * (-20.0e0_rt * z + 36.0e0_rt) - 18.0e0_rt) + 2.0e0_rt);
}

AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
void fwt (const amrex::Real* AMREX_RESTRICT fi,
const amrex::Real* AMREX_RESTRICT wt,
amrex::Real* AMREX_RESTRICT fwtr)
amrex::Real* AMREX_RESTRICT fwtr) noexcept
{

fwtr[0] = fi[ 0]*wt[0] + fi[ 1]*wt[1] + fi[ 2]*wt[2] + fi[18]*wt[3] + fi[19]*wt[4] + fi[20]*wt[5];
Expand All @@ -117,26 +117,26 @@ void fwt (const amrex::Real* AMREX_RESTRICT fi,
// cubic hermite polynomial functions
// psi0 & derivatives
AMREX_GPU_HOST_DEVICE AMREX_INLINE
amrex::Real xpsi0(amrex::Real z)
amrex::Real xpsi0(amrex::Real z) noexcept
{
return z * z * (2.0e0_rt * z - 3.0e0_rt) + 1.0_rt;
}

AMREX_GPU_HOST_DEVICE AMREX_INLINE
amrex::Real xdpsi0(amrex::Real z)
amrex::Real xdpsi0(amrex::Real z) noexcept
{
return z * (6.0e0_rt * z - 6.0e0_rt);
}

// psi1 & derivatives
AMREX_GPU_HOST_DEVICE AMREX_INLINE
amrex::Real xpsi1(amrex::Real z)
amrex::Real xpsi1(amrex::Real z) noexcept
{
return z * (z * (z - 2.0e0_rt) + 1.0e0_rt);
}

AMREX_GPU_HOST_DEVICE AMREX_INLINE
amrex::Real xdpsi1(amrex::Real z)
amrex::Real xdpsi1(amrex::Real z) noexcept
{
return z * (3.0e0_rt * z - 4.0e0_rt) + 1.0e0_rt;
}
Expand Down Expand Up @@ -180,17 +180,7 @@ void apply_electrons (T& state)
amrex::Real mxt = 1.0e0_rt - xt;
amrex::Real mxd = 1.0e0_rt - xd;

// the six density and six temperature basis functions
amrex::Real sit[6];

sit[0] = psi0(xt);
sit[1] = psi1(xt) * dt_sav[jat];
sit[2] = psi2(xt) * dt2_sav[jat];

sit[3] = psi0(mxt);
sit[4] = -psi1(mxt) * dt_sav[jat];
sit[5] = psi2(mxt) * dt2_sav[jat];

// the six density basis functions
amrex::Real sid[6];

sid[0] = psi0(xd);
Expand All @@ -202,16 +192,6 @@ void apply_electrons (T& state)
sid[5] = psi2(mxd) * dd2_sav[iat];

// derivatives of the weight functions
amrex::Real dsit[6];

dsit[0] = dpsi0(xt) * dti_sav[jat];
dsit[1] = dpsi1(xt);
dsit[2] = dpsi2(xt) * dt_sav[jat];

dsit[3] = -dpsi0(mxt) * dti_sav[jat];
dsit[4] = dpsi1(mxt);
dsit[5] = -dpsi2(mxt) * dt_sav[jat];

amrex::Real dsid[6];

dsid[0] = dpsi0(xd) * ddi_sav[iat];
Expand All @@ -222,26 +202,28 @@ void apply_electrons (T& state)
dsid[4] = dpsi1(mxd);
dsid[5] = -dpsi2(mxd) * dd_sav[iat];

// second derivatives of the weight functions
amrex::Real ddsit[6];

ddsit[0] = ddpsi0(xt) * dt2i_sav[jat];
ddsit[1] = ddpsi1(xt) * dti_sav[jat];
ddsit[2] = ddpsi2(xt);

ddsit[3] = ddpsi0(mxt) * dt2i_sav[jat];
ddsit[4] = -ddpsi1(mxt) * dti_sav[jat];
ddsit[5] = ddpsi2(mxt);

// This array saves some subexpressions that go into
// computing the biquintic polynomial. Instead of explicitly
// constructing it in full, we'll use these subexpressions
// and then compute the result as
// (table data * temperature terms) * density terms.

amrex::Real fwtr[6];
amrex::Real sit[6];

{
// temperature basis functions

sit[0] = psi0(xt);
sit[1] = psi1(xt) * dt_sav[jat];
sit[2] = psi2(xt) * dt2_sav[jat];

fwt(fi, sit, fwtr);
sit[3] = psi0(mxt);
sit[4] = -psi1(mxt) * dt_sav[jat];
sit[5] = psi2(mxt) * dt2_sav[jat];

fwt(fi, sit, fwtr);
}

amrex::Real free = 0.e0_rt;
amrex::Real df_d = 0.e0_rt;
Expand All @@ -254,7 +236,19 @@ void apply_electrons (T& state)
df_d = df_d + fwtr[i] * dsid[i];
}

fwt(fi, dsit, fwtr);
{
// temperature derivative of weight functions
// this was originally called dsit
sit[0] = dpsi0(xt) * dti_sav[jat];
sit[1] = dpsi1(xt);
sit[2] = dpsi2(xt) * dt_sav[jat];

sit[3] = -dpsi0(mxt) * dti_sav[jat];
sit[4] = dpsi1(mxt);
sit[5] = -dpsi2(mxt) * dt_sav[jat];

fwt(fi, sit, fwtr);
}

amrex::Real df_t = 0.e0_rt;
amrex::Real df_dt = 0.e0_rt;
Expand All @@ -267,7 +261,20 @@ void apply_electrons (T& state)
df_dt += fwtr[i] * dsid[i];
}

fwt(fi, ddsit, fwtr);
{
// second derivatives of the weight functions
// this was originally called ddsit

sit[0] = ddpsi0(xt) * dt2i_sav[jat];
sit[1] = ddpsi1(xt) * dti_sav[jat];
sit[2] = ddpsi2(xt);

sit[3] = ddpsi0(mxt) * dt2i_sav[jat];
sit[4] = -ddpsi1(mxt) * dti_sav[jat];
sit[5] = ddpsi2(mxt);

fwt(fi, sit, fwtr);
}

amrex::Real df_tt = 0.e0_rt;
for (int i = 0; i <= 5; ++i) {
Expand All @@ -290,18 +297,6 @@ void apply_electrons (T& state)
sid[2] = xpsi0(mxd);
sid[3] = -xpsi1(mxd) * dd_sav[iat];

// derivatives of weight functions
dsit[0] = xdpsi0(xt) * dti_sav[jat];
dsit[1] = xdpsi1(xt);

dsit[2] = -xdpsi0(mxt) * dti_sav[jat];
dsit[3] = xdpsi1(mxt);

dsid[0] = xdpsi0(xd) * ddi_sav[iat];
dsid[1] = xdpsi1(xd);

dsid[2] = -xdpsi0(mxd) * ddi_sav[iat];
dsid[3] = xdpsi1(mxd);

// Reuse subexpressions that would go into computing the
// cubic interpolation.
Expand Down
Loading