Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Episode 3: Physics - Feynman Diagrams #65

Open
amorenobr opened this issue Jul 25, 2022 · 13 comments
Open

Episode 3: Physics - Feynman Diagrams #65

amorenobr opened this issue Jul 25, 2022 · 13 comments

Comments

@amorenobr
Copy link
Contributor

The Feynman package allows to draw Feynman diagrams using matplotlib. This could be included in this episode in order to show more examples and applications

@welcome
Copy link

welcome bot commented Jul 25, 2022

Thanks for opening your first issue here! If you have any questions, feel free to mention one of the conveners, previous contributors, or attend our weekly meeting (see https://hepsoftwarefoundation.org/workinggroups/training.html). Also, sometimes issues go unnoticed, so don't hesitate to @mention some of us, if we do not come back to you within a few days.

@amorenobr amorenobr changed the title Episode 2: Feynman Diagrams Episode 3: Physics - Feynman Diagrams Jul 25, 2022
@amanmdesai
Copy link
Contributor

amanmdesai commented Jul 25, 2022

I have a couple of scripts here (for Higgs-strahlung)

https://github.com/amanmdesai/Feynman-Diagrams/blob/master/higgs_strahlung.py

or this one if you want to show decays of Higgs

https://github.com/amanmdesai/Feynman-Diagrams/blob/master/higgs_cc.py

@amorenobr
Copy link
Contributor Author

Yes Aman, that would be the idea...

@amanmdesai
Copy link
Contributor

amanmdesai commented Jul 25, 2022

How about adding this:

import matplotlib.pyplot as plt
from feynman import Diagram

fig = plt.figure(figsize=(10.,10.))
ax = fig.add_axes([0,0,1,1], frameon=False)

diagram = Diagram(ax) 
diagram.text(.5,0.9,"Higgs Strahlung with H -> cc~ and Z decay to l+ l-", fontsize=20)
in1 = diagram.vertex(xy=(.05,.75), marker='') #quark starting point (left up); xy- vertex coordinates (x,y); marker
in2 = diagram.vertex(xy=(.05,.25), marker='') # anti-quark starting point (left down) 
v1 = diagram.vertex(xy=(.30,.5)) # Z boson starting point (left) 
v2 = diagram.vertex(xy=(.60,.5)) # Z boson starting point (right)
higgsout = diagram.vertex(xy=(.8,.65)) # higgs boson
zhout = diagram.vertex(xy=(.8,.35),marker='')  # produced Z boson in association with Higgs
c1 = diagram.vertex(xy=(.9,.75),marker='') # charm quark 
c2 = diagram.vertex(xy=(.9,.55),marker='') # charm antiquark
l1 = diagram.vertex(xy=(.9,.25),marker='') # lepton 1
l2 = diagram.vertex(xy=(.9,.45),marker='') # lepton 2

q1 = diagram.line(in1, v1) #quark 1; line joining the points 
q2 = diagram.line(v1, in2) #quark 2 
wz1 = diagram.line(v1, v2, style='wiggly',nwiggles=6) # wiggles to represent Z boson 
wz2 = diagram.line(v2, zhout, style='wiggly',nwiggles=6)
higgs = diagram.line(v2, higgsout, arrow=False, style='dashed') # dashed line to represent the higgs
charm1 = diagram.line(c1,higgsout)
charm2 = diagram.line(higgsout, c2)
lep1 = diagram.line(zhout, l1)
lep2 = diagram.line(zhout, l2)

# Text command adds text near the line

q1.text("q",fontsize=30)
q2.text(r"$\bar{\mathrm{q}}$",fontsize=30)
wz1.text("$Z$",t=0.5,y=0.1,fontsize=30)
wz2.text("$Z$",t=0.5,y=-0.15,fontsize=30)
higgs.text("H",fontsize=30)
charm2.text("c",fontsize=30)
charm1.text(r"$\bar{\mathrm{c}}$",fontsize=30)
lep2.text(r"$\mathcal{l}^{\pm}$",t=0.5,y=0.1,fontsize=30)
lep1.text(r"$\mathcal{l}^{\mp}$",t=0.5,y=-0.1,fontsize=30)
diagram.scale(0.6)
diagram.plot()
plt.savefig('zh_hcc.eps', format='eps')

Here is the code with comments

https://github.com/amanmdesai/Feynman-Diagrams/blob/master/higgs_ZH_production_hcc.py

@amorenobr
Copy link
Contributor Author

That looks great Aman. I think it is important to make everything clear, as much as we can.

I don't know if you have had any problem with that, but in my case Feynman runs with python 2.

@amanmdesai
Copy link
Contributor

I am using Python 3.10.4

@klieret
Copy link
Member

klieret commented Jul 25, 2022

Hi @amanmdesai @amorenobr Thanks a lot for starting this! I think we were discussing this a long time ago in one of our training meetings. I'm a bit wary of pushing too many "walls of code" on the students and I think that this will be more of a special use case of matplotlib.
But I think it would indeed be a fun bonus episode that can be included depending on the time budget of the workshop or for students who want more :)

@amorenobr
Copy link
Contributor Author

I agree with you @klieret. Maybe we could add these codes in hidden sections right below every diagram in this episode, so if anybody is interested in learning something fun can take a look :)

@klieret
Copy link
Member

klieret commented Jul 25, 2022

Ah, I also really like that idea :)

@amanmdesai
Copy link
Contributor

amanmdesai commented Jul 26, 2022

The idea sounds good. Codes to the Feynman diagrams could be found here:

https://github.com/GkAntonius/feynman/tree/master/examples/Particle_Physics

1 . plot_VBF.py
2. plot_VH.py
3. plot_ggF_SM.py
4. plot_ttH.py

@klieret
Copy link
Member

klieret commented Jul 26, 2022

We could simply wrap it in a HTML details element like so:

<details>
  <summary>See More</summary>
  This text will be hidden if your browser supports it.
</details>

So feel free to open a PR for that.

For consistency, please format your code with black

@amorenobr
Copy link
Contributor Author

Thanks @klieret and @amanmdesai. I'll open a PR as soon as I can... :)

@stale
Copy link

stale bot commented Sep 24, 2022

This issue or pull request has been automatically marked as stale because it has not had recent activity. Please manually close it, if it is no longer relevant, or ask for help or support to help getting it unstuck. Let me bring this to the attention of @klieret @wdconinc @michmx for now.

@stale stale bot added the stale label Sep 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants