ASCOT5
Loading...
Searching...
No Matches
rfof.h File Reference

Contains the functions to be called from the simulation loop when using ICRH. More...

#include <stdlib.h>
#include "ascot5.h"

Go to the source code of this file.

Data Structures

struct  rfof_marker
 Reusable struct for storing marker specific data during the simulation loop. More...
 
struct  rfof_data
 RFOF simulation input data. More...
 

Typedefs

typedef struct rfof_marker rfof_marker
 Reusable struct for storing marker specific data during the simulation loop.
 

Functions

void rfof_init (rfof_data *rfof)
 Initialise input data.
 
void rfof_free (rfof_data *rfof)
 Deallocates the rfof_input_param struct on the fortran side.
 
void rfof_set_marker_manually (rfof_marker *rfof_mrk, int *id, real *weight, real *R, real *phi, real *z, real *psi, real *charge, real *mass, real *Ekin, real *vnorm, real *mu, real *Pphi, real *vpar, real *vperp, real *gyrof, real *vdriftRho, real *acceleration, int *is_accelerated, int *is_already_allocated)
 Explicitly set the coordinates in a marker struct.
 
void rfof_set_up (rfof_marker *rfof_mrk, rfof_data *rfof_data)
 Initialises resonance history, diagnostics, and the marker struct.
 
void rfof_tear_down (rfof_marker *rfof_mrk)
 Deallocates the data structs used by the RFOF marker simulation data.
 
void rfof_clear_history (rfof_marker *rfof_mrk, int imrk)
 Clears resonance history of an RFOF marker.
 
void rfof_resonance_check_and_kick_gc (particle_simd_gc *p, real *hin, real *hout_rfof, rfof_marker *rfof_mrk, rfof_data *rfof_data, B_field_data *Bdata)
 Check if the marker is in resonance and apply kick.
 
void rfof_eval_rf_wave (real *e_plus_real, real *e_minus_real, real *e_plus_imag, real *e_minus_imag, real R, real z, rfof_data *rfof)
 Calculate the local E+ and E- values of the ICRH field.
 
void rfof_eval_resonance_function (real *omega_res, int *nharm, rfof_marker *rfof_mrk, rfof_data *rfof)
 Evaluate the value of resonance function (zero at the resonance)
 

Detailed Description

Contains the functions to be called from the simulation loop when using ICRH.

Definition in file rfof.h.

Typedef Documentation

◆ rfof_marker

typedef struct rfof_marker rfof_marker

Reusable struct for storing marker specific data during the simulation loop.

The data in this struct is altered during the simulation. Only pointers are stored as the actual data is stored on the Fortran side.

Function Documentation

◆ rfof_init()

void rfof_init ( rfof_data * rfof_data)

Initialise input data.

Reads the ICRH (RFOF) inputs (xml, xsd, ASCII) and initialises the wave field.

Parameters
rfof_datapointer to the RFOF data structure

Definition at line 83 of file rfof.c.

◆ rfof_free()

void rfof_free ( rfof_data * rfof)

Deallocates the rfof_input_param struct on the fortran side.

There exists only one copy of this struct and therefore it is to be deallocated in the simulate.c after the loop is completed.

Definition at line 100 of file rfof.c.

◆ rfof_set_marker_manually()

void rfof_set_marker_manually ( rfof_marker * rfof_mrk,
int * id,
real * weight,
real * R,
real * phi,
real * z,
real * psi,
real * charge,
real * mass,
real * Ekin,
real * vnorm,
real * mu,
real * Pphi,
real * vpar,
real * vperp,
real * gyrof,
real * vdriftRho,
real * acc,
int * is_accelerated,
int * is_already_allocated )

Explicitly set the coordinates in a marker struct.

This routine is only used for testing and in libascot. Only the first marker in the NSIMD array of rfof_marker is manipulated.

Parameters
rfof_mrkpointer to the RFOF marker data
idmarker identifier
weightmarker weight [prt/s]
Rmajor radius [m]
phitoroidal angle [rad]
zz coordinate [m]
psipoloidal flux [Wb/rad]
chargeparticle charge [C]
massparticle mass [kg]
Ekinkinetic energy [J]
vnormvelocity [m/s]
mumagnetic moment [J/T]
Pphicanonical toroidal angular momentum [kg*m/s]
vparperpendicular velocity [m/s]
vperpparallel velocity [m/s]
gyrofgyrofrequency [rad/s]
vdriftRhodrift velocity in radial direction
accaccleration factor, should be 1.0 always
is_acceleratedflag indicating whether acceleration is used, false always
is_already_allocatedflag whether to allocate a new marker struct, should be false always

