The Thomson scattering unit including ray tracing and deflection is a detector driven unit, meaning that the outer loop is over all Thomson detectors specified. Since for each detector there is only one associated laser, the code checks whether the associated laser is currently active and if it is, this laser/detector pair is being processed. The inclusion of ray deflection in a Thomson scattering code presents some computational challenges. The main difficulty that arises is that the Thomson scattering interaction region (IR) from where the spectra will be accumulated, is not known beforehand, but must be established in a first pass through the ray tracing procedure. For each laser/detector pair, the ray tracing Thomson scattering code consists of two main sections during each time step of the simulation: 1) determination of the interaction region and 2) assembling the Thomson spectra. Both sections require a complete laser/detector ray tracing procedure over the entire set of both laser and detector rays. In what follows we will describe each section separately.
Per definition, the interaction region (IR) consists of those cells of the domain that will have both: 1) incoming laser (I, from incident) rays and 2) emerging detector (S, from scattered) rays. Each of these so called IR cells contribute to the final spectrum. In order to find all the IR cells for a specific laser/detector pair, the complete set of rays for both the laser and the detector are launched towards the domain and the cells on which both sets intersect will be identified as IR cells. Both laser and detector rays are launched statistically from their corresponding lenses and towards their target areas. Ray creation, specification and storage follow much the same way as presented for the EnergyDeposition unit in chapter 18.4.7. Setup of laser/detector beams and pulses are also done as presented in chapters 18.4.6 and 18.4.5. If no Ray deflection is specified and both laser and detector beams are cylindrical in shape, the resulting set of IR cells are contained in a region resembling a Steiner solid, i.e. the space obtained from two intersecting cylinders. Ray deflection usually broadens up the IR region and there can be even cases in which the set of IR cells within the IR region is not connected, for example if the number of rays used for the laser and the detector is very low. The user must therefore make sure that the resulting IR region is dense by launching enough rays from the laser and the detector. On the other hand, as we will see below, assembling the Thomson spectrum from the set of each IR cell's laser (I) and detector (S) rays is a multiplicative task in which each I-ray is allowed to scatter into all S-rays. There is hence a delicate balance as to how many rays are lauched and the size of the intended IR region for computations to remain manageable.
The identification of each IR cell is done by introducing extra two counting cell variables ICNT (for laser)
and SCNT (for detector) into the UNK array (see chapter 6.1). ICNT and SCNT are
incremented by +1 whenever a laser or detector ray hits the cell. After the complete sets of laser and detector
rays have been processed through the domain, the IR cells are those for which both ICNT and SCNT are  0.
Once an IR cell has been identified, its ICNT value is overwritten by its unique tag, which will serve
both as a counting index as well as identifying this cell as an IR cell (for example, for visualization purposes)
in the domain.
 0.
Once an IR cell has been identified, its ICNT value is overwritten by its unique tag, which will serve
both as a counting index as well as identifying this cell as an IR cell (for example, for visualization purposes)
in the domain.
During identification of the IR cells, the laser rays will not be allowed to deposit energy in the domain, as this will change subsequent ray tracing for the same laser/detector pair as well as other still to be processed laser/detector pairs. Also power loss by both laser and detector rays is not done at this stage.
Using maximum sized array dimension information from the interaction region finding step, storage arrays are allocated that will hold detailed info about each I-ray and S-ray for each IR cell. The complete set of laser and detector rays for the current laser/detector pair is retraced through the domain, this time all the laser and detector ray info (like direction components of each ray, current power and distance travelled inside each IR cell) as well each IR cell info (like number electron density, electron and ion temperature, etc.) is stored for subsequent assembly of the spectra. This time each ray is allowed to lose power: a laser ray loses absolute power, a detector ray loses relative power starting from an initial power of 1. The total power loss a ray experiences when travelling from the laser lens to the detector lens is given by the absolute power loss times the relative power loss, since power is lost exponentially depending on the time the ray spends in each cell (see Eq.(18.47)).
On each node the local Thomson spectra are assembled by looping over all local IR cells. Each IR cell
contains per definition a set  of incoming laser rays and a set
 of incoming laser rays and a set  of scattered detector rays.
