Skip to content

Tokagridgen tool#925

Open
mp5650 wants to merge 22 commits intomainfrom
tokagridgen-tool
Open

Tokagridgen tool#925
mp5650 wants to merge 22 commits intomainfrom
tokagridgen-tool

Conversation

@mp5650
Copy link
Collaborator

@mp5650 mp5650 commented Dec 18, 2025

resolved merge conflicts by pulling main into the tokagridgen branch.

mp5650 and others added 21 commits October 20, 2025 10:19
…to be the desired width as a fraction of the total psi difference between psi at center and separatrix.
….gkyl into output directory so that pgkyl gridplot tool can be run without running ctest and manually moving needed files into directory.
…s metadata the required settings needed for plotting quickly
…to be the desired width as a fraction of the total psi difference between psi at center and separatrix.
….gkyl into output directory so that pgkyl gridplot tool can be run without running ctest and manually moving needed files into directory.
…s metadata the required settings needed for plotting quickly
@manauref
Copy link
Collaborator

manauref commented Feb 4, 2026

@mp5650 @jjz73 can you please enrich this PR with some examples of how this is used and what it produces?

@mp5650
Copy link
Collaborator Author

mp5650 commented Feb 8, 2026

This PR introduces a grid generation tool which simplifies and expedites the creation of tokamak multiblock grids. The goal of this tool is to write out files for all of the grid quantities and block geometry structs so they can be passed into the simulation input file instead of being generated in the file itself. Instead of writing hundreds of lines of code to set up the block geometry, the user can now just fill out a Lua template file and run the tokagridgen tool.

Creating tokagridgen input

The workflow for using the grid generation tool starts with creating a Lua input file. A template for the input can be generated by calling the tool with the flag -t or –template with the argument “SN” for single null grid or “DN” for double null grid.

Screenshot 2026-02-08 at 5 25 26 PM

Figure 1: Call tokagridgen -t SN for a single null template

The input file requires the following inputs”:

  • name - name of the simulation
  • geqdsk_path - path to the geqdsk file
  • toka_type - single_null or double_null depending on X point geometry
  • use_half_domain - False by default, only needs to be specified as true if the user wants to set up a double null block geometry with all 12 blocks instead of mirroring the lower half over the x-axis.
  • lower_pf - dictionary of geometry parameters for lower private flux region
  • Scrape off layer geometry: for SN cases specify SOL, for DN cases specify outer_SOL and inner_SOL
    - SOL - dictionary of geometry parameters for scrape off layer (required for single null)
    - outer_SOL - dictionary of geometry parameters for outer scrape off later (required for double null)
    - inner_SOL - dictionary of geometry parameters for inner scrape off later (required for double null)
  • core - dictionary of geometry parameters for core region
  • psi - width of psi as a fraction of the psi difference between the separatrix and magnetic axis
    - Of form {PF width, SOL width, core width} for single null
    - Of form {PF width, outer SOL width, inner SOL width, core width} for single null
  • cell_count - number of cells for each region along each computational coordinate
    - Of form {npsi_pf, npsi_sol, npsi_core, ntheta_pf, ntheta_sol, ntheta_core}
  • Plate functions - define functions which are used to generate plate function geometry.

Additionally, example input files for nstxu-DN, asdex, and step can be generated by calling the tool with the -e or –example flag, followed by “asdex”, “step”, or “nstxu_DN”.

Calling tokagridgen to create grid mesh and block geometry

After filling out the Lua input file, the grid generation tool can be used by calling tokagridgen with the -i or –input flag and passing the path to the input file.

Screenshot 2026-02-08 at 5 55 59 PM

Figure 2: Call tokagridgen with -i to create block geometry and grid

Output of tokagridgen tool

The tokagridgen tool creates a folder called _geometry and writes out all output files in there. All of the standard geometric quantities required to set up a simulation mesh are written out as .gkyl files.

Screenshot 2026-02-08 at 6 36 32 PM

Figure 3: Output directory and some files from tokagridgen tool.

Additionally, a _bgeom.gkyl file is written out which contains all of the topology information of the block geometry which can then be loaded into a gkyl_gk_block_geom struct in the simulation input file (function to read gkyl_gk_block_geom from file still needs to be created). This tool also writes out _psi.gkyl and _setting.gkyl files into the output directory. These files are not relevant for simulation inputs but are created to be used with the gridplot tool (Currently an open PR) in PostGkeyll. The gridplot tool automatically reads these files and uses the information to create plots of the nodal grid.

Screenshot 2026-02-08 at 6 16 47 PM Screenshot 2026-02-08 at 6 32 21 PM

Figure 4: gridplot tool results

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.

2 participants