However, when computing derivatives, depending on the magnitude of the field, it is often more accurate to have
df(i) = a * (f(i+1)-f(i-1)) + ... instead of df(i) = a * f(i+1) - a * f(i-1)) + ....
Of course, the impact of this choice is case-specific. For the heat equation at hand, this has a limited impact if the temperature is properly scaled (average is zero). However, this can be an issue if the temperature is not properly scaled (small amplitude derivatives combined with a temperature expressed in Kelvin for instance).
More generally, this choice can have some impact on the conservation of bulk quantities.
Thanks @mathrack , defintely something to have in mind. I guess such issue would be straightforward to catch in tests? In which case the implementation of the stencil application could be written in a different way.
Currently, the draft is using
dot_product
when computing derivativeshttps://github.com/tlestang/heatcompact3d/blob/6b6e21817ccafc5ffde7c9bcf667b6a8f0a97e03/src/module_stencil.f90#L65
However, when computing derivatives, depending on the magnitude of the field, it is often more accurate to have
df(i) = a * (f(i+1)-f(i-1)) + ...
instead ofdf(i) = a * f(i+1) - a * f(i-1)) + ...
.Of course, the impact of this choice is case-specific. For the heat equation at hand, this has a limited impact if the temperature is properly scaled (average is zero). However, this can be an issue if the temperature is not properly scaled (small amplitude derivatives combined with a temperature expressed in Kelvin for instance).
More generally, this choice can have some impact on the conservation of bulk quantities.