Repository navigation
Variational MHD: split sound step for the q model, Kronecker Schur preconditioner for H1vec velocities, per-component weights in StiffnessPreconditioner - #829
Open
nicolominichelli wants to merge 1 commit into
Conversation
…econditioner for H1vec velocities - VariationalQBEvolve(coupling="bq"|"b"|"q"): advance only the coupling of the velocity to B or to q, the other variable and its auxiliary variable fixed (2x2 Newton system). VariationalPerturbativeMHD_with_q(split_sound=True) uses two substeps, variat_qb (b) and variat_sound (q), each energy conserving; the q TAE example uses it (sound solve 8-9 PCG iterations, 2.5 s instead of 4.2 s per step). - Options schur_precond and exb_correction of VariationalPBEvolve and VariationalQBEvolve: ShearAlfvenSchurPreconditioner (now also for u_space="H1vec", with the E x B map into H1vec) for the shear-Alfven Schur operator of the linear p model and of the Alfven substep of the split q model, built in prepare_time_step; fallback to the mass-matrix preconditioner elsewhere. SchurSolverFull/Full3 get a precond setter. - StiffnessPreconditioner (general operators): separable weight shapes per diagonal block (block_shapes=True) instead of one common shape. Exact for separable weights with different profiles per component (curvilinear metric); no change in Cartesian geometry. LinearMHD shear-Alfven PCG iterations on the low-mode TAE: 23-25 -> 14-17. - Tests: energy conservation of the split step and first-order splitting error (verification), same solution with both Schur preconditioners and fallback (test_variational_schur_precond.py). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Follow-up of #824. In the low-mode TAE the linear variational models were 5-10x slower per step than
LinearMHD(about 170 PCG iterations per Schur solve with the mass-matrix preconditioner). This PR reduces the cost of the q model, adds a Kronecker preconditioner for the shear-Alfven Schur operator with an H1vec velocity, and fixes a weight approximation inStiffnessPreconditionerthat also speeds upLinearMHD.All timings below are 4-step profiles of the TAE examples (production grid 16x16x8, hollow torus with inner radius 0.1, dt = 0.5, 4 MPI ranks).
1. Split sound step for the q model
VariationalQBEvolve(coupling="bq" | "b" | "q"), a constructor argument."b"("q") advances only the coupling of the velocity to B (to q), keeping the other variable and its auxiliary variable fixed, with a 2x2 Newton system. The default"bq"is unchanged.VariationalPerturbativeMHD_with_q(split_sound=False). WithTrueit uses two substeps,variat_qb(shear-Alfven/fast) andvariat_sound(sound), similar to the shear-Alfven/magnetosonic split ofLinearMHD.split_sound=True.2. Kronecker preconditioner of the shear-Alfven Schur operator (H1vec)
schur_precond("MassMatrixPreconditioner"default, or"StiffnessPreconditioner") andexb_correctionofVariationalPBEvolveandVariationalQBEvolve.prepare_time_step(alfven_schur_preconditionerinfeec/variational_utilities.py).ShearAlfvenSchurPreconditioner(u_space="H1vec"):basis_ops.Tvand the stabilizationMvn;u_space="Hdiv"path is unchanged.SchurSolverFullandSchurSolverFull3get aprecondsetter.3. Per-component separable weights in
StiffnessPreconditioner(general operators)midandstabwere approximated by one separable shape common to all velocity components. In curvilinear coordinates the component weights have very different profiles. For the H1vec velocity in the torus, G_22 sqrt(g) ~ r^3, and the common shape overestimates the poloidal mass by up to 34x at the inner wall (13.7x for theLinearMHDvelocity).block_shapes=True, the default for general operators). The blocks are inverted independently (block Jacobi), so this costs nothing.StiffnessPreconditioner(grad/curl/div stiffness) is unchanged.LinearMHD: condition number of the preconditioned shear-Alfven operator 66 -> 19.3 (Lanczos). PCG iterations 23-25 -> 14-17 at the default tolerance.Results for the variational models
Block Jacobi (
exb_correction=False) is the fastest variant. The examples still use the default mass-matrix preconditioner; the preconditioner changes only the iteration, not the solution.Analysis: why the H1vec gain is smaller than for
LinearMHDLinearMHDthe E x B correction removes the corresponding near-kernel (kappa 1033 -> 66, and 19.3 with the per-component shapes). For the H1vec velocity it does not, even with an exact solve on the auxiliary space (kappa 196). The image of B0 x grad(phi) apparently does not represent the nearly incompressible H1vec fields near the grid scale. This remains open.Tests
propagators/tests/test_variational_schur_precond.py: both preconditioners give the same solution (linear p, split q); fallback for the unsplit q model.test_verif_VariationalPerturbativeMHD_with_q.py:LinearMHDand the five variational MHD models (2 ranks);test_examplesfor theLinearMHD, p and q low-mode TAE examples.StiffnessPreconditioner. They use its derivative mode, which is unchanged.🤖 Generated with Claude Code