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

Use Dirichlet boundary conditions in 2D heat eq problem #339

Open
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

charleskawczynski
Copy link
Member

The convergence tests have been flakey for a while, and I think I've found the issue.

The 2D heat equation problem is doubly periodic, but I don't think that we're explicitly enforcing the compatibility constraint. The constraint states that the descrete integral of the source terms must be exactly zero (i.e., within machine precision zero). This effectively removes the null space, and chooses a particular solution that we're interested in.

My rough explanation of this is:

  • We're solving an equation for T on a 2D domain, with purely periodic boundaries.
  • This means that T + 14 will also satisfy the equations
  • If we were to solve this with a matrix-based approach, AT = b, then the condition number of A would be Inf.
  • We're not forming a matrix in ClimaCore, we're using an iterative matrix-free method. The result is that the solution is highly sensitive and can easily blow up

There's a few ways to do this:

  • In a matrix-based approach, we could subtract the weighted mean of the right-hand-side (RHS) from the RHS. The result would (need to) be that the discrete integral of the RHS is zero. This is an elegant approach, but requires quite a bit of care and extra machinery.
  • "pin" the solution by setting the solution anywhere in the domain to be a fixed value

Since this problem uses sin as a source term, we have one more option: use Dirichlet boundary conditions. In this approach, we can set the tendency to zero at the boundary, which also effectively pins the solution.

I think the result is that we should see the solution unchanged, but also now stable.

I'm going to trigger CI a bunch of times and see if this fixes the flaky jobs.

(hopefully) closes #283.

@charleskawczynski
Copy link
Member Author

All 2D heat eq passes:

  • build (only one jet job failed, but I've since fixed that)

@charleskawczynski
Copy link
Member Author

Interesting, SSP22Heuns broke. Let's also print debug info from #338.

@charleskawczynski charleskawczynski force-pushed the ck/dirichlet branch 7 times, most recently from 4e10ba9 to 41501aa Compare November 25, 2024 01:43
@charleskawczynski charleskawczynski force-pushed the ck/dirichlet branch 4 times, most recently from 4a19747 to 13aafaa Compare January 6, 2025 15:29
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.

Some convergence tests are flaky
1 participant