hermes-3 icon indicating copy to clipboard operation
hermes-3 copied to clipboard

Nonorthogonal with minimal differential operators MMS test.

Open mrhardman opened this issue 10 months ago • 4 comments

Fixes to the Div_a_Grad_perp_nonorthog(a, f) operator (commit 3d11cb75a90be1125b873b6500d01a1d97aabef6, commit 2e5e82709cfea8af074234df01bf28470c1c487e), merge with master, and new automatic tests integrated with ctest showing a correct implementation. Theses tests are hermes-3/tests/mms/orthogonal_test.py and hermes-3/tests/mms/nonorthogonal_test.py, and may be run interactively by, e.g.,

cd hermes-3/build-path/tests/mms/
python3 orthogonal_test.py

or

cd hermes-3/build-path/
ctest -I 12

These tests can be readily extended to test new nonorthogonal operators and the other existing operators in the Hermes-3 code base.

See /hermes-3/tests/mmsREADME.md for some documentation. Comments and requests appreciated.

Thanks to @dschwoerer for providing an initial MMS test to develop. Thanks to @johnomotani for numerous suggestions and bugfixes.

Below is the plot output from the tests, showing the error (blue), the expected (orange), and the fit of the error (green). Increase the range of $\Delta$ by increasing ntest in the test_input dictionary in hermes-3/tests/mms/orthogonal_test.py and hermes-3/tests/mms/nonorthogonal_test.py. Note that since the number of grid points $N_x = N_y = N_z$, the cost of the test rapidly increases with ntest.

FV::Div_a_Grad_perp(a, f) with orthogonal metric fig_0 Div_a_Grad_perp_nonorthog(a, f) with orthogonal metric fig_1 Div_a_Grad_perp_nonorthog(a, f) with nonorthogonal metric fig_0_non

mrhardman avatar Jan 24 '25 09:01 mrhardman

Can you either change this PR to go into master or open a new one that goes into master: https://github.com/bendudson/hermes-3/compare/bendudson:master...bendudson:nonorthogonal-divops-mms-test-minimal?expand=1

Like this it is hard to see the changes you introduced.

Unfortunately I cannot do that, as I am not a collaborator :-(

dschwoerer avatar Jan 24 '25 13:01 dschwoerer

Changed base to master in response to @dschwoerer's review. Making master the base obscures slightly the changes made in div_ops.cxx. The changes to this with respect to #88 are simply commit https://github.com/bendudson/hermes-3/commit/3d11cb75a90be1125b873b6500d01a1d97aabef6 and commit https://github.com/bendudson/hermes-3/commit/2e5e82709cfea8af074234df01bf28470c1c487e.

mrhardman avatar Jan 24 '25 13:01 mrhardman

@dschwoerer Could you please make a PR with your suggestions into this PR? It looks like some of the functions that you expect to be available are not.

mrhardman avatar Jan 27 '25 14:01 mrhardman

With commit https://github.com/boutproject/hermes-3/pull/285/commits/9ecddebf7a3e57536989df88ced3804a3c0323e9 we can perform a diffusion test solving an equation (up to normalisation) of

 \frac{\partial n}{\partial t} = \nabla \cdot \left( D_n \nabla_\perp n \right)

and we choose D_n to be constant. The input file used for this test is

nout = 50
timestep = 50000.0

MZ = 1

[mesh]

file = "bout.grd.nc"

extrapolate_y = false

[mesh:paralleltransform]
type = shifted

[solver]
type = cvode
use_precon = true
mxstep = 1e5

mxorder = 3
atol = 1e-12
rtol = 1e-5

[hermes]
components = (d, classical_diffusion)

Nnorm = 1e19  # Reference density [m^-3]
Bnorm = 1   # Reference magnetic field [T]
Tnorm = 75   # Reference temperature [eV]
loadmetric = false

[classical_diffusion]
custom_D = 1.0
diagnose = true

##################################################################
# Neutrals

[d]
type = evolve_density
charge = 0
AA = 2

diagnose = true
[Nd]

function = 1 - 0.5*x^2 + x

bndry_core = dirichlet(1.0)  # Core boundary high density
bndry_all = neumann   # All other boundaries low density


The result at the last timestep is plotted here, showing that the solution is very close to 1.0e19, as required at long times by the boundary conditions. Last_timestep_Nd The grid can be generated by modifying the examples from the Hypnotoad integrated tests.

mrhardman avatar Feb 24 '25 14:02 mrhardman