Exemplo n.º 1
0
def calcDecayWidthFull(processId):
    '''
		Calculate the decay width to a given process, defined by processFAID in FeynArts input format.
		Calculates the decay width with LoopTools.
	'''
    # Check if the temporary results folder exists (normally at this point, it should not) and if so, delete it
    if os.path.exists("Temp" + os.sep + "Results"):
        delPath = "Temp" + os.sep + "Results"
        rmtree(delPath)
    os.makedirs("Temp" + os.sep + "Results")  # Recreate the results folder

    # Create the result directory
    CommonFunctions.create_dir_if_not_exist("Results")
    CommonFunctions.create_dir_if_not_exist("Results" + os.sep + processId)

    # Get a list of parameter files
    parameterList = os.listdir("Parameters" + os.sep + processId)

    # Modify the parameter names so that they contain the processId as well
    for i in range(0, len(parameterList)):
        parameterList[i] = processId + "PROCESSSEPARATOR" + parameterList[i]

    # Get the number of cores of the system (TODO: hyperthreading issue? Actually slowing down?)
    numberCores = multiprocessing.cpu_count()

    # Calculate all 1PI contributions in parallel
    for _ in multiprocessing.Pool(numberCores).imap_unordered(
            calcDecayWidthLT, parameterList):
        pass

    # Get the list of all results files
    resultsFiles = os.listdir("Temp" + os.sep + "Results")

    # Convert all result files and store them in the correct directory
    resultsFilesComplete = ''
    for i in range(0, len(resultsFiles)):
        # Create the file name
        filename = "Temp" + os.sep + "Results" + os.sep + resultsFiles[i]

        # Replace the newline character in each file with a proper newline
        fileHandler = open(filename, "r")
        convertedFile = ''
        convertedFileToAll = ''
        for line in fileHandler:
            # Convert the literal newlines to actual ones
            convertedFile += line.replace('\\n', '\n')

            # Skip the first line in all other files than the first, since it contains only the key which is already present
            if (i < 1):
                numberOfLinebreaks = len(line.split('\\n'))
                convertedFileToAll += (line.replace(
                    '\\n', '\n', numberOfLinebreaks - 2)).replace('\\n', '')
            else:
                numberOfLinebreaks = len(line.split('\\n'))
                convertedFileToAll += (((line.split('\\n', 1))[1]).replace(
                    '\\n', '\n', numberOfLinebreaks - 3)).replace('\\n', '')
        fileHandler.close()

        # Store the results file in the correct directory
        fileHandler = open(
            "Results" + os.sep + processId + os.sep + resultsFiles[i], "w+")
        fileHandler.write(convertedFile)
        fileHandler.close()

        # Store the content of all files in a single variable
        resultsFilesComplete += convertedFileToAll

    # Save the complete result file
    filenameAddendum = (resultsFiles[i].split('_'))[0] + '_' + (
        resultsFiles[i].split('_'))[1] + '.txt'
    fileHandler = open(
        "Results" + os.sep + processId + os.sep + filenameAddendum, "w+")
    fileHandler.write(resultsFilesComplete)
    fileHandler.close()

    # Remove the temporary files
    delPath = "Temp"
    rmtree(delPath)
Exemplo n.º 2
0
    createFolders = CommonFunctions.queryBoolean(
        "Do you want to create all necessary folders?")
    calcLagrangian = CommonFunctions.queryBoolean(
        "Do you want to calculate the generic 2HDM Lagrangian?")
    calcSelfEnergies = CommonFunctions.queryBoolean(
        "Do you want to calculate the 2HDM Self-Energies?")
    calcTadpoles = CommonFunctions.queryBoolean(
        "Do you want to calculate the 2HDM Tadpoles?")
    calcProcDep = CommonFunctions.queryBoolean(
        "Do you want to calculate the vertex corrections for the process-dependent definition of alpha and beta?"
    )

#Create all folders
if createFolders:
    CommonFunctions.create_dir_if_not_exist(
        "BuildingBlocks"
    )  # Contains all calculated Self-Energies, Generic Counterterms and the 2HDM Lagrangian
    CommonFunctions.create_dir_if_not_exist("BuildingBlocks" + os.sep +
                                            "SelfEnergiesDerivatives")
    CommonFunctions.create_dir_if_not_exist("BuildingBlocks" + os.sep +
                                            "SelfEnergies")
    CommonFunctions.create_dir_if_not_exist("BuildingBlocks" + os.sep +
                                            "SelfEnergies" + os.sep +
                                            "Alternative")
    CommonFunctions.create_dir_if_not_exist("BuildingBlocks" + os.sep +
                                            "SelfEnergies" + os.sep + "Usual")
    CommonFunctions.create_dir_if_not_exist("BuildingBlocks" + os.sep +
                                            "Tadpoles")
    CommonFunctions.create_dir_if_not_exist("BuildingBlocks" + os.sep +
                                            "Lagrangian")
    CommonFunctions.create_dir_if_not_exist("BuildingBlocks" + os.sep +
Exemplo n.º 3
0
        processString = processString[:-1]

        # Get the symmetry factor (two identical outgoing particles: 2!)
        if processQuery[2][0] == processQuery[2][1]:
            symmetryFactor = 2
        else:
            symmetryFactor = 1

        print('\nThe process {0} -> {1} has valid syntax.\n'.format(
            incomingForm, outgoingForm))
        processId = incomingForm + "to" + outgoingForm  # Unique process id in the form AABBtoXXYY
        processToMathematica = incomingFAForm + "to" + outgoingFAForm  # Same process id, but in the input format for FeynArts

        # Create a unique dir for the process
        CommonFunctions.create_dir_if_not_exist("BuildingBlocks" + os.sep +
                                                "Processes" + os.sep +
                                                processId)
        CommonFunctions.create_dir_if_not_exist("BuildingBlocks" + os.sep +
                                                "Processes" + os.sep +
                                                processId + os.sep +
                                                "TreeLevel")
        CommonFunctions.create_dir_if_not_exist("BuildingBlocks" + os.sep +
                                                "Processes" + os.sep +
                                                processId + os.sep +
                                                "VertexCorrections")
        CommonFunctions.create_dir_if_not_exist("BuildingBlocks" + os.sep +
                                                "Processes" + os.sep +
                                                processId + os.sep +
                                                "VertexTadpoles")

        # Print the process information to a text file