Skip to content

Commit 7bbd4c7

Browse files
authored
Merge pull request #47 from xsuite/release/v0.3.0
Release 0.3.0
2 parents 805cef3 + e371a05 commit 7bbd4c7

Some content is hidden

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

61 files changed

+523431
-1179
lines changed
Lines changed: 179 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,179 @@
1+
%YAML 1.2
2+
---
3+
# Each collimator is a dictionary, with the following set of keys:
4+
# required keys:
5+
# gap [sigma], length [m], angle [deg], material [BE/AL/CU/W/PB/C/C2/Si/Ge/MoGR/CuCD/Mo/Glid/Iner/VA/BL], stage
6+
# (a gap equal to 'null' disables the collimator from tracking)
7+
# optional keys:
8+
# offset [m], side [left/right], tilt [deg] (or tilt_left and tilt_right if different for each jaw)
9+
# special keys:
10+
# active [bool] : Whether or not a collimator is still active in operation. If false, the gap is set to null.
11+
# The difference with just manually setting the gap to 'null' is mainly semantic: these are collimators that are in principle no longer used but still present in the machine.
12+
# crystal [strip/quasi-mosaic] : Use when the collimator is a crystal of the specified type.
13+
# It allows for some extra keys: bend [m], xdim [m], ydim [m], miscut [deg], thick [m] (the thickness of the amorphous layer)
14+
#
15+
# For ease of use, the collimators can be collected in families using standard YAML syntax.
16+
# Each family contains the keys for which all members have the same value (though keys can be overwritten again in the individual collimators).
17+
#
18+
# YAML syntax refresher:
19+
# - indentation matters (spaces, no tabs)
20+
# - comments are preceded with #
21+
# - lists are represented by one item per line preceded with a dash, or in inline format as [ , ... ]
22+
# - dictoraries are represented by one "key : value" per line, or in inline format as { key : value , ... }
23+
# - the & represents a unique name tag
24+
# - the * dereferences the named element
25+
# - the merge operator << merges the subsequent element with the surrounding container (giving higher priority to the other elements in the container than those in the merged element, as to allow overwriting)
26+
All:
27+
- &ALL { parking: 0.025 }
28+
29+
families:
30+
# Momentum cleaning
31+
- &TCP3 { <<: *ALL, gap: 15, stage: primary, material: C, length: 0.6 }
32+
- &TCSG3 { <<: *ALL, gap: 18, stage: secondary, material: C, length: 1 }
33+
- &TCLA3 { <<: *ALL, gap: 20, stage: tertiary, material: Iner, length: 1 }
34+
# Betatron cleaning
35+
- &TCP7 { <<: *ALL, gap: 6, stage: primary, material: C, length: 0.6 }
36+
- &TCSG7 { <<: *ALL, gap: 6.5, stage: secondary, material: C, length: 1 }
37+
- &TCLA7 { <<: *ALL, gap: 8, stage: tertiary, material: Iner, length: 1 }
38+
- &CRY7 { <<: *ALL, gap: null, stage: special, material: Si, length: 0.004, side: left, crystal: strip, active: false }
39+
# Injection protection
40+
- &TCLI { <<: *ALL, gap: null, stage: tertiary, material: C, length: 1, angle: 90 }
41+
- &TDI { <<: *ALL, gap: null, stage: tertiary, material: CU, length: 1.565, angle: 90 }
42+
# Dump protection
43+
- &TCDQ { <<: *ALL, gap: 7.3, stage: tertiary, material: C, length: 3, angle: 0, side: left }
44+
- &TCSP { <<: *ALL, gap: 7.3, stage: secondary, material: C, length: 1, angle: 0 }
45+
# Physics background minimalisation
46+
- &TCT15 { <<: *ALL, gap: 9.5, stage: tertiary, material: Iner, length: 1, parking: 0.020 }
47+
- &TCT2 { <<: *ALL, gap: 37, stage: tertiary, material: Iner, length: 1, }
48+
- &TCT8 { <<: *ALL, gap: 11.5, stage: tertiary, material: Iner, length: 1, }
49+
# Physics debris
50+
- &TCL4 { <<: *ALL, gap: 17, stage: tertiary, material: CU, length: 1, angle: 0}
51+
- &TCL5 { <<: *ALL, gap: 42, stage: tertiary, material: CU, length: 1, angle: 0}
52+
- &TCL6 { <<: *ALL, gap: 20, stage: tertiary, material: Iner, length: 1, angle: 0}
53+
# Physics debris in ALICE (only for ions)
54+
- &TCLD { <<: *ALL, gap: null, stage: tertiary, material: Iner, length: 0.6, angle: 0}
55+
56+
emittance:
57+
x: 3.5e-6
58+
y: 3.5e-6
59+
60+
collimators:
61+
b1:
62+
tcl.4r1.b1: { <<: *TCL4 }
63+
tcl.5r1.b1: { <<: *TCL5 }
64+
tcl.6r1.b1: { <<: *TCL6 }
65+
tctph.4l2.b1: { <<: *TCT2, angle: 0 }
66+
tctpv.4l2.b1: { <<: *TCT2, angle: 90 }
67+
tdisa.a4l2.b1: { <<: *TDI }
68+
tdisb.a4l2.b1: { <<: *TDI }
69+
tdisc.a4l2.b1: { <<: *TDI }
70+
tclia.4r2: { <<: *TCLI }
71+
tclib.6r2.b1: { <<: *TCLI }
72+
tcld.a11r2.b1: { <<: *TCLD }
73+
tcp.6l3.b1: { <<: *TCP3, angle: 0 }
74+
tcsg.5l3.b1: { <<: *TCSG3, angle: 0 }
75+
tcsg.4r3.b1: { <<: *TCSG3, angle: 0 }
76+
tcsg.a5r3.b1: { <<: *TCSG3, angle: 170.7 }
77+
tcsg.b5r3.b1: { <<: *TCSG3, angle: 10.8 }
78+
tcla.a5r3.b1: { <<: *TCLA3, angle: 90 }
79+
tcla.b5r3.b1: { <<: *TCLA3, angle: 0 }
80+
tcla.6r3.b1: { <<: *TCLA3, angle: 0 }
81+
tcla.7r3.b1: { <<: *TCLA3, angle: 0 }
82+
tctph.4l5.b1: { <<: *TCT15, angle: 0 }
83+
tctpv.4l5.b1: { <<: *TCT15, angle: 90 }
84+
tcl.4r5.b1: { <<: *TCL4, }
85+
tcl.5r5.b1: { <<: *TCL5, }
86+
tcl.6r5.b1: { <<: *TCL6, }
87+
tcdqa.a4r6.b1: { <<: *TCDQ }
88+
tcdqa.c4r6.b1: { <<: *TCDQ }
89+
tcdqa.b4r6.b1: { <<: *TCDQ }
90+
tcsp.a4r6.b1: { <<: *TCSP }
91+
tcp.d6l7.b1: { <<: *TCP7, angle: 90, material: MoGR }
92+
tcp.c6l7.b1: { <<: *TCP7, angle: 0, material: MoGR }
93+
tcp.b6l7.b1: { <<: *TCP7, angle: 127.5 }
94+
tcsg.a6l7.b1: { <<: *TCSG7, angle: 141.1 }
95+
tcpcv.a6l7.b1: { <<: *CRY7, angle: 90, bending_radius: 85.10, xdim: 5.0e-3, ydim: 30.0e-3 }
96+
tcsg.b5l7.b1: { <<: *TCSG7, angle: 143.5 }
97+
tcsg.a5l7.b1: { <<: *TCSG7, angle: 40.7 }
98+
tcsg.d4l7.b1: { <<: *TCSG7, angle: 90, material: MoGR }
99+
tcpch.a4l7.b1: { <<: *CRY7, angle: 0, bending_radius: 61.54, xdim: 2.0e-3, ydim: 50.0e-3 }
100+
tcsg.b4l7.b1: { <<: *TCSG7, angle: 0, active: false }
101+
tcspm.b4l7.b1: { <<: *TCSG7, angle: 0, material: MoGR }
102+
tcsg.a4l7.b1: { <<: *TCSG7, angle: 134.6 }
103+
tcsg.a4r7.b1: { <<: *TCSG7, angle: 46.3 }
104+
tcsg.b5r7.b1: { <<: *TCSG7, angle: 141.5 }
105+
tcsg.d5r7.b1: { <<: *TCSG7, angle: 51.4 }
106+
tcsg.e5r7.b1: { <<: *TCSG7, angle: 130.5, active: false }
107+
tcspm.e5r7.b1: { <<: *TCSG7, angle: 130.5, material: MoGR }
108+
tcsg.6r7.b1: { <<: *TCSG7, angle: 0.5, active: false }
109+
tcspm.6r7.b1: { <<: *TCSG7, angle: 0.5, material: MoGR }
110+
tcla.a6r7.b1: { <<: *TCLA7, angle: 90 }
111+
tcla.b6r7.b1: { <<: *TCLA7, angle: 0 }
112+
tcla.c6r7.b1: { <<: *TCLA7, angle: 90 }
113+
tcla.d6r7.b1: { <<: *TCLA7, angle: 0 }
114+
tcla.a7r7.b1: { <<: *TCLA7, angle: 0 }
115+
tctph.4l8.b1: { <<: *TCT8, angle: 0 }
116+
tctpv.4l8.b1: { <<: *TCT8, angle: 90 }
117+
tctph.4l1.b1: { <<: *TCT15, angle: 0 }
118+
tctpv.4l1.b1: { <<: *TCT15, angle: 90 }
119+
120+
b2:
121+
tcl.4l1.b2: { <<: *TCL4 }
122+
tcl.5l1.b2: { <<: *TCL5 }
123+
tcl.6l1.b2: { <<: *TCL6 }
124+
tctph.4r8.b2: { <<: *TCT8, angle: 0 }
125+
tctpv.4r8.b2: { <<: *TCT8, angle: 90 }
126+
tdisa.a4r8.b2: { <<: *TDI }
127+
tdisb.a4r8.b2: { <<: *TDI }
128+
tdisc.a4r8.b2: { <<: *TDI }
129+
tclia.4l8: { <<: *TCLI }
130+
tclib.6l8.b2: { <<: *TCLI }
131+
tcp.d6r7.b2: { <<: *TCP7, angle: 90, material: MoGR }
132+
tcp.c6r7.b2: { <<: *TCP7, angle: 0, material: MoGR }
133+
tcp.b6r7.b2: { <<: *TCP7, angle: 127.5 }
134+
tcsg.a6r7.b2: { <<: *TCSG7, angle: 141.1 }
135+
tcpcv.a6r7.b2: { <<: *CRY7, angle: 90, bending_radius: 74.88, xdim: 5.0e-3, ydim: 30.0e-3 }
136+
tcsg.b5r7.b2: { <<: *TCSG7, angle: 143.5 }
137+
tcsg.a5r7.b2: { <<: *TCSG7, angle: 40.7 }
138+
tcpch.a5r7.b2: { <<: *CRY7, angle: 0, bending_radius: 80.00, xdim: 2.0e-3, ydim: 50.0e-3 }
139+
tcsg.d4r7.b2: { <<: *TCSG7, angle: 90, material: MoGR }
140+
tcspm.d4r7.b2: { <<: *TCSG7, angle: 90, material: MoGR, active: false } # prototype
141+
tcsg.b4r7.b2: { <<: *TCSG7, angle: 0, active: false }
142+
tcspm.b4r7.b2: { <<: *TCSG7, angle: 0, material: MoGR }
143+
tcsg.a4r7.b2: { <<: *TCSG7, angle: 134.6 }
144+
tcsg.a4l7.b2: { <<: *TCSG7, angle: 46.3 }
145+
tcsg.b5l7.b2: { <<: *TCSG7, angle: 141.5 }
146+
tcsg.d5l7.b2: { <<: *TCSG7, angle: 51.4 }
147+
tcsg.e5l7.b2: { <<: *TCSG7, angle: 130.5, active: false }
148+
tcspm.e5l7.b2: { <<: *TCSG7, angle: 130.5, material: MoGR }
149+
tcsg.6l7.b2: { <<: *TCSG7, angle: 0.5, active: false }
150+
tcspm.6l7.b2: { <<: *TCSG7, angle: 0.5, material: MoGR }
151+
tcla.a6l7.b2: { <<: *TCLA7, angle: 90 }
152+
tcla.b6l7.b2: { <<: *TCLA7, angle: 0 }
153+
tcla.c6l7.b2: { <<: *TCLA7, angle: 90 }
154+
tcla.d6l7.b2: { <<: *TCLA7, angle: 0 }
155+
tcla.a7l7.b2: { <<: *TCLA7, angle: 0 }
156+
tcdqa.a4l6.b2: { <<: *TCDQ }
157+
tcdqa.c4l6.b2: { <<: *TCDQ }
158+
tcdqa.b4l6.b2: { <<: *TCDQ }
159+
tcsp.a4l6.b2: { <<: *TCSP }
160+
tctph.4r5.b2: { <<: *TCT15, angle: 0 }
161+
tctpv.4r5.b2: { <<: *TCT15, angle: 90 }
162+
tcl.4l5.b2: { <<: *TCL4 }
163+
tcl.5l5.b2: { <<: *TCL5 }
164+
tcl.6l5.b2: { <<: *TCL6 }
165+
tcp.6r3.b2: { <<: *TCP3, angle: 0 }
166+
tcsg.5r3.b2: { <<: *TCSG3, angle: 0 }
167+
tcsg.4l3.b2: { <<: *TCSG3, angle: 0 }
168+
tcsg.a5l3.b2: { <<: *TCSG3, angle: 170.7 }
169+
tcsg.b5l3.b2: { <<: *TCSG3, angle: 10.8 }
170+
tcla.a5l3.b2: { <<: *TCLA3, angle: 90 }
171+
tcla.b5l3.b2: { <<: *TCLA3, angle: 0 }
172+
tcla.6l3.b2: { <<: *TCLA3, angle: 0 }
173+
tcla.7l3.b2: { <<: *TCLA3, angle: 0 }
174+
tctph.4r2.b2: { <<: *TCT2, angle: 0 }
175+
tctpv.4r2.b2: { <<: *TCT2, angle: 90 }
176+
tcld.a11l2.b2: { <<: *TCLD }
177+
tctph.4r1.b2: { <<: *TCT15, angle: 0 }
178+
tctpv.4r1.b2: { <<: *TCT15, angle: 90 }
179+

