~maddevelopers/mg5amcnlo/new_clustering

« back to all changes in this revision

Viewing changes to tests/unit_tests/loop/test_loop_diagram_generation.py

  • Committer: Rikkert Frederix
  • Date: 2021-09-09 15:51:40 UTC
  • mfrom: (78.75.502 3.2.1)
  • Revision ID: frederix@physik.uzh.ch-20210909155140-rg6umfq68h6h47cf
merge with 3.2.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
"""Unit test library for the various properties of objects in 
17
17
   loop_diagram_generaiton"""
18
18
 
 
19
from __future__ import absolute_import
 
20
from __future__ import print_function
19
21
import copy
20
22
import itertools
21
23
import logging
22
24
import math
23
25
import os
24
26
import sys
 
27
from six.moves import range
25
28
 
26
29
root_path = os.path.split(os.path.dirname(os.path.realpath( __file__ )))[0]
27
30
sys.path.append(os.path.join(root_path, os.path.pardir, os.path.pardir))
28
31
 
29
32
 
 
33
import tests.IOTests as IOTests
30
34
import tests.unit_tests as unittest
31
35
 
32
36
 
 
37
import madgraph.various.misc as misc
 
38
import madgraph.core.color_algebra as color
33
39
import madgraph.core.drawing as draw_lib
34
40
import madgraph.iolibs.drawing_eps as draw
35
41
import madgraph.core.base_objects as base_objects
45
51
                                'input_files')
46
52
_model_file_path = os.path.join(_file_path, os.path.pardir, os.path.pardir,
47
53
                                os.path.pardir,'models')
 
54
_color_one = color.ColorString()
48
55
#===============================================================================
49
56
# Function to load a toy hardcoded Loop Model
50
57
#===============================================================================
154
161
                  'id': 1,
155
162
                  'particles': base_objects.ParticleList(\
156
163
                                        [mypartlist[0]] * 3),
157
 
                  'color': [],
 
164
                  'color': [_color_one],
158
165
                  'lorentz':['L1'],
159
166
                  'couplings':{(0, 0):'G'},
160
167
                  'orders':{'QCD':1}}))
164
171
                  'id': 2,
165
172
                  'particles': base_objects.ParticleList(\
166
173
                                        [mypartlist[0]] * 4),
167
 
                  'color': [],
 
174
                  'color': [_color_one],
168
175
                  'lorentz':['L1'],
169
176
                  'couplings':{(0, 0):'G^2'},
170
177
                  'orders':{'QCD':2}}))
176
183
                                        [mypartlist[1], \
177
184
                                         antiu, \
178
185
                                         mypartlist[0]]),
179
 
                  'color': [],
 
186
                  'color': [_color_one],
180
187
                  'lorentz':['L1'],
181
188
                  'couplings':{(0, 0):'GQQ'},
182
189
                  'orders':{'QCD':1}}))
187
194
                                        [mypartlist[1], \
188
195
                                         antiu, \
189
196
                                         mypartlist[3]]),
190
 
                  'color': [],
 
197
                  'color': [_color_one],
191
198
                  'lorentz':['L1'],
192
199
                  'couplings':{(0, 0):'GQED'},
193
200
                  'orders':{'QED':1}}))
198
205
                                        [mypartlist[2], \
199
206
                                         antid, \
200
207
                                         mypartlist[0]]),
201
 
                  'color': [],
 
208
                  'color': [_color_one],
202
209
                  'lorentz':['L1'],
203
210
                  'couplings':{(0, 0):'GQQ'},
204
211
                  'orders':{'QCD':1}}))
209
216
                                        [mypartlist[2], \
210
217
                                         antid, \
211
218
                                         mypartlist[3]]),
212
 
                  'color': [],
 
219
                  'color': [_color_one],
213
220
                  'lorentz':['L1'],
214
221
                  'couplings':{(0, 0):'GQED'},
215
222
                  'orders':{'QED':1}}))
222
229
                                        [mypartlist[4], \
223
230
                                         antie, \
224
231
                                         mypartlist[3]]),
225
 
                  'color': [],
 
232
                  'color': [_color_one],
226
233
                  'lorentz':['L1'],
227
234
                  'couplings':{(0, 0):'GQED'},
228
235
                  'orders':{'QED':1}}))
235
242
                  'id': 8,
236
243
                  'particles': base_objects.ParticleList(\
237
244
                                        [mypartlist[0]] * 3),
238
 
                  'color': [],
 
245
                  'color': [_color_one],
239
246
                  'lorentz':['L1'],
240
247
                  'couplings':{(0, 0):'G'},
241
248
                  'orders':{'QCD':3},
248
255
                  'id': 9,
249
256
                  'particles': base_objects.ParticleList(\
250
257
                                        [mypartlist[0]] * 4),
251
 
                  'color': [],
 
258
                  'color': [_color_one],
252
259
                  'lorentz':['L1'],
253
260
                  'couplings':{(0, 0):'G^2'},
254
261
                  'orders':{'QCD':4},
263
270
                                        [mypartlist[1], \
264
271
                                         antiu, \
265
272
                                         mypartlist[0]]),
266
 
                  'color': [],
 
273
                  'color': [_color_one],
267
274
                  'lorentz':['L1'],
268
275
                  'couplings':{(0, 0):'GQQ'},
269
276
                  'orders':{'QCD':3},
277
284
                                        [mypartlist[1], \
278
285
                                         antiu, \
279
286
                                         mypartlist[0]]),
280
 
                  'color': [],
 
287
                  'color': [_color_one],
281
288
                  'lorentz':['L1'],
282
289
                  'couplings':{(0, 0):'GQQ'},
283
290
                  'orders':{'QCD':1, 'QED':2},
291
298
                                        [mypartlist[1], \
292
299
                                         antiu, \
293
300
                                         mypartlist[3]]),
294
 
                  'color': [],
 
301
                  'color': [_color_one],
295
302
                  'lorentz':['L1'],
296
303
                  'couplings':{(0, 0):'GQED'},
297
304
                  'orders':{'QED':1, 'QCD':2},
305
312
                                        [mypartlist[1], \
306
313
                                         antiu, \
307
314
                                         mypartlist[3]]),
308
 
                  'color': [],
 
315
                  'color': [_color_one],
309
316
                  'lorentz':['L1'],
310
317
                  'couplings':{(0, 0):'GQED'},
311
318
                  'orders':{'QED':3},
319
326
                                        [mypartlist[2], \
320
327
                                         antid, \
321
328
                                         mypartlist[0]]),
322
 
                  'color': [],
 
329
                  'color': [_color_one],
323
330
                  'lorentz':['L1'],
324
331
                  'couplings':{(0, 0):'GQQ'},
325
332
                  'orders':{'QCD':3},
333
340
                                        [mypartlist[2], \
334
341
                                         antid, \
335
342
                                         mypartlist[0]]),
336
 
                  'color': [],
 
343
                  'color': [_color_one],
337
344
                  'lorentz':['L1'],
338
345
                  'couplings':{(0, 0):'GQQ'},
339
346
                  'orders':{'QCD':1, 'QED':2},
347
354
                                        [mypartlist[2], \
348
355
                                         antid, \
349
356
                                         mypartlist[3]]),
350
 
                  'color': [],
 
357
                  'color': [_color_one],
351
358
                  'lorentz':['L1'],
352
359
                  'couplings':{(0, 0):'GQED'},
353
360
                  'orders':{'QED':1, 'QCD':2},
361
368
                                        [mypartlist[2], \
362
369
                                         antid, \
363
370
                                         mypartlist[3]]),
364
 
                  'color': [],
 
371
                  'color': [_color_one],
365
372
                  'lorentz':['L1'],
366
373
                  'couplings':{(0, 0):'GQED'},
367
374
                  'orders':{'QED':3},
377
384
                                        [mypartlist[4], \
378
385
                                         antie, \
379
386
                                         mypartlist[3]]),
380
 
                  'color': [],
 
387
                  'color': [_color_one],
381
388
                  'lorentz':['L1'],
382
389
                  'couplings':{(0, 0):'GQED'},
383
390
                  'orders':{'QED':3},
394
401
                  'id': 19,
395
402
                  'particles': base_objects.ParticleList(\
396
403
                                        [mypartlist[0]] * 2),
397
 
                  'color': [],
 
404
                  'color': [_color_one],
398
405
                  'lorentz':['L1'],
399
406
                  'couplings':{(0, 0):'G'},
400
407
                  'orders':{'QCD':2},
407
414
                  'id': 20,
408
415
                  'particles': base_objects.ParticleList(\
409
416
                                        [mypartlist[3]] * 2),
