This is the third and final article in a series describing the LaTeX
package FeynMF for easy drawing of professional quality Feynman diagrams
with METAFONT (or MetaPost). This time the mechanisms for extending FeynMF
are covered and some trouble-shooting advice is given.
Here are links to the First
and Second article
in the series.
In [1, 2], I have described the design principles and simple applications of FeynMF [3, 4]. Now it is time to discuss the more esoteric features of FeynMF, those that allow efficient creation of rather complicated Feynman diagrams.
The examples presented in this part can be used as a cookbook from which recipes can be copied without intimate knowledge of METAFONT. Nevertheless, familiarity with some chapters of [5] will certainly be helpful for a deeper understanding of the macros.
Such transformers can be combined with other transformers or with drawing functions and packaged in a style_def:
1 \fmfcmd{%
2 style_def charged_boson expr p =
3 draw (wiggly p);
4 fill (arrow p)
5 enddef;}
The implementation does not attempt to force embellishments (e.g. arrows) into the transformer paradigm, because drawing along a path is inherently different from filling an outline. Therefore embellishments are drawn after each other and not added to the object in a pipeline.
1 \fmfcmd{%
2 vardef bar (expr p, len, ang) =
3 ((-len/2,0)--(len/2,0))
4 rotated (ang + angle
5 direction length(p)/2 of p)
6 shifted point length(p)/2 of p
7 enddef;
8 style_def tfermion expr p =
9 draw_double p;
10 ccutdraw bar (p, 4mm, 60);
11 ccutdraw bar (p, 4mm, -60)
12 enddef;}
The tfermion line style is used in Figure 1
in a Schwinger-Dyson equation. Such definitions can be placed in a little
library of personal preferences and reused later in publications dealing
with similar diagrams.
1 \begin{equation}
2 \begin{split}
3 &\parbox{20mm}{\begin{fmfgraph}(20,5)
4 \fmfleft{i} \fmfright{o}
5 \fmf{tfermion}{i,o}
6 \end{fmfgraph}} \\
7 &\qquad =
8 \parbox{20mm}{\begin{fmfgraph}(20,15)
9 \fmfleft{i} \fmfright{o}
10 \fmf{double}{i,v1} \fmf{double}{v2,o}
11 \fmf{tfermion,tension=.3}{v1,v2}
12 \fmf{gluon,left,tension=0}{v1,v2}
13 \end{fmfgraph}}
14 +\lambda_U
15 \parbox{20mm}{\begin{fmfgraph}(20,15)
16 \fmfleft{i} \fmfright{o} \fmfdot{v}
17 \fmf{double}{i,v,o}
18 \fmf{tfermion}{v,v}
19 \end{fmfgraph}}
20 \end{split}
21 \end{equation}
1 \fmfcmd{%
2 style_def majorana expr p =
3 cdraw p;
4 cfill (harrow (reverse p, .5));
5 cfill (harrow (p, .5))
6 enddef;
7 style_def dbl_majorana expr p =
8 draw_double p;
9 cfill (tarrow (reverse p, .55));
10 cfill (tarrow (p, .55))
11 enddef;}
The first kind has the arrows facing each other at the tip (harrow
has the reference point at the head) and the second kind has them facing
st the base (harrow has the reference point at the tail):
Here we choose a more pragmatic approach and define some pseudo-line styles consisting of reduced and shifted arrows without a line:
1 \fmfcmd{%
2 vardef middir(expr p,ang) =
3 dir(angle direction length(p)/2 of p + ang)
4 enddef;
5 style_def arrow_left expr p =
6 shrink(.7);
7 cfill(arrow p
8 shifted(4thick*middir(p,90)));
9 endshrink
10 enddef;
11 style_def arrow_right expr p =
12 shrink(.7);
13 cfill(arrow p
14 shifted (4thick*middir(p,-90)));
15 endshrink
16 enddef;}
Because the gluon lines occupy more space, we have to define another
style warrow_left which is identical to arrow_left except
for a larger distance 8thick from the line. These pseudo-line
styles are used in lines 23-26 of Figure 2
to place the little arrows. Since the vertices that are connected by these
arcs are already fixed, we can omit the tension=0 option.
1 \begin{fmfgraph*}(50,30)
2 \fmfbottom{pA,pB}
3 \fmftop{pA',k1,k2,pB'}
4 \fmf{fermion,lab.side=left,
5 lab=$p_A$}{pA,vA}
6 \fmf{fermion,lab.side=left,
7 lab=$p_{A'}$}{vA,pA'}
8 \fmf{fermion,lab.side=right,
9 lab=$p_B$}{pB,vB}
10 \fmf{fermion,lab.side=right,
11 lab=$p_{B'}$}{vB,pB'}
12 \fmf{dbl_wiggly,lab.side=right,
13 lab=$q_1$}{vA,v}
14 \fmf{dbl_wiggly,lab.side=left,
15 lab=$q_2$}{vB,v}
16 \fmfdot{vA,vB} \fmfblob{.2w}{v}
17 \fmffreeze
18 \fmf{gluon,lab.side=left,
19 lab=$k_1$}{v,k1}
20 \fmf{gluon,lab.side=left,
21 lab=$k_2$}{k2,v}
22 \fmf{warrow_right}{v,k1}
23 \fmf{warrow_left}{v,k2}
24 \fmf{arrow_left}{vA,v}
25 \fmf{arrow_left}{v,vB}
24 \end{fmfgraph*}
The gluons in lines 18-21 do not affect the layout, because they are added after the position of the vertices are fixed by \fmffreeze. The same effect could be achieved by adding a tension=0 option to the gluons.
We start by defining a couple of utility macros: the macro port(t,p) returns a unit vector pointing to the left of the path p at t:
1 \fmfcmd{%
2 vardef port (expr t, p) =
3 (direction t of p rotated 90)
4 / abs (direction t of p)
5 enddef;}
The macro portpath(a,b,p) returns a copy
of the path p bent to the left by a at the beginning and
end and by b in the middle.
1 \fmfcmd{%
2 vardef portpath (expr a, b, p) =
3 save l; numeric l; l = length p;
4 for t=0 step 0.1 until l+0.05:
5 if t>0: .. fi point t of p
6 shifted ((a+b*sind(180t/l))*port(t,p))
7 endfor
8 if cycle p: .. cycle fi
9 enddef;}
This macro is now used to draw a fat, shaded ``propagator'' along the path
p (Figure 3). Note that
brown_muck is not as general as it could be, because it doesn't
properly handle cyclic paths. This is in principle easy to fix. But the
implementation of shading areas of genus >0 has to behave differently for
METAFONT and MetaPost and would occupy too much space in this short
article. It will be provided in a future version of FeynMF.
1 \fmfcmd{%
2 style_def brown_muck expr p =
3 shadedraw(portpath(thick/2,2thick,p)
4 ..reverse(portpath(-thick/2,-2thick,p))
5 ..cycle)
6 enddef;}
1 \begin{fmfgraph*}(50,30)
2 \fmfleft{i1,i2} \fmfright{o1,o2}
3 \fmf{fermion}{i1,v1,i2}
4 \fmf{fermion}{o2,v2,o1}
5 \fmf{brown_muck,tension=.5,right,%
6 label=$\pi^{0,,\pm},,K^{0,,\pm}$}%
7 {v1,v2,v1}
8 \def\H#1{\fmfv{%
9 label=$H_I^{\Delta C=1}$,%
10 label.dist=6thick}{#1}}
11 \H{v1}\H{v2}\fmfdotn{v}{2}
12 \end{fmfgraph*}
This brown_muck style can now be used just like any other predefined line style, cf. Figure 3 and Figure 4.
1 \fmfcmd{%
2 style_def proton expr p =
3 save mp, sp; pair mp; path sp;
4 mp = point length(p)/2 of p;
5 sp = p shifted -mp scaled 1.05 shifted mp;
6 cdraw sp shifted (2thick*middir(p, 90));
7 cdraw sp shifted (2thick*middir(p,-90));
8 draw_fermion p
9 enddef;}
The outer lines are slightly enlarged to match with the circular blobs.
This solution is not perfect (it would be a default line style in FeynMF
otherwise) because it is not guaranteed to match
always satisfactorily
at the vertices. It is nevertheless a good example for how the style_def
mechanism can be used to streamline FeynMF applications.
1 \begin{fmfgraph*}(50,30)
2 \fmfleft{P,gamma}\fmfright{P',c,cbar}
3 \fmflabel{$\gamma^*$}{gamma}
4 \fmf{proton,lab=$P$}{P,g1}
5 \fmf{proton}{g1,P'}
6 \fmfv{d.sh=circle,d.fi=shaded,d.si=.16w,%
7 lab=$g(x,,Q^2)$,lab.d=.1w,lab.a=-90}{g1}
8 \fmf{gluon,lab.s=left,lab=$xP$}{g1,g2}
9 \fmf{photon,lab.s=right,lab=$p$}{gamma,j1}
10 \fmf{brown_muck,lab.s=right,lab.d=4thick,%
11 lab=$J/\psi$}{j1,j2}
12 \fmf{fermion}{cbar,j2,g2,c}
13 \fmfdot{j1,j2,g2}
14 \end{fmfgraph*}
Instead of redisplaying the Higgs production diagram from [2] once more, we apply the proton style in Figure 4 in a photoproduction diagram. This diagram also shows another application of the brown_muck style.
1 \global\def\NLO#1#2#3#4#5#6#7#8{%
2 \begin{fmfgraph*}(35,25)
3 \fmftop{b,s} \fmfbottom{g}
4 \fmflabel{$b$}{b} \fmflabel{$s$}{s}
5 \fmflabel{$\gamma$}{g}
6 \fmf{fermion}{b,v1}\fmf{fermion}{v2,s}
7 \fmf{phantom,right=5,tag=1}{v1,v2}
8 \fmf{dbl_wiggly}{v1,v2}
9 \fmffreeze
10 \fmfi{fermion}{%
11 subpath (0,1) of vpath1(__v1,__v2)}
12 \fmfi{fermion}{%
13 subpath (1,2) of vpath1(__v1,__v2)}
14 \fmfi{photon}{vloc(__g)
15 .. point 1 of vpath1(__v1,__v2)}
16 \fmfdotn{v}{2}
17 \fmfset{curly_len}{2.5mm}
18 \fmfi{gluon}{%
19 begingroup;
20 clearxy; save p, t;
21 path p[]; numeric t[];
22 p1 = vpath#4(#3); p2 = vpath#8(#7);
23 t1 = #1*length(p1); z1 = point t1 of p1;
24 t2 = #5*length(p2); z2 = point t2 of p2;
25 z1{direction t1 of p1 rotated #2}
26 ..{direction t2 of p2 rotated #6}z2
27 endgroup}
28 \end{fmfgraph*}}
\NLO{.65}{-90}{__v1,__v2}{1}%
{.7}{90}{__v2,__s}{} \qquad
\NLO{.1}{90}{__v1,__v2}{1}
{.7}{90}{__v2,__s}{}
\NLO{.3}{90}{__v1,__v2}{1}%
{.7}{-90}{__v1,__v2}{1} \qquad
\NLO{.3}{-60}{__b,__v1}{}%
{.65}{-120}{__v1,__v2}{1}
Finally, let us return to the subject of [2],
the
immediate mode. One notorious set of diagrams is given by the
NLO contributions to
.
Figure 5 shows how aesthetically pleasing
results can be produced with little effort in FeynMF. Topologically, the
second and fourth diagram are mirror images and it is a matter of taste
which layout style is preferred.
Lines 2-16 are straightforward, except for the trick in line 7, where the quark loop is first drawn invisibly (phantom). Later (lines 10-15) a fermion is drawn on each half (using the undocumented feature that length(p)=2).
The first four arguments of the \NLO macro describe the starting point of the gluon and the final four the end point. The first argument gives the position on the path connecting the vertices specified in the third argument, while the second argument gives the direction relative to this path (this is the non-trivial part). The fourth argument is needed to disambiguate multiple paths connecting the same pair of vertices. The actual path is defined in lines 25-26. Note that the value of the group is the value of the final expression in the group.
The first and second diagram reveal a slight problem with the current implementation of FeynMF: since the coordinate along a METAFONT path doesn't vary uniformly with the actual length, the gluons can appear a bit distorted. The effect is not dramatic, but it might be fixed in a future version anyway.
1 \begin{fmfgraph}(30,3)
2 \fmfset{curly_len}{2mm}
3 \fmfleft{i} \fmfright{o} \fmf{gluon}{i,o}
4 \end{fmfgraph}
while a value of 4mm results in a more loose shape:
Currently, it is to impossible to switch curly_len for individual propagators by using multiple \fmfsets. Most propagators are drawn at the very end and the most recent \fmfset will be in effect for all propagators.
Until this a future version FeynMF will allow for these parameter as options similar to tension, there is a convenient way of achieving the same effect using the extension mechanism. We just define a new style that will locally redefine the appropriate parameters:
1 \fmfcmd{%
2 style_def ir_photon expr p =
3 save wiggly_len, wiggly_slope;
4 wiggly_len = 6mm; wiggly_slope = 45;
5 draw_photon p
6 enddef;
7 style_def uv_photon expr p =
8 save wiggly_len, wiggly_slope;
9 wiggly_len = 2mm; wiggly_slope = 90;
10 draw_photon p
11 enddef;}
In the case of photons, there are two parameters wiggly_len and
wiggly_slope.
The latter should be increased when the wiggles are shortened.
1 \begin{fmfgraph}(40,30)
2 \fmfleftn{i}{2}\fmfrightn{o}{2}\fmftop{g2}
3 \fmf{phantom}{i1,v1,i2}
4 \fmf{fermion}{o1,v2,o2}
5 \fmf{uv_photon}{v1,v2}\fmffreeze
6 \fmf{fermion}{i1,v1,g1,i2}
7 \fmf{ir_photon,tension=0}{g1,g2}
8 \fmfdot{g1,v1,v2}
9 \end{fmfgraph}
In Figure 6, we use both kinds of photons just like any other line style.
The shape of the arrow heads is governed by arrow_len and arrow_ang, with the latter denoting the half opening angle of the arrow head:
1 \begin{fmfgraph}(30,3)
2 \fmfset{arrow_len}{cm}\fmfset{arrow_ang}{25}
3 \fmfleft{i}\fmfright{o}\fmf{fermion}{i,o}
4 \end{fmfgraph}
1 \begin{fmfgraph}(30,3)
2 \fmfset{arrow_len}{cm}\fmfset{arrow_ang}{10}
3 \fmfleft{i}\fmfright{o}\fmf{fermion}{i,o}
4 \end{fmfgraph}
Below is a Makefile rule that supports FeynMF. In lines 1-6, we set up a few variables to make site specific customizations easier: MODE is the printer type (can be found from the file modes.mf, the output of the MakeTeXPK script or from your local wizard). MAG is the magnification which is usually 1, but some LaTeX packages need other values: the most prominent example is seminar.sty, which wants magstep(4). DPI is the product of the printer resolution and MAG. Finally, SUF is a suffix that is used to build the METAFONT file name from the LaTeX file name (they can't share the same name, because the names of the .log files would clash).
1 MODE = laserjet 2 MAG = 1 3 DPI = 300 4 # MAG = magstep(4) 5 # DPI = 622 6 SUF = pics 7 .tex:.dvi 8 -cp $*$(SUF).mf $*$(SUF).mf~ 9 -latex $* 10 if cmp -s $*$(SUF).mf $*$(SUF).mf~; then\ 11 :;\ 12 else\ 13 mf '\mode:=$(MODE);mag:=$(MAG);input '\ 14 $*$(SUF);\ 15 gftopk $*$(SUF).$(DPI)gf;\ 16 latex $*;\ 17 fi 18 while grep -s\ 19 'Rerun to get cross-references right.'\ 20 $*.log;\ 21 do\ 22 latex $*;\ 23 doneLines 8-23 define the sequence of commands that will produce a .dvi-file from the .tex-file (in the actual Makefile, the leading blanks have to be TABs, of course). Lines 8-9 create a copy of the .mf-file and run LaTeX (ignoring errors). Line 10 checks if the .mf-file has changed: if so, it is processed by METAFONT, the resulting .gf-file is turned into a .pk-file and LaTeX is run again (lines 13-16). The loop in lines 18-23 is independent from FeynMF and runs LaTeX until all cross-references are resolved. It should be obvoius how to extend this rule to support BibTeX, makeindex, etc.
Never, ever rely on the automatic font generation methods to run METAFONT for you on the FeynMF files. They will install the output in a system directory (where it doesn't belong) and it might be hard to remove it again. Even worse, some installations will search the system directories first and you might be forever stuck with an obsolete version if you make changes to the diagrams. The same applies to running gftopk.
However, the preferred option is to spread the gospel of FeynMF, of course ...