Pyfeyn

https://pyfeyn.hepforge.org/examples

[1]:
from feynml import FeynmanDiagram, Leg, Propagator, Vertex
from pyfeyn2.render.all import AllRender
from pyfeyn2.render.latex.tikzfeynman import TikzFeynmanRender
from pyfeyn2.auto.position import feynman_adjust_points
from pyfeyn2.auto.label import auto_label
from pyfeyn2.auto.bend import auto_bend
from feynml import Momentum
[2]:
v1 = Vertex().with_xy(-1, 0)
v2 = Vertex().with_xy(1, 0)
v3 = Vertex().with_xy(2, 1)
v4 = Vertex().with_xy(2, -1)

fd = FeynmanDiagram().add(
    v1, v2, v3, v4,
    Propagator().connect(v1, v2).with_type("boson").with_label("$\\gamma/Z$"),
    Propagator(pdgid=1).connect(v2, v3),
    Propagator(pdgid=-1).connect(v2,v4),
    Propagator(name="g").connect(v3,v4).with_style("bend-direction : left"),
    Leg(pdgid=11).with_target(v1).with_xy(-3, 2).with_incoming().with_style("momentum-arrow : true; momentum-arrow-sense : 1").with_momentum(Momentum(name="$\\vec p$")),
    Leg(pdgid=-11).with_target(v1).with_xy(-3, -2).with_incoming(),
    Leg(pdgid=1).with_target(v3).with_xy(3, 2).with_outgoing(),
    Leg(pdgid=-1).with_target(v4).with_xy(3, -2).with_outgoing(),
)
auto_label(fd.propagators + fd.legs)
ar = AllRender(fd)
ar.render()
tikz:
../../_images/gallery_pyfeyn_pyfeyn_2_1.png
pyx:
../../_images/gallery_pyfeyn_pyfeyn_2_3.png
feynmp:
../../_images/gallery_pyfeyn_pyfeyn_2_5.png
feynman:
../../_images/gallery_pyfeyn_pyfeyn_2_7.png
dot:
../../_images/gallery_pyfeyn_pyfeyn_2_9.png
mermaid:
../../_images/gallery_pyfeyn_pyfeyn_2_11.svg
asciipdf:
../../_images/gallery_pyfeyn_pyfeyn_2_13.png
unicodepdf:
../../_images/gallery_pyfeyn_pyfeyn_2_15.png
madgraph:
../../_images/gallery_pyfeyn_pyfeyn_2_17.png
root:
../../_images/gallery_pyfeyn_pyfeyn_2_19.png
Info in <TCanvas::SaveSource>: C++ Macro file: /tmp/tmpirofgrqd.tex has been generated
Info in <TCanvas::Print>: TeX file /tmp/tmpphtm9s41.tex has been created
[3]:
v1 = Vertex(x=-2,y=0)
v2 = Vertex(x= 2,y=0)
l1 = Leg(x=-4,y=0,pdgid=25)
l2 = Leg(x= 4,y=0,pdgid=25)

fd = FeynmanDiagram().add(
    v1, v2,
    Propagator(pdgid=6).connect(v1, v2),
    Propagator(pdgid=-6).connect(v1, v2),
    l1.with_target(v1).with_incoming(),
    l2.with_target(v2).with_outgoing(),
)
auto_label(fd.propagators + fd.legs)
auto_bend(fd)
ar = AllRender(fd)
ar.render()
tikz:
../../_images/gallery_pyfeyn_pyfeyn_3_1.png
pyx:
../../_images/gallery_pyfeyn_pyfeyn_3_3.png
feynmp:
../../_images/gallery_pyfeyn_pyfeyn_3_5.png
feynman:
../../_images/gallery_pyfeyn_pyfeyn_3_7.png
dot:
../../_images/gallery_pyfeyn_pyfeyn_3_9.png
mermaid:
../../_images/gallery_pyfeyn_pyfeyn_3_11.svg
asciipdf:
../../_images/gallery_pyfeyn_pyfeyn_3_13.png
unicodepdf:
../../_images/gallery_pyfeyn_pyfeyn_3_15.png
madgraph:
../../_images/gallery_pyfeyn_pyfeyn_3_17.png
root:
../../_images/gallery_pyfeyn_pyfeyn_3_19.png
Error in <TCanvas::Range>: illegal world coordinates range: x1=-4.400000, y1=0.000000, x2=4.400000, y2=0.000000
Info in <TCanvas::SaveSource>: C++ Macro file: /tmp/tmpwnvz1tx4.tex has been generated
Info in <TCanvas::Print>: TeX file /tmp/tmp82w82usj.tex has been created
[4]:
v1 = Vertex(x=-2,y=0)
v2 = Vertex(x= 2,y=0)
l1 = Leg(x=-4,y=0,pdgid=25)
l2 = Leg(x= 4,y=0,pdgid=25)

fd = FeynmanDiagram().add(
    v1, v2,
    Propagator(pdgid=6).connect(v1, v2),
    Propagator(pdgid=-6).connect(v1, v2),
    #l1.with_target(v1).with_incoming(),
    #l2.with_target(v2).with_outgoing(),
)
auto_label(fd.propagators + fd.legs)
auto_bend(fd)
ar = AllRender(fd)
ar.render()
tikz:
../../_images/gallery_pyfeyn_pyfeyn_4_1.png
pyx:
../../_images/gallery_pyfeyn_pyfeyn_4_3.png
feynmp:
../../_images/gallery_pyfeyn_pyfeyn_4_5.png
feynman:
../../_images/gallery_pyfeyn_pyfeyn_4_7.png
dot:
../../_images/gallery_pyfeyn_pyfeyn_4_9.png
mermaid:
../../_images/gallery_pyfeyn_pyfeyn_4_11.svg
asciipdf:
../../_images/gallery_pyfeyn_pyfeyn_4_13.png
unicodepdf:
../../_images/gallery_pyfeyn_pyfeyn_4_15.png
madgraph:
../../_images/gallery_pyfeyn_pyfeyn_4_17.png
root:
../../_images/gallery_pyfeyn_pyfeyn_4_19.png
Error in <TCanvas::Range>: illegal world coordinates range: x1=-2.200000, y1=0.000000, x2=2.200000, y2=0.000000
Info in <TCanvas::SaveSource>: C++ Macro file: /tmp/tmpuaegz_vt.tex has been generated
Info in <TCanvas::Print>: TeX file /tmp/tmpmqxqycro.tex has been created
[ ]:

[ ]:

[ ]: