Get the solution MAPDL details

M
M Member, Employee Posts: 199
First Comment First Anniversary Ansys Employee Solution Developer Community of Practice Member
edited June 2023 in Structures

I am trying to get the time and memory results out of a solution details.

Does anyone know if this is possible?

Tagged:

Answers

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

    @Bruno Gaudin had created an ACT extension to retrieve the different computed times

  • M
    M Member, Employee Posts: 199
    First Comment First Anniversary Ansys Employee Solution Developer Community of Practice Member

    @Pernelle Marone-Hitz import time is possible for the time (which should match the mapdl time), I am interested in the rest of the data also.

  • M
    M Member, Employee Posts: 199
    First Comment First Anniversary Ansys Employee Solution Developer Community of Practice Member
    Answer ✓

    The script below can be used in a button to set a timer for your analyses.

    # Report Time
    clr.AddReference("Ans.UI.Toolkit.Base")
    clr.AddReference("Ans.UI.Toolkit")
    from Ansys.UI.Toolkit import *
    
    import time
    start = time.time()
    
    for a in Model.Analyses:
        a.Solution.ClearGeneratedData()
    for a in Model.Analyses:
        a.Solve()
        
    totalTime = 0
    totalResultFileSizeInBytes = 0
    totalMemoryInBytes = 0
    
    for SYS in Model.Analyses:
        for SOL in SYS.Children:
            if SOL.Name == 'Solution':
                totalTime = totalTime + SOL.MainThreadCPUTime
                totalResultFileSizeInBytes = totalResultFileSizeInBytes + SOL.ResultFileSize
                totalMemoryInBytes = totalMemoryInBytes + SOL.MemoryUsed
    
    Ptime = str(round((time.time()-start)/60,2))
    Mtime = str(round(totalTime/60,2))
    FileSizeMB = str(round(totalResultFileSizeInBytes/1e6))
    Memory = str(round(totalMemoryInBytes/1e6))
    mess_line1 = 'Clock time: ' + Ptime + ' minutes \n'
    mess_line2 = 'MAPDL time: ' + Mtime + ' minutes \n'
    mess_line3 = 'File size : ' + FileSizeMB + ' MB \n'
    mess_line4 = 'Memory used : ' + Memory + ' MB \n'
    
    MessageBox.Show(mess_line1+mess_line2+mess_line3+mess_line4)
    
  • Chemsdine CHEMAI
    Chemsdine CHEMAI Member, Employee Posts: 201
    First Anniversary Ansys Employee Solution Developer Community of Practice Member 5 Likes
    Answer ✓

    in 2021R1 I got no issue :

    solution=ExtAPI.DataModel.Project.Model.Analyses[0].Solution
    solution.ElapsedRunTime
    solution.MemoryUsed
    solution.ResultFileSize