Skip to content

Abstract classmethods "species" and "options" in StruphyModel

Stefan Possanner requested to merge enable-no-polar into devel

This MR features the following changes, some of which will be described in more detail below:

  1. New abstract classmethods StruphyModel.species(), StruphyModel.options() and Propagator.options()
  2. Added the console command struphy create-params for generating a default parameter file for a model, or display the model options on screen
  3. Automatic testing of models and all available options via struphy test
  4. In StruphyModel.print_scalar_quantities(), auto-check if all are not nan
  5. Updated the Pusher class, removed the separate Pusher classes for Itoh and Gonzalez
  6. Created the new sub-directories pic/pushing/ and pic/accumulation/
  7. Changed the GVECequilibirum to GVECunit interaction. The former now calls the latter at init. Also finished Tutorial 06. Added field line tracing docstring
  8. Added the parameter rmin to GVECequilibirum, which allows to have a hole around the magnetic axis in the mapping GVECunit
  9. Removed psydac mappings entirely
  10. Added Tutorial 06 and added field line tracing docstring
  11. Cleaned up docstrings of mappings and MHD equilibria, added detailed docstring to field_line_tracing
  12. Removed the option mhd_u_space from all models solving LinearMHD. The associated Propagators still have this option though (for future use.)

Points 1. and 2.

The definition of the model species have been moved from __init__ to the new abstract classmetod StruphyModel.species(). The latter returns a dict which must be of the form {'em_fields': {}, 'fluid': {}, 'kinetic': {}}. The rules for defining em_fields, fluid or kinetic species remain the same within this dict.

From now on Struphy will have only one "core" parameter file io/inp/parameters.yml. All model specific parameter files can be created automatically from the core file with the new console command struphy create-params MODEL. This is possible because all model specific inputs must be specified in the new abstract classmethod StruphyModel.options(). The latter holds all available options for each species. options returns a dict of the form {'em_fields': {}, 'fluid': {}, 'kinetic': {}}, where the subkeys are like [species]['options'][...]. That is exactly how they will appear in the auto-generated parameter file. Examples for options are different solvers or pusher algorithms. The chosen options for a run are displayed on screen at startup. The available options for a model can be displayed with struphy create-params MODEL --options.

Any parameters that need to be passed to a model and are not in the standard file parameters.yml must be specified under StruphyModel.options(). The different options must appear there as a list under the correponding key.

Point 3.

The console command struphy test now allows for testing a model (or all models) with all its options, and for different mappings (Cuboid, HollowTorus and Tokamak). There is a --fast option for just testing in the slab (Cuboid).

There is anew cronjob (ci pipeline) that will run every Sunday at 3 a.m., testing all models with all options on the above three domains.

Point 5.

The improved Pusher class can now accomodate all pushers under one roof. To do this, aside from Pusher.kernel, there now are Pusher.init_kernel and Pusher.eval_kernels for iterative methods. The __call__() method is structured as follows:

First, the init_kernel is called, if not None. Then, there is a loop over the stages (e.g. 4 for RK4). Inside of each stage, there is a loop over the iterations (while n_not_converged > 0:). This loop terminates if all markers are converged (not yet implemented), OR if the number of iteration has reached maxiter. The value of maxiter must be 1 for explicit pushers. The parameters maxiter and tol must now be passed as args_opt to all eval_kernels_gc.py and all pusher_kernels_gc.py.

There remain some if-statements to be removed in the future when clearing the marker buffer.

Edited by Stefan Possanner

Merge request reports