examples/everest_block.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import xobjects as xo
2+
import xpart as xp
3+
import xcoll as xc
4+
5+
import matplotlib.pyplot as plt
6+
7+
block = xc.EverestBlock(length=1., material=xc.materials.Tungsten)
8+
9+
part = xp.Particles(x=np.zeros(1000000), energy0=450.e9)
10+
part._init_random_number_generator()
11+
block.track(part)
12+
13+
_ = plt.hist(part.x, bins=200, density=True)
14+
_ = plt.hist(part.px*part.rpp, bins=200, density=True)

examples/lhc_run3_lossmap.py

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
import json
22
import numpy as np
33
from pathlib import Path
4+
import time
5+
start_time = time.time()
6+
import sys, os, contextlib
47

58
import xobjects as xo
69
import xtrack as xt
@@ -22,12 +25,16 @@
2225

2326

2427
# Load from json
25-
line = xt.Line.from_json(path_in / 'machines' / f'lhc_run3_b{beam}.json')
28+
with open(os.devnull, 'w') as fid:
29+
with contextlib.redirect_stdout(fid):
30+
line = xt.Line.from_json(path_in / 'machines' / f'lhc_run3_b{beam}.json')
2631

2732

2833
# Aperture model check
2934
print('\nAperture model check on imported model:')
30-
df_imported = line.check_aperture()
35+
with open(os.devnull, 'w') as fid:
36+
with contextlib.redirect_stdout(fid):
37+
df_imported = line.check_aperture()
3138
assert not np.any(df_imported.has_aperture_problem)
3239

