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 non-conservative convection term #46

Merged
merged 4 commits into from
Oct 22, 2024
Merged

add non-conservative convection term #46

merged 4 commits into from
Oct 22, 2024

Conversation

qiauil
Copy link
Contributor

@qiauil qiauil commented Oct 21, 2024

  • add non-conservative convection term
  • allow to swift between conservative convection and non-conservative convection in steppers

Copy link
Owner

@Ceyron Ceyron left a comment

Choose a reason for hiding this comment

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

Hi Qiang,

thanks for the updated PR. I left some remarks in the code.

exponax/nonlin_fun/_convection.py Outdated Show resolved Hide resolved
exponax/nonlin_fun/_convection.py Outdated Show resolved Hide resolved
exponax/nonlin_fun/_convection.py Outdated Show resolved Hide resolved
exponax/nonlin_fun/_convection.py Outdated Show resolved Hide resolved
exponax/nonlin_fun/_convection.py Outdated Show resolved Hide resolved
exponax/nonlin_fun/_convection.py Outdated Show resolved Hide resolved
exponax/stepper/_korteweg_de_vries.py Outdated Show resolved Hide resolved
@Ceyron
Copy link
Owner

Ceyron commented Oct 21, 2024

A couple more general remarks:

Can you run the pre-commit hook, being in the same folder as the repo and then:

pip install pre-commit
pre-commit install --install-hooks
pre-commit run --all-files

This should resolve code-linting checks.

And please keep docstrings to 80 characters in length if possible

@qiauil qiauil requested a review from Ceyron October 21, 2024 10:56
@Ceyron
Copy link
Owner

Ceyron commented Oct 21, 2024

Thanks for the updates, some last stylistic requests:

  1. In the _convection.py file: please add a newline under the **Arguments:** header, otherwise mkdocs will not correctly produce the documentation
  2. Please use rewrap to ensure that the docstrings are at max 80 characters per line.

@qiauil
Copy link
Contributor Author

qiauil commented Oct 21, 2024

Hi, Felix,

The new commit has been pushed; please take a look.

@Ceyron
Copy link
Owner

Ceyron commented Oct 22, 2024

Thanks for all the work.

I just went over the code for a last time, and I think that the nonconservative eval functions (both for multi-channel and single-channel) should use the u_hat_dealiased for creating nabla_u in lines 167 and 228 of _convection.py. What do you think?

@qiauil
Copy link
Contributor Author

qiauil commented Oct 22, 2024

Hi, Felix,

Good point!
To be honest, I am not sure about that. Do you think the linear operation will change the frequency of the field?
Theoretically, I would prefer to dealias the nabla_u as it is the actual one that does the nonlinear operation.

Anyway, I will currently modify the nabla_u term with the dealiased value; we could do some experiments later to see the difference.

@Ceyron
Copy link
Owner

Ceyron commented Oct 22, 2024

The linear operator (i.e., the derivative_operator) does not move energy between the modes.

Aliasing occurs when we element-wise multiply two states in state space. To avoid creating any (undesirable) aliases, according to Orszag's 2/3 rule, both factors in the product must be zero-ed out in the upper 1/3 frequency range (which is what self. dealias does). Hence, we need to have both nabla_u and u being dealiased. At least, that's my current understanding of dealiasing. We can talk about it more in a separate thread.

With the modifications, I will now merge the PR. Thanks for the work :). If you are up for it, it would also be cool to extend some of the unit tests for the new four permutations of convection, but I'd say that's a separate PR.

@Ceyron Ceyron merged commit 47107ee into Ceyron:dev Oct 22, 2024
4 checks passed
Ceyron added a commit that referenced this pull request Oct 23, 2024
* Also run pre-commit on dev

* Update docs requirements

* Remove old requirements

* Remove no longer needed setup.py

* No longer target incompatible Python versions

* Add credits and improve settings

