Implicit, Fokker-Planck, self collisions for ion species - #353
Implicit, Fokker-Planck, self collisions for ion species#353mrhardman wants to merge 169 commits into
Conversation
…d". See comment in issue #323.
…ncing standard kinetics with FP collisions.
…), this removes random NaN/Inf errors that seem to have to do with these arrays not being assigned zero values.
…lthough still see Inf when using this option).
…ut moments each step.
…, vpa) for testing implicit collision advance.
…ion for commandline execution.
…d_dot for Newton-Krylov method. Now running test_scripts/ImplicitCollisionsTest.jl shows the same result (up to 1e-5) for runs with 1 and 2 cores.
…ne when using test_scripts/ImplicitCollisionsTest.jl non-interactively.
…ed when changing regions at line 285 of test_scripts/ImplicitCollisionsTest.jl. The error seems not to be fixed by synchronizing the anyv block within newton_solve!. The affected array appears to be Fnew, but obtaining a more helpful stacktrace is hindered because the anyv region synchronizations are the only ones permitted within newton_solve! in this setup, but only the serial_region macro appears to trigger the error.
…est-particle operator C[dF,F0].
…, test_implicit_collisions(ngrid=5,nelement_vpa=32,nelement_vperp=16,test_particle_preconditioner=true,test_linearised_advance=true,ntime=10,delta_t=5.0,Lvpa=8.0, Lvperp=4.0, vperp0=0.0).
…fied in test particle preconditioner matrix. A further refactor to introduce a single calculate_rosenbluth_potential!() wrapper may be beneficial.
…check that preconditioner matrix does indeed force F -> F_Maxwellian in steady state.
…sed I - dt * C[dF,F0] time advance matrix.
…, to run test shown in figure 8 of preprint, use test_implicit_collisions(ngrid=5,nelement_vpa=32,nelement_vperp=16, test_linearised_advance=false, test_particle_preconditioner=true, use_Maxwellian_Rosenbluth_coefficients_in_preconditioner=false, test_numerical_conserving_terms=true, delta_t=1.0, ntime=200, Lvpa=8.0, Lvperp=4.0, vth0=0.5). Note the order of magnitude speedup switching between test_particle_preconditioner=false and test_particle_preconditioner=true.
CI tests on Github Actions are failing due to segfaults in NCDatasets calls. The parallel tests do not seem to be affected, don't know why - maybe because they compile a system image?? Hopefully the upstream packages will sort this out eventually. To keep an eye on when this happens, have kept an 'examples' test job that includes NCDatasets, which is expected to fail at the moment. When that job passes again, we should revert this commit.
Although other tests segfault with NCDatasets, HDF5 fails to precompile when using OpenMPI_jll unless NCDatasets is also installed.
…this is the only remaining test failure." This reverts commit 1f26367.
OK. I will address this after merging #363 into this PR. |
…ster Implicit FP collisions: merge master, changing normalisations to new conventions.
…p check in `time_advance.jl`.
|
@johnomotani Although 167ce15 passed all tests, the tests are now failing post merge of #363, and I see still over a thousand files with changes with respect to master. I think the former could be explained by mistakes in automatic merge, although I have not checked what the error is yet. The latter problem seems more serious, since this PR should now include all the normalisation changes etc from #322. Do you see what has gone wrong? |
…-fp-collisions-really-merge-master
…it-fp-collisions-merge-master
…ster Implicit fp collisions merge master, further attempt.
Aiming to make performance tests using this script more representative: * Parallelise array update * Make some diagnostics optional * Start 'run' timing immediately before time-advance loop to exclude all initialisation
* Lift struct lookups out of inner loops. * Put @inbounds call in mass_matrix_interior_loop() * Reduce number of multiplications in assemble_explicit_collision_operator_rhs_parallel_inner_loop()
It should do this as the 'anyv' subblocks are subblocks of the shared-memory block that is synchronized by _block_synchronize(), so every subblock is synchronized. Done by calling _anyv_subblock_synchronize() - although this is mildly inefficient (MPI.Barrier() gets called twice), it is only used for debugging so this should be OK.
Use `comm_anyv_subblock[]` instead of the incorrect `comm_block[]`.
…ebug-parallelise-precon-construction Parallelise Fokker-Planck preconditioner matrix construction
|
Replaced by #383. |
The aim of this PR is to provide the ability to advance the equation
with the implicit, backward-Euler timestepping method, i.e., solve
using the
newton_solve!()functionality provided by @johnomotani. This feature is integrated into the main time advance functions of moment_kinetics so that the implicit implementation of the collision operator can be used with one of the IMEX time advance schemes also provided by @johnomotani.An example input file that uses an IMEX advance to solve the equation (1) above is provided in
examples/fokker-planck/fokker-planck-relaxation-implicit.toml. Note the addition of the input section[fokker_planck_collisions_nonlinear_solver]which provides the flags fornewton_solve!(), and note the presence of a new@enumfor selecting the type of ion advance, e.g.,A separate set of inputs is provided for the ion collision non-linear solve as for the electron non-linear solve in case different default inputs are necessary. At this time I have not tested implicit ion collisions alongside implicit kinetic electrons, but it is plausible that different defaults could be convenient for fast simulations. The list of possible
kinetic_ion_solveroptions are given here https://github.com/mabarnes/moment_kinetics/blob/11e4f651bce559643aa2f179efb630fdf1c3cec2/moment_kinetics/src/input_structs.jl#L51-L65.A series of test scripts have been developed in the building of this feature. In
test_scripts/ImplicitCollisionsTest.jlwe have the test scriptstest_implicit_collisions()https://github.com/mabarnes/moment_kinetics/blob/11e4f651bce559643aa2f179efb630fdf1c3cec2/test_scripts/ImplicitCollisionsTest.jl#L63-L75 andtest_implicit_collisions_wrapper()https://github.com/mabarnes/moment_kinetics/blob/11e4f651bce559643aa2f179efb630fdf1c3cec2/test_scripts/ImplicitCollisionsTest.jl#L217-L230, which can be used to solve equation one with backward-Euler and the initial conditionAn example function call to step with one timestep of backward-Euler would be
I have also extended the coverage of the automatic test scripts
moment_kinetics/test/fokker_planck_tests.jlandmoment_kinetics/test/fokker_planck_time_evolution_tests.jl. The changes inmoment_kinetics/test/fokker_planck_tests.jltestwith$F_0$ a specified distribution function, usually chosen to be $F_i$ at the last timestep;
The changes in
moment_kinetics/test/fokker_planck_time_evolution_tests.jlmoment_kinetics,In summary, this PR
newton_solve!()to support iterations in theanyvregion layout,Before merging, I still need to add
vperp.bc="zero-impose-regularity", which is not supported.set_defaults_and_check_values!()and make[fokker_planck_collisions.nonlinear_solver]a standalone namelist which is read directly from the input TOML insetup_fp_nl_solve(). The functionsetup_fp_nl_solve()should contain any Fokker-Planck specific defaults for the nonlinear solver. Remove thenonlinear_solvermember fromfkpl_collisions_input.nl_solver_params.ion_fp_collisionsin suitable timestep checks.Before merging this PR I would request feedback on
vpa,vperp,zadvection are required