ANSYS

class paransys.ANSYS(exec_loc=None, run_location='C:\\Programacao\\_MinhasBibliotecas\\paransys\\docs_sphinx\\ansys_anl\\', jobname='file', nproc=2, override=False, cleardir=False, add_flags='')

This class creates a couple of script files with some parameters defined here by the user, copy an APDL script file created by the user with the model to be analysed, run everything on ANSYS and get the results from some defined parameters back to Python.

exec_locstr, obligatory

Location of ANSYS executable file.

run_locationstr, optional

ANSYS working directory. Must be a separated directory.

Defaults to ansys_anl inside current directory.

jobnamestr, optional

ANSYS jobname. Defaults to ‘file’.

nprocint, optional

Number of processors. Defaults to 2.

overridebool, optional

Attempts to delete the .lock file at working directory.

It’s useful when ANSYS was interrupted.

Defaults to False

cleardirbool, optional

Delete all the files from ANSYS working directory when call the Run command.

Defaults to False

add_flagsstr, optional

Additional flags to be called with ANSYS.

If it’s an academic version use add_flags=’-aa_r’

Do not use ‘-b -i -o’.

Flags can be found at https://www.sharcnet.ca/Software/Ansys/16.2.3/en-us/help/ans_ope/Hlp_G_OPE3_1.html



Class methods:

ClearAll()

Clear all the properties (not from ANSYS object)

ClearValues()

Clear the values of all variables.

CreateVarIn(name)

Create an INPUT variable.

namestr, obligatory

Variable name.

Do not use spaces in the name!

The same name cannot be used with INPUT and OUTPUT variables.

It’s not case sensitivy, in fact it will be saved in uppercase because of ANSYS.

CreateVarOut(name)

Create an OUTPUT variable.

namestr, obligatory

Variable name.

Do not use spaces in the name!

The same name cannot be used with INPUT and OUTPUT variables.

It’s not case sensitivy, in fact it will be saved in uppercase because of ANSYS.

GetVarOutValues()

Return the values of the Results file from ANSYS for all the OUTPUT variables

Info(act=False)

Turn on/off the return of the commands to Python.

actbool, obligatory

True turn On and False turn Off the return of the commands to Python.

property Length

Return the number of analysis to be executed and the length of INPUT arrays.

Run()

Execute the analysis on ANSYS.

SetLength(length)

Define the number of analysis to be executed and the length of INPUT arrays. Must be set before the variables.

length: int, obligatory

Number of analysis.

SetModel(inputname, extrafiles=[], directory='C:\\Programacao\\_MinhasBibliotecas\\paransys\\docs_sphinx')

Set the input script file to be used and extra files that should be copied together. All this files must be in the same directory set in parameter directory.

inputnamestr, obligatory

Name with extension of the script that will be executed in the analysis. The script must be done in function of the INPUT variables defined here, (as parameters of ANSYS), and must define/calculate ANSYS parameters with the results using the names defined here.

extrafileslist of strings, optional

A list of strings containing extra files (with extension) that are necessary to run the script analys, could be an MODEL with the MESH already generated, for example. An example of extrafiles list is: extrafiles = [‘temps.txt’, ‘model1.ans’, ‘file.db’]

directorystr, optional

If the script is not in the current running Python directory you should place the entire location, if it’s in a subdirectory of current directory you can use ‘/dirname/filename.ext’. Defaults to current running Python directory.

SetVarInValues(name, values)

Set the values of an INPUT variable

namestr, obligatory

Input variable name that will receive the values.

values1D np.array of floats, obligatory

A 1D numpy.array() with the length of this class and the values to be analysed. If the array is not 1D just the first column (0) will be used.