stellaGK / stella

stella is a flux tube gyrokinetic code for micro-stability and turbulence simulations of strongly magnetised plasma.
https://stellagk.github.io/stella/
Other
21 stars 10 forks source link

Numerical instability for small ky rho_ref in branch feature/Davies-linear-EM-terms #100

Open rd1042 opened 1 year ago

rd1042 commented 1 year ago

Issue to track a numerical instability in the electromagnetic stella branch feature/Davies-linear-EM-terms (commit 47f9f536). Possibly related to issue #98 (which mostly concerns the master branch).

Some details of the test case I'm examining has the features:

Example input file attached. I'll provide more information/diagnostics shortly. It looks to me like some problem with the streaming algorithm. (Although there isn't an instability for the unsheared slab geometry with periodic BCs).

input.in.txt

rd1042 commented 1 year ago

This appears to be related to how the centering is performed in the term (Z/T e^(-v^2) ) in the streaming scheme. The current scheme calculates this source term as: sourceterm = Z/T ( e^(-v^2) )_{centered_midpoint} * (\<Delta chi>)\{centered}

This is O(dz^2) centered without z upwinding (i.e. u_z=0), but it "mixes" ( e^(-v^2) ) and () between adjacent gridpoints. An alternative is: sourceterm = Z/T ( e^(-v^2) * \<Delta chi>)\{centered}

which is also O(dz^2) centered without z upwinding, but doesn't "mix" terms from adjacent gridpoints. This alternative approach is implemented in branch bugfix/Davies-linear-EM-terms-maxwellian-centering-streaming . With the same input file as above, this branch is stable. Some next steps/questions are:

rd1042 commented 1 year ago

Just an update that, with branch bugfix/Davies-linear-EM-terms-maxwellian-centering-streaming, numerical instability occurs if ky is reduced to e.g. 0.01. The numerical instability gets worse as the timestep increases, which is the opposite behaviour to the original instability, but the same behaviour as the master branch.

mabarnes commented 1 year ago

so should we interpret this as meaning that with the slight tweak to the centering in the EM implementation, the code behaves in the same way as the master branch? E.g., an electrostatic simulation with the delta phi and h formulations gives the same behaviour as master branch?

rd1042 commented 1 year ago

Not quite - running the same input files for both simulations, the (delta phi and h) approach is more instability-prone (i.e. for a given ky, instability occurs if the timestep exceeds a partiuclar dt_max, and dt_max is smaller for the (delta phi and h) approach).

rd1042 commented 1 year ago

mode_structures_ky0 01

Attached are mode structures for master & em_stella (the latter with the bugfix) showing instabilities for different dt with ky=0.01. master is stable for dt=0.004 (and 0.04, but not shown) but becomes unstable for dt=0.1. The (delta phi and h) approach is unstable for dt=0.004. The mode structures are smooth in z, but seems to change between dt=0.004 and dt=0.1 for the em branch.