410
 
                  'color': [],
 
417
                  'color': [_color_one],
411
418
                  'lorentz':['L1'],
412
419
                  'couplings':{(0, 0):'G'},
413
420
                  'orders':{'QED':2},
421
428
                  'particles': base_objects.ParticleList([\
422
429
                                        mypartlist[4], \
423
430
                                         antie]),
424
 
                  'color': [],
 
431
                  'color': [_color_one],
425
432
                  'lorentz':['L1'],
426
433
                  'couplings':{(0, 0):'G'},
427
434
                  'orders':{'QED':2},
435
442
                  'particles': base_objects.ParticleList([\
436
443
                                        mypartlist[2], \
437
444
                                         antid]),
438
 
                  'color': [],
 
445
                  'color': [_color_one],
439
446
                  'lorentz':['L1'],
440
447
                  'couplings':{(0, 0):'G'},
441
448
                  'orders':{'QED':2},
449
456
                  'particles': base_objects.ParticleList([\
450
457
                                        mypartlist[2], \
451
458
                                         antid]),
452
 
                  'color': [],
 
459
                  'color': [_color_one],
453
460
                  'lorentz':['L1'],
454
461
                  'couplings':{(0, 0):'G'},
455
462
                  'orders':{'QCD':2},
463
470
                  'particles': base_objects.ParticleList([\
464
471
                                        mypartlist[1], \
465
472
                                         antiu]),
466
 
                  'color': [],
 
473
                  'color': [_color_one],
467
474
                  'lorentz':['L1'],
468
475
                  'couplings':{(0, 0):'G'},
469
476
                  'orders':{'QED':2},
477
484
                  'particles': base_objects.ParticleList([\
478
485
                                        mypartlist[1], \
479
486
                                         antid]),
480
 
                  'color': [],
 
487
                  'color': [_color_one],
481
488
                  'lorentz':['L1'],
482
489
                  'couplings':{(0, 0):'G'},
483
490
                  'orders':{'QCD':2},
493
500
                  'id': 26,
494
501
                  'particles': base_objects.ParticleList(\
495
502
                                        [mypartlist[3]] * 3),
496
 
                  'color': [],
 
503
                  'color': [_color_one],
497
504
                  'lorentz':['L1'],
498
505
                  'couplings':{(0, 0):'G'},
499
506
                  'orders':{'QED':3},
508
515
                                        [mypartlist[3],\
509
516
                                        mypartlist[3],\
510
517
                                        mypartlist[0],]),
511
 
                  'color': [],
 
518
                  'color': [_color_one],
512
519
                  'lorentz':['L1'],
513
520
                  'couplings':{(0, 0):'G'},
514
521
                  'orders':{'QED':2, 'QCD':1},
523
530
                                        [mypartlist[3],\
524
531
                                        mypartlist[0],\
525
532
                                        mypartlist[0],]),
526
 
                  'color': [],
 
533
                  'color': [_color_one],
527
534
                  'lorentz':['L1'],
528
535
                  'couplings':{(0, 0):'G'},
529
536
                  'orders':{'QED':1, 'QCD':2},
536
543
                  'id': 29,
537
544
                  'particles': base_objects.ParticleList(\
538
545
                                        [mypartlist[3]] * 4),
539
 
                  'color': [],
 
546
                  'color': [_color_one],
540
547
                  'lorentz':['L1'],
541
548
                  'couplings':{(0, 0):'G'},
542
549
                  'orders':{'QED':4},
552
559
                                        mypartlist[3],\
553
560
                                        mypartlist[3],\
554
561
                                        mypartlist[0]]),
555
 
                  'color': [],
 
562
                  'color': [_color_one],
556
563
                  'lorentz':['L1'],
557
564
                  'couplings':{(0, 0):'G'},
558
565
                  'orders':{'QED':3,'QCD':1},
567
574
                                        mypartlist[3],\
568
575
                                        mypartlist[0],\
569
576
                                        mypartlist[0]]),
570
 
                  'color': [],
 
577
                  'color': [_color_one],
571
578
                  'lorentz':['L1'],
572
579
                  'couplings':{(0, 0):'G'},
573
580
                  'orders':{'QED':2,'QCD':2},
582
589
                                        mypartlist[0],\
583
590
                                        mypartlist[0],\
584
591
                                        mypartlist[0]]),
585
 
                  'color': [],
 
592
                  'color': [_color_one],
586
593
                  'lorentz':['L1'],
587
594
                  'couplings':{(0, 0):'G'},
588
595
                  'orders':{'QED':1,'QCD':3},
596
603
                  'id': 33,
597
604
                  'particles': base_objects.ParticleList(\
598
605
                                        [mypartlist[0]] * 3),
599
 
                  'color': [],
 
606
                  'color': [_color_one],
600
607
                  'lorentz':['L1'],
601
608
                  'couplings':{(0, 0):'G'},
602
609
                  'orders':{'QCD':3},
609
616
                  'id': 34,
610
617
                  'particles': base_objects.ParticleList(\
611
618
                                        [mypartlist[0]] * 4),
612
 
                  'color': [],
 
619
                  'color': [_color_one],
613
620
                  'lorentz':['L1'],
614
621
                  'couplings':{(0, 0):'G^2'},
615
622
                  'orders':{'QCD':4},
624
631
                                        [mypartlist[1], \
625
632
                                         antiu, \
626
633
                                         mypartlist[0]]),
627
 
                  'color': [],
 
634
                  'color': [_color_one],
628
635
                  'lorentz':['L1'],
629
636
                  'couplings':{(0, 0):'GQQ'},
630
637
                  'orders':{'QCD':3},
639
646
                                        [mypartlist[1], \
640
647
                                         antiu, \
641
648
                                         mypartlist[0]]),
642
 
                  'color': [],
 
649
                  'color': [_color_one],
643
650
                  'lorentz':['L1'],
644
651
                  'couplings':{(0, 0):'GQQ'},
645
652
                  'orders':{'QED':2,'QCD':1},
653
660
                                        [mypartlist[1], \
654
661
                                         antiu, \
655
662
                                         mypartlist[3]]),
656
 
                  'color': [],
 
663
                  'color': [_color_one],
657
664
                  'lorentz':['L1'],
658
665
                  'couplings':{(0, 0):'GQED'},
659
666
                  'orders':{'QCD':2,'QED':1},
667
674
                                        [mypartlist[1], \
668
675
                                         antiu, \
669
676
                                         mypartlist[3]]),
670
 
                  'color': [],
 
677
                  'color': [_color_one],
671
678
                  'lorentz':['L1'],
672
679
                  'couplings':{(0, 0):'GQED'},
673
680
                  'orders':{'QED':3},
681
688
                                        [mypartlist[2], \
682
689
                                         antid, \
683
690
                                         mypartlist[0]]),
684
 
                  'color': [],
 
691
                  'color': [_color_one],
685
692
                  'lorentz':['L1'],
686
693
                  'couplings':{(0, 0):'GQQ'},
687
694
                  'orders':{'QCD':3},
695
702
                                        [mypartlist[2], \
696
703
                                         antid, \
697
704
                                         mypartlist[0]]),
698
 
                  'color': [],
 
705
                  'color': [_color_one],
699
706
                  'lorentz':['L1'],
700
707
                  'couplings':{(0, 0):'GQQ'},
701
708
                  'orders':{'QED':2,'QCD':1},
709
716
                                        [mypartlist[2], \
710
717
                                         antid, \
711
718
                                         mypartlist[3]]),
712
 
                  'color': [],
 
719
                  'color': [_color_one],
713
720
                  'lorentz':['L1'],
714
721
                  'couplings':{(0, 0):'GQED'},
715
722
                  'orders':{'QCD':2,'QED':1},
723
730
                                        [mypartlist[2], \
724
731
                                         antid, \
725
732
                                         mypartlist[3]]),
726
 
                  'color': [],
 
733
                  'color': [_color_one],
727
734
                  'lorentz':['L1'],
728
735
                  'couplings':{(0, 0):'GQED'},
729
736
                  'orders':{'QED':3},
739
746
                                        [mypartlist[4], \
740
747
                                         antie, \
741
748
                                         mypartlist[3]]),
742
 
                  'color': [],
 
749
                  'color': [_color_one],
743
750
                  'lorentz':['L1'],
744
751
                  'couplings':{(0, 0):'GQED'},
745
752
                  'orders':{'QED':3},
756
763
                  'particles': base_objects.ParticleList([\
757
764
                                        mypartlist[2], \
758
765
                                         antid]),
759
 
                  'color': [],
 
766
                  'color': [_color_one],
760
767
                  'lorentz':['L1'],
761
768
                  'couplings':{(0, 0):'G'},
762
769
                  'orders':{'QED':2},
770
777
                  'particles': base_objects.ParticleList([\
771
778
                                        mypartlist[2], \
772
779
                                         antid]),
773
 
                  'color': [],
 
780
                  'color': [_color_one],
774
781
                  'lorentz':['L1'],
775
782
                  'couplings':{(0, 0):'G'},
776
783
                  'orders':{'QCD':2},
784
791
                  'particles': base_objects.ParticleList([\
785
792
                                        mypartlist[1], \
786
793
                                         antiu]),
787
 
                  'color': [],
 
794
                  'color': [_color_one],
788
795
                  'lorentz':['L1'],
789
796
                  'couplings':{(0, 0):'G'},
790
797
                  'orders':{'QED':2},
798
805
                  'particles': base_objects.ParticleList([\
799
806
                                        mypartlist[1], \
800
807
                                         antiu]),
801
 
                  'color': [],
 
808
                  'color': [_color_one],
802
809
                  'lorentz':['L1'],
803
810
                  'couplings':{(0, 0):'G'},
804
811
                  'orders':{'QCD':2},
1196
1203
                      # a dd~d~ R2
1197
1204
                      'particles': base_objects.ParticleList(\
1198
1205
                                            [self.mypartlist[0]]*4),
1199
 
                      'color': [],
 
1206
                      'color': [_color_one],
1200
1207
                      'lorentz':['L1'],
1201
1208
                      'couplings':{(0, 0):'G'},
1202
1209
                      'orders':{'QCD':4},
1319
1326
        for inter in newLoopModel['interactions']:
1320
1327
            if inter['type']=='base':
1321
1328
                newInteractionList.append(inter)
1322
 
        
 
1329
 
1323
1330
        myleglist = base_objects.LegList()
1324
1331
        myleglist.append(base_objects.Leg({'id':1,
1325
1332
                                         'state':False}))
1340
1347
                                             antid,
1341
1348
                                             self.mypartlist[2],
1342
1349
                                             antid,]),
1343
 
                      'color': [],
 
1350
                      'color': [_color_one],
1344
1351
                      'lorentz':['L1'],
1345
1352
                      'couplings':{(0, 0):'G'},
1346
1353
                      'orders':{'QCD':4},
1433
1440
                      'id': 1,
1434
1441
                      'particles': base_objects.ParticleList(\
1435
1442
                                            [self.mypartlist[0]] * 3),
1436
 
                      'color': [],
 
1443
                      'color': [_color_one],
1437
1444
                      'lorentz':['L1'],
1438
1445
                      'couplings':{(0, 0):'G'},
1439
1446
                      'orders':{'QCD':1}}))
1443
1450
                      'id': 2,
1444
1451
                      'particles': base_objects.ParticleList(\
1445
1452
                                            [self.mypartlist[0]] * 4),
1446
 
                      'color': [],
 
1453
                      'color': [_color_one],
1447
1454
                      'lorentz':['L1'],
1448
1455
                      'couplings':{(0, 0):'G^2'},
1449
1456
                      'orders':{'QCD':2}}))
1455
1462
                                            [self.mypartlist[1], \
1456
1463
                                             antid, \
1457
1464
                                             self.mypartlist[0]]),
1458
 
                      'color': [],
 
1465
                      'color': [_color_one],
1459
1466
                      'lorentz':['L1'],
1460
1467
                      'couplings':{(0, 0):'GQQ'},
1461
1468
                      'orders':{'QCD':1}}))
1599
1606
 
1600
1607
    myamplitude = diagram_generation.Amplitude()
1601
1608
 
 
1609
    @IOTests.set_global(unitary=False)
1602
1610
    def setUp(self):
1603
1611
        """Load different objects for the tests."""
1604
1612
        
2260
2268
if __name__ == '__main__':
2261
2269
        # Save this model so that it can be loaded by other loop tests
2262
2270
        save_load_object.save_to_file(os.path.join(_input_file_path, 'test_toyLoopModel.pkl'),loadLoopModel())
2263
 
        print "test_toyLoopModel.pkl created."
 
2271
        print("test_toyLoopModel.pkl created.")
2264
2272
        #unittest.main()