Skip to content

Commit a4daf8b

Browse files
authored
Merge pull request #72 from lhcopt/release/v1.3.0
Release/v1.3.0
2 parents dcf1293 + 3990573 commit a4daf8b

33 files changed

+1568
-758
lines changed

.gitignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,3 +148,11 @@ examples/run3_collision/temp/sliceho.res
148148
examples/run3_collision/temp/surveyaux.tfs
149149
examples/run3_collision/temp/twiss.tfs
150150
examples/run3_collision/last_twiss.0.gz
151+
miniconda
152+
pytrain
153+
sixtracktools
154+
xfields
155+
xline
156+
xobjects
157+
xpart
158+
xtrack

python_examples/clean_all

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,6 @@ rm *.tfs
1515
rm -r xline
1616
rm -r temp
1717
rm -r __pycache__
18-
18+
rm -r xsuite_lines
1919
# Remove all links
2020
find -type l -exec rm {} \;

python_examples/hl_lhc_collisions_python/000_pymask.py

Lines changed: 34 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,33 @@
11
import os
22
import sys
33
import json
4-
4+
import yaml
55
import numpy as np
66

7-
87
#####################################################
98
# Read general configurations and setup envirnoment #
109
#####################################################
1110

12-
from config import configuration
11+
assert not(os.path.isfile('config.yaml')
12+
and os.path.isfile('config.py')), (
13+
"Please specify only a config file (yaml or py)")
14+
15+
try:
16+
with open('config.yaml','r') as fid:
17+
configuration = yaml.safe_load(fid)
18+
except:
19+
from config import configuration
20+
21+
# Start tree_maker logging if log_file is present in config
22+
try:
23+
import tree_maker
24+
if 'log_file' not in configuration.keys():
25+
tree_maker=None
26+
except:
27+
tree_maker=None
28+
29+
if tree_maker is not None:
30+
tree_maker.tag_json.tag_it(configuration['log_file'], 'started')
1331

1432
mode = configuration['mode']
1533
tol_beta = configuration['tol_beta']
@@ -27,8 +45,12 @@
2745
knob_settings = configuration['knob_settings']
2846
knob_names = configuration['knob_names']
2947

30-
3148
# Make links
49+
if links['tracking_tools'] == 'auto':
50+
import pymask as pm
51+
links['tracking_tools'] = str(
52+
pm._pkg_root.parent.parent.absolute())
53+
3254
for kk in links.keys():
3355
if os.path.exists(kk):
3456
os.remove(kk)
@@ -77,7 +99,8 @@
7799
mad.globals.par_verbose = int(configuration['verbose_mad_parts'])
78100

79101
# Build sequence (alse creates link to optics_toolkit and calls it)
80-
ost.build_sequence(mad, beam=beam_to_configure)
102+
ost.build_sequence(mad, beam=beam_to_configure,
103+
configuration=configuration)
81104

