Starting ANSYS Products From the Command Line

imageSometimes you just get tired of clicking on icons.  Sometimes you just need to feel the control and power of launching your applications from the command line.  You type it in, you hit the enter key, and sometimes you can actually hear the disk spin up or the fan run faster to cool the processor as the program you asked for, the program you took time to type out, leaps to life in front of you. Satisfaction.

OK, maybe not.  More often you are scripting some batch solves.  Or maybe you are using the graphical user interface in Workbench but you need to set options for the solvers you are running from within workbench.  Because most of the solvers in the ANSYS family of products predate such new-fangled concepts as GUI’s, and because they are often run remotely on other machines, they have command line interfaces. And that gives the knowledgeable user more power and control.

General Concepts for Launching from the Command Line

Although the number of options available changes from application to applications, there a few common things you should know. 

Paths

The first and most important concept is to be aware of the path.  This is where most errors happen. One of the big changes over the years is that as software gets more complicated, the executable program or script that you use to launch a solver is now buried deep down inside a directory structure.  Since we never run in that actual directory we need to tell the operating system where the executable is. You can do this by including the full directory path in your command line argument, or by adding it to your path. 

On Linux follow the directions in the help:

// Installation and Licensing Documentation // Linux Installation Guide // 5. Post-Installation Instructions

for each of the products you want to run. Generally, you need to set the PATH environmental variable in your .cshrc, .login, or .profile. 

On Windows it is not documented, the assumption being that you will be clicking on icons and not typing into a command window.  So a little detective work is needed. Use a file explorer and the Linux documentation on launching to locate the executable for solvers you want to use:

// Installation and Licensing Documentation // Linux Installation Guide // 5. Post-Installation Instructions // 5.3. Launching ANSYS, Inc. Products

