Mapdl#

Mapdl Class Specific Classes or Attributes#

class ansys.mapdl.core.mapdl._MapdlCore(loglevel='DEBUG', use_vtk=None, log_apdl=None, log_file=False, local=True, print_com=False, **start_parm)#

Contains methods in common between all Mapdl subclasses

Mapdl.add_file_handler(filepath[, append, level])

Add a file handler to the mapdl log.

Mapdl.allow_ignore

Invalid commands will be ignored rather than exceptions

Mapdl.chain_commands

Chain several mapdl commands.

Mapdl.directory

Current MAPDL directory.

Mapdl.get([par, entity, entnum, item1, ...])

Retrieves a value and stores it as a scalar parameter or part of an array parameter.

Mapdl.get_array([entity, entnum, item1, ...])

Uses the *VGET command to Return an array from ANSYS as a Python array.

Mapdl.get_value([entity, entnum, item1, ...])

Runs the MAPDL GET command and returns a Python value.

Mapdl.ignore_errors

Flag to ignore MAPDL errors.

Mapdl.jobname

MAPDL job name.

Mapdl.last_response

Returns the last response from MAPDL.

Mapdl.load_table(name, array[, var1, var2, ...])

Load a table from Python to MAPDL.

Mapdl.mesh

Mesh information.

Mapdl.modal_analysis([method, nmode, freqb, ...])

Run a modal with basic settings analysis

Mapdl.non_interactive

Non-interactive context manager.

Mapdl.open_apdl_log(filename[, mode])

Start writing all APDL commands to an MAPDL input file.

Mapdl.open_gui([include_result, inplace])

Save the existing database and open it up in the MAPDL GUI.

Mapdl.parameters

Collection of MAPDL parameters.

Mapdl.result

Binary interface to the result file using pyansys.Result

Mapdl.run(command[, write_to_log, mute])

Run single APDL command.

Mapdl.run_multiline(commands)

Run several commands as a single block

Mapdl.input_strings(commands)

Run several commands as a single block.

Mapdl.set_log_level(loglevel)

Sets log level

Mapdl.version

MAPDL build version.

Constants#

plotting.ALLOWED_TARGETS

Built-in mutable sequence.

plotting.BCS

Built-in mutable sequence.

Latest 2021R1 and newer features#

class ansys.mapdl.core.mapdl_grpc.MapdlGrpc(ip=None, port=None, timeout=15, loglevel='WARNING', log_file=False, cleanup_on_exit=False, log_apdl=None, set_no_abort=True, remove_temp_files=False, print_com=False, channel=None, remote_instance=None, **start_parm)#

This class connects to a GRPC MAPDL server and allows commands to be passed to a persistent session.

Parameters:
ipstr, optional

IP address to connect to the server. Defaults to ‘localhost’.

portint, optional

Port to connect to the mapdl server. Defaults to 50052.

timeoutfloat

Maximum allowable time to connect to the MAPDL server.

loglevelstr, optional

Sets which messages are printed to the console. Default ‘INFO’ prints out all ANSYS messages, ‘WARNING` prints only messages containing ANSYS warnings, and ‘ERROR’ prints only error messages.

cleanup_on_exitbool, optional

Exit MAPDL when Python exits or when this instance is garbage collected.

set_no_abortbool, optional

Sets MAPDL to not abort at the first error within /BATCH mode. Default True.

remove_temp_filesbool, optional

When this parameter is True, the MAPDL working directory will be deleted when MAPDL is exited provided that it is within the temporary user directory. Default False.

log_filebool, optional

Copy the log to a file called logs.log located where the python script is executed. Default True.

print_combool, optional

Print the command /COM arguments to the standard output. Default False.

channelgrpc.Channel, optional

gRPC channel to use for the connection. Can be used as an alternative to the ip and port parameters.

remote_instanceansys.platform.instancemanagement.Instance

The corresponding remote instance when MAPDL is launched through PyPIM. This instance will be deleted when calling Mapdl.exit.

Examples

Connect to an instance of MAPDL already running on locally on the default port 50052.

>>> from ansys.mapdl import core as pymapdl
>>> mapdl = pymapdl.Mapdl()

Connect to an instance of MAPDL running on the LAN on a default port.

>>> mapdl = pymapdl.Mapdl('192.168.1.101')

Connect to an instance of MAPDL running on the LAN on a non-default port.

>>> mapdl = pymapdl.Mapdl('192.168.1.101', port=60001)

If you wish to customize the channel, you can also directly connect directly to gRPC channels. For example, if you wanted to create an insecure channel with a maximum message length of 8 MB.

>>> import grpc
>>> channel = grpc.insecure_channel(
...     '127.0.0.1:50052',
...     options=[
...         ("grpc.max_receive_message_length", 8*1024**2),
...     ],
... )
>>> mapdl = pymapdl.Mapdl(channel=channel)

mapdl_grpc.MapdlGrpc.download(files[, ...])

Download files from the gRPC instance workind directory

mapdl_grpc.MapdlGrpc.list_error_file()

Listing of errors written in JOBNAME.err

mapdl_grpc.MapdlGrpc.list_files([refresh_cache])

List the files in the working directory of MAPDL.

mapdl_grpc.MapdlGrpc.math

APDL math interface

mapdl_grpc.MapdlGrpc.mute

Silence the response from all MAPDL functions unless explicitly set to True.

mapdl_grpc.MapdlGrpc.upload(file_name[, ...])

Upload a file to the grpc instance

Mapdl Information Class#

class ansys.mapdl.core.misc.Information(mapdl)#

This class provide some MAPDL information from /STATUS MAPDL command.

It is also the object that is called when you issue print(mapdl), which means print calls mapdl.info.__str__().

Notes

You cannot directly modify the values of this class.

Some of the results are cached for later calls.

Examples

>>> mapdl.info
Product:             Ansys Mechanical Enterprise
MAPDL Version:       21.2
ansys.mapdl Version: 0.62.dev0
>>> print(mapdl)
Product:             Ansys Mechanical Enterprise
MAPDL Version:       21.2
ansys.mapdl Version: 0.62.dev0
>>> mapdl.info.product
'Ansys Mechanical Enterprise'
>>> info = mapdl.info
>>> info.mapdl_version
'RELEASE  2021 R2           BUILD 21.2      UPDATE 20210601'

Information.product

Retrieve the product from the MAPDL instance.

Information.mapdl_version

Retrieve the MAPDL version from the MAPDL instance.

Information.pymapdl_version

Retrieve the PyMAPDL version from the MAPDL instance.

Information.products

Retrieve the products from the MAPDL instance.

Information.preprocessing_capabilities

Retrieve the preprocessing capabilities from the MAPDL instance.

Information.aux_capabilities

Retrieve the aux capabilities from the MAPDL instance.

Information.solution_options

Retrieve the solution options from the MAPDL instance.

Information.post_capabilities

Retrieve the post capabilities from the MAPDL instance.

Information.title

Retrieve and set the title from the MAPDL instance.

Information.titles

Retrieve the titles from the MAPDL instance.

Information.stitles

Retrieve or set the value for the MAPDL stitle (subtitles).

Information.units

Retrieve the units from the MAPDL instance.

Information.scratch_memory_status

Retrieve the scratch memory status from the MAPDL instance.

Information.database_status

Retrieve the database status from the MAPDL instance.

Information.config_values

Retrieve the config values from the MAPDL instance.

Information.global_status

Retrieve the global status from the MAPDL instance.

Information.job_information

Retrieve the job information from the MAPDL instance.

Information.model_information

Retrieve the model information from the MAPDL instance.

Information.boundary_condition_information

Retrieve the boundary condition information from the MAPDL instance.

Information.routine_information

Retrieve the routine information from the MAPDL instance.

Information.solution_options_configuration

Retrieve the solution options configuration from the MAPDL instance.

Information.load_step_options

Retrieve the load step options from the MAPDL instance.