Each laser/detector ray pair (total of
 of scattered detector rays.
Each laser/detector ray pair (total of  ) info is now used to determine its contribution to the
local spectrum. Each such pair defines a local IR cell scattering angle as well as a scattering direction.
Together with the info of the local IR cell, a spectrum contribution to all recording frequencies is
calculated using the time-averaged scattered power equation for a collection of charges in the
low-velocity charge (
) info is now used to determine its contribution to the
local spectrum. Each such pair defines a local IR cell scattering angle as well as a scattering direction.
Together with the info of the local IR cell, a spectrum contribution to all recording frequencies is
calculated using the time-averaged scattered power equation for a collection of charges in the
low-velocity charge ( ) limit:
) limit:
 is the time-averaged scattered power,
 is the time-averaged scattered power,  the scattered frequency,
 the scattered frequency,
 the frequency shift between the laser and scattered frequency,
 the frequency shift between the laser and scattered frequency,  the incident
laser ray power,
 the incident
laser ray power,  the classical electron radius,
 the classical electron radius,  the distance travelled by the ray inside the IR cell,
 the distance travelled by the ray inside the IR cell,
 the electron number density in the IR cell,
 the electron number density in the IR cell,  the detector lens area in steradians,
 the detector lens area in steradians,  the scattering direction unit vector,
the scattering direction unit vector, 
 the unit vector along the incident laser electric field,
 the unit vector along the incident laser electric field,
 the shift in wavenumber between the laser and scattering wave vectors and
 the shift in wavenumber between the laser and scattering wave vectors and
 the spectral density function. For an unpolarized laser, the unitless scattering
direction factor
 the spectral density function. For an unpolarized laser, the unitless scattering
direction factor 
 is averaged over all possible
 is averaged over all possible 
 orientations:
orientations:
 is the angle between the laser direction and the scattering direction (zero in case of
same direction). If a polarized laser is used, an additional angle
 is the angle between the laser direction and the scattering direction (zero in case of
same direction). If a polarized laser is used, an additional angle  between the polarization plane and
the scattering plane is needed, giving:
 between the polarization plane and
the scattering plane is needed, giving:
 and
 and  are the electron and individual ion susceptibilities and
 are the electron and individual ion susceptibilities and  and
 and  the
number of electrons from the i-th ion and the total number of electrons, respectively.
 the
number of electrons from the i-th ion and the total number of electrons, respectively. 
 and
 and
 are the electron and i-th ion one-dimensional Maxwellian velocity distributions for
the phase velocity
 are the electron and i-th ion one-dimensional Maxwellian velocity distributions for
the phase velocity  :
:
|  |  |  | (30.5) | 
 the Boltzmann constant and
 the Boltzmann constant and  and
 and  the electron (
 the electron ( ) and ion (
) and ion ( ) mass and
temperature. Note the two kind
of electron-ion correlation parts in the above
) mass and
temperature. Note the two kind
of electron-ion correlation parts in the above 
 expression: 1) the first term represents
the ion influence on the electron velocity distribution and 2) the second term is the electron influence
on the ions velocity distribution. Derivation of the
 expression: 1) the first term represents
the ion influence on the electron velocity distribution and 2) the second term is the electron influence
on the ions velocity distribution. Derivation of the 
 expression is involved and the
reader is referred to the literature (Froula et al. 2011, chapters 3 and 5). Since the units of the lhs
of Eq.(30.1) are power per radial frequency (i.e. power per rad/s), we see that
the units for
 expression is involved and the
reader is referred to the literature (Froula et al. 2011, chapters 3 and 5). Since the units of the lhs
of Eq.(30.1) are power per radial frequency (i.e. power per rad/s), we see that
the units for 
 must be s/rad, which is also seen from Eq.(30.4),
where the units of
 must be s/rad, which is also seen from Eq.(30.4),
where the units of  are rad/cm and the units for the velocity distribution functions is s/cm and the
other quantities are dimensionless. The electron and ion susceptibilites are calculated using derivatives
of the plasma dispersion function
 are rad/cm and the units for the velocity distribution functions is s/cm and the
other quantities are dimensionless. The electron and ion susceptibilites are calculated using derivatives
of the plasma dispersion function  :
:
|  |  |  | (30.6) | 
 represent the electrons or ions,
 represent the electrons or ions, 
 is the charge plasma frequency and
 is the charge plasma frequency and
 is the RMS thermal velocity of the charge.
 is the RMS thermal velocity of the charge. 
 is
