ASCOT5
Loading...
Searching...
No Matches
plasma_1DS.c File Reference

1D spline plasma evaluation functions More...

#include <stdlib.h>
#include <math.h>
#include <float.h>
#include "../ascot5.h"
#include "../print.h"
#include "../error.h"
#include "../consts.h"
#include "../spline/interp.h"
#include "plasma_1DS.h"

Go to the source code of this file.

Macros

#define PLASMA_1DS_NONEG   1
 Flag to determine method to prevent negative values in interpolation.
 
#define PLASMA_1DS_LOG   1
 
#define PLASMA_1DS_SQRT   2
 

Functions

int plasma_1DS_init (plasma_1DS_data *data, int nrho, real rhomin, real rhomax, int nion, int *anum, int *znum, real *mass, real *charge, real *Te, real *Ti, real *ne, real *ni)
 Initialize 1DS plasma data and check inputs.
 
void plasma_1DS_free (plasma_1DS_data *data)
 Free allocated resources.
 
void plasma_1DS_offload (plasma_1DS_data *data)
 Offload data to the accelerator.
 
a5err plasma_1DS_eval_temp (real *temp, real rho, int species, plasma_1DS_data *plasma_data)
 Evaluate plasma temperature.
 
a5err plasma_1DS_eval_dens (real *dens, real rho, int species, plasma_1DS_data *plasma_data)
 Evaluate plasma density.
 
a5err plasma_1DS_eval_densandtemp (real *dens, real *temp, real rho, plasma_1DS_data *plasma_data)
 Evaluate plasma density and temperature for all species.
 

Detailed Description

1D spline plasma evaluation functions

Definition in file plasma_1DS.c.

Macro Definition Documentation

◆ PLASMA_1DS_NONEG

#define PLASMA_1DS_NONEG   1

Flag to determine method to prevent negative values in interpolation.

It is possible that interpolating function f(x) with splines yield negative values which would be unphysical if f is density or temperature. To prevent this, one can either interpolate sqrt(f(x)) or log(f(x)) instead because inverse of these functions are always positive.

Set this parameter to

  • 0 : Do nothing
  • 1 : Take logarithm before interpolating
  • 2 : Take square root before interpolating

Definition at line 28 of file plasma_1DS.c.

◆ PLASMA_1DS_LOG

#define PLASMA_1DS_LOG   1

Logarithm flag

Definition at line 31 of file plasma_1DS.c.

◆ PLASMA_1DS_SQRT

#define PLASMA_1DS_SQRT   2

Square root flag

Definition at line 34 of file plasma_1DS.c.

Function Documentation

◆ plasma_1DS_init()

int plasma_1DS_init ( plasma_1DS_data * data,
int nrho,
real rhomin,
real rhomax,
int nion,
int * anum,
int * znum,
real * mass,
real * charge,
real * Te,
real * Ti,
real * ne,
real * ni )

Initialize 1DS plasma data and check inputs.

Parameters
datapointer to the data struct
Returns
zero if initialization succeeded

Definition at line 43 of file plasma_1DS.c.

◆ plasma_1DS_free()

void plasma_1DS_free ( plasma_1DS_data * data)

Free allocated resources.

Parameters
datapointer to the data struct

Definition at line 189 of file plasma_1DS.c.

◆ plasma_1DS_offload()

void plasma_1DS_offload ( plasma_1DS_data * data)

Offload data to the accelerator.

Parameters
datapointer to the data struct

Definition at line 205 of file plasma_1DS.c.

◆ plasma_1DS_eval_temp()

a5err plasma_1DS_eval_temp ( real * temp,
real rho,
int species,
plasma_1DS_data * plasma_data )

Evaluate plasma temperature.

Parameters
temptemperature value will be stored in temp[0]
rhoradial coordinate
speciesindex of plasma species
plasma_datapointer to plasma data struct
Returns
zero if evaluation succeeded

Definition at line 228 of file plasma_1DS.c.

◆ plasma_1DS_eval_dens()

a5err plasma_1DS_eval_dens ( real * dens,
real rho,
int species,
plasma_1DS_data * plasma_data )

Evaluate plasma density.

Parameters
densdensity value will be stored in dens[0]
rhoradial coordinate
speciesindex of plasma species
plasma_datapointer to plasma data struct
Returns
zero if evaluation succeeded

Definition at line 259 of file plasma_1DS.c.

◆ plasma_1DS_eval_densandtemp()

a5err plasma_1DS_eval_densandtemp ( real * dens,
real * temp,
real rho,
plasma_1DS_data * plasma_data )

Evaluate plasma density and temperature for all species.

This function evaluates the density and temperature of all plasma species at the given radial coordinate using spline interpolation.

Parameters
denspointer to where interpolated densities [m^-3] are stored
temppointer to where interpolated temperatures [J] are stored
rhoradial coordinate
plasma_datapointer to plasma data struct
Returns
zero if evaluation succeeded

Definition at line 294 of file plasma_1DS.c.