Skip to content

Commit

Permalink
this fixes the qsat calculation for large T (#1870)
Browse files Browse the repository at this point in the history
  • Loading branch information
asalmgren authored Oct 9, 2024
1 parent b48be61 commit 61da848
Showing 1 changed file with 20 additions and 5 deletions.
25 changes: 20 additions & 5 deletions Source/Utils/ERF_Microphysics_Utils.H
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ amrex::Real erf_esati (amrex::Real t) {

amrex::Real dtt = t-273.16;
AMREX_ALWAYS_ASSERT(dtt>-85);

amrex::Real esati;
if (dtt > 0.0) {
esati = 0.0;
Expand All @@ -59,9 +60,12 @@ amrex::Real erf_esatw (amrex::Real t) {
amrex::Real const a7 = -0.952447341e-13;
amrex::Real const a8 = -0.976195544e-15;

amrex::Real dtt = t-273.16;
AMREX_ALWAYS_ASSERT(dtt>-85);
AMREX_ALWAYS_ASSERT(dtt<70);
amrex::Real dtt_in = t-273.16;
AMREX_ALWAYS_ASSERT(dtt_in>-85);
//
// Rather than assert dt < 70, we impose that the saturation pressure does not change above 70
//
amrex::Real dtt = std::min(dtt_in,70.);
amrex::Real esatw = a0 + dtt*(a1+dtt*(a2+dtt*(a3+dtt*(a4+dtt*(a5+dtt*(a6+dtt*(a7+a8*dtt)))))));
return esatw;
}
Expand Down Expand Up @@ -111,8 +115,19 @@ amrex::Real erf_dtesatw (amrex::Real t) {

amrex::Real dtt = t-273.16;
AMREX_ALWAYS_ASSERT(dtt>-85);
AMREX_ALWAYS_ASSERT(dtt<70);
amrex::Real dtesatw = a0 + dtt*(a1+dtt*(a2+dtt*(a3+dtt*(a4+dtt*(a5+dtt*(a6+dtt*(a7+a8*dtt)))))));

amrex::Real dtesatw;

//
// Rather than assert dt < 70, we impose that the saturation pressure does not change above 70,
// hence the derivative is 0.
//
if (dtt >= 70.) {
dtesatw = amrex::Real(0.0);
} else {
dtesatw = a0 + dtt*(a1+dtt*(a2+dtt*(a3+dtt*(a4+dtt*(a5+dtt*(a6+dtt*(a7+a8*dtt)))))));
}

return dtesatw;
}

Expand Down

0 comments on commit 61da848

Please sign in to comment.