Scientific diagrams using Geometrica

Bruno Autin, CERN

bautin1@club-internet.fr

Introduction

This example is drawn from a talk on a system of particle accelerators designed to produce very intense neutrino beams. Those machines, called neutrino factories [1], comprise a proton driver delivering a several kilowatt beam onto a set of targets. Within the targets, a part of the proton energy is converted into the creation of pions. The pions have a short lifetime and decay into muons and muon neutrinos in a decay channel. The neutrino beam can be used as such but it does not have a sharp angular and energy distribution. To improve the quality of the neutrino beam, one can use the muons which are also unstable but with a lifetime much longer than that of the pions. The muons are then quickly accelerated to several billions of electron-volts and finally stored in a decay ring where they decay into electrons and two families of neutrinos, the electron and muon neutrinos which have an excellent definition in energy and angle well adapted to neutrino oscillations experiments. One of the technical challenges of a neutrino factory is the design of the target system which is submitted to violent heat stresses since about a quarter of the energy of the proton beam is released in heat in the target. A promising design consists of a system of four targets hit sequentially by the proton beam.

The various stages of construction of the above figure are explained starting from 2D constructs, imbedding 2D objects into 3D space, treating whole surfaces and portions of surface and manipulating colors and legends.

2D trajectories

<< Geometrica`Geometrica02`

The geometry of the trajectory is determined by three magnets. The first two are infinitely small (thin lens approximation) and the third one is of finite length. The first and third magnets give a kick ϕ and the midle one a kick -2ϕ. Moreover, the output ray is collinear to the input one. A first sketch of the trajectory of a particle starting at (0,0) is thus given by the polygonal line s. The vertices are defined by the listable function CPoint which has the list of abscissae and the list of ordinates as arguments. The listability is actually a property of most Geometrica functions. The function Segment is generic for any polygonal line and not only for a usual segment defined by two points. It can be automatically labeled with Legend by specifying a string of characters corresponding to the name of the vertices. The option Offset gives the flexibility of adjusting the legend in polar coordinates about the default points of reference.

phi = Pi/6;
l = 30;
{a, b, c, d, e} = 
        CPoint[{0, l, l (1 + Cos[phi]), l (1 + 2 Cos[phi]), 
            2  l (1 +  Cos[phi])}, {0, 0, l Sin[phi], 0, 
            0}];
s = Segment[a, b, c, d, e];
te = 
        Legend["ABCDE", s, 
          Offset -> {1, Pi/2}];
Draw[te, s];

The target is placed on segment CD at the points of parameters 0.1 and 0.2 using the function Pointer. The parameters 0 and 1 correspond to the origin and end respectively. In the drawing, the protons travel on the blue arrow and the pions on the red arrow. The target which is a rod of solid material is simply represented by a black segment of enhanced thickness.

sCD = Segment[c, d];
{λ1, λ2} = {0.1, 0.2};
{t1, t2} = 
        Pointer[sCD, {λ1, λ2}];
{s1, s2, s3} = {Segment[a, b, c, t1], Segment[t1, t2], 
          Segment[t2, d, e]};
Draw[te, Blue, Arrow[s1], Red, Arrow[s3], Black, 
        AbsoluteThickness[2], s2];

