Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HSE Newton Tolerance #2026

Closed
wants to merge 2 commits into from
Closed
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
18 changes: 14 additions & 4 deletions Source/Utils/ERF_HSEUtils.H
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,13 @@ namespace HSEutils
{
int iter=0;
int max_iter=30;
Real eps = 1.0e-6;
Real ieps = 1.0e6;
static constexpr Real tol_max = 1.0e-8;
static constexpr Real tol_grow = 3.16228; // sqrt(10.0)
static constexpr Real eps = 1.0e-6;
static constexpr Real ieps = 1.0e6;
Real tol = std::min(m_tol,tol_max);
Real F_abs = 1.0e6;
Real F_old = 1.0e6;
do {
// Compute change in pressure
Real hi = getRhogivenThetaPress(T, P + eps, RdOCp, qv);
Expand All @@ -63,11 +68,16 @@ namespace HSEutils
Real r_tot = rd * (1. + qt);
F = P + 0.5*r_tot*g*dz + C;
++iter;

// Reduce tolerance if resid is not decreasing
F_abs = std::fabs(F);
if ((F_abs>F_old) && (tol<tol_max)) { tol = std::min(tol*tol_grow,tol_max); }
F_old = F_abs;
}
while (std::abs(F)>m_tol && iter<max_iter);
while (F_abs>tol && iter<max_iter);
if (iter>=max_iter) {
printf("WARNING: HSE Newton iterations did not converge to tolerance!\n");
printf("HSE Newton tol: %e %e\n",F,m_tol);
printf("HSE Newton tol: %e %e\n",F,tol);
}
}

Expand Down
Loading