Skip to content

Eirene Coupling#992

Open
akashukla wants to merge 34 commits intomainfrom
eirene_coupling
Open

Eirene Coupling#992
akashukla wants to merge 34 commits intomainfrom
eirene_coupling

Conversation

@akashukla
Copy link
Copy Markdown
Collaborator

Overview

In this PR we enable the coupling of Gkeyll to Eirene for neutral evolution. The model for including plasma sources in Gkeyll based on eirene output is described in DR #923 . Gkeyll evolves the plasma and Eirene evolves the neutrals (recycling, reactions, etc.). They exchange data through I/O every time Gkeyll outputs data.

This PR contains several parts. The first is the automatic installation of eirene and grid generation parts of SOLPS-ITER as part of the gkeyll mkdeps process. (This only occurs if one uses --build-solps=yes). The second part is the installation of a python library written by @jRoeltgen and me which does post-processing and interpolation routines to pass plasma information from gkeyll to eirene and plasma sources from eirene to gkeyll. The third is the code within Gkeyll itself that applies the sources.

Automatic installation of Eirene + SOLPS-ITER Grid generation

Without modifying the eirene codebase itself, one has to use an existing interface for grid generation and coupling. We are using the SOLPS-ITER (https://github.com/iterorganization/SOLPS-ITER ) interface. The scrip install-deps/build-solps.sh automatically installs the necessary parts SOLPS_ITER into gkylsoft/. This is only tested on perlmutter, as the SOLPS-ITER installation process can be difficult.

Automatic Installation of GK-Neutral_coupling

To actually pass information between Gkeyll and Eirene, post-processing and interpolation routines are required. This is taken care of by the GK-Neutral_coupling repo (https://github.com/jRoeltgen/GK-Neutral_coupling/tree/main) which contains examples and instructions for how to run coupled simulations.

Code Within Gkeyll

With guidance from @manauref, the additions to the code have been written in such a way that they interfere minimally with the rest of the gyrokinetic app. Most of the new code is in gyrokinetic/apps/eirene.c and gyrokinetic/apps/gk_species_source_bgk.c. The second file, gyrokinetic/apps/gk_species_source_bgk.c, has now replaced gk_species_heating.c and retains the old functionality while also adding the ability to apply sources from an external model (EIRENE). I also had to modify array_ops.c with a new function gkyl_array_ceil_range to apply limits on the temperature of the sources come from eirene to improve the stability of simulations.

Input Files

The input file interface is quite simple. You provide

  struct gkyl_gyrokinetic_eirene  eirene = {
    .input_data_path = "./gkeyll_text_input/",
    .output_data_path = "./gkeyll_text_output/",
    .num_coupling_species = 3,
    .coupling_species = {"elc", "ion", "molecule"},
    .coupling_time = {0.5e-3, 0.5e-3, 0.5e-4},
    .core_coll_factor = {75.0, 75.0, 7.5},
    .damping_factor= {2.0e-1, 2.0e-1, 8.0e-1},
    .half_domain = true,
  };

  struct gkyl_gyrokinetic_multib app_inp = {
    .name = "hstep26",

    .cdim = ctx.cdim,
    .poly_order = 1,
    .basis_type = app_args.basis_type,
    .use_gpu = app_args.use_gpu,
    .cfl_frac = 1.0,
    .cfl_frac_omegaH = 1.7*0.5 * 1.1,

    .gk_block_geom = bgeom,
    
    .num_species = 3,
    .species = { elc, ion, molecule},
    .eirene = eirene,


    .field = field,

    .comm = comm
  };

akashukla and others added 30 commits December 14, 2025 16:03
…of a eirene.c to gyrokinetic/apps/eirene.c . It's a bit difficult to figure out how to initialize the bgk sources through eirene.c
…up the diagnostics for the external bgk source type.
…verything looks good now including M2. Test is done with 1 cpu/block. Not tested on gpu yet
… the density or temperature negative during a coupling time. If the sink is too strong in a particular location, the sink rate will be set to something that won't reduce n or T bellow eps*n or eps*T during the coupling time. eps is an input parameter (damping factor) which I set to 0.01 in my tests. This required a new array operation in core gkyl_array_ceil_range.
…dd integrated diagnostics of the whole term. Not yet tested.
…ose to expected energy injection rates for all species. There could be a correction step later on, but I haven't figured that out yet. There is a lot of debugging code in this commit and leftover old functions. I will remove them soon. Need to commit this version because it is working well
…king well and producing expected results. Modified input structs to allow options per species. One debugging block is still in place, going to run a couple more tests and remove that block if we are fine
…accidentally added the lbo energy conservation fix
…d and works, I can run simulations using the SOLPS build and coupling repo produced by these mkdeps with build-solps=yes and build-eirene-coupling=yes.
Comment thread gyrokinetic/apps/eirene.c
#include <assert.h>
#include <time.h>

static bool gyrokinetic_str_ends_in_b67(char *name){
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe I'm ignorant, but I don't know what this b67 (or b1011) means. So if I'm a gkeyll person who doesn't know EIRENE, can we have a more descriptive names for what makes these two files different? We can put a comment that this means the files end in b67, but the function name should make the purpose and operation clear.

Comment thread gyrokinetic/apps/eirene.c
for (int i=0; i<eirene->info.num_coupling_species; ++i) {
struct gk_species *gks = eirene->coupling_species[i];
struct gk_source_bgk *bgk_src = &eirene->bgk_src[i];
cstr fileNm = cstr_from_fmt("%s%s-%s_M0source.txt", eirene->info.input_data_path, app->name, gks->info.name);
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The convention us usually _source_M0.gkyl, so maybe we should keep that for these formats

Comment thread gyrokinetic/apps/eirene.c

eirene->info = gk->eirene;

for (int i=0; i<eirene->info.num_coupling_species; ++i)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please put braces around single line if statements and for loops

gyrokinetic_app_geometry_copy_and_write(app, app->gk_geom->geo_corn.mc2nu_pos_deflated, arr_hocdim, "mc2nu_pos_deflated", mt);
}

gyrokinetic_app_geometry_copy_and_write(app, app->gk_geom->geo_int.mc2p , arr_ho3, "mapc2pint", mt);
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changing this to mapc2p_int might be clearrer and more organized

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants