How can I extract participation factors of a modal analysis?

Options
Pernelle Marone-Hitz
Pernelle Marone-Hitz Member, Moderator, Employee Posts: 810
First Comment First Anniversary Ansys Employee Solution Developer Community of Practice Member
edited June 2023 in Structures

How can I extract participation factors or ratio of effective mass of a modal analysis through scripting?

Tagged:

Best Answer

  • Pernelle Marone-Hitz
    Pernelle Marone-Hitz Member, Moderator, Employee Posts: 810
    First Comment First Anniversary Ansys Employee Solution Developer Community of Practice Member
    Answer ✓
    Options

    Participation factors and similar results are not exposed in GetResultsData.A workaround is to open and read the solver output file to access the information. The following code will extract the ratio of effective mass to total mass:

        # Read solve.out file and store it line by line
            import os
            FileDir=ExtAPI.DataModel.AnalysisList[0].WorkingDir
            TextFile='solve.out'
            SolveOutLines = [] #Declare an empty list named "lines"
                
            with open(os.path.join(FileDir, TextFile), "r") as in_file:  
                for line in in_file: #For each line of text store in a string variable named "SolveOutLines", and
                    SolveOutLines.append(line)  #add that line to list of lines.
                    
            # Create dictionnaries to store frequencies and participation factors (in fact will store ratio of effective mass to total mass)
            RatioX={}
            RatioY={}
            RatioZ={}
    
            # In SolveOutLines search for participation factors
            for line in range(len(SolveOutLines)):
                if SolveOutLines[line]=='          ***** PARTICIPATION FACTOR CALCULATION *****  X  DIRECTION\n' :
                    LineStart=line+3
                    LineEnd=LineStart+NumberOfModes
                    for i in range(LineStart,LineEnd):
                        temp_list=SolveOutLines[i].split(' ') # split text at ' '
                        temp_list2=[]
                        for j in range(len(temp_list)):
                            if temp_list[j] != '' :
                                temp_list2.append(temp_list[j])
                        RatioX[temp_list2[1]]=temp_list2[7]
                elif SolveOutLines[line]=='          ***** PARTICIPATION FACTOR CALCULATION *****  Y  DIRECTION\n' :
                    LineStart=line+3
                    LineEnd=LineStart+NumberOfModes
                    for i in range(LineStart,LineEnd):
                        temp_list=SolveOutLines[i].split(' ') # split text at ' '
                        temp_list2=[]
                        for j in range(len(temp_list)):
                            if temp_list[j] != '' :
                                temp_list2.append(temp_list[j])
                        RatioY[temp_list2[1]]=temp_list2[7]
                elif SolveOutLines[line]=='          ***** PARTICIPATION FACTOR CALCULATION *****  Z  DIRECTION\n' :
                    LineStart=line+3
                    LineEnd=LineStart+NumberOfModes
                    for i in range(LineStart,LineEnd):
                        temp_list=SolveOutLines[i].split(' ') # split text at ' '
                        temp_list2=[]
                        for j in range(len(temp_list)):
                            if temp_list[j] != '' :
                                temp_list2.append(temp_list[j])
                        RatioZ[temp_list2[1]]=temp_list2[7]
                        
            # Deal with numbers that have ('\n') due to exponent coding
            CorrectX=RatioX.values()
            for i in range(len(CorrectX)):
                temp_str=CorrectX[i].split('\n')
                CorrectX[i]=temp_str[0]
            j=0
            for i in RatioX:
                RatioX[i]=CorrectX[j]
                j=j+1   
            CorrectY=RatioY.values()
            for i in range(len(CorrectY)):
                temp_str=CorrectY[i].split('\n')
                CorrectY[i]=temp_str[0]
            j=0
            for i in RatioY:
                RatioY[i]=CorrectY[j]
                j=j+1
            CorrectZ=RatioZ.values()
            for i in range(len(CorrectZ)):
                temp_str=CorrectZ[i].split('\n')
                CorrectZ[i]=temp_str[0]
            j=0
            for i in RatioZ:
                RatioZ[i]=CorrectZ[j]
                j=j+1
    

Answers