mabarnes / moment_kinetics

Other
2 stars 4 forks source link

Separate velocity integration test on 2D grids #138

Closed mrhardman closed 11 months ago

mrhardman commented 1 year ago

The branch https://github.com/mabarnes/moment_kinetics/tree/radial-vperp-standard-DKE-Julia-1.7.2-mpi provides a test script for diagnosing the performance of the 2D velocity integration on a Maxwellian and a bi-Maxwellian distribution. See https://github.com/mabarnes/moment_kinetics/blob/radial-vperp-standard-DKE-Julia-1.7.2-mpi/test_velocity_integrals.jl.

This script is also useful for making sure that the definitions of the pressure are consistent with the definitions of the thermal speed and the temperature. I propose to add this script to the existing check-in tests.

mrhardman commented 1 year ago

This commit https://github.com/mabarnes/moment_kinetics/commit/1932bf5dfe1c26bee57f5bb2fde67f76ce55adae brings test_velocity_integrals.jl into a branch that is much closer to master. The output is

vpa: ngrid: 17 nelement: 20
vperp: ngrid: 17 nelement: 20

Isotropic Maxwellian
dens_test: 0.7499999930140001 dens: 0.75 error: 6.9859998896859565e-9
upar_test: 0.666666624344481 upar: 0.6666666666666666 error: 4.23221856449274e-8
pres_test: 0.666666589564534 pres: 0.6666666666666666 error: 7.710213267841937e-8

biMaxwellian
dens_test: 0.7499999093007056 dens: 0.75 error: 9.069929440830293e-8
upar_test: 0.6666659997200427 upar: 0.6666666666666666 error: 6.669466239284105e-7
ppar_test: 0.7999972321455943 ppar: 0.8 error: 2.767854405782977e-6
pperp_test: 0.2499999697669061 pperp: 0.25 error: 3.023309388949791e-8

Whereas the equivalent output from the script in https://github.com/mabarnes/moment_kinetics/tree/radial-vperp-standard-DKE-Julia-1.7.2-mpi at commit e7b6546089a5f7743946f6127bb54d36b5e4aaa2 (once modified to use the same ngrid, nelement, and discretisation options) gives

vpa: ngrid: 17 nelement: 20 Lvpa: 12.0
vperp: ngrid: 17 nelement: 20 Lvperp: 6.0

Isotropic 2D Maxwellian
dens_test: 0.749999999999915 dens: 0.75 error: 8.504308368628699e-14
upar_test: 0.6666666666667334 upar: 0.6666666666666666 error: 6.672440377997191e-14
pres_test: 0.6666666666665817 pres: 0.6666666666666666 error: 8.493206138382448e-14

1D Maxwellian
dens_test: 0.7499999999999987 dens: 0.75 error: 1.3322676295501878e-15
upar_test: 0.6666666666666637 upar: 0.6666666666666666 error: 2.886579864025407e-15
ppar_test: 0.6666666666666393 ppar: 0.6666666666666666 error: 2.731148640577885e-14

biMaxwellian
dens_test: 0.749999999999855 dens: 0.75 error: 1.4499512701604544e-13
upar_test: 0.6666666666659362 upar: 0.6666666666666666 error: 7.304157279008905e-13
ppar_test: 0.7999999999937362 ppar: 0.8 error: 6.263878304935133e-12
pperp_test: 0.2499999999999531 pperp: 0.25 error: 4.6906922790412864e-14

@johnomotani This suggests that the velocity integration weights may be broken in https://github.com/mabarnes/moment_kinetics/tree/Krook-collisions-MMS-port.

johnomotani commented 1 year ago

I copied test_velocity_integrals.jl from 1932bf5 to e7b6546. After fixing a couple of function arguments, it ran the first part of the test, and gives the similar errors as on 1932bf5 for n and upar, but ppar is wrong.

made inputs
vpa: ngrid: 17 nelement: 20
vperp: ngrid: 17 nelement: 20

Isotropic Maxwellian
dens_test: 0.7499999930140002 dens: 0.75 error: 6.985999778663654e-9
upar_test: 0.6666666243444808 upar: 0.6666666666666666 error: 4.2322185866972006e-8
pres_test: 1.333333179129068 pres: 0.6666666666666666 error: 0.6666665124624013

In the script I copied, vth = sqrt(2.0*ppar/(dens*mass)), which is why the pressure is wrong, but also suggests we should expect to need Lv* that is sqrt(2) bigger on 1932bf5.

On 1932bf5, increasing the box size to Lvpa=20, Lvperp=12 (I actually tried this before noticing the sqrt(2)...), gives much better results

made inputs
vpa: ngrid: 17 nelement: 20
vperp: ngrid: 17 nelement: 20

Isotropic Maxwellian
dens_test: 0.7499999999999492 dens: 0.75 error: 5.084821452783217e-14
upar_test: 0.66666666666671 upar: 0.6666666666666666 error: 4.340972026284362e-14
pres_test: 0.6666666666666172 pres: 0.6666666666666666 error: 4.9404924595819466e-14

biMaxwellian
dens_test: 0.7499999999999701 dens: 0.75 error: 2.986499936241671e-14
upar_test: 0.6666666666666972 upar: 0.6666666666666666 error: 3.0531133177191805e-14
ppar_test: 0.7999999999999748 ppar: 0.8 error: 2.5202062658991053e-14
pperp_test: 0.24999999999999076 pperp: 0.25 error: 9.242606680004428e-15

So no bug?

mrhardman commented 11 months ago

I think that this issue is now addressed by the merge of this PR https://github.com/mabarnes/moment_kinetics/pull/127/commits.