The 'User-defined scattering' version
This version of the 2D and 3D programs allows scattering of the particles, using a User-supplied routine.
The scattering might be caused for example by:
- a grid or mesh
- an artificial thin lens
- a background gas
- an electrode, to produce secondary electrons.
At the end of each step in the trajectory integration the program sends information (the coordinates, velocity components, potential, time -see note on transfer of scattering parameters) to the user-defined routine and expects a return giving new velocity components or an instruction to terminate the trajectory.
The user-defined routine can call upon a data file that contains controlling data. The user is asked to specify the name of this file.
The user-defined routine can also output information to a file that is named in the routine.
Note that if the CPO program simulates a secondary scattering event then this occurs before the program calls the user-defined routine. Therefore if the user-supplied routine is used to change a parameter, such as the current, it is advisable to use neutral parameters in the program’s own secondaries option, for example using unity for the multiplication factor of the current.
A discontinuity in the ray path might cause difficulties for the ray plotting routines, and so the ray path on the screen might appear to be kinked (but the numerical ray data in the information box and the output data file are correct).
More importantly, if the number of steps between the scattering event and a test plane is less than 2 then the interpolation used to find the parameters at the test plane might give an incorrect result. The user should therefore look at the test plane results to check this. If necessary, the ‘maximum step length or time’ might have to be reduced.
Examples of user-defined routines (in C++) are supplied with the CPO package (see detailed instructions for building the scattering dll).
The user-supplied routine has to be compiled and built into a dll (direct-linked-library) file before it can be called by the main program. The original routine needs to be written in C++ (or written in Fortran and translated into C++).
See detailed instructions for building the scattering dll for further advice.
Further detailed information is given in the example routines sct2grid.cpp, sc2lens.cpp, sct3grid.cpp and sct3lens.cpp.