@@ -15,7 +15,7 @@ class LatticeGenerator:
15
15
def generate_base_cas_lattice () -> str :
16
16
"""
17
17
Simple function to help unclutter the notebook.
18
- :return: string you can input into your cpymadtools instance .
18
+ :return: string you can input into your `cpymad.madx.Madx` object .
19
19
"""
20
20
mystring = """
21
21
option, -info, -warn;
@@ -86,7 +86,7 @@ def generate_base_cas_lattice() -> str:
86
86
def generate_onesext_cas_lattice () -> str :
87
87
"""
88
88
Simple function to help unclutter the notebook.
89
- :return: string you can input into your cpymadtools instance .
89
+ :return: string you can input into your `cpymad.madx.Madx` object .
90
90
"""
91
91
mystring = """
92
92
option, -info, -warn;
@@ -174,7 +174,7 @@ def generate_onesext_cas_lattice() -> str:
174
174
def generate_oneoct_cas_lattice () -> str :
175
175
"""
176
176
Simple function to help unclutter the notebook.
177
- :return: string you can input into your cpymadtools instance .
177
+ :return: string you can input into your `cpymad.madx.Madx` object .
178
178
"""
179
179
mystring = """
180
180
option, -info, -warn;
@@ -258,6 +258,199 @@ def generate_oneoct_cas_lattice() -> str:
258
258
"""
259
259
return mystring
260
260
261
+ @staticmethod
262
+ def generate_tripleterrors_study_reference () -> str :
263
+ """
264
+ Generate generic script for reference Twiss, to use in a `cpymad.madx.Madx` object.
265
+ :return: string you can input into your `cpymad.madx.Madx` object.
266
+ """
267
+ script = f"""
268
+ !####################### Make macros available #######################
269
+
270
+ option, -echo, -warn, -info;
271
+ call, file = "/afs/cern.ch/work/f/fesoubel/public/Beta-Beat.src/madx/lib/beta_beat.macros.madx";
272
+ call, file = "/afs/cern.ch/work/f/fesoubel/public/Beta-Beat.src/madx/lib/lhc.macros.madx";
273
+ call, file = "/afs/cern.ch/work/f/fesoubel/public/Beta-Beat.src/madx/lib/hllhc.macros.madx";
274
+
275
+ title, "HLLHC Triplet TFErrors to Beta-Beating";
276
+
277
+ !####################### Call optics files #######################
278
+
279
+ call, file = "/afs/cern.ch/work/f/fesoubel/public/Beta-Beat.src/model/accelerators/lhc/hllhc1.3/lhcrunIII.seq";
280
+ call, file = "/afs/cern.ch/work/f/fesoubel/public/Beta-Beat.src/model/accelerators/lhc/hllhc1.3/main.seq";
281
+ call, file = "/afs/cern.ch/eng/lhc/optics/V6.5/errors/Esubroutines.madx";
282
+
283
+ !####################### Calling modifiers for 15cm optics #######################
284
+
285
+ call, file = "/afs/cern.ch/eng/lhc/optics/HLLHCV1.3/opt_150_150_150_150.madx";
286
+
287
+ !####################### Create beam #######################
288
+
289
+ exec, define_nominal_beams();
290
+
291
+ !####################### Flatten and set START point at ? #######################
292
+
293
+ exec, cycle_sequences();
294
+
295
+ !####################### Default crossing scheme #######################
296
+
297
+ exec, set_default_crossing_scheme();
298
+
299
+ !####################### Selecting to use Beam 1 #######################
300
+
301
+ use, period = LHCB1;
302
+
303
+ !####################### Tune matching and Twiss nominal #######################
304
+
305
+ option, echo, warn, info;
306
+ exec, match_tunes(62.31, 60.32, 1); ! Since we're using beam 1
307
+ twiss;
308
+ """
309
+ return script
310
+
311
+ @staticmethod
312
+ def generate_tripleterrors_study_tferror_job (rand_seed : str , tf_error : str ) -> str :
313
+ """
314
+ Generate generic script for tf_error Twiss, to use in a `cpymad.madx.Madx` object.
315
+ :param rand_seed: the random seed to provide MAD for the errors distributions.
316
+ :param tf_error: the misalignment error value (along the s axis).
317
+ :return: string you can input into your `cpymad.madx.Madx` object.
318
+ """
319
+
320
+ tferror_script = f"""
321
+ !####################### Make macros available #######################
322
+
323
+ option, -echo, -warn, -info;
324
+ call, file = "/afs/cern.ch/work/f/fesoubel/public/Beta-Beat.src/madx/lib/beta_beat.macros.madx";
325
+ call, file = "/afs/cern.ch/work/f/fesoubel/public/Beta-Beat.src/madx/lib/lhc.macros.madx";
326
+ call, file = "/afs/cern.ch/work/f/fesoubel/public/Beta-Beat.src/madx/lib/hllhc.macros.madx";
327
+
328
+ title, "HLLHC Triplet TFErrors to Beta-Beating";
329
+
330
+ !####################### Call optics files #######################
331
+
332
+ call, file = "/afs/cern.ch/work/f/fesoubel/public/Beta-Beat.src/model/accelerators/lhc/hllhc1.3/lhcrunIII.seq";
333
+ call, file = "/afs/cern.ch/work/f/fesoubel/public/Beta-Beat.src/model/accelerators/lhc/hllhc1.3/main.seq";
334
+ call, file = "/afs/cern.ch/eng/lhc/optics/V6.5/errors/Esubroutines.madx";
335
+
336
+ !####################### Calling modifiers for 15cm optics #######################
337
+
338
+ call, file = "/afs/cern.ch/eng/lhc/optics/HLLHCV1.3/opt_150_150_150_150.madx";
339
+
340
+ !####################### Create beam #######################
341
+
342
+ exec, define_nominal_beams();
343
+
344
+ !####################### Flatten and set START point at ? #######################
345
+
346
+ exec, cycle_sequences();
347
+
348
+ !####################### Default crossing scheme #######################
349
+
350
+ exec, set_default_crossing_scheme();
351
+
352
+ !####################### Selecting to use Beam 1 #######################
353
+
354
+ use, period = LHCB1;
355
+
356
+ !####################### Tune matching and Twiss nominal #######################
357
+
358
+ option, echo, warn, info;
359
+ exec, match_tunes(62.31, 60.32, 1); ! Since we're using beam 1
360
+ exec, do_twiss_elements(LHCB1, "./twiss_nominal.dat", 0.0);
361
+
362
+ !####################### For field errors #######################
363
+
364
+ eoption, add, seed = { rand_seed } ; ! Different seed every time
365
+ select, flag=error, clear;
366
+ select, flag=error, pattern = ^MQXF.*[RL][15]; ! Only triplets quadrupoles around IP1 and IP5
367
+ GCUTR = 3; ! Cut gaussians at 3 sigma
368
+ Rr = 0.05; ! Radius for field errors (??)
369
+ ON_B2R = 1; ! Activate field errors
370
+ B2r = { tf_error } ; ! Set field errors magnitude -> Units of B2 error (will be in 1E-4)
371
+ exec, SetEfcomp_Q; ! Assign field errors
372
+
373
+ !####################### Saving errors to file #######################
374
+
375
+ !esave, file="./errors_file.dat"; ! Will save the errors of chosen type.
376
+
377
+ !####################### Tune matching and Twiss with errors #######################
378
+
379
+ exec, match_tunes(62.31, 60.32, 1);
380
+ exec, do_twiss_elements(LHCB1, "./twiss_errors.dat", 0.0);
381
+ """
382
+ return tferror_script
383
+
384
+ @staticmethod
385
+ def generate_tripleterrors_study_mserror_job (rand_seed : str , ms_error : str ) -> str :
386
+ """
387
+ Generate generic script for ms_error Twiss, to use in a `cpymad.madx.Madx` object.
388
+ :param rand_seed: the random seed to provide MAD for the errors distributions.
389
+ :param ms_error: the misalignment error value (along the s axis).
390
+ :return: string you can input into your `cpymad.madx.Madx` object.
391
+ """
392
+
393
+ mserror_script = f"""
394
+ !####################### Make macros available #######################
395
+
396
+ option, -echo, -warn, -info;
397
+ call, file = "/afs/cern.ch/work/f/fesoubel/public/Beta-Beat.src/madx/lib/beta_beat.macros.madx";
398
+ call, file = "/afs/cern.ch/work/f/fesoubel/public/Beta-Beat.src/madx/lib/lhc.macros.madx";
399
+ call, file = "/afs/cern.ch/work/f/fesoubel/public/Beta-Beat.src/madx/lib/hllhc.macros.madx";
400
+
401
+ title, "HLLHC Triplet MSErrors to Beta-Beating";
402
+
403
+ !####################### Call optics files #######################
404
+
405
+ call, file = "/afs/cern.ch/work/f/fesoubel/public/Beta-Beat.src/model/accelerators/lhc/hllhc1.3/lhcrunIII.seq";
406
+ call, file = "/afs/cern.ch/work/f/fesoubel/public/Beta-Beat.src/model/accelerators/lhc/hllhc1.3/main.seq";
407
+ call, file = "/afs/cern.ch/eng/lhc/optics/V6.5/errors/Esubroutines.madx";
408
+
409
+ !####################### Calling modifiers for 15cm optics #######################
410
+
411
+ call, file = "/afs/cern.ch/eng/lhc/optics/HLLHCV1.3/opt_150_150_150_150.madx";
412
+
413
+ !####################### Create beam #######################
414
+
415
+ exec, define_nominal_beams();
416
+
417
+ !####################### Flatten and set START point at ? #######################
418
+
419
+ exec, cycle_sequences();
420
+
421
+ !####################### Default crossing scheme #######################
422
+
423
+ exec, set_default_crossing_scheme();
424
+
425
+ !####################### Selecting to use Beam 1 #######################
426
+
427
+ use, period = LHCB1;
428
+
429
+ !####################### Tune matching and Twiss nominal #######################
430
+
431
+ option, echo, warn, info;
432
+ exec, match_tunes(62.31, 60.32, 1); ! Since we're using beam 1
433
+ exec, do_twiss_elements(LHCB1, "./twiss_nominal.dat", 0.0);
434
+
435
+ !####################### For longitudinal missalignments #######################
436
+
437
+ eoption, add, seed = { rand_seed } ; ! Different seed every time
438
+ select, flag=error, clear;
439
+ select, flag=error, pattern = ^MQXF.*[RL][15]; ! Only triplets quadrupoles around IP1 and IP5
440
+ GCUTR = 3; ! Cut gaussians at 3 sigma
441
+ ealign, ds := { ms_error } * 1E-3 * TGAUSS(GCUTR); ! Gaussian missalignments in meters
442
+
443
+ !####################### Saving errors to file #######################
444
+
445
+ !esave, file="./errors_file.dat"; ! Will save the errors of chosen type.
446
+
447
+ !####################### Tune matching and Twiss with errors #######################
448
+
449
+ exec, match_tunes(62.31, 60.32, 1);
450
+ exec, do_twiss_elements(LHCB1, "./twiss_errors.dat", 0.0);
451
+ """
452
+ return mserror_script
453
+
261
454
262
455
if __name__ == "__main__" :
263
456
raise NotImplementedError ("This module is meant to be imported." )
0 commit comments