Skip to content

How it works

A diagram is built in layers: points joined by lines, a particle on each line, what happens at each point, what runs alongside, then where everything goes and how it is pictured. Each layer is one page in this section, in this order. Below, one diagram is built up a layer at a time. Point at a line of source to see what it draws.

1. Points and lines

Name the points and join them; feynjs places every point itself. Point at a line of source, or step through it with the arrows beside the diagram: what the line draws lights up, and the text beside the diagram says what it does.

in: i1 i2 out: f1 f2 i1 -- a -- i2 a -- b f1 -- b -- f2
in: i1 i2           % i1 and i2 come in, on the left
out: f1 f2          % f1 and f2 go out, on the right
i1 -- a -- i2       % the two incoming lines meet at a
a -- b              % a line from a to b
f1 -- b -- f2       % the two outgoing lines leave b

Writing diagrams covers chains, panels and the switches that apply to a whole diagram.

2. A particle on each line

A particle's name sets the line's style, its arrow and its label in one word.

i1 [e-] -- a -- i2 [e+] a -- [gamma] b f1 [mu-] -- b -- f2 [mu+]
i1 [e-] -- a -- i2 [e+]      % an electron and a positron, named on their points
a -- [gamma] b               % a photon, named on its line
f1 [mu-] -- b -- f2 [mu+]    % a muon pair

in: and out: can go: names starting with i come in and names starting with f go out. Lines, particles and labels has every line style, label and note; All particles and line types lists every name.

Or name the process, as MadGraph writes it, and feynjs works out the points and lines:

e- e+ > gamma > mu- mu+
e- e+ > gamma > mu- mu+      % what comes in > what is exchanged > what goes out

Processes covers decays, decay chains and production modes.

3. What happens at a point

A point can carry a vertex dot and its coupling, or be a blob, a proton beam, a nucleus, or a hadron's quarks.

i1 [e-] -- a -- i2 [e+] a -- [gamma] b f1 [mu-] -- b -- f2 [mu+] a [dot, label=e] b [dot, label=e]
i1 [e-] -- a -- i2 [e+]
a -- [gamma] b
f1 [mu-] -- b -- f2 [mu+]
a [dot, label=e]             % a dot at a, its coupling e beside it
b [dot, label=e]             % and the same at b

Vertices, loops and hadrons also covers loops, boxes, penguins, mesons and spectator quarks.

4. What runs alongside

Colour can be drawn beside the quarks and gluons, and a final state can be drawn as what a detector sees: a jet, a large-R jet with what is inside it, missing energy.

colour flow: on u ubar > g > t tbar
colour flow: on              % draw each colour line beside its quark or gluon
u ubar > g > t tbar          % a quark pair makes a gluon, which makes a top pair

See Colour flow and Detector objects.

5. How it's all laid out

An engine places the points, and one switch picks it; the rest of the source stays the same. Press a button to watch the same diagram move to another layout.

p p > t t~, (t > b w+, w+ > e+ ve), (t~ > b~ w-, w- > j j)
layout: default
p p > t t~, (t > b w+, w+ > e+ ve), (t~ > b~ w-, w- > j j)
  • Default balances forces that encode how physicists draw: decays fan out from their parent, the stages of a cascade grow shorter, nothing crosses.
  • Grid snaps every line to a multiple of 45 degrees, as a diagram drawn on squared paper.
  • Final plane lines up every outgoing particle on the right, as the final state an experiment sees.

Points given at (x, y) stay where they are put, and the rest settle round them. Engines covers each engine and its settings.

6. Drawing the eye

Three marks point a reader at what matters: a pulse on a point or a line, a band for a particle that lives a while, and a brace grouping lines.

i1 [q] -- a -- i2 [qbar'] a [dot, pulse] -- [W+] b b -- [chargino, lifetime={c\tau}] c b -- f1 [neutralino2] c -- f2 [neutralino1] c -- f3 [pi+]
i1 [q] -- a -- i2 [qbar']
a [dot, pulse] -- [W+] b                  % pulse: the point beats and the lines meeting there glow
b -- [chargino, lifetime={c\tau}] c       % lifetime: a band filling in toward the decay, braced with cτ
b -- f1 [neutralino2]
c -- f2 [neutralino1]
c -- f3 [pi+]
in: u d out: mu nu u [u] -- [fermion] a -- [fermion] d [\bar{d}] a -- [W+] b mu [mu+] -- [fermion] b -- [fermion] nu [nu_mu] hadron: \pi^+ = u d [brace]
in: u d
out: mu nu
u [u] -- [fermion] a -- [fermion] d [\bar{d}]    % a u and a d-bar...
a -- [W+] b
mu [mu+] -- [fermion] b -- [fermion] nu [nu_mu]
hadron: \pi^+ = u d [brace]                      % ...braced together as the pion they make

Drawing the eye covers pulses, lifetimes and revealing a diagram step by step; hadrons are in Vertices, loops and hadrons.

7. How it is pictured

The same diagram can be drawn as something else: the kinematics in the lab, a lattice, or for a nuclear process, the textbook picture of the reaction.

2H 3H > 4He n
2H 3H > 4He n                % deuterium and tritium fuse to helium and a neutron

See Views.

The whole syntax, and complete diagrams

Syntax at a glance puts every part of the syntax on one page. Examples has complete diagrams by subject, from the Standard Model to supersymmetry, each with its source.