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

Bug in LHS evaluation of tensors with no bases (for a ball problem, maybe others) #220

Open
evanhanders opened this issue Aug 4, 2022 · 5 comments
Labels
bug Something isn't working
Milestone

Comments

@evanhanders
Copy link
Contributor

Hi folks,

I've been working on getting the fully compressible equations running and conserving energy. In those equation, there is a viscous term like div(e - (1/3) * div_u * I), where I is the identity matrix. I've found that I get incorrect results when I define the identity matrix like so:

eye = dist.TensorField(coords, name='eye')

But I get correct results when I define it like this:

eye = dist.TensorField(coords, name='eye', bases=basis.radial_basis)

If I evaluate operations involving these two definitions of eye, then I find that they give the same result when they're included on the RHS of equations but not when they're included on the LHS, which is where I want them for my diffusive term!

I've thrown together a MWE by modifying the ball internally heated example; see here: Imatrix_internally_heated_convection.py.txt. I've done the following:

  1. Set n_phi = 1 for azimuthal symmetry (runs faster). Also lowered Ra and nr, ntheta so that it runs fast on one core.
  2. Defined eye using both of the definitions above. I'm calling the first definition "smol" and the second "ncc".
  3. Added test fields with equations of the form "dt(test_field) = div(eye*T), which is kinda like the term in the fully compressible equations.
  4. measured the value of the test field for different formulations (smol vs ncc, RHS vs LHS evaluation).

I'm taking the ncc case where the div() term is on the LHS to be the "truth" and comparing the other cases to it. I get something like this (which the attached script will produce if you run it):
test_vals

...so we can see that the smol identity matrix when evaluated on the LHS gives the wrong answer. A simple fix for now seems to be to use the ncc version, but I wanted to make this known!

@kburns
Copy link
Member

kburns commented Aug 4, 2022

Thanks for the report. Here's a minimum working example showing the failure:
implicit_identity_mwe.py.txt

@evanhanders
Copy link
Contributor Author

Thanks, @kburns ! Here's an alternate MWE in test form inside of test_spherical_ncc.py that Daniel and I came up with: test_spherical_ncc.py.txt

(see "test_identity_multiply")

@kburns
Copy link
Member

kburns commented Aug 4, 2022

Looks like the issue is that the intertwiners are not applied to the components of constant fields (a choice we actively made so that spherical BC fields were in spin space instead of regularity space). Not sure there's a really quick fix for this unfortunately.

@kburns
Copy link
Member

kburns commented Aug 4, 2022

Maybe the best we can do right now is raise an error and force you to use NCCs with bases in curvilinear problems.

@evanhanders
Copy link
Contributor Author

As a temporary fix, I think raising an error and saying to make it an NCC works! That's a trivial difference to make to my script as a user, especially if it makes the solution correct.

@kburns kburns added the bug Something isn't working label Aug 26, 2022
@kburns kburns added this to the 3.0.0 milestone Jun 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants