PyFeyn examplesHere's some sample output from pyfeyn, with the source code that produces it: Drell-Yan with QCD vertex correctionVery little code is needed to produce simple diagrams like this one. Note that the labels on the lines are produced by LaTeX and use the predefined names in the hepnames LaTeX package if it's available. from pyfeyn.user import *
processOptions()
fd = FeynDiagram()
in1 = Point(-4, 2)
in2 = Point(-4, -2)
out1 = Point(4, -2)
out2 = Point(4, 2)
in_vtx = Vertex(-2, 0, mark=CIRCLE)
out_vtx = Vertex(2, 0, mark=CIRCLE)
l1 = Label("Drell-Yan QCD vertex correction", x=0, y=2)
fa1 = Fermion(in1, in_vtx).addArrow().addLabel(r"\Pelectron")
fa2 = Fermion(in_vtx, in2).addArrow().addLabel(r"\Ppositron")
fa2.addParallelArrow(size=0.1, displace=-0.06, sense=-1)
bos = Photon(in_vtx, out_vtx).addLabel(r"\Pphoton/\PZ")
fb1 = Fermion(out1, out_vtx).addArrow(0.2).addLabel(r"\APquark")
fb1.addParallelArrow(size=0.1, displace=-0.06, sense=-1)
fb2 = Fermion(out_vtx, out2).addArrow(0.8).addLabel(r"\Pquark")
glu = Gluon(midpoint(out_vtx, out1), midpoint(out_vtx, out2)).set3D()
glu.invert().bend(0.5).addLabel("\Pgluon", displace=0.35)
glu.addParallelArrow(size=0.1, displace=0.2, sense=-1)
fd.draw("pyfeyn-test1.pdf")
produces (click to enlarge):
(PDF version)
Curves and blobsNote that the curly lines automatically match themselves to the outlines of the interaction blobs! I hope this isn't meant to be a real process... from pyfeyn.user import *
fd = FeynDiagram()
p1 = Point(2, -2)
p2 = Point(-2, 2)
p3 = Vertex(1.25, 1.25, mark=CIRCLE)
p4 = p1.midpoint(p2)
p5 = p4.midpoint(p1)
p6 = p4.midpoint(p2)
c1 = Circle(center=p1, radius=0.5, fill=[RED], points=[p1])
c2 = Circle(center=p2, radius=0.3, fill=[GREEN], points=[p2])
e1 = Ellipse(center=p4, xradius=0.5, yradius=1.0,
fill=[MIDNIGHTBLUE], points=[p4])
l0a = Fermion(p1, p4)
l0b = Fermion(p2, p4)
l1 = NamedLine["gluon"](p2, p1).arcThru(x=3, y=0)
l2 = NamedLine["photon"](p1, p2).arcThru(x=0, y=-3)
l3 = Gluon(p2, p3)
l4 = Photon(p1, p3)
l5 = Gluon(p5, p6).bend(-p5.distance(p6)/2.0)
loop1 = Line(p3, p3).arcThru(x=1.75, y=1.75).addArrow(0.55)
l1.addLabel(r"\Pgluon")
l2.addLabel(r"\Pphoton")
l5.addLabel(r"$\Pgluon_1$")
fd.draw("pyfeyn-test2.pdf")
produces (click to enlarge):
(PDF version)
B meson decayThis is a colour-suppressed penguin decay diagram. We'd like to improve the quality of the blob rendering. ## A B-meson colour-suppressed penguin decay diagram
# _
# in1 ------(_)------() out1a
# \ ____() out1b
# \(____
# () out2a
# in2 ---------------() out2b
#
from pyfeyn.user import *
fd = FeynDiagram()
in1 = Point(1, 7)
loop_in = Vertex(4, 7)
loop_out = Vertex(7, 7)
out1a = Point(11, 7)
out1b = Point(11, 5)
in2 = Point(1, 0)
out2a = Point(11, 2)
out2b = Point(11, 0)
out1c = Vertex(out1b.x() - 2, out1b.y())
out1d = Vertex(out2a.x() - 2, out2a.y())
vtx = Vertex(out1c.midpoint(out1d).x() - 1.5, out1c.midpoint(out1d).y())
f_spec = Fermion(out2b, in2).addArrow().addLabel(r"\APdown")
f1 = Fermion(in1, loop_in).addArrow().addLabel(r"\Pbottom")
f2 = Fermion(loop_out, out1a).addArrow().addLabel(r"\Pstrange")
bos1 = Photon(loop_in, loop_out).bend(-1.5).addLabel(r"\PWplus")
f_loop = Fermion(loop_in, loop_out).bend(+1.5).addArrow() \
.addLabel(r"\Pup,\,\Pcharm,\,\Ptop")
bos2 = Photon(f_loop.fracpoint(0.6), vtx).addLabel(r"\Pphoton/\PZ", displace=0.5).bend(0.5)
f3 = Fermion(out1b, out1c).addArrow(0.8).addLabel(r"\APup")
f4 = Fermion(out1c, out1d).arcThru(vtx)
f5 = Fermion(out1d, out2a).addArrow(0.2).addLabel(r"\Pup")
in_blob = Ellipse(x=1, y=3.5, xradius=1, yradius=3.5).setFillStyle(CROSSHATCHED45)
out_blob1 = Ellipse(x=11, y=6, xradius=0.6, yradius=1).setFillStyle(HATCHED135)
out_blob2 = Ellipse(x=11, y=1, xradius=0.6, yradius=1).setFillStyle(HATCHED135)
fd.draw("pyfeyn-test3.pdf")
produces (click to enlarge):
(PDF version)
Higgs loopA top loop contribution to the Higgs boson mass — the canonical "why we need SUSY" diagram. The main point is that it's pretty simple and the code is correspondingly short. from pyfeyn.user import *
fd = FeynDiagram()
in1 = Point(-3, 0)
out1 = Point( 3, 0)
vtx1 = Vertex(-1, 0)
vtx2 = Vertex( 1, 0)
higgs1 = Higgs(in1, vtx1).addLabel(r"\PHiggs")
higgs2 = Higgs(vtx2, out1).addLabel(r"\PHiggs")
loop1 = Fermion(vtx1, vtx2).bend(-1).addArrow().addLabel(r"\APtop")
loop1 = Fermion(vtx2, vtx1).bend(-1).addArrow().addLabel(r"\Ptop")
fd.draw("pyfeyn-test4.pdf")
produces (click to enlarge):
(PDF version)
Multi-linesMulti-lines like these aren't finished yet, but with code like this you can at least get most of the right effect. from pyfeyn.user import *
fd = FeynDiagram()
p1 = Point(-2, 0)
p2 = Point( 2, 0)
fa1 = MultiLine(p1, p2).bend(0.5).addArrow()
c1 = Circle(center=p1, radius=0.5, fill=[color.rgb.red], points=[p1])
c2 = Circle(center=p2, radius=0.5, fill=[color.rgb.blue], points=[p2])
fd.draw("pyfeyn-test5.pdf")
produces (click to enlarge):
(PDF version)
Graviton and SUSY linesNo, we don't know why there are graviton and SUSY lines available by default. Oh, yes we do: they were fun to write! from pyfeyn.user import *
fd = FeynDiagram()
i1 = Point(-4, +2)
i2 = Point(-4, -2)
v1 = Vertex(-2, 0, mark=CircleMark())
v2 = Vertex(+2, 0, mark=CircleMark())
o1 = Point(+4, +2)
o2 = Point(+4, -2)
l1 = Fermion(i1, v1).addArrow()
l2 = Fermion(v1, i2).addArrow()
l1 = Fermion(o1, v2).addArrow(0.25)
l2 = Fermion(v2, o2).addArrow(0.8)
g1 = Gluino(v1, v2).bend(1.5).set3D()
g2 = Gaugino(v1, v2).bend(-1.5).set3D()
g3 = Graviton(midpoint(v2,o2), midpoint(v2,o1)).bend(0.5).set3D()
g1.setStyles([color.rgb.red])
lab = Label("A silly SUSY / graviton demo", x=0, y=2.2)
fd.draw("pyfeyn-test6.pdf")
produces (click to enlarge):
(PDF version)
Silly effectsWhere PyFeyn ends, PyX begins. You can take the output of PyFeyn and use it to make silly effects like these transparency-based rotation and translation "blurs". from pyfeyn.user import *
from pyx import *
fd = FeynDiagram()
in1 = Point(-4, 2)
in2 = Point(-4, -2)
out1 = Point(4, -2)
out2 = Point(4, 2)
in_vtx = Vertex(-2, 0, mark=CIRCLE)
out_vtx = Vertex(2, 0, mark=CIRCLE)
fa1 = Fermion(in1, in_vtx).addArrow().addLabel(r"\Pelectron")
fa2 = Fermion(in_vtx, in2).addArrow().addLabel(r"\Ppositron")
bos = Photon(in_vtx, out_vtx).addLabel(r"\Pphoton/\PZ")
fb1 = Fermion(out1, out_vtx).addArrow(0.2).addLabel(r"\APquark")
fb2 = Fermion(out_vtx, out2).addArrow(0.8).addLabel(r"\Pquark")
glu = Gluon(midpoint(out_vtx, out1), midpoint(out_vtx, out2))
glu.invert().bend(0.5).addLabel("\Pgluon", displace=0.25)
numcopies = 10
angle = 0.8
c1 = fd.drawToCanvas()
c2 = canvas.canvas()
c2.insert(c1, [trafo.rotate(-numcopies*angle)])
c = canvas.canvas()
for i in range(numcopies):
trans = 1 - ((i+1)/float(numcopies))**8
c.insert(c2, [trafo.rotate((i+1)*angle), color.transparency(trans)])
c.insert(c1, [trafo.translate(0.1 - 0.01*(i+1), -5 + 0.05*(i+1)), color.transparency(trans)])
c.writetofile("pyfeyn-test7.pdf")
produces (click to enlarge):
(PDF version)
|