RFOF - RF Library for Orbit Following Codes
RFOF - Radio Frequency Monte Carlo Library for Orbit Following Codes

Developed for the EU-ITM, Integrated modelling project 5, ACT4-2010 and ACT4-2011.

Author:
Thomas Johnson, Antti Salmi, Gyorgy Steinbrecher



What is RFOF?

The RFOF is a library built to handle the interaction between charged particles and RF-wave fields in guiding centre orbit following Monte Carlo codes. The library is based around the work of L.-G. Eriksson and M. Schneider [L.-G. Eriksson and M. Schneider, Phys. Plasmas 12, 072524 (2005), http://pop.aip.org/resource/1/phpaen/v12/i7/p072524_s1].



Code status:

  • The code can find the resonaces position for non-accelerated schemes; i.e. judge if particle is in resonance and predict the time and position of future and past resonance. For time-acceleration the time derivatives are has to be treated over orbit time rather then simulation time and special care has to be taken when the rate of time-acceleration is changed.
  • The code can give RF Monte Carlo kicks, both for accelerated and non-accelerated orbit integration. The accelerated scheme is still not properly tested. The non-accelerated scheme the model has to be validated.
  • The interpolation of the RF wave field is still not implemented; as a temporary solution the wave fiel is taken from coordiantes with index (1,1).
  • The normalisation of the radial electric has been implemented and initial tests seems encouraging. More tests are required and the renormalisation proceedure may require optimization.
  • The MPI communication needed for merging the power absorption information between MPI nodes has been implemented and partially tested.

The quantities in this code are in SI unit with only one exception, $ I_\perp $, which is in [MeV] to make numerical derivatives in the Monte Carlo drift more accurate.

RFOF can run with MPI. When doing so RFOF assumes that all nodes participates in the calculations (by using mpi_reduce and mpi_bcast). Also, it is assumed that there is a node numbered 0.




Overview of source code:

There is a test-driver for RFOF:

RFOF physics and control routines:

RFOF data-objects (data-structures with interpolation):

RFOF diagnostics library:

RFOF numerics library, constants and parameters:




How to couple your orbit following code to RFOF

  1. Generate the data structure needed in RFOF. These should not be global and therefore your code has to keep track of them, i.e. keep your pointers until data is deallcocated. RFOF provides constructors and destructors for these data structures:

    • THE MARKERS: The marker structure are set in the subroutine set_marker_pointers in the module RFOF_markers. The markers data, e.g. v-parallel and psi, are all stored as pointers to your internal markers; thus both your code and RFOF access the same memory. Modifications of the marker data in RFOF are therefore immediately seen in your code and vice versa. The marker data should thus be provides as Fortran TARGETs for all marker variables.

    • THE RESONANCE MEMORY: In order to evaluate the wave-particle interaction strength you need to know the time derivative of the cyclotron frequency of the marker, thus the short term time-history of the particle needs to be stored. This is the purpose of the "resonance-memory". This memory is contructed by the subroutine constructor_rf_resonance_memory_matrix in the module RFOF_resonance_memory. NOTE: that this memory is specific for each particle and has to be reset every time you switch to tracing a new particle. To reset the memory use the subroutine reset_rf_resonance_memory_matrix in the module RFOF_resonance_memory.

    • THE RF WAVE FIELD: The RF wave field is handled entirely inside RFOF. The contructor is dummy_rf_wave_field in the module RFOF_resonance_memory. At the moment this constructor generates a dummy field with constant components over the entire plasma.

    • THE RF-INTERACTION DIAGNOSTICS: The diagnostics is handled entirely inside RFOF. The contructor is contructor_RFOF_cumlative_diagnostics in the module RFOF_diagnostics.

  2. Set global parameters in RFOF. Do this by calling routine initialise_RFOF_parameters , in the RFOF_parameters module, from the orbit code. This routine will set the (R,Z) bounding box inside which the particles are expected to be located.

  3. In case you wish to have an RF-operator that pushes particles in real space as well as in velocity space, then you also need to write a subroutine to provide RFOF with your magnetic field data. The subroutine should be called local_magnetic_field_interface_to_RFOF and the interface for this routine is given below.

  4. Now we are ready to implement the actual call to RFOF that will apply RF "kicks" to the markers. The subroutine to call from your orbit code is RFOF_master in the RFOF_main module. This routine should be called after every time step performed by your orbit solver. What RFOF_master does:

    • The routine will first check is the particle is in resonance with any of the wave-modes in your RF wave field (resonance here mean "close enough to the resonance"). If it is in resonance then it will give the particle RF "kicks" for each resonant wave mode. If the particle is not in resonance it will check if the particle has crossed any resonance without recieving a kick. If so, an error flag is raised, and an estimate for the time at which the particle crossed the resonance is returned. It is suggest the you refine and redo your time step such that the new time step ends at the estimated time of the resonance. In case the step is successful, then the RFOF_master will return the time at which the next resonance should occure. You may then use this time to decide the length of the folloing time step.

  5. Every time you switch from tracing one marker to the next you are have to both set the marker pointers (see above) and to reset the resonance memory as described (see above).

  6. To make sure that the RF power absorbed in RFOF the wave field strength has to be renormalised during the simulation. The is done using the routine update_efield_normalisation in the module RFOF_Efield_update. The call frequency to this routine is not trivial to determine. In principle it should be given by the time scale on which the absorption changes.

  7. At the end of the program all allocated memory should be deallocated using the routine RFOF_destructor in the module RFOF_main.




Interface for the subroutine providing the magnetic field

    interface
       subroutine local_magnetic_field_interface_to_RFOF(R,phi,z, &
            psi,theta,Bmod,F,psi_Estatic,dBmod_dpsi,dF_dpsi,dBmod_dtheta,dF_dtheta)
         !> Major radius
         real(8), intent(in)  :: R
         !> Toroidal angle
         real(8), intent(in)  :: phi
         !> Vertical coordinate
         real(8), intent(in)  :: z
         !> Poloidal flux function
         real(8), intent(out) :: psi
         !> Poloidal angle
         real(8), intent(out) :: theta
         !> Modulus of the magnetic field
         real(8), intent(out) :: Bmod
         !> $ F = R B_\phi $, where $ B_\phi $ is toroidal magnetic field
         real(8), intent(out) :: F
         !> Electrostatic potential
         real(8), intent(out) :: psi_Estatic
	 !> Derivative of Bmod w.r.t psi (OPTIONAL)
         real(8), intent(out) :: dBmod_dpsi
	 !> Derivative of F w.r.t psi (OPTIONAL)
         real(8), intent(out) :: dF_dpsi
	 !> Derivative of Bmod w.r.t psi (OPTIONAL)
         real(8), intent(out) :: dBmod_dtheta
	 !> Derivative of F w.r.t theta (OPTIONAL)
         real(8), intent(out) :: dF_dtheta
       end subroutine local_magnetic_field_interface_to_RFOF
    end interface