-
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
Allow interpolation between grids when restarting #128
Conversation
c33950a
to
e8c4980
Compare
bd6a1f9
to
2b1a260
Compare
e8c4980
to
0bf42de
Compare
2b1a260
to
b1f88ea
Compare
0bf42de
to
0883a6e
Compare
b1f88ea
to
b2d9866
Compare
0883a6e
to
8d8bcd4
Compare
4270457
to
cd37b9f
Compare
[Copying this to the PR page because that will probably be easier to find in future!]
I haven't considered going from 1D to 2D. It should be possible, but will need a bit of work. The interpolation routines were written with velocity space interpolation in mind, so when they have to go past the end of the input grid they fill in values with an exp(-v^2) decay from the last value on the grid. I guess we'd want to add an option to control the extrapolation, which could be set for the r-dimension to something like 'use the last value on the grid'. I'm also not sure what exactly happens with a |
This is what I had in mind. The special exception that you mention is in coordinates.jl -- grids with coord.n = 1 have their wgt[1] set to a constant and grid[1] set to 0.0. If we just plan to copy the data in the "radial dimension" from r.n = 1 to all the other indices, I would have thought we would have a fairly straight forward operation to do. |
cd37b9f
to
20bac6b
Compare
When reloading data for a restart, it is necessary to create `coordinate` objects using the parallelisation of the new simulation, not the parallelisation that was used to write the data.
Only the coordinate ranges are actually different between the parallel_io=true and parallel_io=false branches, so can take a lot of code outside the `if parallel_io` block.
This allows a simulation to restart from a run with different resolution in any or all dimensions, and also to restart from a run with different moment-kinetic settings (`evolve_density`, `evolve_upar` and `evolve_ppar`).
This is needed to get the global_io_range correct, which is needed when reloading.
This will allow them to be reused in other tests.
`discretization_info` is the abstract type inherited by all implementations of a discretization (i.e. `chebyshev_info` and `finite_difference_info`). Also adds a `finite_difference_info` that is used to dispatch to the finite difference methods, instead of using `Bool` for that.
Length-1 dimensions have to be treated a bit specially. Derivatives in those directions should be zero. 'Interpolation' to a grid with more than one point: for spatial dimensions, assume the variable is constant; for velocity dimensions, use a Maxwellian whose peak value is the value on the length-1 grid, and whose width is 1 (in units of the reference speed) - this means that the integral of the variable over velocity space, after accounting for factors of pi^0.5 or pi^1.5 in the normalization of distribution functions, is the same (up to discretization error) after 'interpolating' as it was before.
The special "chebyshev_pseudospectral_vperp" is now handled by having a special case for "vperp" in the "chebyshev_pseudospectral" setup, so the default for "verp_discretization" should just be "chebyshev_pseudospectral".
The case when vpa and vz are not the same direction needs some special handling (for the neutrals) to convert between 1V and 3V. This is not implemented yet, so error in this case when bzeta!=0.
Have added tests for Krook collision operator and restart interpolation.
When not using parallel I/O, should not change the irank/nrank loaded from the original output files. Also check whether current distributed parallelisation is the same as the original distributed parallelisation (changing this is only supported when using parallel I/O).
20bac6b
to
5b2f40e
Compare
5b2f40e
to
f13e3e0
Compare
This branch now includes tests (https://github.com/mabarnes/moment_kinetics/blob/f13e3e03da956e775236d1a6d458eacb31dfcc9b/test/restart_interpolation_tests.jl) and handles interpolation from 1D to 2D and from 1V to 2V or 3V (48dcc80). Should be ready to merge now, I hope. |
Now that the `discretization_info` abstract type is defined, can define the specific types for each implementation in the module along with the implementation. This makes more sense and simplifies the dependencies between different modules.
The method for setting up MPI-capable HDF5 has changed in recent versions of HDF5.jl. Update the docs to reflect the new method.
This makes it easier to read and to refer to, as the amount of information in the file has increased.
Can be used to change resolution, and/or to switch between different moment-kinetic modes, when restarting.
Edit: Can also switch (in a basic way, see the docs) from 1D to 2D, or from 1V to 2V/3V.
This PR also includes some refactoring of the types used to dispatch to different discretization methods for differentiation and interpolation - this is a tidy-up and completion of the refactoring started in #57. Now there is an 'abstract type'
discretization_info
, defined inmoment_kinetics_structs
, which allowschebyshev_info
(now a sub-type ofdiscretization_info
) to be moved back intochebyshev.jl
, and replaces the use ofBool
to indicate finite-difference methods with afinite_difference_info
type (also a subtype ofdiscretization_info
).TODO: