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

Definition of convection in high dimensional burgers equation #43

Closed
qiauil opened this issue Oct 8, 2024 · 14 comments
Closed

Definition of convection in high dimensional burgers equation #43

qiauil opened this issue Oct 8, 2024 · 14 comments

Comments

@qiauil
Copy link
Contributor

qiauil commented Oct 8, 2024

Hi! Felix,

I think there might be an issue with the burgers equation.

The convection term of the burgers equation is defined as

$$ \frac{1}{2} \nabla \cdot \left( u \otimes u \right) $$

However, according to Wikipedia, the definition should be

$$ u \cdot \nabla u $$

Note that $$u \cdot \nabla u = \frac{1}{2} \nabla \cdot \left( u \otimes u \right) $$ only hold for 1d case. For high-dimensional cases,

$$ \nabla \cdot \left( u \otimes u \right) = u \cdot \nabla u + u\nabla \cdot u $$

For example, in 3d case the x component of $\nabla \cdot \left( u \otimes u \right)$ is:

$$ u_x\frac{\partial u_x}{\partial x} +u_y\frac{\partial u_x}{\partial y} +u_z\frac{\partial u_x}{\partial z} +u_x(\frac{\partial u_x}{\partial x} +\frac{\partial u_y}{\partial y} +\frac{\partial u_z}{\partial z}) $$

while the x component of $u \cdot \nabla u$ is only the first part, i.e.,

$$ u_x\frac{\partial u_x}{\partial x} +u_y\frac{\partial u_x}{\partial y} +u_z\frac{\partial u_x}{\partial z} $$

In a word, $$u \cdot \nabla u = \nabla \cdot \left( u \otimes u \right) $$ if u is divergence-free, i.e., $\nabla \cdot u =0$. Otherwise $u \cdot \nabla u=\nabla \cdot \left( u \otimes u \right) - u\nabla \cdot u \neq \frac{1}{2}\nabla \cdot \left( u \otimes u \right)$

@Ceyron
Copy link
Owner

Ceyron commented Oct 14, 2024

Hi Qiang,

That's a great observation. Since as you write

$$ \nabla \cdot (\mathbf{u} \otimes \mathbf{u}) = (\mathbf{u} \cdot \nabla) \mathbf{u} + \mathbf{u} (\nabla \cdot \mathbf{u}) $$

the way the Burgers PDE is currently defined clashes with the definition on Wikipedia because there is no additional incompressibility constraint $\nabla \cdot \mathbf{u} \neq 0$.

I think this should definitely be addressed. What do you think about changing the current flag of single_channel in

single_channel: bool = False,
to a mode argument, with mode being one of:

  1. "conservative": $b_1 \frac{1}{2} \nabla \cdot (\mathbf{u} \otimes \mathbf{u})$
  2. "non_conservative": $b_1 (\mathbf{u} \cdot \nabla) \mathbf{u}$
  3. "single_channel": $b_1 \frac{1}{2} (1 \cdot \nabla) (u^2) = b_1 u (1 \cdot \nabla u)$ (similar to the the first equation on Wikipedia)

Then, one could forward those settings to all steppers that build upon the convection nonlinearity (should only be Burgers & KdV if I am not mistaken).

@qiauil
Copy link
Contributor Author

qiauil commented Oct 14, 2024

Hi, Felix.

