-
Notifications
You must be signed in to change notification settings - Fork 5
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
Kinetic electrons #237
Merged
Merged
Kinetic electrons #237
Conversation
This file contains 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
If dimension has size 1 for some input it cannot be parallelised, so there is no need to check it (for that case). By skipping size 1 dimensions, we can reduce the number of combinations that need debug tests, which speeds up the tests.
...because loading or defining coordinates is done in an `@serial_region`, so the tests would hang without `ignore_MPI=true`.
When running in debug mode, the arrays might be DebugMPISharedArray (for the runs) or Array (when loading coordinates with ignore_MPI=true for testing or post-processing).
This code was moved into initialize_electrons!() function.
Fixes changes from 399e521.
...into a separate function `adaptive_timestep_update_t_params!()` that will be able to be called from the electron version of `adaptive_timestep_update!()` as well, to reduce code duplication. `adaptive_timestep_update_t_params!()` is defined in the `runge_kutta` module to allow it to be used both in time_advance and electron_kinetic_equation modules.
Will allow it to be used by electron_kinetic_equation module as well as time_advance.
...so it can be used for electron distribution function.
Implement pseudo-timestepping for electrons in the same way as timestepping for ions/neutrals. Input for electrons is given in the `[electron_timestepping]` section of the input file - defaults are copied from the `[timestepping]` section, but with `dt`-type options reduced by sqrt(me/mi).
Parallel flow speeds are always small compared to the electron thermal speed, so it seems more sensible not to use an upwinded derivative depending on the sign of electron upar in the electron energy equation.
When initializing the electron distribution function and parallel pressure, want to evolve the energy equation using ion and neutral moments from the `moments` struct, because `scratch` is being used for the electron time advance, but when advancing the electron parallel pressure along with the ion/neutral moments and kinetic equation, need to get some of the ion and neutral moments from `scratch`. This commit makes electron_energy_equation!() take all the moments as arguments, so that the calling site decides which struct they come from.
These checks were not parallised, and hopefully are less useful when we have adaptive timestepping.
...in `makie_post_process()`.
Making a copy before using the `test_input` Dict ensures that the inputs defined in the test scripts are never modified.
...otherwise use `moments.electron.ppar` as `electron_ppar` is not updated in the `scratch` objects by the electron kinetic equation (KE) iteration.
Previously, the moments of the source term were introduced in vpa/vz 'advection speed' and in source_terms in terms of `external_source_amplitude`. The moments were taken assuming that the source is a Maxwellian with temperature `T_source`. This is not true for "energy_source" (where the source is defined as roughly 'f_M - f' in such a way that no particles are introduced). However, the moments of the source term are already calculated in external_density_source and external_pressure_source, so these can be used instead to support more generic source terms.
The array allocation is not important, but the copy is not allowed when `phi` is an `MPIDebugSharedArray`.
When using adaptive timestepping, if the timestep becomes very small it is very unlikely that the electron solve will converge in a fixed (small-ish) number of iterations. This makes the electron solve fragile. It should be more robust to fix the 'sim time' (i.e. normalised physical time that the simulation is run for) for each electron solve, which is what is implemented in this commit.
Using a temperature equation sometimes seems to be more numerically stable. It seems to help keep T_e (and q_e) smoother, which is useful as v_th=sqrt(2*T_e/m_e) is used to scale the grid for the distribution function. Currently a slightly hacky implementation which converts electron_ppar to electron temperature, does the forward-Euler update, then converts back.
This reverts commit aefc278.
This reverts commit 8aa7e1e.
The electron timestep needs to be less than `ion_dt` to prevent the source term that makes the solve for `electron_ppar` into a backward-Euler timestep from being numerically unstable (with explicit timestepping). Also add a maybe-improved initial guess for the implicitly-updated `electron_ppar`, by taking a forward Euler step using `ion_dt` and the initial values of `moments.electron.qpar`, etc.
This computation is now taken care of in `calculate_electron_moment_derivatives!()`.
Mosty due to the changes in "Normalise grid to initial_temperature while initialising f_neutral" (ac7f0a3). A couple of tests were slightly affected by a couple of other small changes.
kinetic electrons have to be moment-kinetic. Currently this requires a 1D1V run.
The normalisation introduced in "Normalise grid to initial_temperature while initialising f_neutral" (ac7f0a3) resulted in an interpolation that caused negative pressure (presumably due to the very low resolution). Tweak `T_wall` to avoid this, by setting it to a value that means no interpolation is needed.
This addition will allow the MMS test to work properly (once the test input is updated).
Also fix inputs for the kinetic electron debug check.
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.
Initial version of kinetic electron implementation. Note that electrons are always moment-kinetic, so that their density and parallel flow can be set by quasineutrality/ambipolarity, with the small-mass-ratio limit of the electron parallel momentum equation being used to calculate the parallel electric field.
Currently only 1D1V supported.
An implicit solve for kinetic electrons is still work-in-progress. It is (partially) implemented, but should not be used yet.
There is an option for 'Braginskii fluid' electrons, where Braginskii's collisional closure is used for the electron parallel heat flux.
Also includes @LucasMontoya4's 'Maxwell diffusion' feature, as this was merged during development.