Ansys Products

Ansys Products

Discuss installation & licensing of our Ansys Teaching and Research products.

Run IronScript from slurm

    • Keniel Peart
      Subscriber

      I want to run a script for my simulation on an hpc does anyone know the command below is my current command without the script

       

      ansysedt -ng -batchsolve -distributed -machinelist list=$machines -monitor -batchoptions ${OPT_FILE}  simulation.aedt

    • randyk
      Ansys Employee

      Hi Keniel,

      Please try the following:

      $  export ANSYSEM_FEATURE_SF6694_NON_GRAPHICAL_COMMAND_EXECUTION_ENABLE=1
      $  ansysedt.exe -features=beta -ng -runscriptandexit []


      Please search AEDT help for "
      Running Ansys Electronics Desktop from a Command Line"

      Note - '-ng' and '-runscriptandexit' have been available since 2019R1

      Desktop automation is in terms of COM calls to the various COM objects exposed by desktop. This has always been unconditionally supported in a general-purpose graphical mode (Desktop with a GUI or in Iconic mode without specialized -batchextract etc modes). When desktop is run in non-graphical mode (-ng in the command line), recorded scripts cannot be played back: instead, a select few commands are available via the -batchextract script.

      To ensure general command execution ability, AnsysET enforced the need for a GUI system: the user’s compute environment required a graphics subsystem (X Servers on Linux in particular) to be configured.

      Some commands when run graphically would be somewhat expensive because of the needed User Interface updates and sometimes a user composes a script with hundreds of such expensive calls slowing the execution down noticeably. Forcing the user to run desktop in GUI mode forced the performance penalties as well.

      Non Graphical Command Limitations

      2019 R1 release starts making progress toward allowing all commands to be run non-graphically. commands will be transitioned in phases and some graphical commands like Plot Export will be unavailable initially. If such commands are used, script execution will be terminated with a suitable error message.

      Enabling from the GUI

      Bring up the Options and enable “beta” features. If enabling all beta features is not desired, then the command line will have to be used with the “-features=SF6694_Non_Graphical_Command_execution” parameter.

      Enabling from the Command Line

      Invoke desktop in ng mode for script execution by specifying the beta flag: this allows the existing -runscriptandexit command-line parameter to work in non-graphical mode as well.

      ansysedt.exe -features=beta -ng -runscriptandexit []

      Note: -features=”beta” turns on all beta features. If there is a need to disable all beta features except “non-graphical command execution”, the more specific “-features=SF6694_Non_Graphical_Command_execution” can be used instead.

      Enabling For Workbench Scenarios

      Prior to 19R1, when workbench was run in batch mode (-B command line parameter), several methods of the Electromagnetics Addin are disabled. This saga-feature enables them back and allows all Workebench<->AnsysEDT interaction to occur fully non-graphically. To enable this, you must set the following environment variable.

      ANSYSEM_FEATURE_SF6694_NON_GRAPHICAL_COMMAND_EXECUTION_ENABLE=1

      Enabling for stand-alone scripting scenarios

      For stand-alone scripting scenarios (where the ipy64.exe interpreter is used instead of ansysem.exe to run the script). Refer to online help and search for “Standalone IronPython” for additional details.

      Standalone graphical scripts, have the following preamble.

      import sys

      sys.path.append("")

      sys.path.append("/PythonFiles/DesktopPlugin")

      import ScriptEnv

      ScriptEnv.Initialize("Ansoft.ElectronicsDesktop")

      This is used for the typical graphical AnsysEDT COM server. For, non-graphical com servers, the final ScriptEnv.Initialize is replaced by ScriptEnv.InitializeNew.

      • Note: InitializeNew does not take the COM ProgID since it launches the Exe directly by computing a path relative to the ScriptEnv.py module.
      • Note: InitializeNew specifies that a new instance is to be launched everytime. This helps by not connecting to existing COM server.

      import sys

      sys.path.append("")

      sys.path.append("/PythonFiles/DesktopPlugin")

      import ScriptEnv

      ScriptEnv.InitializeNew( NonGraphical = True)

    • Keniel Peart
      Subscriber

      Hi Randyk 

      Thank you for your response . Below is my slurm file can you please assist in telling me where exactly is appropriate for the export line

      I have highlighted the 3 places i was thinking ... also please find my ironscript attached . Appreciatre you assistance

      #!/bin/bash

      # SLURM job script to run Ansys in parallel on a single node using 4 CPUs

      #SBATCH --job-name      SAR_gpu_script

      #SBATCH --time          60:00:00          # Wall time

      #SBATCH -p gtx1080

      #SBATCH --gres=gpu:1

      #SBATCH --ntasks=40                        # Number of processes

      #SBATCH --nodes=1

      #SBATCH --mail-user=krp1n21@soton.ac.uk

      #SBATCH --mail-type=ALL 

       

      module load ansysewb/23.2

      OPT_FILE=batch_options.txt

      echo "\$begin 'Config' " > ${OPT_FILE}

      #echo "'HFSS/SolveAdaptiveOnly'=O" >>  ${OPT_FILE}

      #echo '"HFSS 3D Layout Design/MPIVendor"="Intel"' >> $OPT_FILE

      #echo '"tempdirectory"="$SCRATCH"' >> $OPT_FILE

      #echo '"Desktop/ProjectDirectory"="$SCRATCH"' >> $OPT_FILE

      #echo "'ANSYSEM_FEATURE_SF6694_NON_GRAPHICAL_COMMAND_EXECUTION_ENABLE'=1" >>  $OPT_FILE 

      #echo '"Send Config"' >> $OPT_FILE

       

      machines=$(srun bash -c 'hostname' | sort | uniq | awk -v ntasks="$SLURM_NTASKS_PER_NODE" '{print $1 ":" ntasks}' | paste -s -d ',')

      #machines=$(srun bash -c 'hostname -s' | sort | uniq | awk '{print $1 ":" 40}' | paste -s -d ':')

      echo $machines

      export ANSYSEM_FEATURE_SF6694_NON_GRAPHICAL_COMMAND_EXECUTION_ENABLE=1

      # Run ansys commands in file plate in batch mode

      #( the -m & -db flags increase the total amount of memory usable by ansys)

       

      ansysedt -features=beta -ng -runscriptandexit SAR_script.py  -batchsolve -distributed -machinelist list=$machines -monitor -batchoptions ${OPT_FILE} "ANSYSEM_FEATURE_SF6694_NON_GRAPHICAL_COMMAND_EXECUTION_ENABLE=1" "EnbleGPU=1" SAR_simulationi.aedt

       

       

    • randyk
      Ansys Employee

      When submitting to SLURM, below is an example - 'srun' should wrap the 'ansysedt' call.

      InstFolder=/opt/AnsysEM/v241/Linux64
      # SLURM envs
      export ANSYSEM_GENERIC_MPI_WRAPPER=${InstFolder}/schedulers/scripts/utils/slurm_srun_wrapper.sh
      export ANSYSEM_COMMON_PREFIX=${InstFolder}/common
      srun_cmd="srun --overcommit --export=ALL  -n 1 -N 1 --cpu-bind=none --mem-per-cpu=0 --overlap "
      # Autocompute total cores from node allocation
      export ANSYSEM_TASKS_PER_NODE="${SLURM_TASKS_PER_NODE}"
      # Submit AEDT Job (SLURM requires 'srun' and tight integration change to the slurm_srun_wrapper.sh 
      ${srun_cmd} ${InstFolder}/ansysedt -ng -monitor -waitforlicense -useelectronicsppe=1 -distributed -machinelist numcores=24 -auto -batchoptions optionsfilename -batchsolve ${AnalysisSetup} ${JobFolder}/${Project} > ${JobFolder}/${JobName}.progress

Viewing 3 reply threads
  • The topic ‘Run IronScript from slurm’ is closed to new replies.