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

Module for evaluating MHD parameters. More...

#include <stdlib.h>
#include "../ascot5.h"
#include "../print.h"
#include "../error.h"
#include "../boozer.h"
#include "../spline/interp.h"
#include "../B_field.h"
#include "../math.h"
#include "../mhd.h"
#include "mhd_nonstat.h"

Go to the source code of this file.

Functions

int mhd_nonstat_init (mhd_nonstat_data *data, int nmode, int nrho, int ntime, real rhomin, real rhomax, real tmin, real tmax, int *moden, int *modem, real *amplitude_nm, real *omega_nm, real *phase_nm, real *alpha, real *phi)
 Load MHD data.
 
void mhd_nonstat_free (mhd_nonstat_data *data)
 Free allocated resources.
 
void mhd_nonstat_offload (mhd_nonstat_data *data)
 Offload data to the accelerator.
 
a5err mhd_nonstat_eval (real mhd_dmhd[10], real r, real phi, real z, real t, int includemode, boozer_data *boozerdata, mhd_nonstat_data *mhddata, B_field_data *Bdata)
 Evaluate the needed quantities from MHD mode for orbit following.
 
a5err mhd_nonstat_perturbations (real pert_field[7], real r, real phi, real z, real t, int pertonly, int includemode, boozer_data *boozerdata, mhd_nonstat_data *mhddata, B_field_data *Bdata)
 Evaluate mhd perturbed fields Btilde, Etilde and potential Phi for full orbit.
 

Detailed Description

Module for evaluating MHD parameters.

Definition in file mhd_nonstat.c.

Function Documentation

◆ mhd_nonstat_init()

int mhd_nonstat_init ( mhd_nonstat_data * data,
int nmode,
int nrho,
int ntime,
real rhomin,
real rhomax,
real tmin,
real tmax,
int * moden,
int * modem,
real * amplitude_nm,
real * omega_nm,
real * phase_nm,
real * alpha,
real * phi )

Load MHD data.

Parameters
offload_datapointer to data struct
Returns
zero if initialization succeeded.

Definition at line 23 of file mhd_nonstat.c.

◆ mhd_nonstat_free()

void mhd_nonstat_free ( mhd_nonstat_data * data)

Free allocated resources.

Parameters
datapointer to the data struct

Definition at line 86 of file mhd_nonstat.c.

◆ mhd_nonstat_offload()

void mhd_nonstat_offload ( mhd_nonstat_data * data)

Offload data to the accelerator.

Parameters
datapointer to the data struct

Definition at line 103 of file mhd_nonstat.c.

◆ mhd_nonstat_eval()

a5err mhd_nonstat_eval ( real mhd_dmhd[10],
real r,
real phi,
real z,
real t,
int includemode,
boozer_data * boozerdata,
mhd_nonstat_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 include 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 137 of file mhd_nonstat.c.

◆ mhd_nonstat_perturbations()

a5err mhd_nonstat_perturbations ( real pert_field[7],
real r,
real phi,
real z,
real t,
int pertonly,
int includemode,
boozer_data * boozerdata,
mhd_nonstat_data * mhddata,
B_field_data * Bdata )

Evaluate mhd perturbed fields Btilde, Etilde and potential Phi for full orbit.

The values are stored in the given array as

  • pert_field[0] = BtildeR
  • pert_field[1] = BtildePhi
  • pert_field[2] = BtildeZ
  • pert_field[3] = EtildeR
  • pert_field[4] = EtildePhi
  • pert_field[5] = EtildeZ
  • pert_field[6] = Phi

Only the perturbation values for the magnetic field are returned if pertonly=1, otherwise, the total perturbed field is returned. This is done to avoid double evaluation of the magnetic field e.g. in field line tracing. For electric field only the perturbation component is returned always.

Parameters
pert_fieldperturbation field components
rR coordinate [m]
phiphi coordinate [rad]
zz coordinate [m]
ttime coordinate [s]
pertonlyflag whether to return the whole field or only perturbation
includemodemode number to include 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 268 of file mhd_nonstat.c.