The /ansys_inc part is usually replaced with c:\Program Files\ANSYS Inc.  The rest of the path is pretty much the same, swapping forward slashes with backward slashes.  Use these paths in your command line or add to your path by:

  • From the desktop, right-click My Computer and click Properties.
  • In the System Properties window, click on the Advanced tab.
  • In the Advanced section, click the Environment Variables button.
  • Finally, in the Environment Variables window (as shown below), highlight the Path variable in the Systems Variable section and click the Edit button. Add or modify the path lines with the paths you wish the computer to access. Each different directory is separated with a semicolon as shown below.

    Windows enviromental path settings

    Important note for Windows:  If you are typing the path in on the command line, you need to put it in double quotes.  The convention on Windows is to specify directories with spaces in the name.  But the convention is not to have a command line parser that recognizes this.  So you will get an error if you type:

    C:\Program Files\ANSYS Inc\v140\ansys\bin\winx64\ansys140.exe

    But if you put it in quotes, it works fine:

    "C:\Program Files\ANSYS Inc\v140\ansys\bin\winx64\ansys140.exe"

    Versions Numbering

    If you look at the example for launching MAPDL above you will notice that 140 is used in the directory path and in the name of the executable.  This will change with version:  v130, v145, etc…  Just be aware of that if you are reading this blog posting in 3 years and we are on release 16.5.  you would use:

    "C:\Program Files\ANSYS Inc\v165\ansys\bin\winx64\ansys165.exe"

    Where do you Launch From?

    You of course need a command line to launch a solver.  This is usually a window that lets you type operating system commands: called a Command Prompt in Windows or a shell on Linux.  On Linux it can be an xterm window, a console window, or some other terminal window you have opened. 

    But you can also launch from a script, and that script can be launched from a command prompt or shell, or it can be launched by an icon.  All that needs to happen is that the script needs to be executed with the environmental variables required for the command prompt/script or the GUI.  If you don’t know how to make that happen, contact your IT support or someone who understands your operating system and how it runs processes.

    ANSYS Mechanical APDL

    The solver with the most options and capabilities from the command line is Mechanical APDL. So we will start there.  It is important to know these even if you use Mechanical most of the time.  That is because you can set these, and better control your solves, under Tools->Options->Mechanical APDL.  Here is what that dialog looks like:

    image

    The most common settings have their own widgets,  and the others can all be accessed by using “- string” command line style arguments in the first text widget aptly named: Command Line Options.

    Here are the options, grouped for your studying pleasure:

    Option

    Type

    Description

    -ansexe

    Customization

    In the ANSYS Workbench environment, activates a custom ANSYS executable.

    -custom

    Customization

    Calls a custom ANSYS executable. See help on running custom executables for more

    -acc device

    HPC

    Enables the use of GPU compute accelerator. As this is written, nvidia is the only option. But as other cards become available look for this to have other options. Check the help.

    -dis

    HPC

    Enables Distributed ANSYS. See the Parallel Processing Guide for more information.

    -machines

    HPC

    Specifies the machines on which to run a Distributed ANSYS analysis. See Starting Distributed ANSYS in the Parallel Processing Guide for more information.

    -mpi

    HPC

    Specifies the type of MPI to use. See the Parallel Processing Guide for more information.

    -mpifile

    HPC

    Specifies an existing MPI file (appfile) to be used in a Distributed ANSYS run. See Using MPI appfiles in the Parallel Processing Guide for more information.

    -np value

    HPC

    Specifies the number of processors to use when running Distributed ANSYS or Shared-memory ANSYS.

    -d device

    Interface

    Specifies the type of graphics device. This option applies only to interactive mode. For Linux systems, graphics device choices are X11, X11C, or 3D. For Windows systems, graphics device options are WIN32 or WIN32C, or 3D.

    -g

    Interface

    Launches the ANSYS program with the Graphical User Interface (GUI) on. Linux only. On windows do a /SHOW and /MENU,ON to get the GUI up.

    -l language

    Interface

    Specifies a language file to use other than US English.

    -b [list | nolist]

    Launch

    Activates the ANSYS program in batch mode. The options -b list or -b by itself cause the input listing to be included in the output. The -b nolist option causes the input listing not to be included

    -i inputname

    Launch

    Specifies the name of the file to read input into ANSYS for batch processing. On Linux, the preferred method to indicate an input file is <. Requried with -b option.

    -j Jobname

    Launch

    Specifies the initial jobname, a name assigned to all files generated by the program for a specific model. If you omit the -j option, the jobname is assumed to be file.

    -o outputname

    Launch

    Specifies the name of the file to store the output from a batch execution of ANSYS. On Linux, the preferred method to indicate an output file is >.

    -p productname

    Launch

    Defines which ANSYS product will run during the session (ANSYS Multiphysics, ANSYS Structural, etc.). This is how you pull a different licence from the default. Very handing if you have multiple licenses to choose from.

    -s [read | noread]

    Launch

    Specifies whether the program reads the start140.ans file at start-up. If you omit the -s option, ANSYS reads the start140.ans file in interactive mode and not in batch mode.

    -dir

    Luanch

    Defines the initial working directory. Remember to use double quotes if you have spaces in your directory path name. Using the -dir option overrides the ANSYS140_WORKING_DIRECTORY environment variable.

    -db value

    Memory

    Defines the portion of workspace (memory) to be used as the initial allocation for the database. This and -m are the two most important options. If you ever find that ANSYS is writing a *.PAGE file, up this number.

    -m value

    Memory

    Idefines the total memory to reserve for the program. It is always better to reserve it up front rather than letting ANSYS grab as it needs.

    -schost host name

    MFX

    Specifies the host machine on which the coupling service is running (to which the co-simulation participant/solver must connect) in a System Coupling analysis.

    -scname name of the solver

    MFX

    Specifies the unique name used by the co-simulation participant to identify itself to the coupling service in a System Coupling analysis. For Linux systems, you need to escape the quotes or escape the space to have the name recognized with a space:

    -scport port number

    MFX

    Specifies the port on the host machine upon which the coupling service is listening for connections from co-simulation participants in a System Coupling analysis.

    -mfm

    MFX

    Specifies the master field name in an ANSYS Multi-field solver – MFX analysis. See Starting and Stopping an MFX Analysis in the Coupled-Field Analysis Guide for more information.

    -ser value

    MFX

    Specifies the communication port number between ANSYS and CFX in an MFX analysis.

    -dvt

    Other

    Enables ANSYS DesignXplorer advanced task (add-on).

    -dyn

    Other

    Enables LS-DYNA.

    -v

    Other

    Returns the ANSYS release number, update number, copyright date, customer number, and license manager version number. Does not actually run ANSYS MAPDL.

    -name value

    Params

    Defines ANSYS parameters at program start-up. The parameter name must be at least two characters long. These get passed into ANSYS and are used by any APDL scripts you run.

    The ones that everyone should know about are: –p, –m, –db.  We find that not using these to define what license to use (-p) or to control how memory is pre-allocated (-m, –db) generate the most tech support questions.    The next most important is the –np command. Use this to define more processors if you have HPC licenses.

    Cheating – Use the Launcher

    Sometimes the options can get long and confusing.  So what I do is I use the “ANSYS Mechanical APDL Launcher” and fill in all the forms. then go to tools->View Display Command Line and I can see all the options.

    image

    Here is a a fancy command line that got generated that way:

    "C:\Program Files\ANSYS Inc\v140\ANSYS\bin\winx64\ansys140.exe"  -g -p ane3flds -np 2 -acc nvidia -dir "c:\temp" -j "grgewrt1" -s read -m 5000 -db 1000 -l en-us -lstp1 32 -t -d win32 -custom "/temp/myansys.exe"  

    It runs interactive (-g), uses a multiphysics license (-p ane3flds), grabs two processors (-np 2), uses an NVIDEA GPU (-acc nvidia (I don’t have one…)), runs in my temp directory (-dir), uses a job name of grgewrt1 (-j), reads the start.ans file (-s), grabs 5000mb and 1000mb for memory (-m, –db), uses English, passes in a parameter called lstp1 and sets it to 32 (-), uses the win32 graphics driver (-d) and runs my custom ANSYS executable (-custom).

    I have no idea what –t is.  Some undocumented option I guess…

    ANSYS Workbench

  • ANSYS Workbench also has some command line arguments. not as rich as what is available in MAPDL, but still powerful. It allows you to run Mechanical in Batch or Interactive mode, supply python commands as needed.  The key thing to remember is that the workbench interface is not Mechanical or FLUENT. It is the infrastructure that other programs run on. Scripting in workbench allows you to control material properties, parameters, and how systems are created and executed.

    Here are the options:

    Argument

    Operation

    -B

    Run ANSYS Workbench in batch mode. In this mode, the user interface is not displayed and a console window is opened. The functionality of the console window is the same as the ANSYS Workbench Command Window.

    -R <ANSYS Workbench script file>

    Replay the specified ANSYS Workbench script file on start-up. If specified in conjunction with –B, ANSYS Workbench will start in batch mode, execute the specified script, and shut down at the completion of script execution.

    -I

    Run ANSYS Workbench in interactive mode. This is typically the default, but if specified in conjunction with –B, both the user interface and console window are opened.

    -X

    Run ANSYS Workbench interactively and then exit upon completion of script execution. Typically used in conjunction with –R.

    -F <ANSYS Workbench project file>

    Load the specified ANSYS Workbench project file on start-up.

    -E <command>

    Execute the specified ANSYS Workbench scripting command on start-up. You can issue multiple commands, separated with a semicolon (;), or specify this argument multiple times and the commands will be executed in order.

    The big deal in this list is the –B argument.  This allows you to run workbench, and applications controlled by the project page, in batch mode.  You will usually use the –R argument to specify the Iron Python script you want to run.  In most cases you will often want to throw in a –X to make sure it exists when the script is done. 

    Other ANSYS Products

    Here is where it gets boring.  The other products just don’t have all those options. At least not documented.  So you simply find the executable and run it.  Here is the list for Linux. Use it to find the location on Windows.

    Product

    Command

    Mechanical APDL

    /ansys_inc/v140/ansys/bin/ansys140

    ANSYS Workbench

    /ansys_inc/v140/Framework/bin/<platform>/runwb2

    ANSYS CFX

    /ansys_inc/v140/CFX/bin/cfx5

    ANSYS FLUENT

    /ansys_inc/v140/fluent/bin/fluent

    ANSYS ICEM CFD

    /ansys_inc/v140/icemcfd/<platform>/bin/icemcfd

    ANSYS POLYFLOW

    /ansys_inc/v140/polyflow/bin/polyman

    ANSYS CFD-Post

      /ansys_inc/v140/CFD-Post/bin/cfdpost

    ANSYS Icepak

    /ansys_inc/v140/Icepak/bin/icepak

    ANSYS TurboGrid

      /ansys_inc/v140/TurboGrid/bin/cfxtg

    ANSYS AUTODYN

    /ansys_inc/v140/autodyn/bin/autodyn140

    This entry was posted in The Focus. Bookmark the permalink.
    • saranya

      this helps me to resolve the issue.