Definition at line 357 of file rfof.c.

◆ rfof_set_up()

void rfof_set_up ( rfof_marker * rfof_mrk,
rfof_data * rfof )

Initialises resonance history, diagnostics, and the marker struct.

This function is to be called before the simulation loop.

Parameters
rfof_mrkpointer to the local RFOF marker data
rfofpointer to the shared RFOF data

Definition at line 116 of file rfof.c.

◆ rfof_tear_down()

void rfof_tear_down ( rfof_marker * rfof_mrk)

Deallocates the data structs used by the RFOF marker simulation data.

This function is to be called after the simulation loop.

Parameters
rfof_mrkpointer to the RFOF marker simulation data

Definition at line 153 of file rfof.c.

◆ rfof_clear_history()

void rfof_clear_history ( rfof_marker * rfof_mrk,
int i )

Clears resonance history of an RFOF marker.

History should be cleared whenever a marker finishes simulation. The new marker cannot receive ICRH kicks during the first two time steps as its resonance history must have at least two data points stored to estimate the resonance location.

Parameters
rfof_mrkpointer to the RFOF marker simulation data
iindex in the NSIMD array for the marker whose history is cleared

Definition at line 177 of file rfof.c.

◆ rfof_resonance_check_and_kick_gc()

void rfof_resonance_check_and_kick_gc ( particle_simd_gc * p,
real * hin,
real * hout,
rfof_marker * rfof_mrk,
rfof_data * rfof_data,
B_field_data * Bdata )

Check if the marker is in resonance and apply kick.

  1. Updates the fields of the rfof_marker based on the given input ascot_marker.
  2. Calls the "kick" function, which a) Checks resonance condition and b) if in resonance, kicks marker and updates velocity of the rfof marker and consequently also ascot marker (as only pointers are passed when creating the rfof marker).

The time step can fail if the marker overshoots the resonance.

Parameters
ppointer to marker simulation struct
hincurrent time step
houtsuggestion for the next time step with negative sign indicating a failed step
rfof_mrkpointer to the rfof marker simulation struct
rfof_datapointer to the shared rfof data
Bdatapointer to the magnetic field data needed to evaluate psi

Definition at line 206 of file rfof.c.

◆ rfof_eval_rf_wave()

void rfof_eval_rf_wave ( real * e_plus_real,
real * e_minus_real,
real * e_plus_imag,
real * e_minus_imag,
real R,
real z,
rfof_data * rfof )

Calculate the local E+ and E- values of the ICRH field.

The definitions of E+ and E- sometimes differ. In this context, E+ = E_LH * (cos(phi) + i sin(phi)), where E_LH is the magnitude of the left-hand polarised (rotating) component and phi is its phase. That is, E_LH and phi are real. Often, however, E_LH is called E+ which creates confusion. Afterall, in this function, E+ is a complex number.

Parameters
e_plus_realRe("E+"") component of the local wave field @param e_minus_real Re("E-"") component of the local wave field
e_plus_imagIm("E+"") component of the local wave field @param e_minus_imag Im("E-"") component of the local wave field
Rmajor radius coordinate [m]
zz-coordinate [m]
rfofpointer to the RFOF data structure

Definition at line 392 of file rfof.c.

◆ rfof_eval_resonance_function()

void rfof_eval_resonance_function ( real * omega_res,
int * nharm,
rfof_marker * rfof_mrk,
rfof_data * rfof )

Evaluate the value of resonance function (zero at the resonance)

This function finds the closest resonance and in addition to evaluating the resonance function it also returns the corresponding harmonic value.

The resonance is evaluated for the first marker in the NSIMD array in rfof_marker fields.

Parameters
cptr_markervoid pointer to the rfof_marker
rfof_datapointer to the RFOF data structure
omega_resevaluated value of the resonance function
nharmthe number of the closest harmonic found

Definition at line 423 of file rfof.c.