Nice😼! that could be a good solution! But I am still not sure about the single_channel case. Does that mean we only have one channel for the field, i.e., a scalar field, or does it mean a scalar field on 1d mesh🤔? (I would suppose the latter one, as you can't connect a scalar by itself in high-dimensional space) In the torch version, I implemented conservative and nonconservative forms separately, and they both gave the same result in the 1d case. Could you explain the single_cannel's role here a bit more?

Cheers,
Qiang

@Ceyron
Copy link
Owner

Ceyron commented Oct 14, 2024

Re mode switch: Cool 👍. Would you like to create a PR for this feature?

Re single_channel: this is a scalar field in 1D, 2D or 3D. In 1D, all three convection forms should give the same results; it's just how they generalize into higher-dimensional spaces.

@qiauil
Copy link
Contributor Author

qiauil commented Oct 14, 2024

Hi, Felix,

I have added a new pull request, #45, where the non-conservative form of convection is added.

I didn't change the single_channel option since I find it is highly used in the docs and other operators. Changing its name to mode may result in unexpected issues for another part of the code. Also, I noticed that the current single_channel model of the convection operator seems to be the conservative form times 0.5, which might be a little bit confusing when users choose conservative and non-conservative models🤔.

Cheers,
Qiang

@Ceyron
Copy link
Owner

Ceyron commented Oct 15, 2024

Hi Qiang,

Thanks a lot for the PR!

I didn't change the single_channel option since I find it is highly used in the docs and other operators. Changing its name to mode may result in unexpected issues for another part of the code.

That's a fair point. We could also keep the two boolean flags.

Also, I noticed that the current single_channel model of the convection operator seems to be the conservative form times 0.5, which might be a little bit confusing when users choose conservative and non-conservative models🤔.

Are you suggesting that the single_channel hack needs to be different for both the conservative and neoconservative form?

$$ b_1 \frac{1}{2} (\vec{1} \cdot \nabla) (u^2) = b_1 u (\vec{1} \cdot \nabla u) $$

I would say that there are no symbolic differences as between the conservative and neoconservative forms in higher dimensions.

@qiauil
Copy link
Contributor Author

qiauil commented Oct 15, 2024

Hi, Felix,

I see the points. It seems that you treat $\frac{1}{2} \nabla(\mathbf{u}\mathbf{u})$ as the conservative form according to your reply and comment in #45 , while I believe $\nabla(\mathbf{u}\mathbf{u})$ is the conservative form. I think $\nabla(\mathbf{u}\mathbf{u})$ is the correct form as $\frac{1}{2} $ is only used to calculate the non-conservative form with conservative form in 1d. I will first fix the conflict issue, and we can modify this point with more discussions.

Cheers,
Qiang

@Ceyron
Copy link
Owner

Ceyron commented Oct 15, 2024

Hi Qiang,

I am not 100% sure, but keeping the 1/2 factor seems correct because there shouldn't be a difference between 1D and higher dimensions. I will add some more arguments in favor of this later.

@qiauil
Copy link
Contributor Author

qiauil commented Oct 15, 2024

Hi, Felix.

I just checked some material; I would argue that the burgers equation 1D should also be in non-conservative form. You are right, we can discuss it later.

@Ceyron
Copy link
Owner

Ceyron commented Oct 18, 2024

I would argue that the burgers equation 1D should also be in non-conservative form.

In order be consistent with the higher dimensional versions, I agree. How about we keep it as an option, effectively allowing four different permutations: multi-channel conservative, multi-channel nonconservative, single-channel conservative and single-channel nonconservative.

For backward compatibility and since it will then also just a be a nice feature of Exponax I suggest we keep the factor of 1/2 for both single-channel conservative, multi-channel conservative in 1D, and multi-channel conservative in 2D/3D.

This basically means we have the following combinations

setup 1D 2D/3D
non-conservative multi-channel $b_1 u \partial_x u$ $b_1 (\mathbf{u} \cdot \nabla) \mathbf{u}$
non-conservative single-channel $b_1 u\partial_x u$ $b_1 u(\vec{1} \cdot \nabla) u$
conservative multi-channel $b_1 \frac{1}{2} \partial_x (u^2)$ $b_1 \frac{1}{2} \nabla \cdot (\mathbf{u} \otimes \mathbf{u})$
conservative single-channel $b_1 \frac{1}{2} \partial_x (u^2)$ $b_1 \frac{1}{2} (\vec{1} \cdot \nabla) (u^2)$

This would require having two separate single-channel eval methods for the convection nonlinearity.

The default option should be non-conservative and multi-channel.

What do you think?

@qiauil
Copy link
Contributor Author

qiauil commented Oct 18, 2024

Hi, Felix,

I think it should work; we need to make it clear in the docstring, and then It should be all fine for the users to choose!

@Ceyron
Copy link
Owner

Ceyron commented Oct 18, 2024

Amazing,
do you want to make the corresponding changes in #45 ?

@qiauil
Copy link
Contributor Author

qiauil commented Oct 18, 2024

Hi, Felix.

I have added the new feature in #45; please have a check on it.

@qiauil
Copy link
Contributor Author

qiauil commented Oct 21, 2024

Hi, Felix,

The new PR is added as #46, please have a check.

@Ceyron
Copy link
Owner

Ceyron commented Oct 22, 2024

PR is merged.

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

No branches or pull requests

2 participants