Description
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:
- Set n_phi = 1 for azimuthal symmetry (runs faster). Also lowered Ra and nr, ntheta so that it runs fast on one core.
- Defined eye using both of the definitions above. I'm calling the first definition "smol" and the second "ncc".
- 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.
- 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):
...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!