The previous trajectory has to be refined by inserting in D an arc of circle that is the correct trajectory of a particle in a bending magnet of finite length. The angle of deflection is ϕ and the radius of the orbit ρ. The center of the arc is thus K ((Subscript[x, D])+ρ tan ϕ/2, ρ), the end point of the arc is (Subscript[D, 2])((Subscript[x, D])+ρ tan ϕ/2, 0) and the starting point (Subscript[D, 1]) is deduced from (Subscript[D, 2])by rotation of (Subscript[D, 2])about K of angle -ϕ. The detailed form of the arc is a parametric point (PPoint) whose coordinates are expressed as pure functions of the parameter (#1) in the interval defined by PRange. The Geometrica function Segment accepts cartesian points (CPoint) and parametric points as well so that curvilinear trajectories are easily manipulated whether in geometric transformations, measures of length or drawing. The legend is split into two new legends. If some vertex of a segment is not to be labeled, here the last vertex of (Subscript[s, 1]), it suffices to put a blank in the text. The curved  segment\(TraditionalForm\`\(\(s\_3\)\(\ \)\(could\)\(\ \)\(also\)\(\ \)\(be\)\(\ \)\(labeled\)\(\ \)\(but\)\(\ \)\(the\)\(\ \)\(arc\)\(\ \)\(is\)\(\ \)\(decomposed\)\(\ \)\(into\)\(\ \)\(a\)\(\ \)\(large\)\(\ \)\(number\)\(\ \)\(of\)\(\ \)\)\)elementary segments (40) and it was prefered to label the last vertex only.

rho = 30;
x = rho Tan[phi/2];
k = CPoint[x + d[[1]], rho];
d2 = Simplify@CPoint[x + d[[1]], 0];
d1 = Simplify@Rotate[d2, k, -phi];
ar = Arc[k, d1, phi]
s3 = Segment[t1, d1, ar, e];
te1 = 
        Legend["ABC ", s1, 
          Offset -> {1, Pi/2}];
te2 = 
        Legend["E", e, 
          Offset -> {1, 0}];
Draw[te1, te2, Blue, Arrow[s1], Red, Arrow[s3], Black, 
        AbsoluteThickness[2], s2];

Immersion of 2D objects into 3D

The complete target system is of revolution about the axis AE. All the elements which have thus been defined in the plane must be embedded into space. This is simply done using the command To3D which adds to the points a third component set to zero. The head of the first arrow is lengthened using the second optional argument of Arrow.

{aa, bb, cc, dd, ee, tt1, tt2, ss1, ss2, ss3} = 
        To3D[{a, b, c, d, e, t1, t2, s1, s2, 
            s3}];
Draw3D[Blue, Arrow[ss1, 6], Red, Arrow[ss3], Black, 
        AbsoluteThickness[2], ss2];

Magnetic horn

A magnetic horn is a coaxial device which focuses the pions in the vicinity of the target. The field is confined within the horn. For a reason of clarity, the inner contour of the horn will only be drawn. The horn is represented as a surface of revolution generated by a polygonal line rotating about the target axis. The inner side is parallel to the target. The polygonal line is first constructed in 2D using the Mathematica function FoldList and the Geometrica function Translate. The starting point is (Subscript[h, 1]). Then a list h of translation vectors is defined as cartesian points to preserve the listability of Translate that would not work if the vector was specified as a list.

λ3 = 1/5;
θ = 
        Pi/6;
h1 = 
        Translate[t1, CPoint[Sin[phi] , Cos[phi]]];
h=CPoint[{l (λ2 - λ1) Cos[phi],λ3 l Cos[θ - phi]},{-l (λ2 - λ1) 
                Sin[phi], λ3 l Sin[θ - phi]}];
sh = 
        Segment @@ 
          FoldList[Translate[#1, #2] &, h1, 
            h];
Draw[sh, AbsoluteThickness[2], 
        s2];

The horn can now be easily created. The axis of rotation is CD and the surface of revolution is defined by SolidOfRevolution. Note that SurfaceOfRevolution exists in the standard  Mathematica package Graphics. The surface may be colored in a variety of ways; here it has the usual Mathematica representation by combining Paint and the option Lighting.

ax = ELine[cc, dd];
ssh = To3D[sh];
horn = SolidOfRevolution[ssh, ax];
Draw3D[Paint[horn], Lighting -> True];

The four trajectories and the four horns are obtained by rotation of the first beam line bl about the AE axis by steps of π/2. Here, the list processing takes its full power. Alist of beam lines is generated by repeatingly applying Rotate through NestList. The elements of same nature are the columns of the matrix bl4. This matrix has thus to be transposed to extract the list of elements which are submitted to the same graphics directives.

bl = {cc, ss1, ss2, ss3, horn};
ax = ELine[aa, ee]; 
bl4 = NestList[Rotate[#, ax, Pi/2] &, bl, 3]; 
{cc4, ss14, ss24, ss34, {horn41, horn42, horn43, horn44}} = 
        Transpose[bl4];
Draw3D[bb, cc4, Blue, Arrow[ss14, 6], Paint[{horn41, horn43}, Blue], 
        Black, ss24, Red, Arrow[ss34], 
        Paint[{horn42, horn44}, Red]];

Bending magnets

The bending magnet is made of sheets of current that create either  a vertical field (upper and lower sheets) or a horizontal field ( left and right hand sheets). The  sheets are sectors of a cylinder of revolution centered in D and of axis AE. The cylinder is created with the function Cylinder. The first argument is the base  circle, the second argument the direction of the generators defined by a point for the same reason of listablility explained about Translate. Parts of surfaces can be defined and manipulated by acting on the range of variations of the parameters. The option PRange in the function PPoint returned by Cylinder controls the range of the two parameters and the resolution of the isocurves. For a cylinder of revolution, one family of isocurves consists of circles and the other of generators. The first list at the right hand side of PRange is the interval of variations of the angle along a circle. The second list is the interval of variations of the parameter along a generator; the default value (0,1) means that the generator is limited to the base circle and to the end of the definition vector. 
The base circle is defined in 2D by its center D and by its radius. It is then set vertical by rotating it by π/2 about the axis passing through D and perpendiculer to AE.

ci = ECircle[d, λ2 l];
ax1 = ELine[d, ELine[a, e]];
{cci, aax1} = To3D[{ci, ax1}];
cci1 = Rotate[cci, aax1, Pi/2];
cy = Cylinder[CPoint[1, 0, 0], cci1]

The sectors are defined by changing the range of the parameters. Each sector has a π/2 opening, the starting parameter is -π/4. The range (-x,x) means that the cylinder lies along the x axis and is limited by the planes perpendicular to the x-axis of abscissae (-1,1) ρ tan(ϕ/2) since the direction of the generators is given by CPoint[1,0,0]. The resolution of the isocurves is left at its default value. Each sector contains 25 points per circle and 2 points, the end points, per generator. After connection of the points, each cylindrical sector is represented by 25 rectangles.

cy1 = 
        cy /. (PRange -> {x_, y_, 
                  z_}) -> (PRange -> {{-1, 1} 
                    Pi/4, {-1, 1} x, z});
cy2 = 
        cy /. (PRange -> {x_, y_, 
                  z_}) -> (PRange -> {{1, 3} Pi/4, {-1, 1} 
                    x, z});
cy3 = 
        cy /. (PRange -> {x_, y_, 
                  z_}) -> (PRange -> {{3, 5} Pi/4, {-1, 1} 
                    x, z});
cy4 = 
        cy /. (PRange -> {x_, y_, 
                  z_}) -> (PRange -> {{5, 7} Pi/4, {-1, 1} 
                    x, z});
Draw3D[Paint[{cy1, cy3}, Blue], 
        Paint[{cy2, cy4}, Red]];

Assembling the whole system

The final drawing incorporates all the elements which have just been elaborated. Legends are added to label the various parts of the figure. Last the color of the polygons is modified to get a softer rendering. This last manipulation is obtained by superimposing the raw horns and bending magnet. A raw 3D objetct in Geometrica is a cage made of polygons. These cages are colored with a nuance of blue or red then drawn last so that they erase the black cages of the painted objects.

\(\(te = 
        Legend[{"protons", "pions", "horns around targets", "bending magnet"}, 
          CPoint[{0, 110, 70, 90}, 
            0, {5, 5, 25, 25}]];\)\)
Draw3D[te, bb, cc4, Blue, Arrow[ss14, 6], 
        Paint[{horn41, horn43, cy1, cy3}, Blue], Black, ss24, Red, 
        Arrow[ss34], Paint[{horn42, horn44, cy2, cy4}, Red], NavyBlue, 
        horn41, horn43, cy1, cy3, VioletRedMedium, horn42, horn44, cy2, 
        cy4];

Conclusion

The process of creating a 3D scientific diagram has been described in detail. The code is made concise by using list processing extensively: most functions are listable, Geometrica operators can be integrated into list generators such as NestList or FoldList. The versatility in the representation of the objects has been illustrated. The present example could easily be extended to the creation of animations or even simulations since the drawing techniques have a perfect precision. Last the method take its full power when the drawing has to be repeated with a variety of parameters: all the code is then encapsulated in a single function and the call of a single function makes the drawing exceedingly simple. Examples of functional drawing can be found in [2].

References

[1] Proceedings of the ICFA/ECFA Workshop on Neutrino Factories based on Muon Storage Rings, B. Autin editor, Nuclear Instruments and Methods A, Vol. 451 (2000), No 1.
[2] B. Autin et al., BeamOptics, A Program of Analytical Beam Optics, CERN 98-06 (6 August 1998).