-
Notifications
You must be signed in to change notification settings - Fork 57
AddingBeam
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 useUNDEF
instead of a number and then check the number of parameters explicitly in functionPARSE_FUNC(beam)
(below in the same file). If beam type accepts a single parameter with a file name, useFNAME_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 declared 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 tofalse
. 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 thelog
; 2)vorticity
- (only for vortex beam) integer value, how many turns the phase experience, when one makes a full turn around the beam axis; 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) declare them in the beginning ofInitBeam
function or inside a specific case. In the latter variant, surround the whole case with braces. - 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 vectorb
, 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 bothprop
andex
); 5)beam_center
– beam center in the particle reference frame (automatically calculated frombeam_center_0
defined by-beam_center
command line option). 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 defineinc_scale
. If you need temporary local variables (which are used only in this part of the code), either uset1
–t8
or declare your own (with more informative names) in the beginning ofGenerateB
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.
Home (Getting started)
Frequently asked questions
Features
Tutorial
Comparison with other codes
Largest simulations
Compiling ADDA
Installing FFTW3
Installing MPI
Using OpenCL
Installing clFFT
Installing clBLAS
Using sparse mode
Installing MinGW
Using MSYS2
Papers that use ADDA
Awards
References
Links
Acknowledgements
Instruction for committers
Code design & structure
Style guide
Using VS Code
Using Eclipse
Early development history
Adding new ...