the mean thermal velocity normalized phase velocity of the charge, with
 is
the mean thermal velocity normalized phase velocity of the charge, with 
 .
Details about how to evaluate
.
Details about how to evaluate 
 efficiently can again be inferred from
Froula et al. 2011.
 efficiently can again be inferred from
Froula et al. 2011.
For higher temperature plasmas, relativistic effects start to get important, but their inclusion into
the scattering equation becomes much more involved. In specific cases it is possible to include
relativistic effects up to first order in  . For example, if the incident Thomson laser is polarized
such that its electrical field
. For example, if the incident Thomson laser is polarized
such that its electrical field  is perpendicular to the scattering plane and if a polarizer
is placed before the detector that only detects scattered fields with electrical field parallel to
 is perpendicular to the scattering plane and if a polarizer
is placed before the detector that only detects scattered fields with electrical field parallel to  ,
then it can be shown that Eq.(30.1) needs only be augmented multiplicatively
by the relativistic term:
,
then it can be shown that Eq.(30.1) needs only be augmented multiplicatively
by the relativistic term:
After all local spectra contributions have been evaluated, the global contribution to the spectrum for the current laser/detector pair is calculated and added to the overall Thomson spectrum for the detector. Writeout to the Thomson detector file is done after the laser for each detector is no longer active.
To include the use of the ThomsonScattering unit with ray tracing, the following should be
included into the setup line command:
 
  
+ThomsonScatteringWrt thsc_maxPulses=<number> thsc_maxPulseSections=<number> thsc_maxLaserBeams=<number> thsc_maxDetectors=<number>
 for the
Thomson laser beam cross section power function as presented in equation 18.106
(n-th Thomson laser beam).
 for the
Thomson laser beam cross section power function as presented in equation 18.106
(n-th Thomson laser beam).
 along the
major elliptical semiaxis as shown in equation 18.106  (n-th Thomson laser beam).
 along the
major elliptical semiaxis as shown in equation 18.106  (n-th Thomson laser beam).
 along the
minor elliptical semiaxis as shown in equation18.106 (n-th Thomson laser beam).
 along the
minor elliptical semiaxis as shown in equation18.106 (n-th Thomson laser beam).
 for the
laser elliptical lens area (n-th Thomson laser beam).
 for the
laser elliptical lens area (n-th Thomson laser beam).
 (n-th Thomson laser beam).
 (n-th Thomson laser beam).
 (n-th Thomson laser beam).
 (n-th Thomson laser beam).
 (n-th Thomson laser beam).
 (n-th Thomson laser beam).
 (in degrees) of the
incident Thomson laser electrical field with respect to the scattering plane
(cf. Eq.(30.3)). If a negative value is given, the Thomson laser beam is
considered to be unpolarized (n-th Thomson laser beam).
 (in degrees) of the
incident Thomson laser electrical field with respect to the scattering plane
(cf. Eq.(30.3)). If a negative value is given, the Thomson laser beam is
considered to be unpolarized (n-th Thomson laser beam).
 along the Thomson beam's lens target center line (n-th Thomson laser beam).
along the Thomson beam's lens target center line (n-th Thomson laser beam).
 is defined (n-th Thomson laser beam).
 is defined (n-th Thomson laser beam).
 for the
laser elliptical target area (n-th Thomson laser beam).
 for the
laser elliptical target area (n-th Thomson laser beam).
 for the
laser elliptical target area (n-th Thomson laser beam).
 for the
laser elliptical target area (n-th Thomson laser beam).
 (n-th Thomson laser beam).
 (n-th Thomson laser beam).
 (n-th Thomson laser beam).
 (n-th Thomson laser beam).
 (n-th Thomson laser beam).
 (n-th Thomson laser beam).
 for the
detector elliptical lens area (n-th Thomson detector).
 for the
detector elliptical lens area (n-th Thomson detector).
 (n-th Thomson detector).
 (n-th Thomson detector).
 (n-th Thomson detector).
 (n-th Thomson detector).
 (n-th Thomson detector).
 (n-th Thomson detector).
 along the Thomson detector's lens target center line (n-th Thomson detector).
