Esempio n. 1
0
    def colorize(self, diagram, model):
        """Takes a diagram and a model and outputs a dictionary with keys being
        color coefficient index tuples and values a color string (before 
        simplification)."""

        # The smallest value used to create new summed indices
        min_index = -1000
        # The dictionary to be output
        res_dict = {}
        # The dictionary for book keeping of replaced indices
        repl_dict = {}

        for i, vertex in enumerate(diagram.get('vertices')):
            min_index, res_dict = self.add_vertex(vertex, diagram, model,
                                                  repl_dict, res_dict,
                                                  min_index)

        # if the process has no QCD particles
        # Return a list filled with ColorOne if all entries are empty ColorString()
        empty_colorstring = color_algebra.ColorString()
        if all(cs == empty_colorstring for cs in res_dict.values()):
            res_dict = dict(
                (key, color_algebra.ColorString([color_algebra.ColorOne()]))
                for key in res_dict)

        return res_dict
Esempio n. 2
0
    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 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)])]))
Esempio n. 4
0
    def create_new_entry(self, struct1, struct2, Nc_power_min, Nc_power_max,
                         Nc):
        """ Create a new product result, and result with fixed Nc for two color
        basis entries. Implement Nc power limits."""

        # Create color string objects corresponding to color basis
        # keys
        col_str = color_algebra.ColorString()
        col_str.from_immutable(struct1)

        col_str2 = color_algebra.ColorString()
        col_str2.from_immutable(struct2)

        # Complex conjugate the second one and multiply the two
        col_str.product(col_str2.complex_conjugate())

        # Create a color factor to store the result and simplify it
        # taking into account the limit on Nc
        col_fact = color_algebra.ColorFactor([col_str])
        result = col_fact.full_simplify()

        # Keep only terms with Nc_max >= Nc power >= Nc_min
        if Nc_power_min is not None:
            result[:] = [col_str for col_str in result \
                         if col_str.Nc_power >= Nc_power_min]
        if Nc_power_max is not None:
            result[:] = [col_str for col_str in result \
                         if col_str.Nc_power <= Nc_power_max]

        # Calculate the fixed Nc representation
        result_fixed_Nc = result.set_Nc(Nc)

        return result, result_fixed_Nc
Esempio n. 5
0
    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)
Esempio n. 6
0
    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_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_delta6_simplify(self):
        """Test delta6 simplify"""

        # delta6(i,i) = 1
        col_str1 = color.ColorString()
        col_str1.Nc_power = 2
        col_str1.coeff = fractions.Fraction(1, 2)
        col_str2 = color.ColorString()
        col_str2.Nc_power = 1
        col_str2.coeff = fractions.Fraction(1, 2)
        self.assertEqual(color.T6(1, 1).simplify(),
                         color.ColorFactor([col_str1, col_str2]))
Esempio n. 9
0
    def test_f_d_sum(self):
        """Test f and d sum with the right weights giving a Tr"""

        col_str1 = color.ColorString([color.d(1, 2, 3)])
        col_str1.coeff = fractions.Fraction(1, 4)
        col_str2 = color.ColorString([color.f(1, 2, 3)])
        col_str2.coeff = fractions.Fraction(1, 4)
        col_str2.is_imaginary = True

        my_color_factor = color.ColorFactor([col_str1, col_str2])

        self.assertEqual(str(my_color_factor.full_simplify()), '(1 Tr(1,2,3))')
Esempio n. 10
0
    def test_color_string_canonical(self):
        """Test the canonical representation of a immutable color string"""

        immutable1 = (('f', (2, 3, 4)), ('T', (4, 2, 5)))
        immutable2 = (('T', (3, 5)),)

        self.assertEqual(color.ColorString().to_canonical(immutable1 + \
                                                               immutable2)[0],
                         (('T', (2, 4)), ('T', (3, 1, 4)), ('f', (1, 2, 3))))

        self.assertEqual(color.ColorString().to_canonical(immutable1 + \
                                                               immutable2)[1],
                         {3:2, 5:4, 4:3, 2:1})
Esempio n. 11
0
    def test_d_object(self):
        """Test the d color object"""
        # T should have exactly 3 indices!
        self.assertRaises(AssertionError, color.d, 1, 2)

        # Simplify should always return the same ColorFactor
        my_d = color.d(1, 2, 3)
        col_str1 = color.ColorString([color.Tr(1, 2, 3)])
        col_str2 = color.ColorString([color.Tr(3, 2, 1)])
        col_str1.coeff = fractions.Fraction(2, 1)
        col_str2.coeff = fractions.Fraction(2, 1)

        self.assertEqual(my_d.simplify(),
                         color.ColorFactor([col_str1, col_str2]))
Esempio n. 12
0
    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]))
Esempio n. 13
0
    def get_color_matrix_lines(self, matrix_element):
        """Return the color matrix definition lines for this matrix element. 
        Split rows in chunks of size n."""

        ncolor = str(len(matrix_element.get_color_amplitudes()))

        if not matrix_element.get('color_matrix'):
            
            return "static const double denom[1] = {1.};\nstatic const double cf[1][1] = {1.};"
        
        else:
            
            # First define denominator array
            color_denominators = matrix_element.get('color_matrix').get_line_denominators()
            denom_string = "static const double denom[" + ncolor + "] = {%s};" % \
                           ",".join( [ "%i" % denom for denom in color_denominators ] )

            matrix_strings = []
            my_cs = color.ColorString()
            
            for index, denominator in enumerate(color_denominators):
                # Then write the numerators for the matrix elements
                num_list = matrix_element.get('color_matrix').get_line_numerators(index, denominator)

                matrix_strings.append( "{%s}" % ",".join( [ "%d" % i for i in num_list ] ) )
            
            matrix_string = "static const double cf[" + ncolor + "][" + ncolor + "] = {" + ",".join(matrix_strings) + "};"
            
            return "\n".join([denom_string, matrix_string])
Esempio n. 14
0
    def test_f_d_product(self):
        """Test the fully contracted product of f and d"""

        my_color_factor = color.ColorFactor([\
                    color.ColorString([color.f(1, 2, 3), color.d(1, 2, 3)])])

        self.assertEqual(str(my_color_factor.full_simplify()), '')
Esempio n. 15
0
    def test_f_object(self):
        """Test the f color object"""
        # T should have exactly 3 indices!
        self.assertRaises(AssertionError, color.f, 1, 2, 3, 4)

        # Simplify should always return the same ColorFactor
        my_f = color.f(1, 2, 3)
        col_str1 = color.ColorString([color.Tr(1, 2, 3)])
        col_str2 = color.ColorString([color.Tr(3, 2, 1)])
        col_str1.coeff = fractions.Fraction(-2, 1)
        col_str2.coeff = fractions.Fraction(2, 1)
        col_str1.is_imaginary = True
        col_str2.is_imaginary = True

        self.assertEqual(my_f.simplify(),
                         color.ColorFactor([col_str1, col_str2]))
Esempio n. 16
0
    def test_f_product(self):
        """Test the fully contracted product of two f's"""

        my_color_factor = color.ColorFactor([\
                    color.ColorString([color.f(1, 2, 3), color.f(1, 2, 3)])])

        self.assertEqual(str(my_color_factor.full_simplify()),
                         '(-1 Nc^1 )+(1 Nc^3 )')
Esempio n. 17
0
    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)')
Esempio n. 18
0
    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]))
Esempio n. 19
0
    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]))
Esempio n. 20
0
    def test_Tr_product(self):
        """Test a non trivial product of two traces"""

        my_color_factor = color.ColorFactor([\
                    color.ColorString([color.Tr(1, 2, 3, 4, 5, 6, 7),
                                       color.Tr(1, 7, 6, 5, 4, 3, 2)])])

        self.assertEqual(str(my_color_factor.full_simplify()),
        "(1/128 Nc^7 )+(-7/128 Nc^5 )+(21/128 Nc^3 )+(-35/128 Nc^1 )" + \
        "+(35/128 1/Nc^1 )+(-21/128 1/Nc^3 )+(3/64 1/Nc^5 )")
Esempio n. 21
0
    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))")
Esempio n. 22
0
    def setUp(self):
        """Initialize the ColorString test"""
        # Create a test color string

        test_f = color.f(1, 2, 3)
        test_d = color.d(4, 5, 6)

        self.my_col_string = color.ColorString([test_f, test_d],
                                               coeff=fractions.Fraction(2, 3),
                                               Nc_power= -2,
                                               is_imaginary=True)
Esempio n. 23
0
    def test_Tr_simplify(self):
        """Test simplification of trace objects"""

        # Test Tr(a)=0
        self.assertEqual(
            color.Tr(-1).simplify(),
            color.ColorFactor([color.ColorString(coeff=0)]))

        # Test Tr()=Nc
        col_str = color.ColorString()
        col_str.Nc_power = 1
        self.assertEqual(color.Tr().simplify(), color.ColorFactor([col_str]))

        # Test cyclicity
        col_str = color.ColorString([color.Tr(1, 2, 3, 4, 5)])
        self.assertEqual(
            color.Tr(3, 4, 5, 1, 2).simplify(), color.ColorFactor([col_str]))

        # Tr(a,x,b,x,c) = 1/2(Tr(a,c)Tr(b)-1/Nc Tr(a,b,c))
        col_str1 = color.ColorString([color.Tr(1, 2, 4), color.Tr(3)])
        col_str2 = color.ColorString([color.Tr(1, 2, 3, 4)])
        col_str1.coeff = fractions.Fraction(1, 2)
        col_str2.coeff = fractions.Fraction(-1, 2)
        col_str2.Nc_power = -1
        my_tr = color.Tr(1, 2, 100, 3, 100, 4)
        self.assertEqual(my_tr.simplify(),
                         color.ColorFactor([col_str1, col_str2]))

        my_tr = color.Tr(1, 2, 100, 100, 4)

        col_str1 = color.ColorString([color.Tr(1, 2, 4), color.Tr()])
        col_str2 = color.ColorString([color.Tr(1, 2, 4)])
        col_str1.coeff = fractions.Fraction(1, 2)
        col_str2.coeff = fractions.Fraction(-1, 2)
        col_str2.Nc_power = -1
        self.assertEqual(my_tr.simplify(),
                         color.ColorFactor([col_str1, col_str2]))

        my_tr = color.Tr(100, 100)
        col_str1 = color.ColorString([color.Tr(), color.Tr()])
        col_str2 = color.ColorString([color.Tr()])
        col_str1.coeff = fractions.Fraction(1, 2)
        col_str2.coeff = fractions.Fraction(-1, 2)
        col_str2.Nc_power = -1
        self.assertEqual(my_tr.simplify(),
                         color.ColorFactor([col_str1, col_str2]))
Esempio n. 24
0
    def test_gluons(self):
        """Test simplification of chains of f"""

        my_col_fact = color.ColorFactor([color.ColorString([color.f(-3, 1, 2),
                                    color.f(-1, 3, 4),
                                    color.f(-1, 5, -3)
                                    ])])

        self.assertEqual(str(my_col_fact.full_simplify()),
        '(2 I Tr(1,2,3,4,5))+(-2 I Tr(1,2,5,3,4))+(-2 I Tr(1,2,4,3,5))+' + \
        '(2 I Tr(1,2,5,4,3))+(-2 I Tr(1,3,4,5,2))+(2 I Tr(1,5,3,4,2))+' + \
        '(2 I Tr(1,4,3,5,2))+(-2 I Tr(1,5,4,3,2))')
Esempio n. 25
0
    def test_three_f_chain(self):
        """Test a chain of three f's"""

        my_color_factor = color.ColorFactor([\
                    color.ColorString([color.f(1, 2, -1),
                                       color.f(-1, 3, -2),
                                       color.f(-2, 4, 5)])])

        self.assertEqual(str(my_color_factor.full_simplify()),
        "(2 I Tr(1,2,3,4,5))+(-2 I Tr(1,2,4,5,3))+(-2 I Tr(1,2,3,5,4))" + \
        "+(2 I Tr(1,2,5,4,3))+(-2 I Tr(1,3,4,5,2))+(2 I Tr(1,4,5,3,2))" + \
        "+(2 I Tr(1,3,5,4,2))+(-2 I Tr(1,5,4,3,2))")
Esempio n. 26
0
    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]))
Esempio n. 27
0
    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)')
Esempio n. 28
0
    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]))
Esempio n. 29
0
    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)
Esempio n. 30
0
    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)