JP-Ellis / tikz-feynman

Feynman Diagrams with TikZ
http://www.jpellis.me/projects/tikz-feynman
Other
148 stars 20 forks source link

Time reversal, long labels #3

Closed martin-ueding closed 8 years ago

martin-ueding commented 8 years ago

I want to build a Feynman diagram with a scalar vertex correction in first order. It does look kind of okay:

There a couple of things that I'd like to improve:

Is there something I can change in my code? If not, could you perhaps improve the otherwise very promising package?

My code:

\begin{tikzpicture}
    \graph[feynman, horizontal=v1 to v2]{
        a
        -- [fermion, momentum={$\four p$}] h1
        -- [fermion, momentum'={$\four k$}] v1
        -- [fermion, momentum'={$\four k' = \four k + \four q$}] h2
        -- [fermion, momentum={$\four p'$}] b
        ;

        h1 -- [scalar, semi-left, momentum={$\four p - \four k$}] h2;

        v2 -- [photon, momentum={$\four q$}] v1;
    };
\end{tikzpicture}

The \four is some fancy four-vector using boldmath but should not break anything. The snippet is in my homework solutions project.

JP-Ellis commented 8 years ago

Thanks for the feedback, I'm glad you have found this package useful :)

Firstly, the graph can be flipped around by using horizontal'=v1 to v2 instead of horizontal=v1 to v2. The extra ' tells the graphing algorithm to flip the graph around that line, so this should fix your fermion line to be going up.

As for the momentum labels, there is the key momentum/label distance which can move the momentum label further away; however, due to the way Ti_k_Z draws the graph, it doesn't work on a per-arrow basis when used inside a graph and has to be set globally. When I get around to it, I want to fix this and implement a similar syntax to the way labels are created (something like momentum={[label sep=0.5cm] \(k\)}). Your code also illustrates another bug: the momentum arrows override the way the line is draw and remove the effect of bend left unfortunately (something else I have to fix).

Finally, regarding the fermion lines not being bent by the scalar: unfortunately this can't be achieved with the algorithm as it is (at least, to my knowledge). Ti_k_Z-Feynman builds on the existing graphing algorithms from Ti_k_Z and for me to support this, I would need to rework the underlying algorithms to work more intimately with Ti_k_Z-Feynman (which I may do at some point in the future, but it's definitely not a priority). A workaround is to not draw the scalar edge in the graph itself, but draw it afterwards (though I find the

Here is a minimal working example to illustrate the fixes:

\documentclass[tikz]{standalone}
\usepackage{tikz-feynman}

\begin{document}
\begin{tikzpicture}[momentum/label distance=0.5cm]
    \graph[feynman, horizontal'=v1 to v2]{
        a
        -- [fermion, momentum'=\(p\)] h1
        -- [fermion, momentum=\(k\)] v1
        -- [fermion, momentum={\(k' = k + q\)}] h2
        -- [fermion, momentum'=\(p'\)] b
        ;

        h1 -- [scalar, momentum'=\(p - k\)] h2;

        v2 -- [photon, momentum=\(q\)] v1;
    };
\end{tikzpicture}
\begin{tikzpicture}[momentum/label distance=0.5cm]
    \graph[feynman, horizontal'=v1 to v2]{
        a
        -- [fermion, momentum'=\(p\)] h1
        -- [fermion, momentum=\(k\)] v1
        -- [fermion, momentum=\(k + q\)] h2
        -- [fermion, momentum'=\(p'\)] b
        ;

        v2 -- [photon, momentum=\(q\)] v1;
    };
    \draw[scalar, momentum'=\(p - k\)] (h1) to (h2);
\end{tikzpicture}
\end{document}

I have exams finishing on the 9th of November, so I won't be able to fix these bugs until then; however, I certainly intend to get version 1 of Ti_k_Z-Feynman complete soon afterwards :)

martin-ueding commented 8 years ago

Thanks for the suggestions! Those helped me enough to get a nice looking graph. Good luck with your exams!