82105
# Set twiss formats for MAD-X parts (macro from opt. toolkit)
83106
mad.input('exec, twiss_opt;')
@@ -123,7 +146,7 @@
123146
ex={configuration['beam_norm_emit_x'] * 1e-6 / gamma_rel},
124147
ey={configuration['beam_norm_emit_y'] * 1e-6 / gamma_rel},
125148
mass={particle_mass},
126-
charge={particle_charge},
149+
charge={particle_charge};
127150
''')
128151

129152

@@ -268,7 +291,7 @@
268291

269292
if generate_b4_from_b2:
270293
mad_b4 = Madx(command_log="mad_b4.log")
271-
ost.build_sequence(mad_b4, beam=4)
294+
ost.build_sequence(mad_b4, beam=4,configuration=configuration)
272295

273296
pm.configure_b4_from_b2(mad_b4, mad)
274297

@@ -402,7 +425,7 @@
402425
if configuration['enable_knob_synthesis']:
403426
mad_track.input('exec, crossing_disable;')
404427
mad_track.input("call, file='modules/submodule_04e_s1_synthesize_knobs.madx';")
405-
mad_track.input('exec, crossing_restore;')
428+
mad_track.input('exec, crossing_restore;')
406429

407430

408431
##################
@@ -559,3 +582,6 @@
559582
#############################
560583
# N.B. this erases the errors in the mad_track instance
561584
# pm.save_mad_sequence_and_error(mad_track, sequence_to_track, filename='final')
585+
586+
if tree_maker is not None:
587+
tree_maker.tag_json.tag_it(configuration['log_file'], 'completed')
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh
2+
bash Miniconda3-latest-Linux-x86_64.sh -b -p ./miniconda -f
3+
source miniconda/bin/activate
4+
pip install ipython jupyterlab numpy scipy pandas awkward matplotlib
5+
pip install pyarrow pyyaml pytest
6+
pip install cpymad
7+
pip install xsuite
8+
git clone [email protected]:lhcopt/lhcerrors.git
9+
git clone [email protected]:lhcopt/lhctoolkit.git
10+
git clone [email protected]:lhcopt/lhcmask.git
11+
cd lhcmask
12+
git checkout release/v1.3.0
13+
pip install -e .
14+
cd ../
15+
git clone https://github.com/PyCOMPLETE/FillingPatterns.git
16+
pip install ./FillingPatterns
17+
python -m pip install sixtracktools
18+
python -m pip install NAFFlib

python_examples/hl_lhc_collisions_python/checks_and_doc/t005_check_crabs.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ def prepare_line(path, input_type):
140140
ddd = json.load(fid)
141141
partco = xp.Particles.from_dict(ddd['particle_on_madx_co'])
142142
z_slices = s_rel * 2.0
143-
partco = xp.build_particles(particle_ref=partco, zeta=z_slices)
143+
partco = xp.build_particles(particle_on_co=partco, mode='shift', zeta=z_slices)
144144

145145

146146
list_co = ltest.slow_track_elem_by_elem(partco)
@@ -221,7 +221,8 @@ def prepare_line(path, input_type):
221221
part = xp.Particles.from_dict(ddd['particle_on_madx_co'])
222222

223223
z_test = np.array([0, z_crab_track])
224-
part = xp.build_particles(particle_ref=part,
224+
part = xp.build_particles(particle_on_co=part,
225+
mode='shift',
225226
zeta = z_test,
226227
x = 0*z_test + np.array([0, x_twiss[0]]),
227228
y = 0*z_test + np.array([0, y_twiss[0]]),

python_examples/hl_lhc_collisions_python/checks_and_doc/t007_check_orbit_and_lin_normal_form.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
tracker.track(particles)
2222

2323
for nn in 'x px y py zeta delta'.split():
24-
assert np.abs(getattr(particles, nn) - getattr(partCO, nn)) < 1e-11
24+
assert np.abs(getattr(particles, nn) - getattr(partCO, nn)) < 2e-11
2525

2626
WW = np.array(line_dict['WW_finite_diffs'])
2727
WWinv = np.array(line_dict['WWInv_finite_diffs'])
@@ -37,7 +37,7 @@
3737
x_norm = ampl_sigmas * np.sqrt(geom_emit_x) * np.cos(theta)
3838
px_norm = ampl_sigmas * np.sqrt(geom_emit_x) * np.sin(theta)
3939

40-
particles_matched = xp.build_particles(particle_ref=partCO,
40+
particles_matched = xp.build_particles(particle_on_co=partCO,
4141
x_norm=x_norm, px_norm=px_norm,
4242
R_matrix=np.array(line_dict['RR_finite_diffs']))
4343
particles_test = particles_matched.copy()

python_examples/hl_lhc_collisions_python/checks_and_doc/t008_check_against_sixtrack.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,15 @@
3131

3232
tracker = xt.Tracker(line=line)
3333

34-
particles = xp.build_particles(particle_ref=partCO,
34+
particles = xp.build_particles(particle_on_co=partCO,
35+
mode='shift',
3536
x=np.array(displace_x),
3637
y=np.array(displace_y))
3738

3839
tracker.track(particles, turn_by_turn_monitor=True, num_turns=num_turns)
3940

4041
print('Xtrack')
41-
print(tracker.record_last_track.x)
42+
print(tracker.record_last_track.x.transpose())
4243
print('Sixtrack')
4344
print(x_tbt_sixtrack)
4445

python_examples/hl_lhc_collisions_python/checks_and_doc/tests.md

Lines changed: 55 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ We setup the python version:
1616
cd ../../python_examples/hl_lhc_collisions_python
1717

1818
```
19-
In config.py we select:
20-
```python
21-
mode : 'b1_with_bb_legacy_macros'
19+
In config.yaml we select:
20+
```yaml
21+
mode : b1_with_bb_legacy_macros
2222
```
2323
We run the python version:
2424
```
@@ -36,9 +36,9 @@ diff fc.34 ../../examples/hl_lhc_collision/fc.34
3636

3737

3838
## Test 2 - b1 with new bb tools
39-
In config.py we select:
40-
```python
41-
'mode' : 'b1_with_bb',
39+
In config.yaml we select:
40+
```yaml
41+
mode : b1_with_bb
4242
```
4343
4444
We exeute the python version:
@@ -121,10 +121,12 @@ We setup the python version:
121121
cd ../../python_examples/hl_lhc_collisions_python
122122

123123
```
124-
In config.py we select:
125-
```python
126-
'mode' : 'b4_without_bb',
127-
force_leveling : {'on_sep8': -0.03425547139366354, 'on_sep2': 0.14471680504084292}
124+
In config.yaml we select:
125+
```yaml
126+
mode: b4_without_bb,
127+
force_leveling:
128+
on_sep8: -0.03425547139366354
129+
on_sep2: 0.14471680504084292
128130
```
129131
(the separations are forced in order to be consitent with the mad-x test case for which the same values are impored, as the legacy leveling macro does not work in this case).
130132
@@ -155,10 +157,12 @@ We setup the python version:
155157
cd ../../python_examples/hl_lhc_collisions_python
156158

157159
```
158-
In config.py we select:
159-
```python
160-
'mode' : 'b4_from_b2_without_bb',
161-
'force_leveling' : {'on_sep8': -0.03425547139366354, 'on_sep2': 0.14471680504084292}
160+
In config.yaml we select:
161+
```yaml
162+
mode: b4_from_b2_without_bb
163+
force_leveling:
164+
on_sep8: -0.03425547139366354
165+
on_sep2: 0.14471680504084292
162166
```
163167
(the separations are forced in order to be consitent with the mad-x test case for which the same values are impored, as the legacy leveling macro does not work in this case).
164168
@@ -183,10 +187,9 @@ We setup the python version:
183187
cd ../../python_examples/hl_lhc_collisions_python
184188

185189
```
186-
In config.py we select:
190+
In config.yaml we select:
187191
```python
188-
'mode' : 'b4_from_b2_with_bb',
189-
192+
mode: b4_from_b2_with_bb,
190193
```
191194
We run the python version:
192195
```
@@ -222,6 +225,41 @@ phi_weak = Phi
222225
phi_c_weak = Phi_c
223226
```
224227

228+
## Test 7 and 8 - Check the matching and the tracking
229+
230+
Select on config.yaml
231+
232+
```yaml
233+
beam: b1_without_bb
234+
```
235+
and run
236+
237+
```bash
238+
python t003_fc_to_fort.py
239+
python t007_check_orbit_and_lin_normal_form.py
240+
python t008_check_against_sixtrack.py
241+
```
242+
243+
then repeat for
244+
245+
```yaml
246+
beam: b1_with_bb
247+
```
248+
249+
and
250+
251+
```yaml
252+
beam: b4_from_b2_without_bb
253+
```
254+
255+
and
256+
257+
```yaml
258+
beam: b4_from_b2_with_bb
259+
```
260+
261+
262+
225263
## To check a mad test againt its reference
226264
227265
```bash

0 commit comments

Comments
 (0)