How to set cpu cores when solving by ACT script?

wanghao
wanghao Member Posts: 27
10 Comments Name Dropper
**

Hi
I'm trying to solve an analysis such as explicit dynamics analysis by ACT script like:

# some pre-process scripts

Model.Solve(True)

Is there any way that can set the cpu cores by ACT script?

I noticed Model.Solve() has 2 function signature.

 Solve(self: Model, wait: bool, config: SolveConfiguration)
 |              Run the Solve action.
 |          
 |              wait: Wait or not for the solve to be done.
 |              config: The solve configuration to use. If null, the default.
Solve(self: Model, wait: bool, config: str)
 |              Run the Solve action.
 |          
 |              wait: Wait or not for the solve to be done.
 |              config: The solve configuration to use. Results in a new error message if the input 
 |               solve configuration does not exist. If none is provided, the default is used 
 |               for the solve.

Is there any examples for SolveConfiguration or the solve config struct?

Comments

  • PawelRek
    PawelRek Member Posts: 2
    First Comment
    **

    Hey, in "Scripting in Mechanical Guide" there is a section called "Perform Solution While Specifying Solution Handler and the Number of Cores" which looks like this:

    # Get the existing My Computer, Background solve configuration
    config =  ExtAPI.Application.SolveConfigurations["My Computer, Background"]
    config.SetAsDefault()
    
    for cores in range(8,13):
        config.SolveProcessSettings.MaxNumberOfCores = cores
        Model.Analyses[0].Solution.ClearGeneratedData()
        # pass in True to wait for the solve to complete
        Model.Analyses[0].Solution.Solve(True)
        Model.Analyses[0].Solution.GetResults()
        elapsed_time = Model.Analyses[0].Solution.ElapsedRunTime
        print "%d cores took %d secs" % (cores, elapsed_time)
    

    but it doesn't work (at least when running 23R2 version). ANSYS, please let us, users, know, how to fix this code be able to control number of cores within ACT scripting.