def test_K6_objects(self): """Test K6 product simplifications""" #K6(m,i,j)K6Bar(m,k,l) = 1/2(T(l,i)T(k,j) # + T(k,i)T(l,j) my_K6 = color.K6(1,101,102) my_K6Bar = color.K6Bar(1,103,104) col_str1 = color.ColorString([color.T(104,101), color.T(103,102)]) col_str2 = color.ColorString([color.T(103,101), color.T(104,102)]) col_str1.coeff = fractions.Fraction(1, 2) col_str2.coeff = fractions.Fraction(1, 2) self.assertEqual(my_K6.pair_simplify(my_K6Bar), color.ColorFactor([col_str1, col_str2])) #K6(m,i,j)K6Bar(n,j,i) = delta6(m,n) my_K6 = color.K6(1,101,102) my_K6Bar = color.K6Bar(2,102,101) self.assertEqual(my_K6.pair_simplify(my_K6Bar), color.ColorFactor([\ color.ColorString([color.T6(1,2)])])) #K6(m,i,j)K6Bar(n,i,j) = delta6(m,n). my_K6 = color.K6(1,101,102) my_K6Bar = color.K6Bar(2,101,102) self.assertEqual(my_K6.pair_simplify(my_K6Bar), color.ColorFactor([\ color.ColorString([color.T6(1,2)])]))
def test_colorize_uu_gg(self): """Test the colorize function for uu~ > gg""" myleglist = base_objects.LegList() myleglist.append(base_objects.Leg({'id': -2, 'state': False})) myleglist.append(base_objects.Leg({'id': 2, 'state': False})) myleglist.extend([base_objects.Leg({'id': 21, 'state': True})] * 2) myprocess = base_objects.Process({ 'legs': myleglist, 'model': self.mymodel }) myamplitude = diagram_generation.Amplitude() myamplitude.set('process', myprocess) myamplitude.generate_diagrams() my_col_basis = color_amp.ColorBasis() # S channel col_dict = my_col_basis.colorize(myamplitude['diagrams'][0], self.mymodel) goal_dict = { (0, 0): color.ColorString([color.T(-1000, 1, 2), color.f(3, 4, -1000)]) } self.assertEqual(col_dict, goal_dict) # T channel col_dict = my_col_basis.colorize(myamplitude['diagrams'][1], self.mymodel) goal_dict = { (0, 0): color.ColorString([color.T(3, 1, -1000), color.T(4, -1000, 2)]) } self.assertEqual(col_dict, goal_dict) # U channel col_dict = my_col_basis.colorize(myamplitude['diagrams'][2], self.mymodel) goal_dict = { (0, 0): color.ColorString([color.T(4, 1, -1000), color.T(3, -1000, 2)]) } self.assertEqual(col_dict, goal_dict)
def test_delta3_pair_simplify(self): """Test delta3 simplify""" self.assertEqual(color.K6(1,101,103).pair_simplify(color.T(101,102)), color.ColorFactor([color.ColorString([color.K6(1,103,102)])])) self.assertEqual(color.K6(1,103,102).pair_simplify(color.T(102,101)), color.ColorFactor([color.ColorString([color.K6(1,103,101)])])) self.assertEqual(color.K6Bar(1,101,103).pair_simplify(color.T(102,101)), color.ColorFactor([color.ColorString([color.K6Bar(1,103,102)])])) self.assertEqual(color.K6Bar(1,103,101).pair_simplify(color.T(102,101)), color.ColorFactor([color.ColorString([color.K6Bar(1,103,102)])]))
def test_epsilon_object(self): """Test the epsilon object""" # Espilon should have exactly 3 indices! self.assertRaises(AssertionError, color.Epsilon, 1, 2) my_epsilon1 = color.Epsilon(2, 3, 1) my_epsilon2 = color.Epsilon(5, 1, 4) my_epsilon2 = my_epsilon2.complex_conjugate() my_goal_str1 = color.ColorString([color.T(2, 4), color.T(3, 5)]) my_goal_str2 = color.ColorString([color.T(2, 5), color.T(3, 4)]) my_goal_str2.coeff = fractions.Fraction(-1) self.assertEqual(my_epsilon1.pair_simplify(my_epsilon2), color.ColorFactor([my_goal_str1, my_goal_str2]))
def closeColorLoop(self, colorize_dict, lcut_charge, lcut_numbers): """ Add a color delta in the right representation (depending on the color charge carried by the L-cut particle whose number are given in the loop_numbers argument) to close the loop color trace """ # But for T3 and T6 for example, we must make sure to add a delta with # the first index in the fundamental representation. if lcut_charge < 0: lcut_numbers.reverse() if abs(lcut_charge) == 1: # No color carried by the lcut particle, there is nothing to do. return elif abs(lcut_charge) == 3: closingCS=color_algebra.ColorString(\ [color_algebra.T(lcut_numbers[1],lcut_numbers[0])]) elif abs(lcut_charge) == 6: closingCS=color_algebra.ColorString(\ [color_algebra.T6(lcut_numbers[1],lcut_numbers[0])]) elif abs(lcut_charge) == 8: closingCS=color_algebra.ColorString(\ [color_algebra.Tr(lcut_numbers[1],lcut_numbers[0])], fractions.Fraction(2, 1)) else: raise color_amp.ColorBasis.ColorBasisError, \ "L-cut particle has an unsupported color representation %s" % lcut_charge # Append it to all color strings for this diagram. for CS in colorize_dict.values(): CS.product(closingCS)
def get_color_flow_string(my_color_string, octet_indices): """Return the color_flow_string (i.e., composed only of T's with 2 indices) associated to my_color_string. Take a list of the external leg color octet state indices as an input. Returns only the leading N contribution!""" # Create a new color factor to allow for simplification my_cf = color_algebra.ColorFactor([my_color_string]) # Add one T per external octet for indices in octet_indices: if indices[0] == -6: # Add a K6 which contracts the antisextet index to a # pair of antitriplets my_cf[0].append( color_algebra.K6(indices[1], indices[2], indices[3])) if indices[0] == 6: # Add a K6Bar which contracts the sextet index to a # pair of triplets my_cf[0].append( color_algebra.K6Bar(indices[1], indices[2], indices[3])) if abs(indices[0]) == 8: # Add a T which contracts the octet to a # triplet-antitriplet pair my_cf[0].append( color_algebra.T(indices[1], indices[2], indices[3])) # Simplify the whole thing my_cf = my_cf.full_simplify() # If the result is empty, just return if not my_cf: return my_cf # Return the string with the highest N coefficient # (leading N decomposition), and the value of this coeff max_coeff = max([cs.Nc_power for cs in my_cf]) res_cs = [cs for cs in my_cf if cs.Nc_power == max_coeff] # If more than one string at leading N... if len(res_cs) > 1 and any([not cs.near_equivalent(res_cs[0]) \ for cs in res_cs]): raise ColorBasis.ColorBasisError, \ "More than one color string with leading N coeff: %s" % str(res_cs) res_cs = res_cs[0] # If the result string does not contain only T's with two indices # and Epsilon/EpsilonBar objects for col_obj in res_cs: if not isinstance(col_obj, color_algebra.T) and \ not col_obj.__class__.__name__.startswith('Epsilon'): raise ColorBasis.ColorBasisError, \ "Color flow decomposition %s contains non T/Epsilon elements" % \ str(res_cs) if isinstance(col_obj, color_algebra.T) and len(col_obj) != 2: raise ColorBasis.ColorBasisError, \ "Color flow decomposition %s contains T's w/o 2 indices" % \ str(res_cs) return res_cs
def closeColorLoop(self, colorize_dict, lcut_charge, lcut_numbers): """ Add a color delta in the right representation (depending on the color charge carried by the L-cut particle whose number are given in the loop_numbers argument) to close the loop color trace.""" # But for T3 and T6 for example, we must make sure to add a delta with # the first index in the fundamental representation. if lcut_charge < 0: lcut_numbers.reverse() if abs(lcut_charge) == 1: # No color carried by the lcut particle, there is nothing to do. return elif abs(lcut_charge) == 3: closingCS=color_algebra.ColorString(\ [color_algebra.T(lcut_numbers[1],lcut_numbers[0])]) elif abs(lcut_charge) == 6: closingCS=color_algebra.ColorString(\ [color_algebra.T6(lcut_numbers[1],lcut_numbers[0])]) elif abs(lcut_charge) == 8: closingCS=color_algebra.ColorString(\ [color_algebra.Tr(lcut_numbers[1],lcut_numbers[0])], fractions.Fraction(2, 1)) else: raise color_amp.ColorBasis.ColorBasisError, \ "L-cut particle has an unsupported color representation %s" % lcut_charge # Append it to all color strings for this diagram. for CS in colorize_dict.values(): # The double full_simplify() below brings significantly slowdown # so that it should be used only when loop_Nc_power is actuall used. if self.compute_loop_nc: # We first compute the NcPower of this ColorString before # *before* the loop color flow is sewed together. max_CS_lcut_diag_Nc_power = max(cs.Nc_power \ for cs in color_algebra.ColorFactor([CS]).full_simplify()) # We add here the closing color structure. CS.product(closingCS) if self.compute_loop_nc: # Now compute the Nc power *after* the loop color flow is sewed # together and again compute the overall maximum power of Nc # appearing in this simplified sewed structure. simplified_cs = color_algebra.ColorFactor([CS]).full_simplify() if not simplified_cs: # It can be that the color structure simplifies to zero. CS.loop_Nc_power = 0 continue max_CS_loop_diag_Nc_power = max(cs.Nc_power \ for cs in simplified_cs) # We can now set the power of Nc brought by the potential loop # color trace to the corresponding attribute of this ColorStructure CS.loop_Nc_power = max_CS_loop_diag_Nc_power - \ max_CS_lcut_diag_Nc_power else: # When not computing loop_nc (whcih is typically used for now # only when doing LoopInduced + Madevent, we set the # CS.loop_Nc_power to None so that it will cause problems if used. CS.loop_Nc_power = None
def test_complex_conjugate(self): """Test the complex conjugation of a color string""" my_color_string = color.ColorString([color.T(3, 4, 102, 103), color.Tr(1, 2, 3)]) my_color_string.is_imaginary = True self.assertEqual(str(my_color_string.complex_conjugate()), '-1 I T(4,3,103,102) Tr(3,2,1)')
def test_T_simplify(self): """Test T simplify""" # T(a,b,c,...,i,i) = Tr(a,b,c,...) self.assertEqual(color.T(1, 2, 3, 100, 100).simplify(), color.ColorFactor([\ color.ColorString([color.Tr(1, 2, 3)])])) # T(a,x,b,x,c,i,j) = 1/2(T(a,c,i,j)Tr(b)-1/Nc T(a,b,c,i,j)) my_T = color.T(1, 2, 100, 3, 100, 4, 101, 102) col_str1 = color.ColorString([color.T(1, 2, 4, 101, 102), color.Tr(3)]) col_str2 = color.ColorString([color.T(1, 2, 3, 4, 101, 102)]) col_str1.coeff = fractions.Fraction(1, 2) col_str2.coeff = fractions.Fraction(-1, 2) col_str2.Nc_power = -1 self.assertEqual(my_T.simplify(), color.ColorFactor([col_str1, col_str2])) self.assertEqual(my_T.simplify(), color.ColorFactor([col_str1, col_str2]))
def test_T_f_product(self): """Test a non trivial T f f product""" my_color_factor = color.ColorFactor([\ color.ColorString([color.T(-1000, 1, 2), color.f(-1, -1000, 5), color.f(-1, 4, 3)])]) self.assertEqual(str(my_color_factor.full_simplify()), "(-1 T(5,4,3,1,2))+(1 T(5,3,4,1,2))+(1 T(4,3,5,1,2))+(-1 T(3,4,5,1,2))")
def test_replace_indices(self): """Test indices replacement""" repl_dict = {1: 2, 2: 3, 3: 1} my_color_string = color.ColorString( [color.T(1, 2, 3, 4), color.Tr(3, 2, 1)]) my_color_string.replace_indices(repl_dict) self.assertEqual(str(my_color_string), '1 T(2,3,1,4) Tr(1,3,2)') inv_repl_dict = dict([v, k] for k, v in repl_dict.items()) my_color_string.replace_indices(inv_repl_dict) self.assertEqual(str(my_color_string), '1 T(1,2,3,4) Tr(3,2,1)')
def test_Tr_pair_simplify(self): """Test Tr object product simplification""" my_Tr1 = color.Tr(1, 2, 3) my_Tr2 = color.Tr(4, 2, 5) my_T = color.T(4, 2, 5, 101, 102) col_str1 = color.ColorString([color.Tr(1, 5, 4, 3)]) col_str2 = color.ColorString([color.Tr(1, 3), color.Tr(4, 5)]) col_str1.coeff = fractions.Fraction(1, 2) col_str2.coeff = fractions.Fraction(-1, 2) col_str2.Nc_power = -1 self.assertEqual(my_Tr1.pair_simplify(my_Tr2), color.ColorFactor([col_str1, col_str2])) col_str1 = color.ColorString([color.T(4, 3, 1, 5, 101, 102)]) col_str2 = color.ColorString([color.Tr(1, 3), color.T(4, 5, 101, 102)]) col_str1.coeff = fractions.Fraction(1, 2) col_str2.coeff = fractions.Fraction(-1, 2) col_str2.Nc_power = -1 self.assertEqual(my_Tr1.pair_simplify(my_T), color.ColorFactor([col_str1, col_str2]))
def test_T6_simplify(self): """Test T6 simplify""" # T6(a,i,j) = 2(K6(i,ii,jj)T(a,jj,kk)K6Bar(j,kk,ii)) my_T6 = color.T6(1,101,102) color.T6.new_index = 10000 k6 = color.K6(101, 10000, 10001) t = color.T(1, 10001, 10002) k6b = color.K6Bar(102, 10002, 10000) col_string = color.ColorString([k6, t, k6b]) col_string.coeff = fractions.Fraction(2, 1) self.assertEqual(my_T6.simplify(), color.ColorFactor([col_string])) my_T6 = color.T6(1,101,102) k6 = color.K6(101, 10003, 10004) t = color.T(1, 10004, 10005) k6b = color.K6Bar(102, 10005, 10003) col_string = color.ColorString([k6, t, k6b]) col_string.coeff = fractions.Fraction(2, 1) self.assertEqual(my_T6.simplify(), color.ColorFactor([col_string]))
def test_color_flow_string_epsilon(self): """Test the color flow decomposition of strings including Epsilon and color sextets""" # g q > trip q my_cs = color.ColorString( [color.Epsilon(-1000, 2, 3), color.T(1, 4, -1000)]) goal_cs = color.ColorString( [color.T(4, 2001), color.Epsilon(1001, 2, 3)]) goal_cs.coeff = fractions.Fraction(1, 2) self.assertEqual( color_amp.ColorBasis.get_color_flow_string(my_cs, [(8, 1, 1001, 2001)]), goal_cs) # g q > six q~ my_cs = color.ColorString( [color.K6(3, -1000, 4), color.T(1, -1000, 2)]) goal_cs = color.ColorString( [color.T(1001, 2), color.T(1003, 4), color.T(3003, 2001)]) goal_cs.coeff = fractions.Fraction(1, 4) self.assertEqual( color_amp.ColorBasis.get_color_flow_string(my_cs, [(8, 1, 1001, 2001), (6, 3, 1003, 3003)]), goal_cs) # g q~ > trip > q~ q q~ my_cs = color.ColorString([ color.Epsilon(-1000, 2, 4), color.EpsilonBar(-1001, 3, 5), color.T(1, -1001, -1000) ]) goal_cs = color.ColorString( [color.Epsilon(1001, 2, 4), color.EpsilonBar(2001, 3, 5)]) goal_cs.coeff = fractions.Fraction(1, 2) self.assertEqual( color_amp.ColorBasis.get_color_flow_string(my_cs, [(8, 1, 1001, 2001)]), goal_cs)
def test_T_pair_simplify(self): """Test T object products simplifications""" my_T1 = color.T(1, 2, 3, 101, 102) my_T2 = color.T(4, 5, 102, 103) self.assertEqual(my_T1.pair_simplify(my_T2), color.ColorFactor([color.ColorString([\ color.T(1, 2, 3, 4, 5, 101, 103)])])) my_T3 = color.T(4, 2, 5, 103, 104) col_str1 = color.ColorString([color.T(1, 5, 101, 104), color.T(4, 3, 103, 102)]) col_str2 = color.ColorString([color.T(1, 3, 101, 102), color.T(4, 5, 103, 104)]) col_str1.coeff = fractions.Fraction(1, 2) col_str2.coeff = fractions.Fraction(-1, 2) col_str2.Nc_power = -1 self.assertEqual(my_T1.pair_simplify(my_T3), color.ColorFactor([col_str1, col_str2]))
def test_ungrouping_lepton(self): """check that the routines which ungroup the process for the muon/electron processes works as expected""" # Setup A simple model mypartlist = base_objects.ParticleList() myinterlist = base_objects.InteractionList() # A quark U and its antiparticle mypartlist.append( base_objects.Particle({ 'name': 'u', 'antiname': 'u~', 'spin': 2, 'color': 3, 'mass': 'zero', 'width': 'zero', 'texname': 'u', 'antitexname': '\bar u', 'line': 'straight', 'charge': 2. / 3., 'pdg_code': 2, 'propagating': True, 'is_part': True, 'self_antipart': False })) u = mypartlist[-1] antiu = copy.copy(u) antiu.set('is_part', False) # A quark D and its antiparticle mypartlist.append( base_objects.Particle({ 'name': 'd', 'antiname': 'd~', 'spin': 2, 'color': 3, 'mass': 'zero', 'width': 'zero', 'texname': 'd', 'antitexname': '\bar d', 'line': 'straight', 'charge': -1. / 3., 'pdg_code': 1, 'propagating': True, 'is_part': True, 'self_antipart': False })) d = mypartlist[-1] antid = copy.copy(d) antid.set('is_part', False) # A quark C and its antiparticle mypartlist.append( base_objects.Particle({ 'name': 'c', 'antiname': 'c~', 'spin': 2, 'color': 3, 'mass': 'zero', 'width': 'zero', 'texname': 'u', 'antitexname': '\bar u', 'line': 'straight', 'charge': 2. / 3., 'pdg_code': 4, 'propagating': True, 'is_part': True, 'self_antipart': False })) c = mypartlist[-1] antic = copy.copy(c) antic.set('is_part', False) # electron/positront mypartlist.append( base_objects.Particle({ 'name': 'e-', 'antiname': 'e+', 'spin': 2, 'color': 1, 'mass': 'zero', 'width': 'zero', 'texname': 'u', 'antitexname': '\bar u', 'line': 'straight', 'charge': 1, 'pdg_code': 11, 'propagating': True, 'is_part': True, 'self_antipart': False })) e = mypartlist[-1] antie = copy.copy(e) mu = copy.copy(e) antie.set('is_part', False) mu.set('name', 'mu-') mu.set('antiname', 'mu+') mu.set('pdg_code', 13) mypartlist.append(mu) antimu = copy.copy(mu) antimu.set('is_part', False) # A Z mypartlist.append( base_objects.Particle({ 'name': 'z', 'antiname': 'z', 'spin': 3, 'color': 1, 'mass': 'MZ', 'width': 'WZ', 'texname': 'Z', 'antitexname': 'Z', 'line': 'wavy', 'charge': 0., 'pdg_code': 23, 'propagating': True, 'is_part': True, 'self_antipart': True })) z = mypartlist[-1] # Coupling of Z to quarks myinterlist.append(base_objects.Interaction({ 'id': 1, 'particles': base_objects.ParticleList(\ [antiu, \ u, \ z]), 'color': [color.ColorString([color.T(1,0)])], 'lorentz':['FFV1', 'FFV2'], 'couplings':{(0, 0):'GUZ1', (0, 1):'GUZ2'}, 'orders':{'QED':1}})) myinterlist.append(base_objects.Interaction({ 'id': 2, 'particles': base_objects.ParticleList(\ [antid, \ d, \ z]), 'color': [color.ColorString([color.T(1,0)])], 'lorentz':['FFV1', 'FFV2'], 'couplings':{(0, 0):'GDZ1', (0, 1):'GDZ2'}, 'orders':{'QED':1}})) myinterlist.append(base_objects.Interaction({ 'id': 3, 'particles': base_objects.ParticleList(\ [antic, \ c, \ z]), 'color': [color.ColorString([color.T(1,0)])], 'lorentz':['FFV1', 'FFV2'], 'couplings':{(0, 0):'GUZ1', (0, 1):'GUZ2'}, 'orders':{'QED':1}})) # Coupling of Z to leptons myinterlist.append(base_objects.Interaction({ 'id': 4, 'particles': base_objects.ParticleList(\ [antie, \ e, \ z]), 'color': [color.ColorString()], 'lorentz':['FFV1', 'FFV2'], 'couplings':{(0, 0):'GLZ1', (0, 1):'GLZ2'}, 'orders':{'QED':1}})) # Coupling of Z to leptons myinterlist.append(base_objects.Interaction({ 'id': 5, 'particles': base_objects.ParticleList(\ [antimu, \ mu, \ z]), 'color': [color.ColorString()], 'lorentz':['FFV1', 'FFV2'], 'couplings':{(0, 0):'GLZ1', (0, 1):'GLZ2'}, 'orders':{'QED':1}})) mymodel = base_objects.Model() mymodel.set('particles', mypartlist) mymodel.set('interactions', myinterlist) mymodel.set('name', 'sm') procs = [[1, -1, 23], [2, -2, 23], [4, -4, 23]] decays = [[23, 11, -11], [23, 13, -13]] coreamplitudes = diagram_generation.AmplitudeList() decayamplitudes = diagram_generation.AmplitudeList() decayprocs = base_objects.ProcessList() #Building the basic objects for proc in procs: # Define the multiprocess my_leglist = base_objects.LegList([\ base_objects.Leg({'id': id, 'state': True}) for id in proc]) my_leglist[0].set('state', False) my_leglist[1].set('state', False) my_process = base_objects.Process({ 'legs': my_leglist, 'model': mymodel }) my_amplitude = diagram_generation.Amplitude(my_process) my_amplitude.set('has_mirror_process', True) coreamplitudes.append(my_amplitude) for proc in decays: # Define the multiprocess my_leglist = base_objects.LegList([\ base_objects.Leg({'id': id, 'state': True}) for id in proc]) my_leglist[0].set('state', False) my_process = base_objects.Process({ 'legs': my_leglist, 'model': mymodel, 'is_decay_chain': True }) my_amplitude = diagram_generation.Amplitude(my_process) decayamplitudes.append(my_amplitude) decayprocs.append(my_process) decays = diagram_generation.DecayChainAmplitudeList([\ diagram_generation.DecayChainAmplitude({\ 'amplitudes': decayamplitudes})]) decay_chains = diagram_generation.DecayChainAmplitude({\ 'amplitudes': coreamplitudes, 'decay_chains': decays}) dc_subproc_group = group_subprocs.DecayChainSubProcessGroup.\ group_amplitudes(\ diagram_generation.DecayChainAmplitudeList([decay_chains])) subproc_groups = \ dc_subproc_group.generate_helas_decay_chain_subproc_groups() ###################### ## Make the test!! ## ###################### self.assertEqual(len(subproc_groups), 1) subproc_groups = subproc_groups.split_lepton_grouping() self.assertEqual(len(subproc_groups), 2) # check that indeed for group in subproc_groups: self.assertEqual(len(group['matrix_elements']), 2) has_muon = any( abs(l['id']) == 13 for l in group['matrix_elements'][0] ['processes'][0]['decay_chains'][0]['legs']) for me in group['matrix_elements']: if abs(me['processes'][0]['legs'][0]['id']) == 1: self.assertEqual(len(me['processes']), 1) else: self.assertEqual(len(me['processes']), 2) for proc in me['processes']: for dec in proc['decay_chains']: if has_muon: self.assertFalse( any(abs(l['id']) == 11 for l in dec['legs'])) else: self.assertFalse( any(abs(l['id']) == 13 for l in dec['legs'])) self.assertNotEqual(group['name'], 'qq_z_z_ll') if has_muon: self.assertEqual(group['name'], 'qq_z_z_mummup') else: self.assertEqual(group['name'], 'qq_z_z_emep') group['name']
def legs_to_color_link_string(leg1, leg2): #test written, all cases """given two FKSlegs, returns a dictionary containing: --string: the color link between the two particles, to be appended to the old color string extra minus or 1/2 factor are included as it was done in MadDipole --replacements: a pair of lists containing the replacements of the color indices in the old string to match the link """ #the second-to-last index of the t is the triplet, # the last is the anti-triplet legs = FKSLegList([leg1, leg2]) dict = {} min_index = -3000 iglu = min_index * 2 string = color_algebra.ColorString() replacements = [] if leg1 != leg2: for leg in legs: min_index -= 1 num = leg.get('number') replacements.append([num, min_index]) icol = 1 if not leg.get('state'): icol = -1 if leg.get('color') * icol == 3: string.product( color_algebra.ColorString( [color_algebra.T(iglu, num, min_index)])) string.coeff = string.coeff * (-1) elif leg.get('color') * icol == -3: string.product( color_algebra.ColorString( [color_algebra.T(iglu, min_index, num)])) elif leg.get('color') == 8: string.product( color_algebra.ColorString( init_list=[color_algebra.f(min_index, iglu, num)], is_imaginary=True)) else: icol = 1 if not leg1.get('state'): icol = -1 num = leg1.get('number') replacements.append([num, min_index - 1]) if leg1.get('color') * icol == 3: string = color_algebra.ColorString( [color_algebra.T(iglu, iglu, num, min_index - 1)]) elif leg1.get('color') * icol == -3: string = color_algebra.ColorString( [color_algebra.T(iglu, iglu, min_index - 1, num)]) elif leg1.get('color') == 8: string = color_algebra.ColorString( init_list=[color_algebra.f(min_index - 1, iglu, min_index)], is_imaginary=True) string.product( color_algebra.ColorString( init_list=[color_algebra.f(min_index, iglu, num)], is_imaginary=True)) string.coeff = string.coeff * fractions.Fraction(1, 2) dict['replacements'] = replacements dict['string'] = string return dict
color.ColorString([color.f(-1, 0, 2), color.f(-1, 1, 3)]), color.ColorString([color.f(-1, 0, 3), color.f(-1, 1, 2)]), color.ColorString([color.f(-1, 0, 1), color.f(-1, 2, 3)]) ], 'lorentz': ['L(p1,p2,p3)', 'L(p2,p3,p1)', 'L3'], 'couplings': {(0, 0): 'G^2', (1, 1): 'G^2', (2, 2): 'G^2'}, 'orders': {'QCD': 2} })) # u u~ g interactions.append(base_objects.Interaction({ 'id': 3, 'particles': base_objects.ParticleList([ up, antiup, gluon ]), 'color': [color.ColorString([color.T(2, 0, 1)])], 'lorentz': ['L1'], 'couplings': {(0, 0): 'GQQ'}, 'orders': {'QCD': 1} })) # d d~ g interactions.append(base_objects.Interaction({ 'id': 4, 'particles': base_objects.ParticleList([ down, antidown, gluon ]), 'color': [color.ColorString([color.T(2, 0, 1)])], 'lorentz': ['L1'], 'couplings': {(0, 0): 'GQQ'}, 'orders': {'QCD': 1}
def test_read_interactions(self): """Test the output of import interactions.dat file""" particles_dat_str = """ve ve~ F S ZERO ZERO S ve 12 vm vm~ F S ZERO ZERO S vm 14 vt vt~ F S ZERO ZERO S vt 16 e- e+ F S ZERO ZERO S e 11 m- m+ F S ZERO ZERO S m 13 tt- tt+ F S MTA ZERO S tt 15 u u~ F S ZERO ZERO T u 2 c c~ F S MC ZERO T c 4 t t~ F S MT WT T t 6 d d~ F S ZERO ZERO T d 1 s s~ F S ZERO ZERO T s 3 b b~ F S MB ZERO T b 5 a a V W ZERO ZERO S a 22 z z V W MZ WZ S Z 23 w+ w- V W MW WW S W 24 g g V C ZERO ZERO O G 21 h h S D MH WH S H 25 T1 T1 T D ZERO ZERO O T1 8000002""" interactions_dat_str = """# Interactions associated with Standard_Model w+ w- a MGVX3 QED g g T1 MGVX2 QCD a w+ w- w+ w- MGVX6 DUM0 QED QED n e- ve w- MGVX24 QED e+ ve~ w+ MGVX25 QED u u g MGVX1 QCD u u a MGVX4 QED # And now some bad format entries # which should be ignored with a warning k+ k- a test QED g g test QCD""" fsock_part = StringIO.StringIO(particles_dat_str) fsock_inter = StringIO.StringIO(interactions_dat_str) myparts = import_v4.read_particles_v4(fsock_part) wplus = copy.copy(myparts[14]) wmin = copy.copy(myparts[14]) wmin.set('is_part', False) eminus = copy.copy(myparts[3]) eplus = copy.copy(myparts[3]) eplus.set('is_part', False) enu = copy.copy(myparts[0]) enubar = copy.copy(myparts[0]) enubar.set('is_part', False) photon = copy.copy(myparts[12]) gluon = copy.copy(myparts[15]) t1 = copy.copy(myparts[17]) u = myparts[6] ubar = copy.copy(myparts[6]) ubar.set('is_part', False) my_i_f = color.ColorString([color.f(0, 1, 2)]) my_i_f.is_imaginary = True goal_inter_list = base_objects.InteractionList([ \ base_objects.Interaction( {'id':1, 'particles':base_objects.ParticleList([ wplus, wmin, photon]), 'color':[], 'lorentz':[''], 'couplings':{(0, 0):'MGVX3'}, 'orders':{'QED':1}}), base_objects.Interaction( {'id':2, 'particles':base_objects.ParticleList([ gluon, gluon, t1]), 'color':[my_i_f], 'lorentz':['A'], 'couplings':{(0, 0):'MGVX2'}, 'orders':{'QCD':1}}), base_objects.Interaction( {'id':3, 'particles':base_objects.ParticleList([ wplus, wmin, wplus, wmin]), 'color':[], 'lorentz':['WWVVN'], 'couplings':{(0, 0):'MGVX6'}, 'orders':{'QED':2}}), base_objects.Interaction( {'id':4, 'particles':base_objects.ParticleList([ eplus, enu, wmin]), 'color':[], 'lorentz':[''], 'couplings':{(0, 0):'MGVX24'}, 'orders':{'QED':1}}), base_objects.Interaction( {'id':5, 'particles':base_objects.ParticleList([ eminus, enubar, wplus]), 'color':[], 'lorentz':[''], 'couplings':{(0, 0):'MGVX25'}, 'orders':{'QED':1}}), base_objects.Interaction( {'id':6, 'particles':base_objects.ParticleList([ ubar, u, gluon]), 'color':[color.ColorString(\ [color.T(2, 1, 0)])], 'lorentz':[''], 'couplings':{(0, 0):'MGVX1'}, 'orders':{'QCD':1}}), base_objects.Interaction( {'id':7, 'particles':base_objects.ParticleList([ ubar, u, photon]), 'color':[color.ColorString(\ [color.T(1, 0)])], 'lorentz':[''], 'couplings':{(0, 0):'MGVX4'}, 'orders':{'QED':1}})]) result = import_v4.read_interactions_v4(fsock_inter, myparts) self.assertEqual(len(result), len(goal_inter_list)) for i in range(len(result)): self.assertEqual(result[i], goal_inter_list[i])
def test_sextet_products(self): """Test non trivial product of sextet operators""" # T6[2, 101, 102] T6[2, 102, 103] = (-1 + Nc) (2 + Nc) delta6[101, 103])/Nc my_color_factor = color.ColorFactor([\ color.ColorString([color.T6(2, 101, 102), color.T6(2, 102, 103)])]) col_str1 = color.ColorString([color.T6(101,103)]) col_str1.Nc_power = 1 col_str2 = copy.copy(col_str1) col_str2.Nc_power = 0 col_str3 = copy.copy(col_str1) col_str3.Nc_power = -1 col_str3.coeff = fractions.Fraction(-2, 1) self.assertEqual(my_color_factor.full_simplify(), color.ColorFactor([col_str1, col_str2, col_str3])) # T6[2, 101, 102] T6[3, 102, 101] = 1/2 (2 + Nc) delta8[2, 3] my_color_factor = color.ColorFactor([\ color.ColorString([color.T6(2, 101, 102), color.T6(3, 102, 101)])]) col_str1 = color.ColorString([color.Tr(2,3)]) col_str1.Nc_power = 1 col_str1.coeff = fractions.Fraction(1) col_str2 = copy.copy(col_str1) col_str2.Nc_power = 0 col_str2.coeff = fractions.Fraction(2) self.assertEqual(my_color_factor.full_simplify(), color.ColorFactor([col_str1, col_str2])) # K6[1, 101, 102] T[2, 102, 103] T[2, 103, 104] K6Bar[1, 104, 101] # = 1/4 (-1 + Nc) (1 + Nc)^2 # = 1/4 (-1 - Nc + Nc^2 + Nc^3) my_color_factor = color.ColorFactor([\ color.ColorString([color.K6(1, 101, 102), color.T(2, 102, 103), color.T(2, 103, 104), color.K6Bar(1, 104, 101)])]) col_str1 = color.ColorString() col_str1.Nc_power = 3 col_str1.coeff = fractions.Fraction(1, 4) col_str2 = color.ColorString() col_str2.Nc_power = 2 col_str2.coeff = fractions.Fraction(1, 4) col_str3 = color.ColorString() col_str3.Nc_power = 1 col_str3.coeff = fractions.Fraction(-1, 4) col_str4 = color.ColorString() col_str4.Nc_power = 0 col_str4.coeff = fractions.Fraction(-1, 4) self.assertEqual(my_color_factor.full_simplify(), color.ColorFactor([col_str1, col_str3, col_str2, col_str4])) # T6[2, 101, 102] T6[2, 102, 103] K6[103, 99, 98] K6Bar[101, 98, 99] # = 1/2 (-1 + Nc) (1 + Nc) (2 + Nc) # = 1/2 (Nc^3 + 2 Nc^2 - Nc - 2) my_color_factor = color.ColorFactor([\ color.ColorString([color.T6(2, 101, 102), color.T6(2, 102, 103), color.K6(103,99, 98), color.K6Bar(101, 98, 99)])]) col_str1 = color.ColorString() col_str1.Nc_power = 3 col_str1.coeff = fractions.Fraction(1, 2) col_str2 = color.ColorString() col_str2.Nc_power = 2 col_str2.coeff = fractions.Fraction(1, 1) col_str3 = color.ColorString() col_str3.Nc_power = 1 col_str3.coeff = fractions.Fraction(-1, 2) col_str4 = color.ColorString() col_str4.Nc_power = 0 col_str4.coeff = fractions.Fraction(-1, 1) self.assertEqual(my_color_factor.full_simplify(), color.ColorFactor([col_str2, col_str1, col_str3, col_str4])) # K6[103, 99, 98] T[80, 98, 100] K6Bar[103, 100, 97] T[80, 99, 97] # = -(1/4) + Nc^2/4 my_color_factor = color.ColorFactor([\ color.ColorString([color.K6(103, 99, 98), color.T(80, 98, 100), color.K6Bar(103, 100, 97), color.T(80, 99, 97)])]) col_str1 = color.ColorString() col_str1.Nc_power = 2 col_str1.coeff = fractions.Fraction(1, 4) col_str2 = color.ColorString() col_str2.Nc_power = 0 col_str2.coeff = fractions.Fraction(-1, 4) self.assertEqual(my_color_factor.full_simplify(), color.ColorFactor([col_str1, col_str2]))
def test_colorize_uux_ggg(self): """Test the colorize function for uu~ > ggg""" myleglist = base_objects.LegList() myleglist.append(base_objects.Leg({'id': 2, 'state': False})) myleglist.append(base_objects.Leg({'id': -2, 'state': False})) myleglist.extend([base_objects.Leg({'id': 21, 'state': True})] * 3) myprocess = base_objects.Process({ 'legs': myleglist, 'model': self.mymodel }) myamplitude = diagram_generation.Amplitude() myamplitude.set('process', myprocess) myamplitude.generate_diagrams() my_col_basis = color_amp.ColorBasis() # First diagram with two 3-gluon vertices col_dict = my_col_basis.colorize(myamplitude['diagrams'][0], self.mymodel) goal_dict = { (0, 0, 0): color.ColorString([ color.T(-1000, 2, 1), color.f(-1001, 3, 4), color.f(-1000, -1001, 5) ]) } self.assertEqual(col_dict, goal_dict) # Diagram with one 4-gluon vertex col_dict = my_col_basis.colorize(myamplitude['diagrams'][3], self.mymodel) goal_dict = { (0, 0): color.ColorString([ color.T(-1000, 2, 1), color.f(-1001, 3, 5), color.f(-1001, 4, -1000) ]), (0, 1): color.ColorString([ color.T(-1000, 2, 1), color.f(-1002, 3, -1000), color.f(-1002, 4, 5) ]), (0, 2): color.ColorString([ color.T(-1000, 2, 1), color.f(-1003, 3, 4), color.f(-1003, 5, -1000) ]) } self.assertEqual(col_dict, goal_dict)
def setUp(self): # Set up model mypartlist = base_objects.ParticleList() myinterlist = base_objects.InteractionList() # u and c quarkd and their antiparticles mypartlist.append( base_objects.Particle({ 'name': 'u', 'antiname': 'u~', 'spin': 2, 'color': 3, 'mass': 'ZERO', 'width': 'ZERO', 'texname': 'u', 'antitexname': '\bar u', 'line': 'straight', 'charge': 2. / 3., 'pdg_code': 2, 'propagating': True, 'is_part': True, 'self_antipart': False })) u = mypartlist[len(mypartlist) - 1] antiu = copy.copy(u) antiu.set('is_part', False) mypartlist.append( base_objects.Particle({ 'name': 'c', 'antiname': 'c~', 'spin': 2, 'color': 3, 'mass': 'MC', 'width': 'ZERO', 'texname': 'c', 'antitexname': '\bar c', 'line': 'straight', 'charge': 2. / 3., 'pdg_code': 4, 'propagating': True, 'is_part': True, 'self_antipart': False })) c = mypartlist[len(mypartlist) - 1] antic = copy.copy(c) antic.set('is_part', False) # A gluon mypartlist.append( base_objects.Particle({ 'name': 'g', 'antiname': 'g', 'spin': 3, 'color': 8, 'mass': 'ZERO', 'width': 'ZERO', 'texname': 'g', 'antitexname': 'g', 'line': 'curly', 'charge': 0., 'pdg_code': 21, 'propagating': True, 'is_part': True, 'self_antipart': True })) g = mypartlist[len(mypartlist) - 1] # A photon mypartlist.append( base_objects.Particle({ 'name': 'Z', 'antiname': 'Z', 'spin': 3, 'color': 1, 'mass': 'MZ', 'width': 'WZ', 'texname': 'Z', 'antitexname': 'Z', 'line': 'wavy', 'charge': 0., 'pdg_code': 23, 'propagating': True, 'is_part': True, 'self_antipart': True })) z = mypartlist[len(mypartlist) - 1] # Gluon couplings to quarks myinterlist.append(base_objects.Interaction({ 'id': 1, 'particles': base_objects.ParticleList(\ [antiu, \ u, \ g]), 'color': [color.ColorString([color.T(2, 1, 0)])], 'lorentz':['FFV1'], 'couplings':{(0, 0):'GC_10'}, 'orders':{'QCD':1}})) # Gamma couplings to quarks myinterlist.append(base_objects.Interaction({ 'id': 2, 'particles': base_objects.ParticleList(\ [antiu, \ u, \ z]), 'color': [color.ColorString([color.T(1, 0)])], 'lorentz':['FFV2', 'FFV5'], 'couplings':{(0,0): 'GC_35', (0,1): 'GC_47'}, 'orders':{'QED':1}})) self.mymodel.set('particles', mypartlist) self.mymodel.set('interactions', myinterlist) self.mymodel.set('name', 'sm') self.mypythonmodel = helas_call_writers.PythonUFOHelasCallWriter( self.mymodel) myleglist = base_objects.LegList() myleglist.append(base_objects.Leg({'id': 2, 'state': False})) myleglist.append(base_objects.Leg({'id': -2, 'state': False})) myleglist.append(base_objects.Leg({'id': 2, 'state': True})) myleglist.append(base_objects.Leg({'id': -2, 'state': True})) myproc = base_objects.Process({ 'legs': myleglist, 'model': self.mymodel }) myamplitude = diagram_generation.Amplitude({'process': myproc}) self.mymatrixelement = helas_objects.HelasMultiProcess(myamplitude) myleglist = base_objects.LegList() myleglist.append( base_objects.Leg({ 'id': 4, 'state': False, 'number': 1 })) myleglist.append( base_objects.Leg({ 'id': -4, 'state': False, 'number': 2 })) myleglist.append( base_objects.Leg({ 'id': 4, 'state': True, 'number': 3 })) myleglist.append( base_objects.Leg({ 'id': -4, 'state': True, 'number': 4 })) myproc = base_objects.Process({ 'legs': myleglist, 'model': self.mymodel }) self.mymatrixelement.get('matrix_elements')[0].\ get('processes').append(myproc) self.exporter = export_python.ProcessExporterPython(\ self.mymatrixelement, self.mypythonmodel)
def test_color_flow_string(self): """Test the color flow decomposition of various color strings""" # qq~>qq~ my_cs = color.ColorString([color.T(-1000, 1, 2), color.T(-1000, 3, 4)]) goal_cs = color.ColorString([color.T(1, 4), color.T(3, 2)]) goal_cs.coeff = fractions.Fraction(1, 2) self.assertEqual(color_amp.ColorBasis.get_color_flow_string(my_cs, []), goal_cs) # qq~>qq~g my_cs = color.ColorString( [color.T(-1000, 1, 2), color.T(-1000, 3, 4), color.T(5, 4, 6)]) goal_cs = color.ColorString( [color.T(1, 2005), color.T(3, 2), color.T(1005, 6)]) goal_cs.coeff = fractions.Fraction(1, 4) self.assertEqual( color_amp.ColorBasis.get_color_flow_string(my_cs, [(8, 5, 1005, 2005)]), goal_cs) # gg>gg my_cs = color.ColorString( [color.Tr(-1000, 1, 2), color.Tr(-1000, 3, 4)]) goal_cs = color.ColorString([ color.T(1001, 2002), color.T(1002, 2003), color.T(1003, 2004), color.T(1004, 2001) ]) goal_cs.coeff = fractions.Fraction(1, 32) self.assertEqual( color_amp.ColorBasis.get_color_flow_string(my_cs, [(8, 1, 1001, 2001), (8, 2, 1002, 2002), (8, 3, 1003, 2003), (8, 4, 1004, 2004)]), goal_cs)
def read_interactions_v4(fsock, ref_part_list): """Read a list of interactions from stream fsock, using the old v4 format. Requires a ParticleList object as an input to recognize particle names.""" logger.info('load interactions') myinterlist = InteractionList() if not isinstance(ref_part_list, ParticleList): raise ValueError, \ "Object %s is not a valid ParticleList" % repr(ref_part_list) for line in fsock: myinter = Interaction() line = line.split("#", 2)[0] # remove any comment line = line.strip() # makes the string clean if line != "": # skip blank values = line.split() part_list = ParticleList() try: for str_name in values: curr_part = ref_part_list.get_copy(str_name.lower()) if isinstance(curr_part, Particle): # Look at the total number of strings, stop if # anyway not enough, required if a variable name # corresponds to a particle! (eg G) if len(values) >= 2 * len(part_list) + 1: part_list.append(curr_part) else: break # also stops if string does not correspond to # a particle name else: break if len(part_list) < 3: raise Interaction.PhysicsObjectError, \ "Vertex with less than 3 known particles found." # Flip part/antipart of first part for FFV, FFS, FFT vertices # according to v4 convention spin_array = [part['spin'] for part in part_list] if spin_array[:2] == [2, 2] and \ not part_list[0].get('self_antipart'): part_list[0]['is_part'] = not part_list[0]['is_part'] myinter.set('particles', part_list) # Give color structure # Order particles according to color # Don't consider singlets color_parts = sorted(enumerate(part_list), lambda p1, p2:\ p1[1].get_color() - p2[1].get_color()) color_ind = [(i, part.get_color()) for i, part in \ color_parts if part.get_color() !=1] colors = [c for i, c in color_ind] ind = [i for i, c in color_ind] # Set color empty by default myinter.set('color', []) if not colors: # All color singlets - set empty pass elif colors == [-3, 3]: # triplet-triplet-singlet coupling myinter.set('color', [color.ColorString(\ [color.T(ind[1], ind[0])])]) elif colors == [8, 8]: # octet-octet-singlet coupling my_cs = color.ColorString(\ [color.Tr(ind[0], ind[1])]) my_cs.coeff = fractions.Fraction(2) myinter.set('color', [my_cs]) elif colors == [-3, 3, 8]: # triplet-triplet-octet coupling myinter.set('color', [color.ColorString(\ [color.T(ind[2], ind[1], ind[0])])]) elif colors == [8, 8, 8]: # Triple glue coupling my_color_string = color.ColorString(\ [color.f(ind[0], ind[1], ind[2])]) my_color_string.is_imaginary = True myinter.set('color', [my_color_string]) elif colors == [-3, 3, 8, 8]: my_cs1 = color.ColorString(\ [color.T(ind[2], ind[3], ind[1], ind[0])]) my_cs2 = color.ColorString(\ [color.T(ind[3], ind[2], ind[1], ind[0])]) myinter.set('color', [my_cs1, my_cs2]) elif colors == [8, 8, 8, 8]: # 4-glue coupling cs1 = color.ColorString( [color.f(0, 1, -1), color.f(2, 3, -1)]) #cs1.coeff = fractions.Fraction(-1) cs2 = color.ColorString( [color.f(2, 0, -1), color.f(1, 3, -1)]) #cs2.coeff = fractions.Fraction(-1) cs3 = color.ColorString( [color.f(1, 2, -1), color.f(0, 3, -1)]) #cs3.coeff = fractions.Fraction(-1) myinter.set('color', [cs1, cs2, cs3]) # The following line are expected to be correct but not physical validations # have been performed. So we keep it commented for the moment. # elif colors == [3, 3, 3]: # my_color_string = color.ColorString(\ # [color.Epsilon(ind[0], ind[1], ind[2])]) # myinter.set('color', [my_color_string]) # elif colors == [-3, -3, -3]: # my_color_string = color.ColorString(\ # [color.EpsilonBar(ind[0], ind[1], ind[2])]) # myinter.set('color', [my_color_string]) else: logger.warning(\ "Color combination %s not yet implemented." % \ repr(colors)) # Set the Lorentz structure. Default for 3-particle # vertices is empty string, for 4-particle pair of # empty strings myinter.set('lorentz', ['']) pdg_codes = sorted([part.get_pdg_code() for part in part_list]) # WWWW and WWVV if pdg_codes == [-24, -24, 24, 24]: myinter.set('lorentz', ['WWWW']) elif spin_array == [3, 3, 3, 3] and \ 24 in pdg_codes and - 24 in pdg_codes: myinter.set('lorentz', ['WWVV']) # gggg if pdg_codes == [21, 21, 21, 21]: myinter.set('lorentz', ['gggg1', 'gggg2', 'gggg3']) # go-go-g # Using the special fvigox routine provides the minus # sign necessary for octet Majorana-vector interactions if spin_array == [2, 2, 3] and colors == [8, 8, 8] and \ part_list[0].get('self_antipart') and \ part_list[1].get('self_antipart'): myinter.set('lorentz', ['go']) # If extra flag, add this to Lorentz if len(values) > 3 * len(part_list) - 4: myinter.get('lorentz')[0] = \ myinter.get('lorentz')[0]\ + values[3 * len(part_list) - 4].upper() # Use the other strings to fill variable names and tags # Couplings: special treatment for 4-vertices, where MG4 used # two couplings, while MG5 only uses one (with the exception # of the 4g vertex, which needs special treatment) # DUM0 and DUM1 are used as placeholders by FR, corresponds to 1 if len(part_list) == 3 or \ values[len(part_list) + 1] in ['DUM', 'DUM0', 'DUM1']: # We can just use the first coupling, since the second # is a dummy myinter.set('couplings', {(0, 0): values[len(part_list)]}) if myinter.get('lorentz')[0] == 'WWWWN': # Should only use one Helas amplitude for electroweak # 4-vector vertices with FR. I choose W3W3NX. myinter.set('lorentz', ['WWVVN']) elif values[len(part_list)] in ['DUM', 'DUM0', 'DUM1']: # We can just use the second coupling, since the first # is a dummy myinter.set('couplings', {(0, 0): values[len(part_list) + 1]}) elif pdg_codes == [21, 21, 21, 21]: # gggg myinter.set( 'couplings', { (0, 0): values[len(part_list)], (1, 1): values[len(part_list)], (2, 2): values[len(part_list)] }) elif myinter.get('lorentz')[0] == 'WWWW': # Need special treatment of v4 SM WWWW couplings since # MG5 can only have one coupling per Lorentz structure myinter.set('couplings', {(0, 0):\ 'sqrt(' + values[len(part_list)] + \ '**2+' + \ values[len(part_list) + 1] + \ '**2)'}) else: #if myinter.get('lorentz')[0] == 'WWVV': # Need special treatment of v4 SM WWVV couplings since # MG5 can only have one coupling per Lorentz structure myinter.set('couplings', {(0, 0):values[len(part_list)] + \ '*' + \ values[len(part_list) + 1]}) #raise Interaction.PhysicsObjectError, \ # "Only FR-style 4-vertices implemented." # SPECIAL TREATMENT OF COLOR # g g sq sq (two different color structures, same Lorentz) if spin_array == [3, 3, 1, 1] and colors == [-3, 3, 8, 8]: myinter.set( 'couplings', { (0, 0): values[len(part_list)], (1, 0): values[len(part_list)] }) # Coupling orders - needs to be fixed order_list = values[2 * len(part_list) - 2: \ 3 * len(part_list) - 4] def count_duplicates_in_list(dupedlist): """return a dictionary with key the element of dupeList and with value the number of times that they are in this list""" unique_set = set(item for item in dupedlist) ret_dict = {} for item in unique_set: ret_dict[item] = dupedlist.count(item) return ret_dict myinter.set('orders', count_duplicates_in_list(order_list)) myinter.set('id', len(myinterlist) + 1) myinterlist.append(myinter) except Interaction.PhysicsObjectError, why: logger.error("Interaction ignored: %s" % why)
def setUp(self): # A gluon self.mypartlist.append( base_objects.Particle({ 'name': 'g', 'antiname': 'g', 'spin': 3, 'color': 8, 'mass': 'zero', 'width': 'zero', 'texname': 'g', 'antitexname': 'g', 'line': 'curly', 'charge': 0., 'pdg_code': 21, 'propagating': True, 'is_part': True, 'self_antipart': True })) # A quark U and its antiparticle self.mypartlist.append( base_objects.Particle({ 'name': 'u', 'antiname': 'u~', 'spin': 2, 'color': 3, 'mass': 'zero', 'width': 'zero', 'texname': 'u', 'antitexname': '\bar u', 'line': 'straight', 'charge': 2. / 3., 'pdg_code': 2, 'propagating': True, 'is_part': True, 'self_antipart': False })) antiu = copy.copy(self.mypartlist[1]) antiu.set('is_part', False) # A quark D and its antiparticle self.mypartlist.append( base_objects.Particle({ 'name': 'd', 'antiname': 'd~', 'spin': 2, 'color': 3, 'mass': 'zero', 'width': 'zero', 'texname': 'u', 'antitexname': '\bar u', 'line': 'straight', 'charge': -1. / 3., 'pdg_code': 1, 'propagating': True, 'is_part': True, 'self_antipart': False })) antid = copy.copy(self.mypartlist[2]) antid.set('is_part', False) # 3 gluon vertiex self.myinterlist.append(base_objects.Interaction({ 'id': 1, 'particles': base_objects.ParticleList(\ [self.mypartlist[0]] * 3), 'color': [color.ColorString([color.f(0, 1, 2)])], 'lorentz':['L1'], 'couplings':{(0, 0):'G'}, 'orders':{'QCD':1}})) # 4 gluon vertex self.myinterlist.append(base_objects.Interaction({ 'id': 2, 'particles': base_objects.ParticleList(\ [self.mypartlist[0]] * 4), 'color': [color.ColorString([color.f(-1, 0, 2), color.f(-1, 1, 3)]), color.ColorString([color.f(-1, 0, 3), color.f(-1, 1, 2)]), color.ColorString([color.f(-1, 0, 1), color.f(-1, 2, 3)])], 'lorentz':['L(p1,p2,p3)', 'L(p2,p3,p1)', 'L3'], 'couplings':{(0, 0):'G^2', (1, 1):'G^2', (2, 2):'G^2'}, 'orders':{'QCD':2}})) # Gluon couplings to up and down quarks self.myinterlist.append(base_objects.Interaction({ 'id': 3, 'particles': base_objects.ParticleList(\ [self.mypartlist[1], \ antiu, \ self.mypartlist[0]]), 'color': [color.ColorString([color.T(2, 0, 1)])], 'lorentz':['L1'], 'couplings':{(0, 0):'GQQ'}, 'orders':{'QCD':1}})) self.myinterlist.append(base_objects.Interaction({ 'id': 4, 'particles': base_objects.ParticleList(\ [self.mypartlist[2], \ antid, \ self.mypartlist[0]]), 'color': [color.ColorString([color.T(2, 0, 1)])], 'lorentz':['L1'], 'couplings':{(0, 0):'GQQ'}, 'orders':{'QCD':1}})) self.mymodel.set('particles', self.mypartlist) self.mymodel.set('interactions', self.myinterlist)