10 using namespace amrex;
14 const amrex::Real
TOL = 1.e-8;
55 Real dFdp = 1.0 + 0.25*ieps*(hi - lo)*g*dz;
57 if (P < 1.0e3) amrex::Warning(
"P < 1000 [Pa]; Domain height may be too large...");
58 AMREX_ALWAYS_ASSERT(P > 0.0);
62 AMREX_ALWAYS_ASSERT(rd > 0.0);
63 Real r_tot = rd * (1. +
qt);
64 F = P + 0.5*r_tot*g*dz + C;
67 while (std::abs(
F)>m_tol && iter<max_iter);
69 printf(
"WARNING: HSE Newton iterations did not converge to tolerance!\n");
70 printf(
"HSE Newton tol: %e %e\n",
F,m_tol);
90 const amrex::Real&
theta,
93 const amrex::Real& dz,
94 const int klo,
const int khi)
101 Real half_dz = 0.5*dz;
110 bool converged_hse =
false;
114 for (
int iter = 0; iter <
MAX_ITER && !converged_hse; iter++)
119 Real A = p_hse - p_eos;
123 Real drho = A / (dpdr + half_dz *
CONST_GRAV);
125 r[klo] = r[klo] + drho;
128 if (std::abs(drho) <
TOL)
130 converged_hse =
true;
144 for (
int k = kstart; k <= khi; k++)
148 bool converged_hse =
false;
155 for (
int iter = 0; iter <
MAX_ITER && !converged_hse; iter++)
157 Real r_avg = 0.5 * (r[k-1]+r[k]);
161 Real A = p_hse - p_eos;
171 if (std::abs(drho) <
TOL * r[k-1])
173 converged_hse =
true;
198 AMREX_GPU_HOST_DEVICE
203 const amrex::Real& r_sfc,
204 const amrex::Real&
theta,
207 const amrex::Array4<amrex::Real const> z_cc,
208 const int& klo,
const int& khi)
222 Real half_dz = z_cc(i,j,k0);
227 bool converged_hse =
false;
231 for (
int iter = 0; iter <
MAX_ITER && !converged_hse; iter++)
236 Real A = p_hse - p_eos;
240 Real drho = A / (dpdr + half_dz *
CONST_GRAV);
242 r[k0] = r[k0] + drho;
245 if (std::abs(drho) <
TOL)
247 converged_hse =
true;
262 for (
int k = kstart; k <= khi; k++)
266 bool converged_hse =
false;
268 Real dz_loc = (z_cc(i,j,k) - z_cc(i,j,k-1));
275 for (
int iter = 0; iter <
MAX_ITER && !converged_hse; iter++)
277 p_hse = p[k-1] - dz_loc * 0.5 * (r[k-1]+r[k]) *
CONST_GRAV;
280 Real A = p_hse - p_eos;
289 if (std::abs(drho) <
TOL * r[k-1])
291 converged_hse =
true;
constexpr amrex::Real p_0
Definition: ERF_Constants.H:18
constexpr amrex::Real CONST_GRAV
Definition: ERF_Constants.H:21
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real getPgivenRTh(const amrex::Real rhotheta, const amrex::Real qv=0.)
Definition: ERF_EOS.H:84
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real getRhogivenThetaPress(const amrex::Real th, const amrex::Real p, const amrex::Real rdOcp, const amrex::Real qv=0.0)
Definition: ERF_EOS.H:99
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real getdPdRgivenConstantTheta(const amrex::Real rho, const amrex::Real theta, const amrex::Real qv=0.0)
Definition: ERF_EOS.H:130
Definition: ERF_HSEUtils.H:9
const int MAX_ITER
Definition: ERF_HSEUtils.H:13
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void Newton_Raphson_hse(const Real &m_tol, const Real &RdOCp, const Real &dz, const Real &g, const Real &C, const Real &T, const Real &qt, const Real &qv, Real &P, Real &rd, Real &F)
Definition: ERF_HSEUtils.H:35
const amrex::Real TOL
Definition: ERF_HSEUtils.H:14
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void init_isentropic_hse_terrain(int i, int j, const amrex::Real &r_sfc, const amrex::Real &theta, amrex::Real *r, amrex::Real *p, const amrex::Array4< amrex::Real const > z_cc, const int &klo, const int &khi)
Definition: ERF_HSEUtils.H:201
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void init_isentropic_hse(const amrex::Real &r_sfc, const amrex::Real &theta, amrex::Real *r, amrex::Real *p, const amrex::Real &dz, const int klo, const int khi)
Definition: ERF_HSEUtils.H:89
@ theta
Definition: ERF_MM5.H:20
@ qt
Definition: ERF_Kessler.H:35
@ qv
Definition: ERF_Kessler.H:36
@ T
Definition: ERF_IndexDefines.H:99
Definition: ERF_ConsoleIO.cpp:12