ASCOT5
Loading...
Searching...
No Matches
Data Structures | Macros | Typedefs | Enumerations | Functions | Variables
mhd.h File Reference

Header file for mhd.c. More...

#include "ascot5.h"
#include "error.h"
#include "B_field.h"
#include "boozer.h"
#include "mhd/mhd_stat.h"
#include "mhd/mhd_nonstat.h"

Go to the source code of this file.

Data Structures

struct  mhd_offload_data
 MHD offload data. More...
 
struct  mhd_data
 MHD simulation data. More...
 

Macros

#define MHD_INCLUDE_ALL   -1
 includemode parameter to include all modes (default)
 

Typedefs

typedef enum mhd_type mhd_type
 MHD input types.
 

Enumerations

enum  mhd_type { mhd_type_stat , mhd_type_nonstat }
 MHD input types. More...
 

Functions

int mhd_init_offload (mhd_offload_data *offload_data, real **offload_array)
 Load MHD data and prepare parameters.
 
void mhd_free_offload (mhd_offload_data *offload_data, real **offload_array)
 Free offload array and reset parameters.
 
int mhd_init (mhd_data *data, mhd_offload_data *offload_data, real *offload_array)
 Initialize MHD data struct on target.
 
a5err mhd_eval (real mhd_dmhd[10], real r, real phi, real z, real t, int includemode, boozer_data *boozerdata, mhd_data *mhddata, B_field_data *Bdata)
 Evaluate the needed quantities from MHD mode for orbit following.
 
 DECLARE_TARGET_SIMD_UNIFORM (boozerdata, mhddata, Bdata, pertonly, includemode) a5err mhd_perturbations(real pert_field[7]
 
int mhd_get_n_modes (mhd_data *mhddata)
 Return number of modes.
 
const int * mhd_get_nmode (mhd_data *mhddata)
 Return mode toroidal numbers.
 
const int * mhd_get_mmode (mhd_data *mhddata)
 Return mode poloidal numbers.
 
const realmhd_get_amplitude (mhd_data *mhddata)
 Return mode amplitudes.
 
const realmhd_get_frequency (mhd_data *mhddata)
 Return mode frequencies.
 
const realmhd_get_phase (mhd_data *mhddata)
 Return mode phases.
 

Variables

real r
 
real real phi
 
real real real z
 
real real real real t
 
real real real real int pertonly
 
real real real real int int includemode
 
real real real real int int boozer_databoozerdata
 
real real real real int int boozer_data mhd_datamhddata
 
real real real real int int boozer_data mhd_data B_field_dataBdata
 

Detailed Description

Header file for mhd.c.

Contains a list declaring all mhd_types, and declaration of mhd_offload_data and mhd_data structs.

Definition in file mhd.h.

Macro Definition Documentation

◆ MHD_INCLUDE_ALL

#define MHD_INCLUDE_ALL   -1

includemode parameter to include all modes (default)

Definition at line 19 of file mhd.h.

Typedef Documentation

◆ mhd_type

typedef enum mhd_type mhd_type

MHD input types.

MHD types are used in the MHD interface (mhd.c) to direct function calls to correct MHD instances. Each MHD instance must have a corresponding type.

Enumeration Type Documentation

◆ mhd_type

enum mhd_type

MHD input types.

MHD types are used in the MHD interface (mhd.c) to direct function calls to correct MHD instances. Each MHD instance must have a corresponding type.

Enumerator
mhd_type_stat 

MHD where mode amplitude does not depend on time

mhd_type_nonstat 

MHD where mode amplitude depends on time

Definition at line 27 of file mhd.h.

Function Documentation

◆ mhd_init_offload()

int mhd_init_offload ( mhd_offload_data * offload_data,
real ** offload_array )

Load MHD data and prepare parameters.

This function fills the relevant MHD offload struct with parameters and allocates and fills the offload array.

The offload data has to have a type when this function is called as it should be set when the offload data is constructed from inputs.

This function is host only.

Parameters
offload_datapointer to offload data struct
offload_arraypointer to pointer to offload array
Returns
zero if initialization succeeded

Definition at line 45 of file mhd.c.

◆ mhd_free_offload()

void mhd_free_offload ( mhd_offload_data * offload_data,
real ** offload_array )

Free offload array and reset parameters.

This function deallocates the offload_array.

This function is host only.

Parameters
offload_datapointer to offload data struct
offload_arraypointer to pointer to offload array

Definition at line 90 of file mhd.c.

◆ mhd_init()

int mhd_init ( mhd_data * mhddata,
mhd_offload_data * offload_data,
real * offload_array )

Initialize MHD data struct on target.

This function copies the electric field parameters from the offload struct to the struct on target and sets the MHD data pointers to correct offsets in the offload array.

This function returns error if the offload data has not been initialized. The instances themselves should not return an error since all they do is assign pointers and values.

Parameters
mhddatapointer to data struct on target
offload_datapointer to offload data struct
offload_arraythe offload array
Returns
Non-zero integer if offload was not initialized beforehand

Definition at line 121 of file mhd.c.

◆ mhd_eval()

a5err mhd_eval ( real mhd_dmhd[10],
real r,
real phi,
real z,
real t,
int includemode,
boozer_data * boozerdata,
mhd_data * mhddata,
B_field_data * Bdata )

Evaluate the needed quantities from MHD mode for orbit following.

The quantities to be evaluated are alpha, phi, grad alpha, grad phi, partial t alpha, partial t phi

The values are stored in the given array as:

  • mhd_dmhd[0] = alpha
  • mhd_dmhd[1] = dalpha/dt
  • mhd_dmhd[2] = grad alpha, r component
  • mhd_dmhd[3] = grad alpha, phi component
  • mhd_dmhd[4] = grad alpha, z component
  • mhd_dmhd[5] = phi
  • mhd_dmhd[6] = dphi/dt
  • mhd_dmhd[7] = grad phi, r component
  • mhd_dmhd[8] = grad phi, phi component
  • mhd_dmhd[9] = grad phi, z component
Parameters
mhd_dmhd
rR coordinate [m]
phiphi coordinate [rad]
zz coordinate [m]
ttime coordinate [s]
includemodemode number to be included or MHD_INCLUDE_ALL
boozerdatapointer to boozer data
mhddatapointer to mhd data
Bdatapointer to magnetic field data
Returns
Non-zero a5err value if evaluation failed, zero otherwise

Definition at line 178 of file mhd.c.

◆ mhd_get_n_modes()

int mhd_get_n_modes ( mhd_data * mhddata)

Return number of modes.

Parameters
mhddatapointer to mhd data
Returns
number of modes

Definition at line 270 of file mhd.c.

◆ mhd_get_nmode()

const int * mhd_get_nmode ( mhd_data * mhddata)

Return mode toroidal numbers.

Parameters
mhddatapointer to mhd data
Returns
mode n numbers

Definition at line 290 of file mhd.c.

◆ mhd_get_mmode()

const int * mhd_get_mmode ( mhd_data * mhddata)

Return mode poloidal numbers.

Parameters
mhddatapointer to mhd data
Returns
mode m numbers

Definition at line 310 of file mhd.c.

◆ mhd_get_amplitude()

const real * mhd_get_amplitude ( mhd_data * mhddata)

Return mode amplitudes.

Parameters
mhddatapointer to mhd data
Returns
mode amplitudes

Definition at line 330 of file mhd.c.

◆ mhd_get_frequency()

const real * mhd_get_frequency ( mhd_data * mhddata)

Return mode frequencies.

Parameters
mhddatapointer to mhd data
Returns
mode omega

Definition at line 350 of file mhd.c.

◆ mhd_get_phase()

const real * mhd_get_phase ( mhd_data * mhddata)

Return mode phases.

Parameters
mhddatapointer to mhd data
Returns
mode phases

Definition at line 370 of file mhd.c.

Variable Documentation

◆ r

real r

Definition at line 76 of file mhd.h.

◆ phi

real real phi

Definition at line 76 of file mhd.h.

◆ z

Definition at line 76 of file mhd.h.

◆ t

Definition at line 77 of file mhd.h.

◆ pertonly

real real real real int pertonly

Definition at line 77 of file mhd.h.

◆ includemode

real real real real int int includemode

Definition at line 77 of file mhd.h.

◆ boozerdata

real real real real int int boozer_data* boozerdata

Definition at line 78 of file mhd.h.

◆ mhddata

real real real real int int boozer_data mhd_data* mhddata

Definition at line 78 of file mhd.h.

◆ Bdata

Definition at line 79 of file mhd.h.