Exemplo n.º 1
0
    def computeBetaFunctions(self):
        loggingInfo("Computing the RGES ...")
        for couplingType, terms in self.toCalculate.items():
            if self.loopDic[couplingType] == 0:
                continue

            loggingInfo("     -> " + couplingType)
            for n in range(self.loopDic[couplingType]):
                loggingInfo("         -> " + str(n + 1) + "-loop")
                print_progress(0,
                               len(terms),
                               prefix=' ' * 8,
                               bar_length=10,
                               printTime=self.times)
                for i, term in enumerate(terms):
                    self.allRGEs[couplingType][n].append(
                        self.RGclasses[couplingType].compute(*term, nLoops=n))
                    print_progress(i + 1,
                                   len(terms),
                                   prefix=' ' * 8,
                                   bar_length=10,
                                   printTime=self.times,
                                   logProgress=True)

        loggingInfo("    ... Done")
Exemplo n.º 2
0
    def expand(self):
        """ Performs a first level of expansion of the Lagrangian. More precisely, replaces
        all the occurences of user-defined quantities with their expression."""
        def isComplex(cType, c, expTerm):
            return (cType in ('QuarticTerms', 'TrilinearTerms', 'ScalarMasses')
                    and c + 'star' not in self.potential[cType] and
                    not (c[-4:] == 'star' and c[:-4] in self.potential[cType])
                    and expTerm.find(I) != set())

        count = 0
        content = ()
        for couplingType, terms in self.potential.items():
            if couplingType in self.translateContent:
                self.dicToFill = self.translateDic(self.RGmodule)[couplingType]
                content = self.translateContent[couplingType]
                self.currentPotentialDic = self.potential[couplingType]
            else:
                continue

            for coupling, term in list(terms.items()):
                TensorObject.globalTensorCount = 1
                parsedTerm = []

                try:
                    expTerm = self.parseExpression(
                        term, expandedTerm=parsedTerm).dic[()]
                except BaseException as e:
                    loggingCritical(
                        f"\nError while expanding the term '{coupling}':")
                    loggingCritical(f" -> {str(e)}")
                    exit()

                self.expandedPotential[couplingType][coupling] = parsedTerm[0]
                self.fullyExpandedPotential[couplingType][coupling] = expTerm

                self.fillTensorDic(coupling, expTerm, content)

                if isComplex(couplingType, coupling, expTerm):
                    self.conjugateScalarTerm(couplingType, coupling, content)
                    count += 1

                count += 1
                print_progress(count,
                               self.model.nCouplings,
                               prefix=' ' * 4,
                               bar_length=20,
                               printTime=self.model.times,
                               logProgress=True)

            # Finally, remove all vanishing elements from dict
            for k, v in list(self.dicToFill.items()):
                if v == 0:
                    self.dicToFill.pop(k)
Exemplo n.º 3
0
    def mapBetaFunctions(self):
        loggingInfo("Re-combining the RGES ...")

        #This is for progress bar
        nTot = 0
        count = 0
        for couplingType, RGlist in self.allRGEs.items():
            nTot += len(
                self.potential[couplingType]) * self.loopDic[couplingType]

        for couplingType, RGloops in self.allRGEs.items():
            mat = self.lagrangianMapping[couplingType]
            for n, RGlist in RGloops.items():
                couplingRGEs = mat * Matrix(RGlist)

                # Take into account the beta-exponent
                expFactor = 1
                if 'Anomalous' not in couplingType:
                    exponent = self.betaExponent(n + 1) - 2 * (n + 1)
                    if exponent != 0:
                        expFactor = Pow(4 * pi, exponent)

                for pos, coupling in enumerate(
                        list(self.potential[couplingType])):
                    try:
                        self.couplingRGEs[couplingType][n][coupling] = expand(
                            couplingRGEs[pos] * expFactor)
                    except BaseException as e:
                        loggingCritical(
                            f"Error expanding term at : {couplingType}, {n}, {pos}"
                        )
                        loggingCritical(e)
                        exit()
                    count += 1
                    print_progress(count,
                                   nTot,
                                   prefix='    ',
                                   bar_length=20,
                                   printTime=self.times)
Exemplo n.º 4
0
    def constructMapping(self, RGmodule):
        loggingInfo("Mapping the model onto the general Lagrangian ...")

        #Gauge couplings mapping, taking into account possible kinetic mixing
        noMix = {}
        mix = {}
        alreadyTaken = set()

        for el in itertools.combinations_with_replacement(
                range(RGmodule.nGi), 2):
            A, B = [RGmodule.gi[i] for i in el]
            c = RGmodule.G_(A, B)
            if c != 0 and c not in alreadyTaken:
                dic = noMix if A == B else mix

                if not self.upper:
                    A, B = B, A

                dic[(A, B)] = len(dic)
                alreadyTaken.add(c)

        newInds = {**noMix, **{k: v + len(noMix) for k, v in mix.items()}}
        gaugeMatrix = zeros(len(newInds))

        def delta(A, B):
            if A == B:
                return 1
            return 0

        def G(A, B):
            if RGmodule.G_(A, B) == 0:
                return 0
            if not self.kinMix or A not in RGmodule.Ugauge or B not in RGmodule.Ugauge:
                return sqrt(RGmodule.G_(A, B)).args[0]

            i, j = RGmodule.Ugauge.index(A), RGmodule.Ugauge.index(B)
            return self.kinMat[i, j]

        for (A, B), X in newInds.items():
            for (C, D), Y in newInds.items():
                gaugeMatrix[X,
                            Y] = G(B, D) * delta(A, C) + G(A, D) * delta(B, C)

        gaugeMatrix = simplify(gaugeMatrix.inv())

        couplingType = 'GaugeCouplings'
        self.potential[couplingType] = {}
        for c in self.gaugeCouplings:
            self.potential[couplingType][c] = 0

        self.lagrangianMapping[couplingType] = gaugeMatrix * self.betaFactor
        self.toCalculate[couplingType] = list(newInds.keys())

        count = 0
        translation = self.translateDic(RGmodule)
        for couplingType in self.potential:
            if couplingType == 'Definitions':
                continue
            if (couplingType in translation
                    and self.potential[couplingType] != {}
                    and translation[couplingType] != {}):
                coeffList = [c for c in self.potential[couplingType].keys()]
                mappingMatrix = SparseMatrix(len(coeffList), len(coeffList), 0)
                dicList = []

                auxDic = {}
                sortFunc = lambda x: (len(set(x[0])),
                                      len(x[1].as_coeff_add()[1]), x[0])

                for key, val in translation[couplingType].items():
                    if key[-1] is True:
                        continue
                    if val not in auxDic:
                        auxDic[val] = key
                    elif sortFunc((key, val)) < sortFunc((auxDic[val], val)):
                        auxDic[val] = key

                rank = 0
                for v, k in auxDic.items():
                    matTry = self.fillMappingMatrix(mappingMatrix, rank,
                                                    coeffList, (k, v))
                    newRank = matTry.rank()
                    if (newRank > rank):
                        mappingMatrix = matTry
                        rank = newRank
                        dicList.append(k)

                        count += 1
                        print_progress(count,
                                       self.nCouplings,
                                       prefix=' ' * 4,
                                       bar_length=20,
                                       printTime=self.times,
                                       logProgress=True)

                    if newRank == len(coeffList):
                        self.lagrangianMapping[couplingType] = Matrix(
                            mappingMatrix).inv() * self.betaFactor
                        break
                else:
                    # The mapping matrix is not invertible
                    ns = mappingMatrix.nullspace()
                    cVec = Matrix([
                        Symbol('O(' + el + ')') for el in coeffList
                    ]).transpose()

                    errorMess = "\n\nError in Lagrangian mapping: matrix of couplings is not invertible. "
                    errorMess += f"The following operators in '{couplingType}' are linearly dependent:\n\n"
                    for vec in ns:
                        errorMess += f"  {(cVec*vec)[0,0]} = 0\n"
                    loggingCritical(errorMess[:-1])
                    exit()

                self.toCalculate[couplingType] = dicList

        # Add vevs and anomalous dimensions by hand (not related to the Lagrangian)
        if self.vevs != {}:
            couplingType = 'Vevs'

            self.potential[couplingType] = {}
            for c in self.vevs:
                self.potential[couplingType][c] = 0
            self.lagrangianMapping[couplingType] = eye(len(
                self.vevs)) * self.betaFactor
            self.toCalculate[couplingType] = list(RGmodule.Vdic.keys())

        if self.fermionAnomalous != {}:
            couplingType = 'FermionAnomalous'

            self.potential[couplingType] = {}
            for c in self.fermionAnomalous:
                self.potential[couplingType][c] = 0
            self.lagrangianMapping[couplingType] = eye(
                len(self.fermionAnomalous))
            self.toCalculate[couplingType] = list(RGmodule.gammaFdic.keys())

        if self.scalarAnomalous != {}:
            couplingType = 'ScalarAnomalous'

            self.potential[couplingType] = {}
            for c in self.scalarAnomalous:
                self.potential[couplingType][c] = 0
            self.lagrangianMapping[couplingType] = eye(
                len(self.scalarAnomalous))
            self.toCalculate[couplingType] = list(RGmodule.gammaSdic.keys())
Exemplo n.º 5
0
    def constructMapping(self, RGmodule):
        loggingInfo("Mapping the model onto the general Lagrangian ...")

        #Gauge couplings mapping, taking into account possible kinetic mixing
        noMix = {}
        mix = {}
        alreadyTaken = set()

        for el in itertools.combinations_with_replacement(
                range(RGmodule.nGi), 2):
            A, B = [RGmodule.gi[i] for i in el]
            c = RGmodule.G_(A, B)
            if c != 0 and c not in alreadyTaken:
                dic = noMix if A == B else mix

                if not self.upper:
                    A, B = B, A

                dic[(A, B)] = len(dic)
                alreadyTaken.add(c)

        newInds = {**noMix, **{k: v + len(noMix) for k, v in mix.items()}}
        gaugeMatrix = zeros(len(newInds))

        def delta(A, B):
            if A == B:
                return 1
            return 0

        def G(A, B):
            if RGmodule.G_(A, B) == 0:
                return 0
            if not self.kinMix or A not in RGmodule.Ugauge or B not in RGmodule.Ugauge:
                return sqrt(RGmodule.G_(A, B)).args[0]

            i, j = RGmodule.Ugauge.index(A), RGmodule.Ugauge.index(B)
            return self.kinMat[i, j]

        for (A, B), X in newInds.items():
            for (C, D), Y in newInds.items():
                gaugeMatrix[X,
                            Y] = G(B, D) * delta(A, C) + G(A, D) * delta(B, C)

        gaugeMatrix = simplify(gaugeMatrix.inv())

        couplingType = 'GaugeCouplings'
        self.potential[couplingType] = {}
        for c in self.gaugeCouplings:
            self.potential[couplingType][c] = 0

        self.lagrangianMapping[couplingType] = gaugeMatrix * self.betaFactor
        self.toCalculate[couplingType] = list(newInds.keys())

        count = 0
        translation = self.translateDic(RGmodule)
        for couplingType in self.potential:
            if couplingType == 'Definitions':
                continue
            if (couplingType in translation
                    and self.potential[couplingType] != {}
                    and translation[couplingType] != {}):
                coeffList = []
                dicList = []
                mappingMatrix = []
                sortedList = []

                coeffList = [c for c in self.potential[couplingType].keys()]

                mappingMatrix = SparseMatrix(len(coeffList), len(coeffList), 0)
                sortedList = sorted(
                    [(key, val)
                     for key, val in translation[couplingType].items()
                     if not (type(key[-1]) == bool and key[-1] == True)],
                    key=lambda x:
                    (len(set(x[0])), len(x[1].as_coeff_add()[1]), x[0]))

                trys = 0
                for el in sortedList:
                    trys += 1
                    matTry = self.fillMappingMatrix(mappingMatrix, coeffList,
                                                    el)
                    if (matTry.rank() > mappingMatrix.rank()):
                        mappingMatrix = matTry
                        dicList.append(el[0])

                        count += 1
                        print_progress(count,
                                       self.nCouplings,
                                       prefix=' ' * 4,
                                       bar_length=20,
                                       printTime=self.times,
                                       logProgress=True)

                    if matTry.rank() == len(coeffList):
                        break

                try:
                    self.lagrangianMapping[couplingType] = Matrix(
                        mappingMatrix).inv() * self.betaFactor
                except:
                    # from sympy import pretty
                    loggingCritical(
                        "\nError in Lagrangian mapping : matrix of couplings is not invertible."
                    )
                    loggingCritical("\tCoupling type : " + couplingType)
                    # loggingCritical("\t\t" + pretty(mappingMatrix).replace("\n", "\n\t\t"))
                    exit()

                self.toCalculate[couplingType] = dicList

        # Add vevs and anomalous dimensions by hand (not related to the Lagrangian)
        if self.vevs != {}:
            couplingType = 'Vevs'

            self.potential[couplingType] = {}
            for c in self.vevs:
                self.potential[couplingType][c] = 0
            self.lagrangianMapping[couplingType] = eye(len(
                self.vevs)) * self.betaFactor
            self.toCalculate[couplingType] = list(RGmodule.Vdic.keys())

        if self.fermionAnomalous != {}:
            couplingType = 'FermionAnomalous'

            self.potential[couplingType] = {}
            for c in self.fermionAnomalous:
                self.potential[couplingType][c] = 0
            self.lagrangianMapping[couplingType] = eye(
                len(self.fermionAnomalous))
            self.toCalculate[couplingType] = list(RGmodule.gammaFdic.keys())

        if self.scalarAnomalous != {}:
            couplingType = 'ScalarAnomalous'

            self.potential[couplingType] = {}
            for c in self.scalarAnomalous:
                self.potential[couplingType][c] = 0
            self.lagrangianMapping[couplingType] = eye(
                len(self.scalarAnomalous))
            self.toCalculate[couplingType] = list(RGmodule.gammaSdic.keys())