We’re putting the final touches on our new badges platform. Badge issuance remains temporarily paused, but all completions are being recorded and will be fulfilled once the platform is live. Thank you for your patience.
General Mechanical

General Mechanical

Topics related to Mechanical Enterprise, Motion, Additive Print and more.

Setting up “number of processors” in Ansys Mechanical

    • Saurabh.Prabhakar
      Subscriber

      Hi All,  I have ANSYS Mechanical setup within ANSYS Workbench. I have written a python script which will be called from ANSYS Workbench to change "number of processors" in ANSYS Mechanical. For some reason, send command function for setting up "number of processors" in ANSYS Mechanical is not working properly. It is not changing the values. When I used the command using Mechanical Editor with ANSYS Mechanical window, commands work properly.  Has anyone come across this issue?  I am using below code to change "number of processors" in ANSYS Mechanical with ANSYS Workbench framework. *********************************************************************************************************************************************

      import os
       
      ###### Open Project #####
      Open(FilePath="/home/test.wbpj")
       
      mech_script_cmds = """
             config = ExtAPI.Application.SolveConfigurations["My Computer"]
             config.SolveProcessSettings.MaxNumberOfCores = 10
             """
       
      system = GetSystem(Name="SYS")
      model = system.GetContainer(ComponentName="Model")
      model.Edit(Interactive=True)
      model.SendCommand(Language="Python", Command=mech_script_cmds)
       
      *************************************************************************************************
      Any help will be appreciated.
       
      ## save project ##
      Save(FilePath="/home/test_f.wbpj", Overwrite=True)

       

       

       

    • SaiD
      Ansys Employee

      Hello,

      When I copied your script and ran it, I got an error related to indentation. So I had to correct the indentation as follows:

      mech_script_cmds = """
      config = ExtAPI.Application.SolveConfigurations["My Computer"]
      config.SolveProcessSettings.MaxNumberOfCores = 8
      """
       
      Once that was fixed, the script ran without any errors. Due to the "Interactive=True" command, Mechanical would open up and show the old number of cores. However, if I closed Mechanical and reopened it by double clicking on the Model cell of the Analysis System in Workbench, it would show up the correct number of cores as set in the script. So this is one workaround.
       
      The other option is to use "Interactive=False". Is there a reason why you need it to be "Interactive=True"? You could simply change it to:
      model.Edit(Interactive=False)
       
      This way the script will get executed without opening Mechanical, it will save a new test_f.wbpj and then if you open Mechanical, it should reflect the correct number of cores.
       
       
    • Erik Kostson
      Ansys Employee

      Hi

       

      See the discuss forum for scripting questions:

      https://discuss.ansys.com/discussion/4402/how-to-control-number-of-cores-used-when-solving-mechanical-system-in-wb-in-batch?utm_source=community-search&utm_medium=organic-search&utm_term=How+to+control+number+of+cores+used+when+solving+Mechanical+system+in+WB+in+batch%3F

       

      All the best

       

      Erik

Viewing 2 reply threads
  • You must be logged in to reply to this topic.