1

I'm never used this package and I dont know how to use it to draw the diagramas.

Tried to draw some examples I found, but they dont even apear on my pdf file.

I saw on other forums that I had to run a mpost file, but I dont know where I can find or how to run this file. Here are my attemps:

\documentclass[10pt,a4paper]{article}
\usepackage[margin=2.4cm]{geometry} % margins
\usepackage{amsmath}
\usepackage{graphicx}
\usepackage{feynmp}
\usepackage{feynmp-auto}

% macro to compile Feynman graphs without extra scripts
\DeclareGraphicsRule{*}{mps}{*}{}
\makeatletter
\def\endfmffile{
    \fmfcmd{\p@rcent\space the end.^^J end.^^J endinput;}
    \if@fmfio
    \immediate\closeout\@outfmf
    \fi
    %\ifnum\pdfshellescape=\@ne
    \ifnum\pdfshellescape>\z@
    \immediate\write18{mpost \thefmffile}
    \fi}
\makeatother

\begin{document}
    
    
    
    \begin{figure}[h]
        \vspace{10mm}
        \centering
        \begin{fmffile}{attemp 1}
            \begin{fmfgraph*}(150,100)
                \fmfleft{i1}%%determina o termos da esquerda
                \fmfright{o2} %% determina o termo da direita
                \fmflabel{$e^-$}{i1}%%  um e- que vem da esquerda
                \fmflabel{$e^-$}{o2}%% um e- que vai pra direita
                \fmf{photon}{v1,v2}%% foton vai do vértice 1 para o 2
                \fmf{fermion}{i1,v1,o2} %fermion vem do termo i1, da esquerda, entra no vertice v1, vai de v1 para v2, e de v2 para o termo o2.
                \fmf{photon}{v1,o1} %% foton vem do vértice de baixo pra direita, o2
            \end{fmfgraph*}
        \end{fmffile}
        \vspace{5mm}
        \caption{Feynman diagram for Compton scattering} %\label{compton}
    \end{figure}
    
    \large
    \begin{fmffile}{feyngraph}
        \begin{fmfgraph*}(110,60)
            \fmfleft{i1,i2}
            \fmfright{o1,o2}
            \fmflabel{$\mu^-$}{i1}
            \fmflabel{$e^-$}{i2}
            \fmflabel{$\mu^-$}{o1}
            \fmflabel{$e^-$}{o2}
            \fmf{fermion}{i1,v1,o1}
            \fmf{fermion}{i2,v2,o2}
            \fmf{photon,label=$\gamma$}{v1,v2}
        \end{fmfgraph*}
    \end{fmffile}
    
    \newcommand{\marrow}[5]{%
        \fmfcmd{style_def marrow#1
            expr p = drawarrow subpath (1/4, 3/4) of p shifted 6 #2 withpen pencircle scaled 0.4;
            label.#3(btex #4 etex, point 0.5 of p shifted 6 #2);
            enddef;}
        \fmf{marrow#1,tension=0}{#5}}
    
    \begin{fmffile}{diagram with arrows}
        \begin{fmfgraph*}(110,60)
            \fmfleft{i1,i2}
            \fmfright{o1,o2}
            \fmflabel{$e^-$}{i2}
            \fmflabel{$e^-$}{o2}
            \fmflabel{$\mu^-$}{i1}
            \fmflabel{$\mu^-$}{o1}
            \fmf{fermion}{i2,v2,o2}
            \marrow{ea}{ up }{top}{$p_1$}{i2,v2}
            \marrow{eb}{down}{bot}{$p_3$}{v2,o2}
            \fmf{fermion}{i1,v1,o1}
            \marrow{ma}{down}{bot}{$p_2$}{i1,v1}
            \marrow{mb}{ up }{top}{$p_4$}{v1,o1}
            \fmf{photon,label=$\gamma$}{v2,v1}
        \end{fmfgraph*}
    \end{fmffile}

\end{document}

1 Answer 1

1

Excuse me for my delay but I have only cleaned your code and fixed it better because there are man eRrORS. It very difficult for me explained step by steps my improvements.

Here my MWE that works:

\documentclass[10pt,a4paper]{article}
\usepackage[margin=2.4cm]{geometry} % margins
\usepackage{amsmath,amssymb}
\usepackage{graphicx}
\usepackage{feynmp-auto}
\begin{document}
\begin{figure}[h]
        \vspace{10mm}
        \centering
        \begin{fmffile}{zxc}
            \begin{fmfgraph*}(150,100)
                \fmfleft{i1}%%determina o termos da esquerda
                \fmfright{o2} %% determina o termo da direita
                \fmflabel{$e^-$}{i1}%%  um e- que vem da esquerda
                \fmflabel{$e^-$}{o2}%% um e- que vai pra direita
                \fmf{photon}{v1,v2}%% foton vai do vértice 1 para o 2
                \fmf{fermion}{i1,v1,o2} %fermion vem do termo i1, da esquerda, entra no vertice v1, vai de v1 para v2, e de v2 para o termo o.
                \fmf{photon}{v1,o1} %% foton vem do vértice de baixo pra direita, o2
            \end{fmfgraph*}
        \end{fmffile}
        \vspace{5mm}
        \caption{Feynman diagram for Compton scattering} %\label{compton}
    \end{figure}
    \large
    \[\begin{fmffile}{feyngraph}
        \begin{fmfgraph*}(110,60)
            \fmfleft{i1,i2}
            \fmfright{o1,o2}
            \fmflabel{$\mu^-$}{i1}
            \fmflabel{$e^-$}{i2}
            \fmflabel{$\mu^-$}{o1}
            \fmflabel{$e^-$}{o2}
            \fmf{fermion}{i1,v1,o1}
            \fmf{fermion}{i2,v2,o2}
            \fmf{photon,label=$\gamma$}{v1,v2}
        \end{fmfgraph*}
    \end{fmffile}\qquad 
        \newcommand{\marrow}[5]{%
        \fmfcmd{style_def marrow#1
            expr p = drawarrow subpath (1/4, 3/4) of p shifted 6 #2 withpen pencircle scaled 0.4;
            label.#3(btex #4 etex, point 0.5 of p shifted 6 #2);
            enddef;}
        \fmf{marrow#1,tension=0}{#5}}
        \begin{fmffile}{dgs}
        \begin{fmfgraph*}(110,60)
            \fmfleft{i1,i2}
            \fmfright{o1,o2}
            \fmflabel{$e^-$}{i2}
            \fmflabel{$e^-$}{o2}
            \fmflabel{$\mu^-$}{i1}
            \fmflabel{$\mu^-$}{o1}
            \fmf{fermion}{i2,v2,o2}
            \marrow{ea}{ up }{top}{$p_1$}{i2,v2}
            \marrow{eb}{down}{bot}{$p_3$}{v2,o2}
            \fmf{fermion}{i1,v1,o1}
            \marrow{ma}{down}{bot}{$p_2$}{i1,v1}
            \marrow{mb}{ up }{top}{$p_4$}{v1,o1}
            \fmf{photon,label=$\gamma$}{v2,v1}
        \end{fmfgraph*}
    \end{fmffile}\]

\end{document}

enter image description here

5
  • I compiled your code and yet the diagrams dont appear on my pdf. I dont know what i am missing. I compiled twice, following the recomendations of other foruns, and nothing happened. Dec 13, 2021 at 15:16
  • @GabrielVian I don't know the causes. It may be that you haven't updated your LaTeX distribution. I don't know what you are using either TeXLive or >MikTeX. Please keep me informed.
    – Sebastiano
    Dec 13, 2021 at 17:49
  • 1
    Iam using MikTex and keeping it updated. Could this problem have any relation with that "mpost file" I mentioned? Dec 13, 2021 at 17:52
  • @GabrielVian Have you some mistakes? Can you use papeeria.com to compile it?
    – Sebastiano
    Dec 13, 2021 at 17:54
  • 1
    I compiled it on papeeria.com, and it worked. Thats weird, might be something with my compilator. Dec 13, 2021 at 18:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.