Skip to content
Maxim Yurkin edited this page Jun 24, 2018 · 8 revisions

All places in the code, where something should be added, are commented. These comments start with TO ADD NEW BEAM and contain detailed description; the text below is less detailed. Added code should be analogous to beam types already present. The procedure is the following:

  • Add new beam descriptor in the file const.h. Starting descriptor name with B_ is recommended, as well as adding a descriptive comment.
  • Add information about the new beam type in the file param.c. It should be a new row in the constant array beam_opt. This line should contain: the beam name (it will be used in a command line), usage string (the description of possible input parameters), help string (it will be shown when -h option is used), possible number of parameters (real values), beam descriptor. If this beam type can accept variable number of parameters use UNDEF instead of a number and then check the number of parameters explicitly in function PARSE_FUNC(beam) (below in the same file). If beam type accepts a single parameter with a file name, use FNAME_ARG instead.
  • Add initialization of the new beam type as a new case in the long switch in the function InitBeam in the file GenerateB.c. This initialization should save all parameters from the array beam_pars to local variables, which should be defined in the beginning of the file (the place for that is shown by a comment). Then test all input parameters for consistency (for that you are encouraged to use functions from param.h since they would automatically produce informative output in case of error). If the shape breaks any symmetry, corresponding variables should be set to false. However, asymmetry due to location of beam center is handled automatically. Then initialize the following variables: 1) beam_descr – descriptive string that would be shown in the log; 2) beam_asym – whether beam center does not coincide with the reference frame origin. If it is set to true, then set also beam_center_0 – 3D radius-vector of beam center in the laboratory reference frame; 3) all other auxiliary variables that are used in beam generation (below). If the new beam type is incompatible with -surf, add an explicit exception. If you need temporary local variables (which are used only in this part of the code) define them in the beginning of InitBeam function.
  • Add definition of the new beam type as a new case in the long switch in the function GenerateB in the file GenerateB.c. This definition should set complex vector b, describing the incident field in the particle reference frame. It is set inside the cycle for each dipole of the particle and is calculated using 1) DipoleCoord – array of dipole coordinates; 2) prop – propagation direction of the incident field; 3) ex – direction of incident polarization; 4) ey – complementary unity vector of polarization (orthogonal to both prop and ex); 5) beam_center – beam center in the particle reference frame (automatically calculated from beam_center_0 defined in InitBeam). If the new beam type is compatible with '-surf', include here the corresponding code. For that you will need the variables, related to surface, defined in vars.c. In that case you also need to define inc_scale. If you need temporary local variables (which are used only in this part of the code), either use t1t8 or define your own (with more informative names) in the beginning of GenerateB function.
  • Take a look at function ExtCross in file crosssec.c. Used formulae for non-plane beams assume that the amplitude of the beam is unity at the focal point. So either make sure that the new beam type satisfies this condition or add other formulae to this function.

Please refer to section Incident Beam of the manual for description of the above-mentioned variables and for general overview of how the incident beam is treated inside ADDA.

If you add a new predefined beam type to ADDA according to the described procedure, please consider contributing your code to be incorporated in future releases.

Clone this wiki locally