Extension: Json and NetCDF utilities
#include "dg/file/file.h"
Loading...
Searching...
No Matches
The Probes diagnostics module
Collaboration diagram for The Probes diagnostics module:

Classes

struct  dg::file::Probes< NcFile, Topology >
 Facilitate output at selected points. More...
 
struct  dg::file::ProbesParams
 Parameter struct for probe values. More...
 

Functions

ProbesParams dg::file::parse_probes (const dg::file::WrappedJsonValue &js, enum error probes_err=file::error::is_silent)
 Parse probe field in json file for use with Probes class.
 

Detailed Description

Function Documentation

◆ parse_probes()

ProbesParams dg::file::parse_probes ( const dg::file::WrappedJsonValue & js,
enum error probes_err = file::error::is_silent )
inline

Parse probe field in json file for use with Probes class.

A synthetic diagnostics in FELTOR is equivalent to outputting the computational fields including their first derivatives in time interpolated to any grid location (as if a measurement was done at that location). The output frequency is typically higher than the output frequency of the entire computation fields (otherwise you could just interpolate those at the end of the simulation).

In the input file, it is required to define the interpolation coordinates named coords-names (in this example "R", "Z" and "P") as arrays. The length of the position arrays must match each other. There is no limit on the size of the arrays; they are typically not performance relevant unless a large percentage of actual grid coordinates is reached

"probes" :
{
"input" : "coords",
"coords" :
{
"format" : format, // see paragraph below
"coords-names" : ["R","Z","P"], // name of coordinates ( need to be in order passed to interpolation function)
"R": [90, 95, 100], // R coordinates in rho\_s
"Z": [0, 0, 0], // Z coordinates in rho\_s
"P": [0, 0, 3] // phi coordinates in radian (values outside the interval
// $[0,2\pi]$ will be taken modulo $2\pi$ (unsigned))
}
}

The "coords" field can be read from an external json file alternatively using

"probes" :
{
"input" : "file",
"file" : "path/to/file.json", // relative to where the program is executed from
"scale" : [1000,1000,1] // convert coords from SI units to dimenless units
}
Note
By default the "probes" input field is optional and can be left away entirely. No probes will be written into the output file then. Be sure not to have any spelling mistakes on "probes" if you do want them though.

All measurements from points, lines, surfaces and volumes with different purposes and different diagnostics, must be concatenated and flattened into the one-dimensional coordinate arrays and the measurements are written to file as one-dimensional arrays. In this way the book-keeping "which point belongs to which diagnostics and is neighbor to which other point" may become challening. This is why the "format" field exists.

The format value is a user-defined json value that is ignored by feltor, converted to a styled string and then stored as an attribute to the probes group in the output file. Its purpose is to hold parsing information for the (flat) \( R \), \( Z \), \( P \) arrays for post-processing. For example

"format" : [
{"name" : "x-probe", "pos" : [0,10], "shape" : [10]},
{"name" : "omp", "pos" : [10,1010], "shape" : [10,10,10]}
]

interprets the first ten points in the probes array as a linear "x-probe" line, while the remaining 1000 points belong to a 3d measurement volume called "omp". From this information e.g. array views can be easily created in python:

named_arr = dict()
for f in format:
named_arr[f["name"]] = arr[f["pos"][0]:f["pos"][1]].reshape( f["shape"])
Parameters
jsinput json value
probes_errwhat to do if "probes" is missing from js (overwrites js error mode) If silent, the ProbesParams remain empty if the field is absent
Returns
parsed values
Attention
In MPI all threads will read in the probes. Only the master thread stores the coordinates in ProbesParams.coords[i] the others are empty (and thus also the ProbesParams.get_coords_sizes() function will return zero on non-master ranks)
Here is the call graph for this function: