Merge lp:~maddevelopers/mg5amcnlo/fix_split_interaction_color into lp:~madteam/mg5amcnlo/trunk

Proposed by Johan Alwall
Status: Merged
Merge reported by: Olivier Mattelaer
Merged at revision: not available
Proposed branch: lp:~maddevelopers/mg5amcnlo/fix_split_interaction_color
Merge into: lp:~madteam/mg5amcnlo/trunk
Diff against target: 130 lines (+86/-2)
3 files modified
madgraph/VERSION (+1/-1)
madgraph/core/color_amp.py (+8/-1)
tests/unit_tests/core/test_color_amp.py (+77/-0)
To merge this branch: bzr merge lp:~maddevelopers/mg5amcnlo/fix_split_interaction_color
Reviewer Review Type Date Requested Status
Olivier Mattelaer Approve
Review via email: mp+51069@code.launchpad.net

Description of the change

Fixed color_amp.py to only take into account color strings that are actually used for couplings in the interaction. A situation when color strings are not used can happen when interactions are split due to different coupling orders for different couplings.

To post a comment you must log in.
Revision history for this message
Olivier Mattelaer (olivier-mattelaer) wrote :

The modifications in the code are fined.
Is it correct that this is more an optimisation update?

What I will suggest is to merge this version and the path completion fix at the same time.

Cheers,

Olivier

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'madgraph/VERSION'
2--- madgraph/VERSION 2011-02-11 16:31:01 +0000
3+++ madgraph/VERSION 2011-02-24 05:02:54 +0000
4@@ -1,3 +1,3 @@
5 version = 0.6.2.1
6-date = 2011-02-11
7+date = 2011-02-17
8
9
10=== modified file 'madgraph/core/color_amp.py'
11--- madgraph/core/color_amp.py 2010-12-29 01:59:06 +0000
12+++ madgraph/core/color_amp.py 2011-02-24 05:02:54 +0000
13@@ -174,7 +174,9 @@
14 # Update the result dict using the current vertex ColorString object
15 # If more than one, create different entries
16 inter_color = model.get_interaction(vertex['id'])['color']
17-
18+ inter_indices = [i for (i,j) in \
19+ model.get_interaction(vertex['id'])['couplings'].keys()]
20+
21 # For colorless vertices, return a copy of res_dict
22 # Where one 0 has been added to each color index chain key
23 if not inter_color:
24@@ -190,6 +192,11 @@
25 new_res_dict = {}
26 for i, col_str in \
27 enumerate(inter_color):
28+
29+ # Ignore color string if it doesn't correspond to any coupling
30+ if i not in inter_indices:
31+ continue
32+
33 # Build the new element
34 mod_col_str = col_str.create_copy()
35
36
37=== modified file 'tests/unit_tests/core/test_color_amp.py'
38--- tests/unit_tests/core/test_color_amp.py 2010-12-29 01:59:06 +0000
39+++ tests/unit_tests/core/test_color_amp.py 2011-02-24 05:02:54 +0000
40@@ -284,6 +284,81 @@
41
42 self.assertEqual(col_dict, goal_dict)
43
44+ def test_colorize_funny_model(self):
45+ """Test the colorize function for uu~ > ggg"""
46+
47+ mypartlist = base_objects.ParticleList()
48+ myinterlist = base_objects.InteractionList()
49+ mymodel = base_objects.Model()
50+
51+ # A gluon
52+ mypartlist.append(base_objects.Particle({'name':'g',
53+ 'antiname':'g',
54+ 'spin':3,
55+ 'color':8,
56+ 'mass':'zero',
57+ 'width':'zero',
58+ 'texname':'g',
59+ 'antitexname':'g',
60+ 'line':'curly',
61+ 'charge':0.,
62+ 'pdg_code':21,
63+ 'propagating':True,
64+ 'is_part':True,
65+ 'self_antipart':True}))
66+
67+ # 3 gluon vertiex
68+ myinterlist.append(base_objects.Interaction({
69+ 'id': 1,
70+ 'particles': base_objects.ParticleList(\
71+ [mypartlist[0]] * 3),
72+ 'color': [color.ColorString([color.f(0, 1, 2)]),
73+ color.ColorString([color.f(0, 2, 1)]),
74+ color.ColorString([color.f(1, 2, 0)])],
75+ 'lorentz':['L1'],
76+ 'couplings':{(0, 0):'G', (2,0):'G'},
77+ 'orders':{'QCD':1}}))
78+
79+ mymodel.set('particles', mypartlist)
80+ mymodel.set('interactions', myinterlist)
81+
82+ myleglist = base_objects.LegList()
83+
84+ myleglist.append(base_objects.Leg({'id':21,
85+ 'state':False}))
86+ myleglist.append(base_objects.Leg({'id':21,
87+ 'state':False}))
88+
89+ myleglist.extend([base_objects.Leg({'id':21,
90+ 'state':True})] * 2)
91+
92+ myprocess = base_objects.Process({'legs':myleglist,
93+ 'model':mymodel})
94+
95+ myamplitude = diagram_generation.Amplitude()
96+
97+ myamplitude.set('process', myprocess)
98+
99+ myamplitude.generate_diagrams()
100+
101+ my_col_basis = color_amp.ColorBasis()
102+
103+ # Check that only the color structures that are actually used are included
104+ col_dict = my_col_basis.colorize(myamplitude['diagrams'][0],
105+ mymodel)
106+ goal_dict = {(0, 0): color.ColorString([color.f(-1000, 1, 2),
107+ color.f(-1000, 3, 4)]),
108+ (0, 2): color.ColorString([color.f(-1000, 1, 2),
109+ color.f(3, 4, -1000)]),
110+ (2, 0): color.ColorString([color.f(1, 2, -1000),
111+ color.f(-1000, 3, 4)]),
112+ (2, 2):color.ColorString([color.f(1, 2, -1000),
113+ color.f(3, 4, -1000)])}
114+
115+
116+ self.assertEqual(col_dict, goal_dict)
117+
118+
119 def test_color_basis_uux_aggg(self):
120 """Test the color basis building for uu~ > aggg (3! elements)"""
121
122@@ -402,6 +477,8 @@
123 [(8, 1, 1001, 2001)]),
124 goal_cs)
125
126+
127+
128
129 class ColorSquareTest(unittest.TestCase):
130 """Test class for the color_amp module"""

Subscribers

People subscribed via source and target branches