Skip to content

Commit 49ded0e

Browse files
authored
Merge pull request #265 from jgray-19/docsTranslated
Translated documentation with latex changes
2 parents dbd2ecc + cbcd548 commit 49ded0e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

70 files changed

+9575
-33
lines changed
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# -- Custom Lexer ------------------------------------------------------------
2+
from pygments.lexers.scripting import LuaLexer
3+
from pygments.token import Comment, Operator
4+
5+
6+
class MadLexer(LuaLexer):
7+
"""
8+
Exactly the same as the Lua Lexer, except for the following changes:
9+
New name, aliases, filenames and url (also removed mimetypes)
10+
The comment can also be !
11+
The character "\\" is now an accepted operator.
12+
"""
13+
14+
name = 'MAD'
15+
url = "https://mad.web.cern.ch/mad/"
16+
aliases = ['mad']
17+
filenames = ['*.mad']
18+
mimetypes = []
19+
20+
tokens = {
21+
**LuaLexer.tokens,
22+
'ws': [
23+
(r'(?:!.*$)', Comment.Single),
24+
*LuaLexer.tokens["ws"],
25+
],
26+
'base': [
27+
(r'\\', Operator),
28+
*LuaLexer.tokens["base"],
29+
],
30+
}

docs/source/alignments.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
.. _ch.phy.align:
2+
3+
Misalignments
4+
=============
5+

docs/source/aperture.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
.. _ch.phy.aper:
2+
3+
Aperture
4+
========

docs/source/beam.rst

Lines changed: 231 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,231 @@
1+
Beams
2+
=====
3+
.. _ch.gen.beam:
4+
5+
The ``beam`` object is the *root object* of beams that store information relative to particles and particle beams. It also provides a simple interface to the particles and nuclei database.
6+
7+
The ``beam`` module extends the :doc:`typeid <types>` module with the ``is_beam`` *function*, which returns ``true`` if its argument is a ``beam`` object, ``false`` otherwise.
8+
9+
Attributes
10+
----------
11+
12+
The ``beam`` *object* provides the following attributes:
13+
14+
**particle**
15+
A *string* specifying the name of the particle. (default: ``"positron"``).
16+
17+
**mass**
18+
A *number* specifying the energy-mass of the particle [GeV]. (default: ``emass``).
19+
20+
**charge**
21+
A *number* specifying the charge of the particle in [q] unit of ``qelect``. [#f1]_ (default: ``1``).
22+
23+
**spin**
24+
A *number* specifying the spin of the particle. (default: ``0``).
25+
26+
**emrad**
27+
A *lambda* returning the electromagnetic radius of the particle [m],
28+
29+
:math:`\mathrm{emrad} = \mathrm{krad\_GeV}\times\mathrm{charge}^2/\mathrm{mass}` where :math:`\mathrm{krad\_GeV} = 10^{-9} (4 \pi\varepsilon_0)^{-1} q`.
30+
31+
**aphot**
32+
A *lambda* returning the average number of photon emitted per bending unit,
33+
34+
:math:`\mathrm{aphot} = \mathrm{kpht\_GeV}\times\mathrm{charge}^2*\mathrm{betgam}` where :math:`\mathrm{kpht\_GeV}` :math:`= \frac{5}{2\sqrt{3}}`.
35+
36+
**energy**
37+
A *number* specifying the particle energy [GeV]. (default: ``1``).
38+
39+
**pc**
40+
A *lambda* returning the particle momentum times the speed of light [GeV],
41+
42+
:math:`\mathrm{pc} = (\mathrm{energy}^2 - \mathrm{mass}^2)^{\frac{1}{2}}`.
43+
44+
**beta**
45+
A *lambda* returning the particle relativistic :math:`\beta=\frac{v}{c}`,
46+
47+
:math:`\mathrm{beta} = (1 - (\mathrm{mass}/\mathrm{energy})^2)^{\frac{1}{2}}`.
48+
49+
**gamma**
50+
A *lambda* returning the particle Lorentz factor :math:`\gamma=(1-\beta^2)^{-\frac{1}{2}}`,
51+
52+
:math:`\mathrm{gamma} = \mathrm{energy}/\mathrm{mass}`.
53+
54+
**betgam**
55+
A *lambda* returning the product :math:`\beta\gamma`,
56+
57+
:math:`\mathrm{betgam} = (\mathrm{gamma}^2 - 1)^\frac{1}{2}`.
58+
59+
**pc2**
60+
A *lambda* returning :math:`\mathrm{pc}^2`, avoiding the square root.
61+
62+
**beta2**
63+
A *lambda* returning :math:`\mathrm{beta}^2`, avoiding the square root.
64+
65+
**betgam2**
66+
A *lambda* returning :math:`\mathrm{betgam}^2`, avoiding the square root.
67+
68+
**brho**
69+
A *lambda* returning the magnetic rigidity [T.m],
70+
71+
:literal:`brho = GeV_c * pc/|charge|` where ``GeV_c`` = :math:`10^{9}/c`
72+
73+
**ex**
74+
A *number* specifying the horizontal emittance :math:`\epsilon_x` [m]. (default: ``1``).
75+
76+
**ey**
77+
A *number* specifying the vertical emittance :math:`\epsilon_y` [m]. (default: ``1``).
78+
79+
**et**
80+
A *number* specifying the longitudinal emittance :math:`\epsilon_t` [m]. (default: :literal:`1e-3`).
81+
82+
**exn**
83+
A *lambda* returning the normalized horizontal emittance [m],
84+
85+
:literal:`exn = ex * betgam`.
86+
87+
**eyn**
88+
A *lambda* returning the normalized vertical emittance [m],
89+
90+
:literal:`eyn = ey * betgam`.
91+
92+
**etn**
93+
A *lambda* returning the normalized longitudinal emittance [m],
94+
95+
:literal:`etn = et * betgam`.
96+
97+
**nbunch**
98+
A *number* specifying the number of particle bunches in the machine. (default: ``0``).
99+
100+
**npart**
101+
A *number* specifying the number of particles per bunch. (default: ``0``).
102+
103+
**sigt**
104+
A *number* specifying the bunch length in :math:`c \sigma_t`. (default: ``1``).
105+
106+
**sige**
107+
A *number* specifying the relative energy spread in :math:`\sigma_E/E` [GeV]. (default: :literal:`1e-3`).
108+
109+
110+
The ``beam`` *object* also implements a special protect-and-update mechanism for its attributes to ensure consistency and precedence between the physical quantities stored internally:
111+
112+
#. The following attributes are *read-only*, i.e. writing to them triggers an error:
113+
``mass, charge, spin, emrad, aphot``
114+
115+
#. The following attributes are *read-write*, i.e. hold values, with their accepted numerical ranges:
116+
``particle, energy`` :math:`>` ``mass``,
117+
``ex`` :math:`>0`, ``ey`` :math:`>0`, ``et`` :math:`>0`,
118+
``nbunch`` :math:`>0`, ``npart`` :math:`>0`, ``sigt`` :math:`>0`, ``sige`` :math:`>0`.
119+
120+
#. The following attributes are *read-update*, i.e. setting these attributes update the ``energy``, with their accepted numerical ranges:
121+
``pc`` :math:`>0`, :math:`0.9>` ``beta`` :math:`>0`, ``gamma`` :math:`>1`, ``betgam`` :math:`>0.1`, ``brho`` :math:`>0`,
122+
``pc2``, ``beta2``, ``betgam2``.
123+
#. The following attributes are *read-update*, i.e. setting these attributes update the emittances ``ex``, ``ey``, and ``et`` repectively, with their accepted numerical ranges:
124+
``exn`` :math:`>0`, ``eyn`` :math:`>0`, ``etn`` :math:`>0`.
125+
126+
127+
Methods
128+
-------
129+
130+
The ``beam`` object provides the following methods:
131+
132+
**new_particle**
133+
A *method* ``(particle, mass, charge, [spin])`` creating new particles or nuclei and store them in the particles database. The arguments specify in order the new ``particle``'s name, energy-``mass`` [GeV], ``charge`` [q], and ``spin`` (default: ``0``). These arguments can also be grouped into a *table* with same attribute names as the argument names and passed as the solely argument.
134+
135+
**set_variables**
136+
A *method* ``(set)`` returning ``self`` with the attributes set to the pairs (*key*, *value*) contained in ``set``. This method overrides the original one to implement the special protect-and-update mechanism, but the order of the updates is undefined. It also creates new particle on-the-fly if the ``mass`` and the ``charge`` are defined, and then select it. Shortcut ``setvar``.
137+
138+
**showdb**
139+
A *method* ``([file])`` displaying the content of the particles database to ``file`` (default: ``io.stdout``).
140+
141+
142+
Metamethods
143+
-----------
144+
145+
The ``beam`` object provides the following metamethods:
146+
147+
**__init**
148+
A *metamethod* ``()`` returning ``self`` after having processed the attributes with the special protect-and-update mechanism, where the order of the updates is undefined. It also creates new particle on-the-fly if the ``mass`` and the ``charge`` are defined, and then select it.
149+
150+
**__newindex**
151+
A *metamethod* ``(key, val)`` called by the assignment operator ``[key]=val`` to create new attributes for the pairs (*key*, *value*) or to update the underlying physical quantity of the ``beam`` objects.
152+
153+
154+
The following attribute is stored with metamethods in the metatable, but has different purpose:
155+
156+
157+
**__beam**
158+
A unique private *reference* that characterizes beams.
159+
160+
161+
Particles database
162+
------------------
163+
164+
The ``beam`` *object* manages the particles database, which is shared by all ``beam`` instances. The default set of supported particles is:
165+
electron, positron, proton, antiproton, neutron, antineutron, ion, muon,
166+
antimuon, deuteron, antideuteron, negmuon (=muon), posmuon (=antimuon).
167+
168+
New particles can be added to the database, either explicitly using the ``new_particle`` method, or by creating or updating a beam *object* and specifying all the attributes of a particle, i.e. ``particle``'s name, ``charge``, ``mass``, and (optional) ``spin``:
169+
170+
.. code-block:: lua
171+
172+
local beam in MAD
173+
local nmass, pmass, mumass in MAD.constant
174+
175+
-- create a new particle
176+
beam:new_particle{ particle='mymuon', mass=mumass, charge=-1, spin=1/2 }
177+
178+
-- create a new beam and a new nucleus
179+
local pbbeam = beam { particle='pb208', mass=82*pmass+126*nmass, charge=82 }
180+
181+
The particles database can be displayed with the ``showdb`` method at any time from any beam:
182+
183+
.. code-block:: lua
184+
185+
beam:showdb() -- check that both, mymuon and pb208 are in the database.
186+
187+
188+
Particle charges
189+
----------------
190+
191+
The physics of \MAD is aware of particle charges. To enable the compatibility with codes like MAD-X that ignores the particle charges, the global option ``nocharge`` can be used to control the behavior of created beams as shown by the following example:
192+
193+
.. code-block:: lua
194+
195+
local beam, option in MAD
196+
local beam1 = beam { particle="electron" } -- beam with negative charge
197+
print(beam1.charge, option.nocharge) -- display: -1 false
198+
199+
option.nocharge = true -- disable particle charges
200+
local beam2 = beam { particle="electron" } -- beam with negative charge
201+
print(beam2.charge, option.nocharge) -- display: 1 true
202+
203+
-- beam1 was created before nocharge activation...
204+
print(beam1.charge, option.nocharge) -- display: -1 true
205+
206+
This approach ensures consistency of beams behavior during their entire lifetime. [#f2]_
207+
208+
Examples
209+
--------
210+
211+
212+
213+
.. code-block:: lua
214+
215+
local beam in MAD
216+
local lhcb1, lhcb2 in MADX
217+
local nmass, pmass, amass in MAD.constant
218+
local pbmass = 82*pmass+126*nmass
219+
220+
-- attach a new beam with a new particle to lhcb1 and lhcb2.
221+
lhc1.beam = beam 'Pb208' { particle='pb208', mass=pbmass, charge=82 }
222+
lhc2.beam = lhc1.beam -- let sequences share the same beam...
223+
224+
-- print Pb208 nuclei energy-mass in GeV and unified atomic mass.
225+
print(lhcb1.beam.mass, lhcb1.beam.mass/amass)
226+
227+
228+
.. rubric:: Footnotes
229+
230+
.. [#f1] The ``qelect`` value is defined in the :doc:`constants` module.``
231+
.. [#f2] The option ``rbarc`` in MAD-X is too volatile and does not ensure such consistency...

docs/source/beta0.rst

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
Beta0 Blocks
2+
============
3+
.. _ch.gen.beta0:
4+
5+
6+
7+
The ``beta0`` object is the *root object* of beta0 blocks that store information relative to the phase space at given positions, e.g. initial conditions, Poincaré section.
8+
9+
The ``beta0`` module extends the :doc:`typeid <types>` module with the ``is_beta0`` *function*, which returns ``true`` if its argument is a ``beta0`` object, ``false`` otherwise.
10+
11+
Attributes
12+
----------
13+
14+
The ``beta0`` *object* provides the following attributes:
15+
16+
**particle**
17+
A *string* specifying the name of the particle. (default: ``"positron"``).
18+
19+
20+
Methods
21+
-------
22+
23+
The ``beta0`` object provides the following methods:
24+
25+
**showdb**
26+
A *method* ``([file])`` displaying the content of the particles database to ``file`` (default: ``io.stdout``).
27+
28+
29+
Metamethods
30+
-----------
31+
32+
The ``beta0`` object provides the following metamethods:
33+
34+
**__init**
35+
A *metamethod* ``()`` returning \SLF after having processed the attributes with the special protect-and-update mechanism, where the order of the updates is undefined. It also creates new particle on-the-fly if the ``mass`` and the ``charge`` are defined, and then select it.
36+
37+
38+
39+
40+
**__beta0**
41+
A unique private *reference* that characterizes beta0 blocks.
42+
43+
44+
Examples
45+
--------
46+
47+
.. rubric:: Footnotes
48+

docs/source/cffi.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
.. _ch.prg.cffi:
2+
3+
Using C FFI
4+
===========

0 commit comments

Comments
 (0)