Skip to content

Conversation

@wthrowe
Copy link
Member

@wthrowe wthrowe commented Apr 30, 2025

Proposed changes

Upgrade instructions

Code review checklist

  • The code is documented and the documentation renders correctly. Run
    make doc to generate the documentation locally into BUILD_DIR/docs/html.
    Then open index.html.
  • The code follows the stylistic and code quality guidelines listed in the
    code review guide.
  • The PR lists upgrade instructions and is labeled bugfix or
    new feature if appropriate.

Further comments

umax * rel_truncation_error_coarsened;
if ((target_rel_truncation_error.has_value() and
rel_truncation_error_coarsened <=
target_rel_truncation_error.value()) and
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't generally disagree with people needing to set both, but just for a record of it: would the but be fixed by doing value_or(std::numeric_limits<double>::inf()?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. Infinity before the second commit changed to zero after would also have worked.

Comment on lines 64 to 65
if (rel_truncation_error_coarsened <= target_rel_truncation_error or
abs_truncation_error_coarsened <= target_abs_truncation_error) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we recast this and the above check into something like:

err = abs(error)/(atol + rtol * abs(u))

I ask because I find that much easier to understand than the logic here, and it nicely maps onto 17.2.7-17.2.9 in Numerical Recipes. I think this does effectively that, if I understand correctly.

Up to you, just an idea on how to eliminate the logic, because I think the logic is subtle and requires more thought.

@wthrowe
Copy link
Member Author

wthrowe commented May 1, 2025

@nilsvu has said he may disagree with this change, and has asked that we wait until he has a change to look at it next week. (And has pointed out that the docs need updating.)

@nilsvu
Copy link
Member

nilsvu commented May 1, 2025

Thanks @wthrowe. No I don't disagree with the change, you can go ahead. When I wrote this logic I did intend to have the criterion satisfy both rel and abs target if both are specified, with the idea that you want to stay below those targets if you set them. This is also what the option helpstrings say, so I don't consider this a bugfix. You're changing the behavior to satisfy either the rel or abs target. If you think that makes more sense then go ahead with the change, but also change the docs.

@nilsdeppe
Copy link
Member

Okay, so my (rather strong) preference is to use
$\mathcal{E}=\frac{|\Delta|}{\epsilon_{\mathrm{abs}}+|u|\epsilon_{\mathrm{rel}}}$.
Then we require $\mathcal{E}&lt;1$ to not refine, and the same for the "one fewer point" in order to coarsen. The goal is that you smoothly transition to "not caring" about a variable whose value is too small if you set an absolute & relative tolerance. If you set an absolute tolerance of $0$ then you only use the relative tolerance, and same with setting a relative tolerance of $0$ to only care about the absolute value. I believe this is what the time steppers already do.

@nilsvu
Copy link
Member

nilsvu commented May 5, 2025

Yep I agree that it makes more sense to transition between rel and abs tol for this criterion, rather than satisfy both.

@wthrowe
Copy link
Member Author

wthrowe commented May 8, 2025

Added a fixup and a new commit changing the interface to the power monitor error because it was confusing.

Copy link
Member

@nilsdeppe nilsdeppe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Please squash

wthrowe added 3 commits May 12, 2025 19:14
Setting either value to None completely prevented decreasing
resolution.
Previously tried to satisfy both tolerances instead of just the less
restrictive.
There are two overloads, one of which returned the error while the
other returned -log10 of the error.  This was very confusing, and all
actual uses immediately undid the logarithm.
@nilsdeppe nilsdeppe merged commit 661e0f0 into sxs-collaboration:develop May 14, 2025
24 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants