ASCOT5
Loading...
Searching...
No Matches
Functions
B_TC.c File Reference

Trivial Cartesian magnetic field. More...

#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include "../ascot5.h"
#include "../error.h"
#include "../print.h"
#include "B_TC.h"

Go to the source code of this file.

Functions

int B_TC_init_offload (B_TC_offload_data *offload_data, real **offload_array)
 Initialize magnetic field offload data.
 
void B_TC_free_offload (B_TC_offload_data *offload_data, real **offload_array)
 Free offload array.
 
void B_TC_init (B_TC_data *Bdata, B_TC_offload_data *offload_data, real *offload_array)
 Initialize magnetic field data struct on target.
 
a5err B_TC_eval_psi (real *psi, real r, real phi, real z, B_TC_data *Bdata)
 Evaluate poloidal flux psi.
 
a5err B_TC_eval_psi_dpsi (real psi_dpsi[4], real r, real phi, real z, B_TC_data *Bdata)
 Evaluate poloidal flux psi and its derivatives.
 
a5err B_TC_eval_rho_drho (real rho_drho[4], real r, real phi, real z, B_TC_data *Bdata)
 Evaluate normalized poloidal flux rho and its derivatives.
 
a5err B_TC_eval_B (real B[3], real r, real phi, real z, B_TC_data *Bdata)
 Evaluate magnetic field.
 
a5err B_TC_eval_B_dB (real B_dB[12], real r, real phi, real z, B_TC_data *Bdata)
 Evaluate magnetic field and its derivatives.
 
a5err B_TC_get_axis_rz (real rz[2], B_TC_data *Bdata)
 Return magnetic axis R-coordinate.
 

Detailed Description

Trivial Cartesian magnetic field.

Magnetic field whose Cartesian components $(B_x, B_y, B_z)$ have user-defined values at the origo $(R,z) = (0,0)$, and constant Jacobian

\[
\begin{bmatrix}
\frac{\partial B_x}{\partial x}, &\frac{\partial B_x}{\partial y},
&\frac{\partial B_x}{\partial z} \\
\frac{\partial B_y}{\partial x}, &\frac{\partial B_y}{\partial y},
&\frac{\partial B_y}{\partial z} \\
\frac{\partial B_z}{\partial x}, &\frac{\partial B_z}{\partial y},
&\frac{\partial B_z}{\partial z}
\end{bmatrix}
\]

This magnetic field is intended to serve debugging and testing purposes. Other values $\psi$, $\rho$ and magnetic axis coordinates have fixed user-defined values.

Definition in file B_TC.c.

Function Documentation

◆ B_TC_init_offload()

int B_TC_init_offload ( B_TC_offload_data * offload_data,
real ** offload_array )

Initialize magnetic field offload data.

The offload data struct is very simple and contains only the necessary fields which are all initialized when the data is read (except B_TC.offload_array_length). The offload array is not required at all. Therefore, this function only sets the offload_array_length to zero, assigns a NULL pointer to offload_array, and prints sanity checks so that user may verify that data was initialized succesfully.

Parameters
offload_datapointer to offload data struct
offload_arraypointer to offload array
Returns
zero to indicate success

Definition at line 47 of file B_TC.c.

◆ B_TC_free_offload()

void B_TC_free_offload ( B_TC_offload_data * offload_data,
real ** offload_array )

Free offload array.

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

Definition at line 78 of file B_TC.c.

◆ B_TC_init()

void B_TC_init ( B_TC_data * Bdata,
B_TC_offload_data * offload_data,
real * offload_array )

Initialize magnetic field data struct on target.

Parameters
Bdatapointer to data struct on target
offload_datapointer to offload data struct
offload_arrayoffload array

Definition at line 91 of file B_TC.c.

◆ B_TC_eval_psi()

a5err B_TC_eval_psi ( real * psi,
real r,
real phi,
real z,
B_TC_data * Bdata )

Evaluate poloidal flux psi.

Parameters
psipointer where psi [V*s*m^-1] value will be stored
rR coordinate [m]
phiphi coordinate [rad]
zz coordinate [m]
Bdatapointer to magnetic field data struct
Returns
zero to indicate success

Definition at line 114 of file B_TC.c.

◆ B_TC_eval_psi_dpsi()

a5err B_TC_eval_psi_dpsi ( real psi_dpsi[4],
real r,
real phi,
real z,
B_TC_data * Bdata )

Evaluate poloidal flux psi and its derivatives.

Parameters
psi_dpsipointer for storing psi [V*s*m^-1] and its derivatives
rR coordinate [m]
phiphi coordinate [rad]
zz coordinate [m]
Bdatapointer to magnetic field data struct
Returns
zero to indicate success

Definition at line 132 of file B_TC.c.

◆ B_TC_eval_rho_drho()

a5err B_TC_eval_rho_drho ( real rho_drho[4],
real r,
real phi,
real z,
B_TC_data * Bdata )

Evaluate normalized poloidal flux rho and its derivatives.

Parameters
rho_drhopointer where rho and its derivatives will be stored
rR coordinate [m]
phiphi coordinate [rad]
zz coordinate [m]
Bdatapointer to magnetic field data struct
Returns
zero to indicate success

Definition at line 153 of file B_TC.c.

◆ B_TC_eval_B()

a5err B_TC_eval_B ( real B[3],
real r,
real phi,
real z,
B_TC_data * Bdata )

Evaluate magnetic field.

Parameters
Bpointer to array where magnetic field values are stored
rR coordinate [m]
phiphi coordinate [rad]
zz coordinate [m]
Bdatapointer to magnetic field data struct
Returns
zero to indicate success

Definition at line 175 of file B_TC.c.

◆ B_TC_eval_B_dB()

a5err B_TC_eval_B_dB ( real B_dB[12],
real r,
real phi,
real z,
B_TC_data * Bdata )

Evaluate magnetic field and its derivatives.

Parameters
B_dBpointer to array where the field and its derivatives are stored
rR coordinate [m]
phiphi coordinate [rad]
zz coordinate [m]
Bdatapointer to magnetic field data struct
Returns
zero to indicate success

Definition at line 207 of file B_TC.c.

◆ B_TC_get_axis_rz()

a5err B_TC_get_axis_rz ( real rz[2],
B_TC_data * Bdata )

Return magnetic axis R-coordinate.

Parameters
rzpointer where axis R and z [m] values will be stored
Bdatapointer to magnetic field data struct
Returns
Zero a5err value as this function can't fail.

Definition at line 246 of file B_TC.c.