-
Notifications
You must be signed in to change notification settings - Fork 4
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
Gyroaverages #186
Comments
In order to reduce the number of operations in the applying gyroaverage matrix (which contains mostly zeros), I need to find a convenient way to restrict the summation indices in the following loop
In python I would do this by constructing a list of tuples I would consider using a compound index (this would just require an array of size
@johnomotani Do you have any suggestions? |
This question seems to be partially address here by this thread discussing the construction of a vector of vectors of variable length: https://discourse.julialang.org/t/q-vector-of-vectors-of-variable-lengths/102817. By first looping over the
and then fill with the required index |
The above described optimisation carried out on commit 9ad86b5 (tests passed locally tested up to 4 cores). For the problem size considered (see the examples posted in the PR, ngrid = 5, nelement = 4 for all dimensions except vperp, which has 2 elements), a factor of 1.5 speed up is observed on 2 cores. This speed up might be larger for larger problem sizes and smaller rhostar. Unfortunately this optimisation introduces another problem, which is the large arrays the indexing moment_kinetics/moment_kinetics/src/gyroaverages.jl Lines 24 to 26 in 9ad86b5
MPISharedArray{Array{mk_int,1},ndims} , where Array{mk_int,1} is intended to be a variable length array. This means that addressing this problem requires some thoughts about the shared-memory functions.
@johnomotani Is the shared-memory formalism generalisable to more abstract types (arrays of variable length?) Is there a better way to achieve my optimisation? |
A less ambitious but potentially more successful method of indexing the summation over |
The two uploaded file sets show the potential importance of the gyroaverages feature. Without numerical dissipation, the periodic 2D initial condition breaks up into fine structures that go unstable. This is still true with numerical dissipation, if it is not large enough. This means that any physics that would occur at Larmor scales may break the solutions, because it occurs at the grid scale of a drift-kinetic model. Previously we have observed similar problems with simulations with wall boundary conditions. 2D-periodic-2 crashes at time = 1.15 with r_dissipation_coefficient = 0.0 2D-periodic-2-diss does not crash with r_dissipation_coefficient = 1.0e-2 |
Reopening issue to track progress (and make it easy to find). |
Gyroaverages may be crucial for providing a physical cut-off to the wavenumber spectrum required to be resolved in the moment_kinetics model.
Initial experiments implementing an ion gyroaverage is in the branch https://github.com/mabarnes/moment_kinetics/tree/feature-gyroaverages.
To test the feature, run https://github.com/mabarnes/moment_kinetics/blob/feature-gyroaverages/test_scripts/gyroaverage_test.jl.
Here the Lagrange Polynomial representation is used to precompute integration weights as a function of z and r, in place of the integral in gyrophase, which is only a line integral in (z,r) space. The test plots the field
phi
and the gyroaveragegphi
for several values ofvperp
. Boundary conditions are not yet dealt with, meaning that the code will definitely produce poor results near the domain boundary. The code is written assuming fully local grids in memory.To do list:
Comments appreciated @johnomotani @mabarnes.
The text was updated successfully, but these errors were encountered: