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

Plasma interface. More...

#include <stdio.h>
#include <stdlib.h>
#include "ascot5.h"
#include "error.h"
#include "print.h"
#include "plasma.h"
#include "plasma/plasma_1D.h"
#include "plasma/plasma_2D.h"
#include "plasma/plasma_1Dt.h"
#include "plasma/plasma_1DS.h"
#include "consts.h"

Go to the source code of this file.

Functions

void plasma_free (plasma_data *data)
 Free allocated resources.
void plasma_offload (plasma_data *data)
 Offload data to the accelerator.
a5err plasma_eval_temp (real *temp, real rho, real r, real phi, real z, real t, int species, plasma_data *pls_data)
 Evaluate plasma temperature.
a5err plasma_eval_dens (real *dens, real rho, real r, real phi, real z, real t, int species, plasma_data *pls_data)
 Evaluate plasma density.
a5err plasma_eval_densandtemp (real *dens, real *temp, real rho, real r, real phi, real z, real t, plasma_data *pls_data)
 Evaluate plasma density and temperature for all species.
a5err plasma_eval_flow (real *vflow, real rho, real r, real phi, real z, real t, plasma_data *pls_data)
 Evalate plasma flow along the field lines.
int plasma_get_n_species (plasma_data *pls_data)
 Get the number of plasma species.
const real * plasma_get_species_mass (plasma_data *pls_data)
 Get mass of all plasma species.
const real * plasma_get_species_charge (plasma_data *pls_data)
 Get charge of all plasma species.
const int * plasma_get_species_znum (plasma_data *pls_data)
 Get charge number of ion species.
const int * plasma_get_species_anum (plasma_data *pls_data)
 Get atomic mass number of ion species.

Detailed Description

Plasma interface.

This is an interface through which plasma data is initialized and accessed. Reading e.g. from disk is done elsewhere.

To add a new plasma instance, make sure these functions are implemented and called from this interface, and that plasma.h contains enum type for the new instance.

The interface checks which instance given data corresponds to from the "type"-field in plasma_offload_data or plasma_data that is given as an argument, and calls the relevant function for that instance.

Plasma species are referred by their index number: if a function returns e.g. an array containing species densities these are ordered as electrons first by different ion species in no particular order. However, the order is invariant and consistent across all functions.

Maximum number of plasma species is defined by MAX_SPECIES in ascot5.h.

Definition in file plasma.c.

Function Documentation

◆ plasma_free()

void plasma_free ( plasma_data * data)

Free allocated resources.

Parameters
datapointer to the data struct

Definition at line 40 of file plasma.c.

◆ plasma_offload()

void plasma_offload ( plasma_data * data)

Offload data to the accelerator.

Parameters
datapointer to the data struct

Definition at line 62 of file plasma.c.

◆ plasma_eval_temp()

a5err plasma_eval_temp ( real * temp,
real rho,
real r,
real phi,
real z,
real t,
int species,
plasma_data * pls_data )

Evaluate plasma temperature.

This function evaluates the temperature of a given plasma species at the given position.

This is a SIMD function.

Parameters
temparray where evaluated temperature [J] is stored
rhonormalized poloidal flux coordinate
rR-coordinate [m]
phiphi-coordinate [rad]
zz-coordinate [m]
ttime coordinate [s]
speciesindex of plasma species, 1 refers to electrons
pls_datapointer to plasma data struct
Returns
Non-zero a5err value if evaluation failed, zero otherwise

Definition at line 98 of file plasma.c.

◆ plasma_eval_dens()

a5err plasma_eval_dens ( real * dens,
real rho,
real r,
real phi,
real z,
real t,
int species,
plasma_data * pls_data )

Evaluate plasma density.

This function evaluates the density of a plasma species at the given radial coordinate.

This is a SIMD function.

Parameters
densarray where evaluated density will be stored
rhonormalized poloidal flux coordinate
rR-coordinate [m]
phiphi-coordinate [rad]
zz-coordinate [m]
ttime coordinate [s]
speciesindex of plasma species, 1 refers to electrons
pls_datapointer to plasma data struct
Returns
Non-zero a5err value if evaluation failed, zero otherwise

Definition at line 151 of file plasma.c.

◆ plasma_eval_densandtemp()

a5err plasma_eval_densandtemp ( real * dens,
real * temp,
real rho,
real r,
real phi,
real z,
real t,
plasma_data * pls_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.

This is a SIMD function.

Parameters
denspointer where density [m^-3] will be stored
temppointer where temperature [J] will be stored
rhonormalized poloidal flux coordinate
rR-coordinate [m]
phiphi-coordinate [rad]
zz-coordinate [m]
ttime coordinate [s]
pls_datapointer to plasma data struct
Returns
Non-zero a5err value if evaluation failed, zero otherwise

Definition at line 204 of file plasma.c.

◆ plasma_eval_flow()

a5err plasma_eval_flow ( real * vflow,
real rho,
real r,
real phi,
real z,
real t,
plasma_data * pls_data )

Evalate plasma flow along the field lines.

Parameters
vflowpointer where the flow value is stored [m/s]
rhoparticle rho coordinate [1]
rparticle R coordinate [m]
phiparticle toroidal coordinate [rad]
zparticle z coordinate [m]
tparticle time coordinate [s]
pls_datapointer to plasma data

Definition at line 258 of file plasma.c.

◆ plasma_get_n_species()

int plasma_get_n_species ( plasma_data * pls_data)

Get the number of plasma species.

Retrieve the number of how many plasma species the data contains. The number includes electrons.

This is a SIMD function.

Parameters
pls_datapointer to plasma data struct
Returns
The number of plasma species

Definition at line 311 of file plasma.c.

◆ plasma_get_species_mass()

const real * plasma_get_species_mass ( plasma_data * pls_data)

Get mass of all plasma species.

Retrieve species' mass.

This is a SIMD function.

Parameters
pls_datapointer to plasma data struct
Returns
Pointer to array containing the requested mass values [kg]

Definition at line 345 of file plasma.c.

◆ plasma_get_species_charge()

const real * plasma_get_species_charge ( plasma_data * pls_data)

Get charge of all plasma species.

Retrieve species' charge.

This is a SIMD function.

Parameters
pls_datapointer to plasma data struct
Returns
Pointer to array containing the requested charge values [C]

Definition at line 379 of file plasma.c.

◆ plasma_get_species_znum()

const int * plasma_get_species_znum ( plasma_data * pls_data)

Get charge number of ion species.

This is a SIMD function.

Parameters
pls_datapointer to plasma data struct
Returns
Pointer to array containing the charge numbers

Definition at line 411 of file plasma.c.

◆ plasma_get_species_anum()

const int * plasma_get_species_anum ( plasma_data * pls_data)

Get atomic mass number of ion species.

This is a SIMD function.

Parameters
pls_datapointer to plasma data struct
Returns
Pointer to array containing the atomic mass numbers

Definition at line 443 of file plasma.c.