along the Thomson detector's lens target center line (n-th Thomson detector).
 is defined (n-th Thomson detector).
 is defined (n-th Thomson detector).
 as in Eq.(30.1). If false, the output is in power
 as in Eq.(30.1). If false, the output is in power 
 ,
which is
,
which is 
 multiplied by the corresponding bin size
 multiplied by the corresponding bin size 
 . One has to be aware that
. One has to be aware that
 can sometimes be grossly overestimated, particularly for very narrow Thomson spectra with small widths.
This happens if the recording wavelength window is to broadly set (n-th Thomson detector).
 can sometimes be grossly overestimated, particularly for very narrow Thomson spectra with small widths.
This happens if the recording wavelength window is to broadly set (n-th Thomson detector).
 for the
detector elliptical target area (n-th Thomson detector).
 for the
detector elliptical target area (n-th Thomson detector).
 for the
detector elliptical target area (n-th Thomson detector).
 for the
detector elliptical target area (n-th Thomson detector).
 (n-th Thomson detector).
 (n-th Thomson detector).
 (n-th Thomson detector).
 (n-th Thomson detector).
 (n-th Thomson detector).
 (n-th Thomson detector).
 is polarized and perpendicular to
the scattering plane and a polarizer is used at the detector to select the scattered radiation electric
field
 is polarized and perpendicular to
the scattering plane and a polarizer is used at the detector to select the scattered radiation electric
field  to be parallel to
 to be parallel to  . Unless the experimental setup to be simulated does correspond
exactly to this situation, it is best to avoid this term (n-th Thomson detector).
. Unless the experimental setup to be simulated does correspond
exactly to this situation, it is best to avoid this term (n-th Thomson detector).
 and
 and  using Eq.(18.46) and replacing the
time integration term in Eq.(18.47) by
 using Eq.(18.46) and replacing the
time integration term in Eq.(18.47) by  , i.e. treating
, i.e. treating  as constant
in the cell. If false, the more expensive time integration formalism from Eq.(18.59)
is used.
 as constant
in the cell. If false, the more expensive time integration formalism from Eq.(18.59)
is used.
 and should only very rarely be changed.
 and should only very rarely be changed.
 or
 or 
 ) on the detector screens (default 'es20.10').
) on the detector screens (default 'es20.10').
 will be rescaled such that
they always deliver a positive (greater or equal zero) value for the number of electrons in a cell.
 will be rescaled such that
they always deliver a positive (greater or equal zero) value for the number of electrons in a cell.
 will be rescaled such that
they always deliver a positive (greater or equal zero) value for the electron temperature in a cell.
 will be rescaled such that
they always deliver a positive (greater or equal zero) value for the electron temperature in a cell.
 basename
basename ThscEnergyProfile.dat, where
ThscEnergyProfile.dat, where  basename
basename is the base name of the simulation.
 is the base name of the simulation.
 basename
basename ThscLaserBeamsPrint.txt, where
ThscLaserBeamsPrint.txt, where  basename
basename is the base
name of the simulation.
 is the base
name of the simulation.
 basename
basename ThscDetectorsPrint.txt, where
ThscDetectorsPrint.txt, where  basename
basename is the base
name of the simulation.
 is the base
name of the simulation.
 basename
basename ThscMainPrint.txt, where
ThscMainPrint.txt, where  basename
basename is the base
name of the simulation.
 is the base
name of the simulation.
 basename
basename ThscLaserPulsesPrint.txt, where
ThscLaserPulsesPrint.txt, where  basename
basename is the base
name of the simulation.
 is the base
name of the simulation.
 basename
basename
 fileLabel
fileLabel
 PID
PID .txt,
where
.txt,
where  basename
basename is the base name of the simulation,
 is the base name of the simulation,  fileLabel
fileLabel is a file label name given
by the user and PID is the processor rank number. This runtime parameter should only be used for
debugging purposes (default =  false) by developers of the code.
 is a file label name given
by the user and PID is the processor rank number. This runtime parameter should only be used for
debugging purposes (default =  false) by developers of the code.
 basename
basename ThscSpecies.txt, where
ThscSpecies.txt, where  basename
basename is
the base name of the simulation.
 is
the base name of the simulation.