Skip to content

Add Laplace diffusion in terms of entropy variables #2406

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

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

Conversation

jlchan
Copy link
Contributor

@jlchan jlchan commented May 17, 2025

Adds the symmetrized version of Laplacian diffusion using the gradient of entropy variables and a change of variables to the conservative variables. For now, the change of variables uses ForwardDiff.jacobian, but can be specialized if the analytical formula is known to improve speed.

This formulation is provably entropy dissipative unlike LaplaceDiffusion.

Copy link
Contributor

Review checklist

This checklist is meant to assist creators of PRs (to let them know what reviewers will typically look for) and reviewers (to guide them in a structured review process). Items do not need to be checked explicitly for a PR to be eligible for merging.

Purpose and scope

  • The PR has a single goal that is clear from the PR title and/or description.
  • All code changes represent a single set of modifications that logically belong together.
  • No more than 500 lines of code are changed or there is no obvious way to split the PR into multiple PRs.

Code quality

  • The code can be understood easily.
  • Newly introduced names for variables etc. are self-descriptive and consistent with existing naming conventions.
  • There are no redundancies that can be removed by simple modularization/refactoring.
  • There are no leftover debug statements or commented code sections.
  • The code adheres to our conventions and style guide, and to the Julia guidelines.

Documentation

  • New functions and types are documented with a docstring or top-level comment.
  • Relevant publications are referenced in docstrings (see example for formatting).
  • Inline comments are used to document longer or unusual code sections.
  • Comments describe intent ("why?") and not just functionality ("what?").
  • If the PR introduces a significant change or new feature, it is documented in NEWS.md with its PR number.

Testing

  • The PR passes all tests.
  • New or modified lines of code are covered by tests.
  • New or modified tests run in less then 10 seconds.

Performance

  • There are no type instabilities or memory allocations in performance-critical parts.
  • If the PR intent is to improve performance, before/after time measurements are posted in the PR.

Verification

  • The correctness of the code was verified using appropriate tests.
  • If new equations/methods are added, a convergence test has been run and the results
    are posted in the PR.

Created with ❤️ by the Trixi.jl community.

Copy link

codecov bot commented May 18, 2025

Codecov Report

Attention: Patch coverage is 72.09302% with 12 lines in your changes missing coverage. Please review.

Project coverage is 96.92%. Comparing base (4238b89) to head (b2b2757).

Files with missing lines Patch % Lines
...c/equations/laplace_diffusion_entropy_variables.jl 36.84% 12 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2406      +/-   ##
==========================================
- Coverage   96.95%   96.92%   -0.03%     
==========================================
  Files         504      508       +4     
  Lines       41721    41764      +43     
==========================================
+ Hits        40448    40479      +31     
- Misses       1273     1285      +12     
Flag Coverage Δ
unittests 96.92% <72.09%> (-0.03%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@jlchan
Copy link
Contributor Author

jlchan commented May 18, 2025

I don't think the test failures are related to this PR...

Copy link
Contributor

@DanielDoehring DanielDoehring left a comment

Choose a reason for hiding this comment

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

I have two main suggestions:

  1. For the standard Laplace we have the 3 files for the dimensions. Maybe do this also here?

  2. Would it be possible to implement the Laplace operator similar to the Gradients for Navier-Stokes, i.e., with distinction between
    GradientVariablesPrimitive and GradientVariablesEntropy?

    CompressibleNavierStokesDiffusion1D(equations; mu, Pr,
    gradient_variables=GradientVariablesPrimitive())

@DanielDoehring DanielDoehring added the enhancement New feature or request label May 19, 2025
@jlchan
Copy link
Contributor Author

jlchan commented May 19, 2025

Thanks, @DanielDoehring!

1. For the standard Laplace we have the 3 files for the dimensions. Maybe do this also here?

I'm not opposed to this, but is there an advantage of having multiple files for a single equation? I sometimes find it harder to navigate code split across multiple files compared with just scrolling through a single file.

2. Would it be possible to implement the Laplace operator similar to the Gradients for Navier-Stokes, i.e., with distinction between
   `GradientVariablesPrimitive` and `GradientVariablesEntropy`?
   https://github.com/trixi-framework/Trixi.jl/blob/5acf73a96f4d4e72cb72169ede148c8d106838fb/src/equations/compressible_navier_stokes_1d.jl#L9-L10

I thought of implementing it this way. However, I was worried that LaplaceDiffusion also serves as a template for anyone trying to implement their own custom diffusion model and didn't want to necessarily clutter the "default" parabolic equations.

@ranocha, @sloede, any thoughts on this?

@ranocha
Copy link
Member

ranocha commented May 19, 2025

Thanks, @DanielDoehring!

1. For the standard Laplace we have the 3 files for the dimensions. Maybe do this also here?

I'm not opposed to this, but is there an advantage of having multiple files for a single equation? I sometimes find it harder to navigate code split across multiple files compared with just scrolling through a single file.

I don't have a strong opinion here but @sloede often favored many files.

2. Would it be possible to implement the Laplace operator similar to the Gradients for Navier-Stokes, i.e., with distinction between
   `GradientVariablesPrimitive` and `GradientVariablesEntropy`?
   https://github.com/trixi-framework/Trixi.jl/blob/5acf73a96f4d4e72cb72169ede148c8d106838fb/src/equations/compressible_navier_stokes_1d.jl#L9-L10

I thought of implementing it this way. However, I was worried that LaplaceDiffusion also serves as a template for anyone trying to implement their own custom diffusion model and didn't want to necessarily clutter the "default" parabolic equations.

I agree with you 👍

@jlchan jlchan requested a review from DanielDoehring May 19, 2025 15:39
DanielDoehring
DanielDoehring previously approved these changes May 19, 2025
@jlchan
Copy link
Contributor Author

jlchan commented May 19, 2025

Sorry @DanielDoehring, forgot to format some new files. Can you reapprove?

DanielDoehring
DanielDoehring previously approved these changes May 19, 2025
Copy link
Member

@ranocha ranocha left a comment

Choose a reason for hiding this comment

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

Thanks! I just have a few minor suggestions.

Co-authored-by: Hendrik Ranocha <ranocha@users.noreply.github.com>
@jlchan
Copy link
Contributor Author

jlchan commented May 20, 2025

Thanks for the review @ranocha!

@jlchan jlchan requested a review from ranocha May 20, 2025 15:02
Copy link
Member

@ranocha ranocha left a comment

Choose a reason for hiding this comment

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

Thanks!

@ranocha ranocha enabled auto-merge (squash) May 21, 2025 07:39
Copy link
Member

@ranocha ranocha left a comment

Choose a reason for hiding this comment

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

Sorry, I forgot: Could you please add a NEWS.md entry?

@ranocha ranocha disabled auto-merge May 21, 2025 07:40
@jlchan
Copy link
Contributor Author

jlchan commented May 21, 2025

Ah! Of course, will add that in a bit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants