add new notes and restructure

This commit is contained in:
hiro98 2020-03-31 12:16:57 +02:00
parent 17178156fa
commit d05c1601d1
4 changed files with 14 additions and 434 deletions

Binary file not shown.

View file

@ -79,6 +79,9 @@ Viele Gruesse, Frank
- [[file:prog/python/qqgg/analytical_xs.ipynb][Notebook mit Implementierung der XS]]
- Zeigte fehler in Rechnung auf
** Monte Carlo Methods
- [[file:prog/python/qqgg/analytical_xs.org::*Numerical Integration][Integration]]
- [[file:prog/python/qqgg/analytical_xs.org::*Sampling and Analysis][Sampling and Analysis]]
* Clock Table
#+BEGIN: clocktable :scope file :maxlevel 2
#+CAPTION: Clock summary at [2020-03-18 Wed 21:01]

View file

@ -1,420 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<!-- 2020-03-28 Sat 11:30 -->
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>&lrm;</title>
<meta name="generator" content="Org mode" />
<style type="text/css">
<!--/*--><![CDATA[/*><!--*/
.title { text-align: center;
margin-bottom: .2em; }
.subtitle { text-align: center;
font-size: medium;
font-weight: bold;
margin-top:0; }
.todo { font-family: monospace; color: red; }
.done { font-family: monospace; color: green; }
.priority { font-family: monospace; color: orange; }
.tag { background-color: #eee; font-family: monospace;
padding: 2px; font-size: 80%; font-weight: normal; }
.timestamp { color: #bebebe; }
.timestamp-kwd { color: #5f9ea0; }
.org-right { margin-left: auto; margin-right: 0px; text-align: right; }
.org-left { margin-left: 0px; margin-right: auto; text-align: left; }
.org-center { margin-left: auto; margin-right: auto; text-align: center; }
.underline { text-decoration: underline; }
#postamble p, #preamble p { font-size: 90%; margin: .2em; }
p.verse { margin-left: 3%; }
pre {
border: 1px solid #ccc;
box-shadow: 3px 3px 3px #eee;
padding: 8pt;
font-family: monospace;
overflow: auto;
margin: 1.2em;
}
pre.src {
position: relative;
overflow: visible;
padding-top: 1.2em;
}
pre.src:before {
display: none;
position: absolute;
background-color: white;
top: -10px;
right: 10px;
padding: 3px;
border: 1px solid black;
}
pre.src:hover:before { display: inline;}
/* Languages per Org manual */
pre.src-asymptote:before { content: 'Asymptote'; }
pre.src-awk:before { content: 'Awk'; }
pre.src-C:before { content: 'C'; }
/* pre.src-C++ doesn't work in CSS */
pre.src-clojure:before { content: 'Clojure'; }
pre.src-css:before { content: 'CSS'; }
pre.src-D:before { content: 'D'; }
pre.src-ditaa:before { content: 'ditaa'; }
pre.src-dot:before { content: 'Graphviz'; }
pre.src-calc:before { content: 'Emacs Calc'; }
pre.src-emacs-lisp:before { content: 'Emacs Lisp'; }
pre.src-fortran:before { content: 'Fortran'; }
pre.src-gnuplot:before { content: 'gnuplot'; }
pre.src-haskell:before { content: 'Haskell'; }
pre.src-hledger:before { content: 'hledger'; }
pre.src-java:before { content: 'Java'; }
pre.src-js:before { content: 'Javascript'; }
pre.src-latex:before { content: 'LaTeX'; }
pre.src-ledger:before { content: 'Ledger'; }
pre.src-lisp:before { content: 'Lisp'; }
pre.src-lilypond:before { content: 'Lilypond'; }
pre.src-lua:before { content: 'Lua'; }
pre.src-matlab:before { content: 'MATLAB'; }
pre.src-mscgen:before { content: 'Mscgen'; }
pre.src-ocaml:before { content: 'Objective Caml'; }
pre.src-octave:before { content: 'Octave'; }
pre.src-org:before { content: 'Org mode'; }
pre.src-oz:before { content: 'OZ'; }
pre.src-plantuml:before { content: 'Plantuml'; }
pre.src-processing:before { content: 'Processing.js'; }
pre.src-python:before { content: 'Python'; }
pre.src-R:before { content: 'R'; }
pre.src-ruby:before { content: 'Ruby'; }
pre.src-sass:before { content: 'Sass'; }
pre.src-scheme:before { content: 'Scheme'; }
pre.src-screen:before { content: 'Gnu Screen'; }
pre.src-sed:before { content: 'Sed'; }
pre.src-sh:before { content: 'shell'; }
pre.src-sql:before { content: 'SQL'; }
pre.src-sqlite:before { content: 'SQLite'; }
/* additional languages in org.el's org-babel-load-languages alist */
pre.src-forth:before { content: 'Forth'; }
pre.src-io:before { content: 'IO'; }
pre.src-J:before { content: 'J'; }
pre.src-makefile:before { content: 'Makefile'; }
pre.src-maxima:before { content: 'Maxima'; }
pre.src-perl:before { content: 'Perl'; }
pre.src-picolisp:before { content: 'Pico Lisp'; }
pre.src-scala:before { content: 'Scala'; }
pre.src-shell:before { content: 'Shell Script'; }
pre.src-ebnf2ps:before { content: 'ebfn2ps'; }
/* additional language identifiers per "defun org-babel-execute"
in ob-*.el */
pre.src-cpp:before { content: 'C++'; }
pre.src-abc:before { content: 'ABC'; }
pre.src-coq:before { content: 'Coq'; }
pre.src-groovy:before { content: 'Groovy'; }
/* additional language identifiers from org-babel-shell-names in
ob-shell.el: ob-shell is the only babel language using a lambda to put
the execution function name together. */
pre.src-bash:before { content: 'bash'; }
pre.src-csh:before { content: 'csh'; }
pre.src-ash:before { content: 'ash'; }
pre.src-dash:before { content: 'dash'; }
pre.src-ksh:before { content: 'ksh'; }
pre.src-mksh:before { content: 'mksh'; }
pre.src-posh:before { content: 'posh'; }
/* Additional Emacs modes also supported by the LaTeX listings package */
pre.src-ada:before { content: 'Ada'; }
pre.src-asm:before { content: 'Assembler'; }
pre.src-caml:before { content: 'Caml'; }
pre.src-delphi:before { content: 'Delphi'; }
pre.src-html:before { content: 'HTML'; }
pre.src-idl:before { content: 'IDL'; }
pre.src-mercury:before { content: 'Mercury'; }
pre.src-metapost:before { content: 'MetaPost'; }
pre.src-modula-2:before { content: 'Modula-2'; }
pre.src-pascal:before { content: 'Pascal'; }
pre.src-ps:before { content: 'PostScript'; }
pre.src-prolog:before { content: 'Prolog'; }
pre.src-simula:before { content: 'Simula'; }
pre.src-tcl:before { content: 'tcl'; }
pre.src-tex:before { content: 'TeX'; }
pre.src-plain-tex:before { content: 'Plain TeX'; }
pre.src-verilog:before { content: 'Verilog'; }
pre.src-vhdl:before { content: 'VHDL'; }
pre.src-xml:before { content: 'XML'; }
pre.src-nxml:before { content: 'XML'; }
/* add a generic configuration mode; LaTeX export needs an additional
(add-to-list 'org-latex-listings-langs '(conf " ")) in .emacs */
pre.src-conf:before { content: 'Configuration File'; }
table { border-collapse:collapse; }
caption.t-above { caption-side: top; }
caption.t-bottom { caption-side: bottom; }
td, th { vertical-align:top; }
th.org-right { text-align: center; }
th.org-left { text-align: center; }
th.org-center { text-align: center; }
td.org-right { text-align: right; }
td.org-left { text-align: left; }
td.org-center { text-align: center; }
dt { font-weight: bold; }
.footpara { display: inline; }
.footdef { margin-bottom: 1em; }
.figure { padding: 1em; }
.figure p { text-align: center; }
.inlinetask {
padding: 10px;
border: 2px solid gray;
margin: 10px;
background: #ffffcc;
}
#org-div-home-and-up
{ text-align: right; font-size: 70%; white-space: nowrap; }
textarea { overflow-x: auto; }
.linenr { font-size: smaller }
.code-highlighted { background-color: #ffff00; }
.org-info-js_info-navigation { border-style: none; }
#org-info-js_console-label
{ font-size: 10px; font-weight: bold; white-space: nowrap; }
.org-info-js_search-highlight
{ background-color: #ffff00; color: #000000; font-weight: bold; }
.org-svg { width: 90%; }
/*]]>*/-->
</style>
<script type="text/javascript">
/*
@licstart The following is the entire license notice for the
JavaScript code in this tag.
Copyright (C) 2012-2019 Free Software Foundation, Inc.
The JavaScript code in this tag is free software: you can
redistribute it and/or modify it under the terms of the GNU
General Public License (GNU GPL) as published by the Free Software
Foundation, either version 3 of the License, or (at your option)
any later version. The code is distributed WITHOUT ANY WARRANTY;
without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU GPL for more details.
As additional permission under GNU GPL version 3 section 7, you
may distribute non-source (e.g., minimized or compacted) forms of
that code without the copy of the GNU GPL normally required by
section 4, provided you include this license notice and a URL
through which recipients can access the Corresponding Source.
@licend The above is the entire license notice
for the JavaScript code in this tag.
*/
<!--/*--><![CDATA[/*><!--*/
function CodeHighlightOn(elem, id)
{
var target = document.getElementById(id);
if(null != target) {
elem.cacheClassElem = elem.className;
elem.cacheClassTarget = target.className;
target.className = "code-highlighted";
elem.className = "code-highlighted";
}
}
function CodeHighlightOff(elem, id)
{
var target = document.getElementById(id);
if(elem.cacheClassElem)
elem.className = elem.cacheClassElem;
if(elem.cacheClassTarget)
target.className = elem.cacheClassTarget;
}
/*]]>*///-->
</script>
</head>
<body>
<div id="content">
<div id="table-of-contents">
<h2>Table of Contents</h2>
<div id="text-table-of-contents">
<ul>
<li><a href="#org255850a">1. Init</a>
<ul>
<li><a href="#org2f3a4e9">1.1. Required Modules</a></li>
<li><a href="#org2e97ca2">1.2. Utilities</a></li>
</ul>
</li>
<li><a href="#org468bdb4">2. Implementation</a></li>
<li><a href="#org9989482">3. Calculations</a>
<ul>
<li><a href="#org9716522">3.1. XS qq -&gt; gamma gamma</a></li>
</ul>
</li>
</ul>
</div>
</div>
<div id="outline-container-org255850a" class="outline-2">
<h2 id="org255850a"><span class="section-number-2">1</span> Init</h2>
<div class="outline-text-2" id="text-1">
</div>
<div id="outline-container-org2f3a4e9" class="outline-3">
<h3 id="org2f3a4e9"><span class="section-number-3">1.1</span> Required Modules</h3>
<div class="outline-text-3" id="text-1-1">
<div class="org-src-container">
<pre class="src src-ipython" id="org91f75e0"><span style="color: #859900; font-weight: bold;">import</span> numpy <span style="color: #859900; font-weight: bold;">as</span> np
<span style="color: #859900; font-weight: bold;">import</span> matplotlib.pyplot <span style="color: #859900; font-weight: bold;">as</span> plt
</pre>
</div>
</div>
</div>
<div id="outline-container-org2e97ca2" class="outline-3">
<h3 id="org2e97ca2"><span class="section-number-3">1.2</span> Utilities</h3>
<div class="outline-text-3" id="text-1-2">
<div class="org-src-container">
<pre class="src src-ipython" id="org41306d9">%run ../utility.py
</pre>
</div>
</div>
</div>
</div>
<div id="outline-container-org468bdb4" class="outline-2">
<h2 id="org468bdb4"><span class="section-number-2">2</span> Implementation</h2>
<div class="outline-text-2" id="text-2">
<div class="org-src-container">
<pre class="src src-ipython" id="org30462c1"><span style="color: #35a69c; font-style: italic;">"""</span>
<span style="color: #35a69c; font-style: italic;">Implementation of the analytical cross section for q q_bar -&gt;</span>
<span style="color: #35a69c; font-style: italic;">gamma gamma</span>
<span style="color: #35a69c; font-style: italic;">Author: Valentin Boettcher <a href="mailto:hiro%40protagon.space">&lt;hiro@protagon.space&gt;</a></span>
<span style="color: #35a69c; font-style: italic;">"""</span>
<span style="color: #859900; font-weight: bold;">import</span> numpy <span style="color: #859900; font-weight: bold;">as</span> np
<span style="color: #859900; font-weight: bold;">from</span> scipy.constants <span style="color: #859900; font-weight: bold;">import</span> alpha
<span style="color: #96A7A9; font-style: italic;"># </span><span style="color: #96A7A9; font-style: italic;">NOTE: a more elegant solution would be a decorator</span>
<span style="color: #859900; font-weight: bold;">def</span> <span style="color: #b58900;">energy_factor</span>(charge, esp):
<span style="color: #35a69c; font-style: italic;">"""</span>
<span style="color: #35a69c; font-style: italic;"> Calculates the factor common to all other values in this module</span>
<span style="color: #35a69c; font-style: italic;"> Arguments:</span>
<span style="color: #35a69c; font-style: italic;"> esp -- center of momentum energy in GeV</span>
<span style="color: #35a69c; font-style: italic;"> charge -- charge of the particle in units of the elementary charge</span>
<span style="color: #35a69c; font-style: italic;"> """</span>
<span style="color: #859900; font-weight: bold;">return</span> charge**4*(alpha/esp)**2/6
<span style="color: #859900; font-weight: bold;">def</span> <span style="color: #b58900;">diff_xs</span>(theta, charge, esp):
<span style="color: #35a69c; font-style: italic;">"""</span>
<span style="color: #35a69c; font-style: italic;"> Calculates the differential cross section as a function of the</span>
<span style="color: #35a69c; font-style: italic;"> azimuth angle theta in units of 1/GeV^2.</span>
<span style="color: #35a69c; font-style: italic;"> Arguments:</span>
<span style="color: #35a69c; font-style: italic;"> theta -- azimuth angle</span>
<span style="color: #35a69c; font-style: italic;"> esp -- center of momentum energy in GeV</span>
<span style="color: #35a69c; font-style: italic;"> charge -- charge of the particle in units of the elementary charge</span>
<span style="color: #35a69c; font-style: italic;"> """</span>
<span style="color: #268bd2;">f</span> = energy_factor(charge, esp)
<span style="color: #859900; font-weight: bold;">return</span> f*((np.cos(theta)**+1)/np.sin(theta)**2)
<span style="color: #859900; font-weight: bold;">def</span> <span style="color: #b58900;">diff_xs_eta</span>(eta, charge, esp):
<span style="color: #35a69c; font-style: italic;">"""</span>
<span style="color: #35a69c; font-style: italic;"> Calculates the differential cross section as a function of the</span>
<span style="color: #35a69c; font-style: italic;"> pseudo rapidity of the photons in units of 1/GeV^2.</span>
<span style="color: #35a69c; font-style: italic;"> Arguments:</span>
<span style="color: #35a69c; font-style: italic;"> eta -- pseudo rapidity</span>
<span style="color: #35a69c; font-style: italic;"> esp -- center of momentum energy in GeV</span>
<span style="color: #35a69c; font-style: italic;"> charge -- charge of the particle in units of the elementary charge</span>
<span style="color: #35a69c; font-style: italic;"> """</span>
<span style="color: #268bd2;">f</span> = energy_factor(charge, esp)
<span style="color: #859900; font-weight: bold;">return</span> f*(2*np.cosh(eta)**2 - 1)
<span style="color: #859900; font-weight: bold;">def</span> <span style="color: #b58900;">total_xs_eta</span>(eta, charge, esp):
<span style="color: #35a69c; font-style: italic;">"""</span>
<span style="color: #35a69c; font-style: italic;"> Calculates the total cross section as a function of the pseudo</span>
<span style="color: #35a69c; font-style: italic;"> rapidity of the photons in units of 1/GeV^2. If the rapditiy is</span>
<span style="color: #35a69c; font-style: italic;"> specified as a tuple, it is interpreted as an interval. Otherwise</span>
<span style="color: #35a69c; font-style: italic;"> the interval [-eta, eta] will be used.</span>
<span style="color: #35a69c; font-style: italic;"> Arguments:</span>
<span style="color: #35a69c; font-style: italic;"> eta -- pseudo rapidity (tuple or number)</span>
<span style="color: #35a69c; font-style: italic;"> esp -- center of momentum energy in GeV</span>
<span style="color: #35a69c; font-style: italic;"> charge -- charge of the particle in units of the elementar charge</span>
<span style="color: #35a69c; font-style: italic;"> """</span>
<span style="color: #268bd2;">f</span> = energy_factor(charge, esp)
<span style="color: #859900; font-weight: bold;">if</span> <span style="color: #859900; font-weight: bold;">not</span> <span style="color: #d33682; font-style: italic;">isinstance</span>(eta, <span style="color: #d33682; font-style: italic;">tuple</span>):
<span style="color: #268bd2;">eta</span> = (-eta, eta)
<span style="color: #859900; font-weight: bold;">if</span> <span style="color: #d33682; font-style: italic;">len</span>(eta) != 2:
<span style="color: #859900; font-weight: bold;">raise</span> <span style="color: #b58900; font-style: italic;">ValueError</span>(<span style="color: #2aa198;">'Invalid eta cut.'</span>)
<span style="color: #859900; font-weight: bold;">def</span> <span style="color: #b58900;">F</span>(x):
<span style="color: #859900; font-weight: bold;">return</span> np.tanh(x) - 2*x
<span style="color: #859900; font-weight: bold;">return</span> 2*np.pi*f*(F(eta[0]) - F(eta[1]))
</pre>
</div>
</div>
</div>
<div id="outline-container-org9989482" class="outline-2">
<h2 id="org9989482"><span class="section-number-2">3</span> Calculations</h2>
<div class="outline-text-2" id="text-3">
</div>
<div id="outline-container-org9716522" class="outline-3">
<h3 id="org9716522"><span class="section-number-3">3.1</span> XS qq -&gt; gamma gamma</h3>
<div class="outline-text-3" id="text-3-1">
<p>
First, set up the input parameters.
</p>
<div class="org-src-container">
<pre class="src src-ipython" id="org9135f0f"><span style="color: #268bd2;">eta</span> = 2.5
<span style="color: #268bd2;">charge</span> = 1/3
<span style="color: #268bd2;">esp</span> = 200 <span style="color: #96A7A9; font-style: italic;"># </span><span style="color: #96A7A9; font-style: italic;">GeV</span>
</pre>
</div>
<p>
And now calculate the cross section in picobarn.
</p>
<div class="org-src-container">
<pre class="src src-ipython" id="org1b205cb"><span style="color: #268bd2;">xs_gev</span> = total_xs_eta(eta, charge, esp)
<span style="color: #268bd2;">xs_pb</span> = gev_to_pb(xs_gev)
<span style="color: #859900; font-weight: bold;">print</span>(tex_value(xs_pb, unit=r<span style="color: #2aa198;">'\pico\barn'</span>, prefix=r<span style="color: #2aa198;">'\eta = '</span>))
</pre>
</div>
<p>
<a href="../../../results/xs/xs.tex">../../../results/xs/xs.tex</a>
</p>
<p>
Compared to sherpa, it's pretty close.
</p>
<div class="org-src-container">
<pre class="src src-ipython" id="org2bcb666"><span style="color: #268bd2;">sherpa</span> = 0.0538009
xs_pb/sherpa
</pre>
</div>
<p>
0.9998585425137037
</p>
<p>
I had to set the runcard option <code>EW_SCHEME: alpha0</code> to use the pure
QED coupling constant.
</p>
</div>
</div>
</div>
</div>
<div id="postamble" class="status">
<p class="date">Created: 2020-03-28 Sat 11:30</p>
<p class="validation"><a href="http://validator.w3.org/check?uri=referer">Validate</a></p>
</div>
</body>
</html>

View file

@ -142,11 +142,19 @@ charge = 1/3
esp = 200 # GeV
#+END_SRC
Set up the integration and plot intervals.
#+begin_src ipython :session :exports both :results raw drawer
interval_η = [-η, η]
interval = η_to_θ([-η, η])
interval_cosθ = np.cos(interval)
interval_pt = η_to_pt([0, η], esp/2)
plot_interval = [0.1, np.pi-.1]
#+end_src
#+RESULTS: 7e62918a-2935-41ac-94e0-f0e7c3af8e0d
:RESULTS:
:END:
*** Analytical Integratin
And now calculate the cross section in picobarn.
#+NAME: cf853fb6-d338-482e-bc55-bd9f8e796495
@ -175,19 +183,7 @@ Compared to sherpa, it's pretty close.
I had to set the runcard option ~EW_SCHEME: alpha0~ to use the pure
QED coupling constant.
*** Numerical Integration and Sampling
Set up the integration and plot intervals.
#+begin_src ipython :session :exports both :results raw drawer
interval_η = [-η, η]
interval = η_to_θ([-η, η])
interval_cosθ = np.cos(interval)
interval_pt = η_to_pt([0, η], esp/2)
plot_interval = [0.1, np.pi-.1]
#+end_src
#+RESULTS:
:RESULTS:
:END:
*** Numerical Integration
Plot our nice distribution:
#+begin_src ipython :session :exports both :results raw drawer
@ -257,6 +253,7 @@ print(tex_value(xs_pb_mc, unit=r'\pico\barn', prefix=r'\sigma = ', prec=5))
[[file:results/xs_mc.tex]]
:END:
*** Sampling and Analysis
Now we monte-carlo sample our distribution.
#+begin_src ipython :session :exports both :results raw drawer
cosθ_sample = sample(lambda x: diff_xs_cosθ(x, charge, esp), interval_cosθ)