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

Add and test function-based indefinite integrals #1504

Merged
merged 1 commit into from
Oct 23, 2023
Merged

Add and test function-based indefinite integrals #1504

merged 1 commit into from
Oct 23, 2023

Conversation

charleskawczynski
Copy link
Member

This PR adds an indefinite integral implementation that uses a function-based input argument. Concretely, given ϕ(z), this interface allows us to solve for ∂ϕ/∂z = f(ϕ,z). The existing field-based implementation cannot be used in this situation, because f is a function of ϕ, which is what we're computing. So, this implementation uses RootSolvers to find ϕ at the next level in order to provide a somewhat generic interface.

Unfortunately, one limitation of this is that ϕ must be a scalar field, and it cannot be, e.g., a NamedTuple. We could try to lift this assumption, but that would require adjustments to RootSolvers.

Closes #1492.

Copy link
Member

@Sbozzolo Sbozzolo left a comment

Choose a reason for hiding this comment

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

Looks good to me.

Does the error in your test converge to zero if you increase the resolution of your space?

src/Operators/integrals.jl Show resolved Hide resolved
src/Operators/integrals.jl Show resolved Hide resolved
src/Operators/integrals.jl Show resolved Hide resolved
@charleskawczynski
Copy link
Member Author

charleskawczynski commented Oct 20, 2023

Does the error in your test converge to zero if you increase the resolution of your space?

I didn't add a convergence test, that'd probably be a good idea to have, generally, though. I can confirm that the new operator is 2nd order accurate (by adjusting the existing test and commenting out some printed things), but adding that test does make the test suite a bit more complicated (we're already looping over float type, functions to integrate, I unrolled the loop over spaces to make debugging easier, adding a loop over number of vertical elements will put it back to cubic). I'm fine with adding it if you think it's worth it.

@Sbozzolo
Copy link
Member

Does the error in your test converge to zero if you increase the resolution of your space?

I didn't add a convergence, that'd probably be a good idea though. I can confirm that the new operator is 2nd order accurate, but adding that test does make the test suite a bit more complicated. I'm fine with adding it if you think it's worth it.

For simple operations like this, I think that it would be a stronger test of correctness. We probably just need to run the same test with twice as many vertical elements and check the correct scaling in the error, and this might be a second for loop along with for FT in (Float32, Float64). However, I agree that it makes the testsuite more complicated, so it is up to you if you want to implement it or leave it as a possible future improvement.

@charleskawczynski
Copy link
Member Author

For simple operations like this, I think that it would be a stronger test of correctness. We probably just need to run the same test with twice as many vertical elements and check the correct scaling in the error, and this might be a second for loop along with for FT in (Float32, Float64). However, I agree that it makes the testsuite more complicated, so it is up to you if you want to implement it or leave it as a possible future improvement.

I agree. In the interest in reducing package load times sooner than later, I'll open an issue to add convergence tests. Maybe they can be added more simply in some way.

@charleskawczynski
Copy link
Member Author

@Sbozzolo, alright to merge?

@charleskawczynski
Copy link
Member Author

Opened #1508.

@Sbozzolo
Copy link
Member

@Sbozzolo, alright to merge?

Can you please add line to explain in the docstring what average is and why might want to change the default value?

@charleskawczynski
Copy link
Member Author

Can you please add line to explain in the docstring what average is and why might want to change the default value?

Ah, thanks. I did update it but I must have accidentally stashed it. Updated, can you take another look @Sbozzolo?

@Sbozzolo Sbozzolo self-requested a review October 20, 2023 18:43
Copy link
Member

@Sbozzolo Sbozzolo left a comment

Choose a reason for hiding this comment

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

Thank you!

@charleskawczynski
Copy link
Member Author

bors r+

bors bot added a commit that referenced this pull request Oct 20, 2023
1504: Add and test function-based indefinite integrals r=charleskawczynski a=charleskawczynski

This PR adds an indefinite integral implementation that uses a function-based input argument. Concretely, given `ϕ(z)`, this interface allows us to solve for `∂ϕ/∂z = f(ϕ,z)`. The existing field-based implementation cannot be used in this situation, because `f` is a function of `ϕ`, which is what we're computing. So, this implementation uses RootSolvers to find `ϕ` at the next level in order to provide a somewhat generic interface.

Unfortunately, one limitation of this is that `ϕ` must be a scalar field, and it cannot be, e.g., a `NamedTuple`. We could try to lift this assumption, but that would require adjustments to RootSolvers.

Closes #1492.

Co-authored-by: Charles Kawczynski <kawczynski.charles@gmail.com>
@bors
Copy link
Contributor

bors bot commented Oct 20, 2023

Build failed:

@charleskawczynski
Copy link
Member Author

bors r+

bors bot added a commit that referenced this pull request Oct 23, 2023
1504: Add and test function-based indefinite integrals r=charleskawczynski a=charleskawczynski

This PR adds an indefinite integral implementation that uses a function-based input argument. Concretely, given `ϕ(z)`, this interface allows us to solve for `∂ϕ/∂z = f(ϕ,z)`. The existing field-based implementation cannot be used in this situation, because `f` is a function of `ϕ`, which is what we're computing. So, this implementation uses RootSolvers to find `ϕ` at the next level in order to provide a somewhat generic interface.

Unfortunately, one limitation of this is that `ϕ` must be a scalar field, and it cannot be, e.g., a `NamedTuple`. We could try to lift this assumption, but that would require adjustments to RootSolvers.

Closes #1492.

1515: remove distributed TempestRemap tests r=charleskawczynski a=simonbyrne

This isn't how we should do distributed remapping, so i'll just disable them.

Avoids #1513.

- [x] Code follows the [style guidelines](https://clima.github.io/ClimateMachine.jl/latest/DevDocs/CodeStyle/) OR N/A.
- [x] Unit tests are included OR N/A.
- [x] Code is exercised in an integration test OR N/A.
- [x] Documentation has been added/updated OR N/A.


Co-authored-by: Charles Kawczynski <kawczynski.charles@gmail.com>
Co-authored-by: Simon Byrne <simonbyrne@gmail.com>
@bors
Copy link
Contributor

bors bot commented Oct 23, 2023

Build failed (retrying...):

@bors
Copy link
Contributor

bors bot commented Oct 23, 2023

Canceled.

@charleskawczynski
Copy link
Member Author

bors r+

@bors
Copy link
Contributor

bors bot commented Oct 23, 2023

Build succeeded!

The publicly hosted instance of bors-ng is deprecated and will go away soon.

If you want to self-host your own instance, instructions are here.
For more help, visit the forum.

If you want to switch to GitHub's built-in merge queue, visit their help page.

@bors bors bot merged commit 1e36b66 into main Oct 23, 2023
8 checks passed
@bors bors bot deleted the ck/column_ops2 branch October 23, 2023 21:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Define indefinite column integrals for arbitrary functions
2 participants