* Wrap FFT for specific array structures in Exponax (#4)

* Add custom wrapped FFT calls

* Rewrite derivative routines to use wrapped FFT calls

* Make number of spatial dims optional

* Run black

* Correctly declare as optional

* Use wrapped routines

* Use wrapped routines

* Use wrapped routines

* Use wrapped routines

* Use wrapped routines

* Use wrapped routines

* Export the spectral submodule

* Add more details on usage

* Start documentation of spectral module

* Stepper restructure (#21)

* Move reaction into stepper

* Adapt imports in tests

* Move linear timesteppers into separete files

* Move generic physical stepper into submodule

* Rename to nonlinear

* Correctly export in submodule

* Move utilities

* Export generic utilities

* Fully translate linear generic stepper

* Fully translate convection stepper

* Fully translate generic nonlinear stepper

* Fully translate generic Gradient norm stepper

* Correctly forward dealiasing fraction

* No need to set dealiasing fraction

* Fully translate generic polynomial stepper

* Don't translate vorticity convection

* Remove normalized submodule

* Remove no longer relevant exports

* Export generic stepper

* Fix issues with dealiasing_fraction arguments

* Adapt tests

* Remove commented sections

* Adapt cross-references

* New docs layout to better reflect the API

* Add a boilerplate for the overview

* Consistent docs (#26)

* Add documentation to base

* Add documentation to etdrk core

* Adapt to Equinox style

* Change to Equinox style

* Change to Equinox style

* Change to Equinox style

* Fix typo

* Consistent documentation

* Improve nonlin fun base documentation

* Change to Equinox style

* Improve docs for convection

* Improve docs for gradient norm

* Improve docs for combined general nonlinearity

* Fix docstring

* Improve and fix documentation

* Fix broken link

* Adapt to Equinox style

* Improve documentation

* Add clarification

* better wording

* Fix convection difficulty computation

* Improve doc of generic gradient norm stepper

* Add docstring

* Add documentation

* Add documentation

* Add documentation

* Use correct tuple typing (#27)

* Add type hints (#28)

* Fourier repeated stepper (#29)

* Implement logic of fourier substepping

* Forward .step() to call signature with shape check

* Add hints from Base Stepper

* Add hints on cost-saving

* Also add hint to constructor

* Add a test for the new repeated stepper

* Add CI for running a test on PRs

* Fix repeated Python versions

* Fourier Interpolation and Up/Downsampling (#33)

* Add simple Fourier interpolator

* Add 1D tests

* Add tests in 2d

* Loosen tests

* Fix the generalization to 2d

* Add tests in 3d

* Forward indexing convention

* Correctly use ellipsis

* Add documentation

* Add documentation

* Add utility to get modes slices

* Add test for mode slice generation

* Return tuples

* Utility to move between resolutions

* Add tests for mapping between resolutions

* Fix issue with oddball sanity

* Add new utilities to documentation

* Add documentation

* Add return type hint

* Simple showcase of new functions

* Properly rerun notebook

* Add PyTest dependency

* Fix tests to use tuples

* Loosen requirements on (decaying) Burgers problem

* Add requirement on 3d volume renderer

* Use quotes to correctly get 3.10

* Ignore test requiring GPU

* Remove vape dependency because we no longer test for it

* Spectral updates (#35)

* Preliminary function to compute the spectrum

* Potential improvement to spectrum computation

* Add hint on enstrophy

* Fix on wavenumber norm computation

* Rename to better reflect its effect on oddball mode

* Add tests on filter mask

* Improve first half of spectral documentation

* Merge common subexpressions

* Extend and fix documentation

* Add experimental convinience function to extract the Fourier coefficients

* Unify the creation of scaling arrays

* Test scaling array for norm_compensation

* Add tests for coefficient extraction in 1D

* Test for coefficient extration in 2D

* Enhance docstring

* Remove experimental function

* Fix spectrum function

* Export get_spectrum instead of make_incompressible

* Adapt docs

* Use proper links

* Enhance docstring

* Enhance docstring

* Test the spectrum creation

* Restructure docstring

* Tests helper utilities for fft setup

* Hyperviscous kdv [BREAKING] (#36)

* Have the dispersion operator being created seperately

* Make KdV hyper-viscous by default

* Remove unnecessary copy

* Requires new coefficients to work with changed defaults in KdV

* Fourier Coefficient Extractor (#38)

* Add function

* Enhance docstring

* Change rounding default

* Add coefficient extractor to docs

* Quicker spectrum in 1D

* More validation (#39)

* Add note

* Add 2d and 3d advection

* Add diffusion analytical solution in 2D

* Add diffusion test in 3D

* Ensure all presets are working

* Employ a fix for single facets

* Use Exponax viz routines

* Also employ fix for faceted animations

* Fix defaults for Kolmogorov

* Change to exponax viz routines

* Add 3D dynamics

* Add hint on where to find the reference qualitative rollouts

* Re-Execute Notebook

* Re-Execute Notebook

* Re-Execute notebook

* Start with a validation notebook for KdV

* Test if KdV without convection is purely linear

* Finished KdV soliton comparison

* Faster way to compute the spectrum binning in higher dimensions

* Improved version of kolmogorov comparison

* Improved Metrics System (#40)

* Start implementing metrics tests

* Starting a notebook on validating the metrics

* [WIP] Start generalizing the fourier nRMSE to allow for derivative based losses

* Set up a new structure for metrics

* New export structure

* Overwrite the existing metrics submodule

* Adapt tests because domain_extent is now considered correctly

* Test against analytical solution

* Fix parameterization of test

* Start set up with a new fourier metrics implementation

* Ensure correct shape

* Add first test on Fourier aggregation

* Add basic abolute metrics, more TODO

* Port the correlation metric

* New API in docs

* Port new spatial metrics to API docs

* Rework correlation documentation

* Add drafts on an advanced background notebook on metrics and their relation to functional norms

* Fix the scaling in the Fourier aggregation

* Use pytest approx

* Fix scaling

* Add equivalence test of Fourier and spatial aggregation

* Rework implementations

* Remove mean correlation

* Add soboleb based metrics

* Add helper function to apply metric functions on batched states

* Test with non-unit domain

* Start with a low-level introduction to metrics

* Add basics notebook

* Adapt API docs

* Add to API docs

* Add documentation to spatial metrics

* Reference does not be zero in normalized metrics

* Add documentation

* Fix documentation

* Test Sobolev against manual adding of derivatives with fourier-base metrics

* Fix typo

* Add documentation

* Add tests on Filtering

* Add notes on preliminary notebook

* Fix broken links

* Also add warning to advanced metrics notebook

* Continue with the metric convergence notebook, still WIP

* Add example on Sobolev usage

* Finish validation notebook

* Add temporal convergence notebook (#41)

* Add warning for KS conservative in higher dimensions

* Symmetric Metrics & Metrics improvements (#44)

* Extend docstring for symmetric metrics

* Improve aggregator docstring

* Fix that identity is only guaranteed for L^p norm

* Fix docstring

* Implement symmetric mode

* Fix missing sqrt

* Add symmetric versions for MAE, MSE, and RMSE

* Add new symmetric metrics to documentation

* Add test for symmetric metrics

* Ensure mean is only taken over axis zero in case there are additional axes

* Add details

* Add non-conservative convection term (#46)

* add non-conservative convection term

* fix errors in docstring

* update docstring

* use the dealiased value for non-conservative convection

* Fix non-forwarded conservative flag

* Small Improvements to Gaussian Random Field (#48)

* Retain mean mode from white noise

* Add comment on why there is a 2.0 in denominator

* Polynomial Stepper Fix (#49)

* Have general diffusion coefficient consisten with norm/diff

* Use correct sign on quadratic nonlinearity

* Conservative KS should use conservative convection (#50)

* Conservative KS should use conservative convection

* Adapt tests

* Consistent Generic Steppers (#52)

* Use consistent attribute names

* Forward API changes to tests

* Forward changes to qualitative rollout

* Ensure single-channel convection nonlin is conservative (#53)

* Rework KS Attributes (#54)

* Remove name of diffusivities from combustion KS

* Remove name of diffusivities from conservative KS

* Foward changes to tests

* Fix missing factor of 0.5

* Rework 1D example notebook

* Docs tweak (#55)

* Change to proper markdown

* Add KS conservative docstring

* Re-Execute IC notebook

* Rerun general and normalized notebookt

* Rerun subclassing example

* Rerun showcase 2D

* Add solver overview in 3D

* Add 3D Solver overview to docs

* Automatically deduce version number

---------

Co-authored-by: Qiang <[email protected]>
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.

2 participants