Mapdl
module#
Mapdl
methods and attributes#
- class ansys.mapdl.core.mapdl.MapdlBase(loglevel='DEBUG', use_vtk=None, log_apdl=None, log_file=False, local=True, print_com=False, file_type_for_plots='PNG', **start_parm)#
Base MAPDL class shared across all MAPDL subclasses.
Warning
This class should NOT be imported by itself. You should always import a subclass of it like
MapdlGrpc
|
Add a file handler to the mapdl log. |
Invalid commands will be ignored rather than exceptions |
|
True when MAPDL gRPC server is executing a command. |
|
Chain several mapdl commands. |
|
Whether check if the name which is given to the parameter is allowed or not |
|
Default file type for plots. |
|
Current MAPDL directory. |
|
Return true if the MAPDL session exited |
|
Returns true if the MAPDL instance is exiting. |
|
Returns the current file type for plotting. |
|
Force text output globally by turning the |
|
|
Retrieves a value and stores it as a scalar parameter or part of an array parameter. |
|
Uses the |
|
Get ESOL data. |
|
Get the applied nodal constrains: |
|
Get the applied nodal loads. |
|
Get NSOL solutions |
|
Runs the MAPDL GET command and returns a Python value. |
|
Obtain the variable values. |
Return the hostname of the machine MAPDL is running in. |
|
Invalid commands will be ignored rather than exceptions |
|
General information |
|
|
Run several commands as a single block. |
True when there is an active connect to the gRPC server |
|
Return true if using console to connect to the MAPDL instance. |
|
Return true if using corba to connect to the MAPDL instance. |
|
Return true if using grpc to connect to the MAPDL instance. |
|
Returns the job id where the MAPDL is running in. |
|
MAPDL job name. |
|
|
Kill an HPC job |
Returns the last response from MAPDL. |
|
Check if the MAPDL instance has been launched by PyMAPDL. |
|
Listing of errors written in JOBNAME.err |
|
|
List the files in the working directory of MAPDL. |
|
Load an array from Python to MAPDL. |
|
Load a table from Python to into MAPDL. |
Instance is in use within a pool |
|
MAPDL Python-based logger |
|
Returns |
|
Silence the response from all MAPDL functions unless explicitly set to |
|
Instance unique identifier. |
|
Non-interactive context manager. |
|
Check if MAPDL is running on docker. |
|
|
Start writing all APDL commands to an MAPDL input file. |
|
Save the existing database and open it up in the MAPDL GUI. |
Return the platform where MAPDL is running. |
|
Whether to print or not to the console the |
|
Check if the MAPDL process is alive |
|
Removes the filehander from the log |
|
Binary interface to the result file using |
|
Return the RST file path. |
|
|
Run single APDL command. |
|
Runs a command or commands at a routine and then revert to the prior routine. |
|
Run several commands as a single block :rtype: |
Save selection |
|
|
Return a scalar parameter as a float. |
|
Take an MAPDL screenshot and show it in a popup window. |
|
Sets log level |
The thermal result object |
|
Returns if using VTK by default or not. |
|
MAPDL build version. |
Constants#
Built-in mutable sequence. |
|
Built-in mutable sequence. |
mapdl_grpc.MapdlGrpc
methods#
- 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_dir_on_exit=False, print_com=False, disable_run_at_connect=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:
- ip
str
,optional
IP address to connect to the server. The default is ‘localhost’.
- port
int
,optional
Port to connect to the MAPDL server. The default is
50052
.- timeout
float
,optional
Maximum allowable time to connect to the MAPDL server.
- loglevel
str
,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. The default is
True
.- remove_temp_dirbool,
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. The default isFalse
.- log_filebool,
optional
Copy the log to a file called logs.log located where the python script is executed. The default is
True
.- print_combool,
optional
Print the command
/COM
arguments to the standard output. The default isFalse
.- disable_run_at_connect: bool, optional
Whether to disable the housekeeping commands when connecting. The default is
False
.- channel
grpc.Channel
,optional
gRPC channel to use for the connection. This parameter can be used as an alternative to the
ip
andport
parameters.- remote_instance
ansys.platform.instancemanagement.Instance
The corresponding remote instance when MAPDL is launched through PyPIM. This instance will be deleted when calling
Mapdl.exit
.- file_type_for_plots: [“PNG”, “TIFF”, “PNG”, “VRML”, “TERM”], Optional
Change the default file type for plots using
/SHOW
, by default it isPNG
.
- ip
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)
Returns the gRPC channel state. |
|
Return MAPDL status. |
|
Return the type of connection to the instance, namely: grpc, corba or console. |
|
|
Download files from the gRPC instance working directory :rtype: |
Download all the project files located in the MAPDL working directory. |
|
|
Download remote result files to a local directory |
|
Specifies the data file where results are to be found. |
Return the MAPDL gRPC instance IP. |
|
Check if the instance is running locally or remotely. |
|
Listing of errors written in JOBNAME.err |
|
|
List the files in the working directory of MAPDL. |
Silence the response from all MAPDL functions unless explicitly set to |
|
Returns the MAPDL gRPC instance port. |
|
|
Upload a file to the grpc instance |