xmpl2d07, 7th 'example' data file for CPO2D
Automatic iteration to focus a beam by a threecylinder lens.
This is the 2D version of xmpl3d06.
The number of segments used in the present example is small enough for the example to be run with the ‘demo’ version of CPO2D. Higher accuracy could of course be obtained with more segments, using the standard or full versions of CPO2D.
The lens is a 3cylinder lens. All 3 cylinders have the radius 0.5, and they extend from z=5.0 to 0.55, 0.45 to 0.45 and 0.55 to 5.0. The initial voltages are set at 1, 7 and 4.
The following parameters are specified for the iteration:
(1) voltage number 2 is to be varied, and the initial excursion is 0.1,
(2) a focus is require on axis, at z=5,
(3) 4 rays are to be used (all starting from z=4, with initial launch angles of .01, .02, .03 and .04),
(4) a maximum of 16 iterations is allowed,
(5) a 'penalty' is introduced if the radius of a ray at the focal plane is greater than 0.1,
(6) further penalties are added if voltage number 2 goes below 2 or above 20, or if the final angles go beyond +/ 0.1 rad to the z axis (in fact none of these penalties are serious for the present problem they are included only for illustrative purposes).
It can be seen that the final value of v2 is 5.65, and that the 'disc of least confusion' is correctly at z=5.
This is the sequence of iterations (as put into file temp7a.dat):
Iteration number 
voltage number 2 
size of focus 

1 
7.000000 
1.688E01 
=best so far 
2 
7.100000 
1.850E01 

3 
6.900000 
1.523E01 
=best so far 
4 
6.800000 
1.356E01 
=best so far 
5 
6.600000 
1.016E01 
=best so far 
6 
6.400000 
8.327E02 
=best so far 
7 
6.000000 
4.706E02 
=best so far 
8 
5.600000 
1.673E02 
=best so far 
9 
4.800000 
7.144E02 

10 
5.200000 
4.151E02 

11 
5.400000 
2.695E02 

12 
5.800000 
2.828E02 

13 
5.500000 
2.140E02 

14 
5.700000 
1.872E02 

15 
5.650000 
1.439E02 
=best so far 
16 
5.625000 
1.557E02 

Clearly, further improvement would be possible.
(The convergence is slow here it sometimes seems that the simplex technique is less 'clever' for 1 variable than it is for more than 1.)
More generally, up to 7 different voltages can be varied simultaneously to optimised a focus.
More importantly, the electrodes should be shaped, following the advice given in publication number 68.
To reduce the amount of information in the output data file to a minimum put 'z' (for 'zero') when the level of information is requested (see the relevant note).
(In the ‘demo’ version of the program the maximum number of ray points is easily exceeded. To obtain all the ray information it might be necessary to use longer step lengths.)