3340

@@ -44,10 +51,12 @@
4451

4552
# Aperture model check
4653
print('\nAperture model check after introducing collimators:')
47-
df_with_coll = line.check_aperture()
54+
with open(os.devnull, 'w') as fid:
55+
with contextlib.redirect_stdout(fid):
56+
df_with_coll = line.check_aperture()
4857
assert not np.any(df_with_coll.has_aperture_problem)
4958

50-
59+
5160
# Build the tracker
5261
coll_manager.build_tracker()
5362

@@ -57,12 +66,6 @@
5766
coll_manager.set_openings()
5867

5968

60-
# Aperture model check
61-
print('\nAperture model check after introducing collimators:')
62-
df_with_coll = line.check_aperture()
63-
assert not np.any(df_with_coll.has_aperture_problem)
64-
65-
6669
# Generate initial pencil distribution on horizontal collimator
6770
tcp = f"tcp.{'c' if plane=='H' else 'd'}6{'l' if beam=='1' else 'r'}7.b{beam}"
6871
part = coll_manager.generate_pencil_on_collimator(tcp, num_particles=num_particles)
@@ -90,6 +93,6 @@
9093
# Save a summary of the collimator losses to a text file
9194
summary = coll_manager.summary(part, file=Path(path_out,f'coll_summary_B{beam}{plane}.out'))
9295
print(summary)
93-
96+
print(f"Total calculation time {time.time()-start_time}s")
9497

9598
exit()

0 commit comments

Comments
 (0)