Result Class#

class ansys.mapdl.reader.rst.Result(filename, read_mesh=True, parse_vtk=True, **kwargs)

Reads a binary ANSYS result file.

Parameters:
  • filename (str, pathlib.Path, optional) – Filename of the ANSYS binary result file.

  • ignore_cyclic (bool, optional) – Ignores any cyclic properties.

  • read_mesh (bool, optional) – Debug parameter. Set to False to disable reading in the mesh from the result file.

  • parse_vtk (bool, optional) – Set to False to skip the parsing the mesh as a VTK UnstructuredGrid, which might take a long time for large models.

Examples

>>> from ansys.mapdl import reader as pymapdl_reader
>>> rst = pymapdl_reader.read_binary('file.rst')
animate_nodal_displacement(rnum, comp='norm', node_components=None, element_components=None, sel_type_all=True, add_text=True, displacement_factor=0.1, n_frames=100, loop=True, movie_filename=None, progress_bar=True, **kwargs)

Animate nodal solution.

Assumes nodal solution is a displacement array from a modal or static solution.

rnumint or list

Cumulative result number with zero based indexing, or a list containing (step, substep) of the requested result.

compstr, default: “norm”

Scalar component to display. Options are 'x', 'y', 'z', and 'norm', and None.

node_componentslist, optional

Accepts either a string or a list strings of node components to plot. For example: ['MY_COMPONENT', 'MY_OTHER_COMPONENT]

element_componentslist, optional

Accepts either a string or a list strings of element components to plot. For example: ['MY_COMPONENT', 'MY_OTHER_COMPONENT]

sel_type_allbool, optional

If node_components is specified, plots those elements containing all nodes of the component. Default True.

add_textbool, optional

Adds information about the result.

displacement_factorfloat, optional

Increases or decreases displacement by a factor.

n_framesint, optional

Number of “frames” between each full cycle.

loopbool, optional

Loop the animation. Default True. Disable this to animate once and close. Automatically disabled when off_screen=True and movie_filename is set.

movie_filenamestr, pathlib.Path, optional

Filename of the movie to open. Filename should end in 'mp4', but other filetypes may be supported like "gif". See imagio.get_writer. A single loop of the mode will be recorded.

progress_barbool, default: True

Displays a progress bar when generating a movie while off_screen=True.

kwargsoptional keyword arguments

See pyvista.plot() for additional keyword arguments.

Examples

Animate the first result interactively.

>>> rst.animate_nodal_solution(0)

Animate second result while displaying the x scalars without looping

>>> rst.animate_nodal_solution(1, comp='x', loop=False)

Animate the second result and save as a movie.

>>> rst.animate_nodal_solution(0, movie_filename='disp.mp4')

Animate the second result and save as a movie in the background.

>>> rst.animate_nodal_solution(0, movie_filename='disp.mp4', off_screen=True)

Disable plotting within the notebook.

>>> rst.animate_nodal_solution(0, notebook=False)
animate_nodal_solution(rnum, comp='norm', node_components=None, element_components=None, sel_type_all=True, add_text=True, displacement_factor=0.1, n_frames=100, loop=True, movie_filename=None, progress_bar=True, **kwargs)

Animate nodal solution.

Assumes nodal solution is a displacement array from a modal or static solution.

rnumint or list

Cumulative result number with zero based indexing, or a list containing (step, substep) of the requested result.

compstr, default: “norm”

Scalar component to display. Options are 'x', 'y', 'z', and 'norm', and None.

node_componentslist, optional

Accepts either a string or a list strings of node components to plot. For example: ['MY_COMPONENT', 'MY_OTHER_COMPONENT]

element_componentslist, optional

Accepts either a string or a list strings of element components to plot. For example: ['MY_COMPONENT', 'MY_OTHER_COMPONENT]

sel_type_allbool, optional

If node_components is specified, plots those elements containing all nodes of the component. Default True.

add_textbool, optional

Adds information about the result.

displacement_factorfloat, optional

Increases or decreases displacement by a factor.

n_framesint, optional

Number of “frames” between each full cycle.

loopbool, optional

Loop the animation. Default True. Disable this to animate once and close. Automatically disabled when off_screen=True and movie_filename is set.

movie_filenamestr, pathlib.Path, optional

Filename of the movie to open. Filename should end in 'mp4', but other filetypes may be supported like "gif". See imagio.get_writer. A single loop of the mode will be recorded.

progress_barbool, default: True

Displays a progress bar when generating a movie while off_screen=True.

kwargsoptional keyword arguments

See pyvista.plot() for additional keyword arguments.

Examples

Animate the first result interactively.

>>> rst.animate_nodal_solution(0)

Animate second result while displaying the x scalars without looping

>>> rst.animate_nodal_solution(1, comp='x', loop=False)

Animate the second result and save as a movie.

>>> rst.animate_nodal_solution(0, movie_filename='disp.mp4')

Animate the second result and save as a movie in the background.

>>> rst.animate_nodal_solution(0, movie_filename='disp.mp4', off_screen=True)

Disable plotting within the notebook.

>>> rst.animate_nodal_solution(0, notebook=False)
animate_nodal_solution_set(rnums=None, comp='norm', node_components=None, element_components=None, sel_type_all=True, loop=True, movie_filename=None, add_text=True, fps=20, **kwargs)

Animate a set of nodal solutions.

Animates the scalars of all the result sets. Best when used with a series of static analyses.

rnumscollection.Iterable

Range or list containing the zero based indexed cumulative result numbers to animate.

compstr, optional

Scalar component to display. Options are 'x', 'y', 'z', and 'norm', and None. Not applicable for a thermal analysis.

node_componentslist, optional

Accepts either a string or a list strings of node components to plot. For example: ['MY_COMPONENT', 'MY_OTHER_COMPONENT]

element_componentslist, optional

Accepts either a string or a list strings of element components to plot. For example: ['MY_COMPONENT', 'MY_OTHER_COMPONENT]

sel_type_allbool, optional

If node_components is specified, plots those elements containing all nodes of the component. Default True.

loopbool, optional

Loop the animation. Default True. Disable this to animate once and close.

movie_filenamestr, optional

Filename of the movie to open. Filename should end in 'mp4', but other filetypes may be supported. See imagio.get_writer. A single loop of the mode will be recorded.

add_textbool, optional

Adds information about the result to the animation.

fpsint, optional

Frames per second. Defaults to 20 and limited to hardware capabilities and model density. Carries over to movies created by providing the movie_filename argument, but not to gifs.

kwargsoptional keyword arguments, optional

See help(pyvista.Plot) for additional keyword arguments.

Examples

Animate all results

>>> rst.animate_nodal_solution_set()

Animate every 50th result in a set of results and save to a gif. Use the “zx” camera position to view the ZX plane from the top down.

>>> rsets = range(0, rst.nsets, 50)
>>> rst.animate_nodal_solution_set(rsets,
...                                scalar_bar_args={'title': 'My Animation'},
...                                lighting=False, cpos='zx',
...                                movie_filename='example.gif')
property available_results

Available result types.

Examples

>>> rst.available_results
Available Results:
ENS : Nodal stresses
ENG : Element energies and volume
EEL : Nodal elastic strains
EPL : Nodal plastic strains
ETH : Nodal thermal strains (includes swelling strains)
EUL : Element euler angles
ENL : Nodal nonlinear items, e.g. equivalent plastic strains
EPT : Nodal temperatures
NSL : Nodal displacements
RF  : Nodal reaction forces
cs_4x4(cs_cord, as_vtk_matrix=False)

Return a 4x4 transformation matrix for a given coordinate system.

Parameters:
  • cs_cord (int) – Coordinate system index.

  • as_vtk_matrix (bool, default: False) – Return the transformation matrix as a vtkMatrix4x4.

Returns:

Matrix or vtkMatrix4x4 depending on the value of as_vtk_matrix.

Return type:

np.ndarray | vtk.vtkMatrix4x4

Notes

Values 11 and greater correspond to local coordinate systems

Examples

Return the transformation matrix for coordinate system 1.

>>> tmat = rst.cs_4x4(1)
>>> tmat
array([[1., 0., 0., 0.],
       [0., 1., 0., 0.],
       [0., 0., 1., 0.],
       [0., 0., 0., 1.]])

Return the transformation matrix for coordinate system 5. This corresponds to CSYS, 5, the cylindrical with global Cartesian Y as the axis of rotation.

>>> tmat = rst.cs_4x4(5)
>>> tmat
array([[ 1.,  0.,  0.,  0.],
       [ 0.,  0., -1.,  0.],
       [ 0.,  1.,  0.,  0.],
       [ 0.,  0.,  0.,  1.]])
cylindrical_nodal_stress(rnum, nodes=None)

Retrieves the stresses for each node in the solution in the cylindrical coordinate system as the following values:

R, THETA, Z, RTHETA, THETAZ, and RZ

The order of the results corresponds to the sorted node numbering.

Computes the nodal stress by averaging the stress for each element at each node. Due to the discontinuities across elements, stresses will vary based on the element they are evaluated from.

Parameters:
  • rnum (int or list) – Cumulative result number with zero based indexing, or a list containing (step, substep) of the requested result.

  • nodes (str, sequence of int or str, optional) –

    Select a limited subset of nodes. Can be a nodal component or array of node numbers. For example

    • "MY_COMPONENT"

    • ['MY_COMPONENT', 'MY_OTHER_COMPONENT]

    • np.arange(1000, 2001)

Returns:

  • nnum (numpy.ndarray) – Node numbers of the result.

  • stress (numpy.ndarray) – Stresses at R, THETA, Z, RTHETA, THETAZ, RZ averaged at each corner node where R is radial.

Examples

>>> from ansys.mapdl import reader as pymapdl_reader
>>> rst = pymapdl_reader.read_binary('file.rst')
>>> nnum, stress = rst.cylindrical_nodal_stress(0)

Return the cylindrical nodal stress just for the nodal component 'MY_COMPONENT'.

>>> nnum, stress = rst.cylindrical_nodal_stress(0, nodes='MY_COMPONENT')

Return the nodal stress just for the nodes from 20 through 50.

>>> nnum, stress = rst.cylindrical_nodal_stress(0, nodes=range(20, 51))

Notes

Nodes without a stress value will be NAN. Equivalent ANSYS commands: RSYS, 1 PRNSOL, S

property element_components

Dictionary of ansys element components from the result file.

Examples

>>> from ansys.mapdl import reader as pymapdl_reader
>>> from ansys.mapdl.reader import examples
>>> rst = pymapdl_reader.read_binary(examples.rstfile)
>>> rst.element_components
{'ECOMP1': array([17, 18, 21, 22, 23, 24, 25, 26, 27, 28, 29,
        30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40], dtype=int32),
'ECOMP2': array([ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,
        14, 15, 16, 17, 18, 19, 20, 23, 24], dtype=int32),
'ELEM_COMP': array([ 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
        16, 17, 18, 19, 20], dtype=int32)}
element_lookup(element_id)

Index of the element the element within the result mesh

element_solution_data(rnum, datatype, sort=True, **kwargs)

Retrieves element solution data. Similar to ETABLE.

Parameters:
  • rnum (int or list) – Cumulative result number with zero based indexing, or a list containing (step, substep) of the requested result.

  • datatype (str) –

    Element data type to retrieve.

    • EMS: misc. data

    • ENF: nodal forces

    • ENS: nodal stresses

    • ENG: volume and energies

    • EGR: nodal gradients

    • EEL: elastic strains

    • EPL: plastic strains

    • ECR: creep strains

    • ETH: thermal strains

    • EUL: euler angles

    • EFX: nodal fluxes

    • ELF: local forces

    • EMN: misc. non-sum values

    • ECD: element current densities

    • ENL: nodal nonlinear data

    • EHC: calculated heat generations

    • EPT: element temperatures

    • ESF: element surface stresses

    • EDI: diffusion strains

    • ETB: ETABLE items

    • ECT: contact data

    • EXY: integration point locations

    • EBA: back stresses

    • ESV: state variables

    • MNL: material nonlinear record

  • sort (bool) – Sort results by element number. Default True.

  • **kwargs (optional keyword arguments) – Hidden options for distributed result files.

Returns:

  • enum (np.ndarray) – Element numbers.

  • element_data (list) – List with one data item for each element.

  • enode (list) – Node numbers corresponding to each element. results. One list entry for each element.

Notes

See ANSYS element documentation for available items for each element type. See:

https://www.mm.bme.hu/~gyebro/files/ans_help_v182/ans_elem/

Examples

Retrieve “LS” solution results from an PIPE59 element for result set 1

>>> enum, edata, enode = result.element_solution_data(0, datatype='ENS')
>>> enum[0]  # first element number
>>> enode[0]  # nodes belonging to element 1
>>> edata[0]  # data belonging to element 1
array([ -4266.19   ,   -376.18857,  -8161.785  , -64706.766  ,
        -4266.19   ,   -376.18857,  -8161.785  , -45754.594  ,
        -4266.19   ,   -376.18857,  -8161.785  ,      0.     ,
        -4266.19   ,   -376.18857,  -8161.785  ,  45754.594  ,
        -4266.19   ,   -376.18857,  -8161.785  ,  64706.766  ,
        -4266.19   ,   -376.18857,  -8161.785  ,  45754.594  ,
        -4266.19   ,   -376.18857,  -8161.785  ,      0.     ,
        -4266.19   ,   -376.18857,  -8161.785  , -45754.594  ,
        -4274.038  ,   -376.62527,  -8171.2603 ,   2202.7085 ,
       -29566.24   ,   -376.62527,  -8171.2603 ,   1557.55   ,
       -40042.613  ,   -376.62527,  -8171.2603 ,      0.     ,
       -29566.24   ,   -376.62527,  -8171.2603 ,  -1557.55   ,
        -4274.038  ,   -376.62527,  -8171.2603 ,  -2202.7085 ,
        21018.164  ,   -376.62527,  -8171.2603 ,  -1557.55   ,
        31494.537  ,   -376.62527,  -8171.2603 ,      0.     ,
        21018.164  ,   -376.62527,  -8171.2603 ,   1557.55   ],
      dtype=float32)

This data corresponds to the results you would obtain directly from MAPDL with ESOL commands:

>>> ansys.esol(nvar='2', elem=enum[0], node=enode[0][0], item='LS', comp=1)
>>> ansys.vget(par='SD_LOC1', ir='2', tstrt='1') # store in a variable
>>> ansys.read_float_parameter('SD_LOC1(1)')
-4266.19
element_stress(rnum, principal=False, in_element_coord_sys=False, **kwargs)

Retrieves the element component stresses.

Equivalent ANSYS command: PRESOL, S

Parameters:
  • rnum (int or list) – Cumulative result number with zero based indexing, or a list containing (step, substep) of the requested result.

  • principal (bool, optional) – Returns principal stresses instead of component stresses. Default False.

  • in_element_coord_sys (bool, optional) – Returns the results in the element coordinate system. Default False and will return the results in the global coordinate system.

  • **kwargs (optional keyword arguments) – Hidden options for distributed result files.

Returns:

  • enum (np.ndarray) – ANSYS element numbers corresponding to each element.

  • element_stress (list) – Stresses at each element for each node for Sx Sy Sz Sxy Syz Sxz or SIGMA1, SIGMA2, SIGMA3, SINT, SEQV when principal is True.

  • enode (list) – Node numbers corresponding to each element’s stress results. One list entry for each element.

Examples

Element component stress for the first result set.

>>> rst.element_stress(0)

Element principal stress for the first result set.

>>> enum, element_stress, enode = result.element_stress(0, principal=True)

Notes

Shell stresses for element 181 are returned for top and bottom layers. Results are ordered such that the top layer and then the bottom layer is reported.

property filename: str

String form of the filename. This property is read-only.

property materials

Result file material properties.

Returns:

Dictionary of Materials. Keys are the material numbers, and each material is a dictionary of the material properrties of that material with only the valid entries filled.

Return type:

dict

Notes

Material properties:

  • EX : Elastic modulus, element x direction (Force/Area)

  • EY : Elastic modulus, element y direction (Force/Area)

  • EZ : Elastic modulus, element z direction (Force/Area)

  • ALPX : Coefficient of thermal expansion, element x direction (Strain/Temp)

  • ALPY : Coefficient of thermal expansion, element y direction (Strain/Temp)

  • ALPZ : Coefficient of thermal expansion, element z direction (Strain/Temp)

  • REFT : Reference temperature (as a property) [TREF]

  • PRXY : Major Poisson’s ratio, x-y plane

  • PRYZ : Major Poisson’s ratio, y-z plane

  • PRX Z : Major Poisson’s ratio, x-z plane

  • NUXY : Minor Poisson’s ratio, x-y plane

  • NUYZ : Minor Poisson’s ratio, y-z plane

  • NUXZ : Minor Poisson’s ratio, x-z plane

  • GXY : Shear modulus, x-y plane (Force/Area)

  • GYZ : Shear modulus, y-z plane (Force/Area)

  • GXZ : Shear modulus, x-z plane (Force/Area)

  • DAMP : K matrix multiplier for damping [BETAD] (Time)

  • MUCoefficient of friction (or, for FLUID29 and FLUID30

    elements, boundary admittance)

  • DENS : Mass density (Mass/Vol)

  • C : Specific heat (Heat/Mass*Temp)

  • ENTH : Enthalpy (e DENS*C d(Temp)) (Heat/Vol)

  • KXXThermal conductivity, element x direction

    (Heat*Length / (Time*Area*Temp))

  • KYYThermal conductivity, element y direction

    (Heat*Length / (Time*Area*Temp))

  • KZZThermal conductivity, element z direction

    (Heat*Length / (Time*Area*Temp))

  • HF : Convection (or film) coefficient (Heat / (Time*Area*Temp))

  • EMIS : Emissivity

  • QRATE : Heat generation rate (MASS71 element only) (Heat/Time)

  • VISC : Viscosity (Force*Time / Length2)

  • SONC : Sonic velocity (FLUID29 and FLUID30 elements only) (Length/Time)

  • RSVX : Electrical resistivity, element x direction (Resistance*Area / Length)

  • RSVY : Electrical resistivity, element y direction (Resistance*Area / Length)

  • RSVZ : Electrical resistivity, element z direction (Resistance*Area / Length)

  • PERX : Electric permittivity, element x direction (Charge2 / (Force*Length))

  • PERY : Electric permittivity, element y direction (Charge2 / (Force*Length))

  • PERZ : Electric permittivity, element z direction (Charge2 / (Force*Length))

  • MURX : Magnetic relative permeability, element x direction

  • MURY : Magnetic relative permeability, element y direction

  • MURZ : Magnetic relative permeability, element z direction

  • MGXX : Magnetic coercive force, element x direction (Charge / (Length*Time))

  • MGYY : Magnetic coercive force, element y direction (Charge / (Length*Time))

  • MGZZ : Magnetic coercive force, element z direction (Charge / (Length*Time))

Materials may contain the key "stress_failure_criteria", which contains failure criteria information for temperature-dependent stress limits. This includes the following keys:

  • XTEN : Allowable tensile stress or strain in the x-direction. (Must be positive.)

  • XCMP : Allowable compressive stress or strain in the x-direction. (Defaults to negative of XTEN.)

  • YTEN : Allowable tensile stress or strain in the y-direction. (Must be positive.)

  • YCMP : Allowable compressive stress or strain in the y-direction. (Defaults to negative of YTEN.)

  • ZTEN : Allowable tensile stress or strain in the z-direction. (Must be positive.)

  • ZCMP : Allowable compressive stress or strain in the z-direction. (Defaults to negative of ZTEN.)

  • XY : Allowable XY stress or shear strain. (Must be positive.)

  • YZ : Allowable YZ stress or shear strain. (Must be positive.)

  • XZ : Allowable XZ stress or shear strain. (Must be positive.)

  • XYCP : XY coupling coefficient (Used only if Lab1 = S). Defaults to -1.0. [1]

  • YZCP : YZ coupling coefficient (Used only if Lab1 = S). Defaults to -1.0. [1]

  • XZCP : XZ coupling coefficient (Used only if Lab1 = S). Defaults to -1.0. [1]

  • XZIT : XZ tensile inclination parameter for Puck failure index (default = 0.0)

  • XZIC : XZ compressive inclination parameter for Puck failure index (default = 0.0)

  • YZIT : YZ tensile inclination parameter for Puck failure index (default = 0.0)

  • YZIC : YZ compressive inclination parameter for Puck failure index (default = 0.0)

Examples

Return the material properties from the example result file. Note that the keys of rst.materials is the material type.

>>> from ansys.mapdl import reader as pymapdl_reader
>>> from ansys.mapdl.reader import examples
>>> rst = pymapdl_reader.read_binary(examples.rstfile)
>>> rst.materials
{1: {'EX': 16900000.0, 'NUXY': 0.31, 'DENS': 0.00041408}}
property mesh

Mesh from result file.

Examples

>>> rst.mesh
ANSYS Mesh
  Number of Nodes:              1448
  Number of Elements:           226
  Number of Element Types:      1
  Number of Node Components:    0
  Number of Element Components: 0
property n_results

Number of results

property n_sector

Number of sectors

nodal_acceleration(rnum, in_nodal_coord_sys=False)

Nodal velocities for a given result set.

Parameters:
  • rnum (int or list) – Cumulative result number with zero based indexing, or a list containing (step, substep) of the requested result.

  • in_nodal_coord_sys (bool, optional) – When True, returns results in the nodal coordinate system. Default False.

Returns:

  • nnum (int np.ndarray) – Node numbers associated with the results.

  • result (float np.ndarray) – Array of nodal accelerations. Array is (nnod x sumdof), the number of nodes by the number of degrees of freedom which includes numdof and nfldof

Examples

>>> from ansys.mapdl import reader as pymapdl_reader
>>> rst = pymapdl_reader.read_binary('file.rst')
>>> nnum, data = rst.nodal_acceleration(0)

Notes

Some solution results may not include results for each node. These results are removed by and the node numbers of the solution results are reflected in nnum.

nodal_boundary_conditions(rnum)

Nodal boundary conditions for a given result number.

These nodal boundary conditions are generally set with the APDL command D. For example, D, 25, UX, 0.001

Parameters:

rnum (int or list) – Cumulative result number with zero based indexing, or a list containing (step, substep) of the requested result.

Returns:

  • nnum (np.ndarray) – Node numbers of the nodes with boundary conditions.

  • dof (np.ndarray) – Array of indices of the degrees of freedom of the nodes with boundary conditions. See rst.result_dof for the degrees of freedom associated with each index.

  • bc (np.ndarray) – Boundary conditions.

Examples

Print the boundary conditions where: - Node 3 is fixed - Node 25 has UX=0.001 - Node 26 has UY=0.0011 - Node 27 has UZ=0.0012

>>> rst.nodal_boundary_conditions(0)
(array([ 3,  3,  3, 25, 26, 27], dtype=int32),
array([1, 2, 3, 1, 2, 3], dtype=int32),
array([0.    , 0.    , 0.    , 0.001 , 0.0011, 0.0012]))
nodal_displacement(rnum, in_nodal_coord_sys=False, nodes=None)

Returns the DOF solution for each node in the global cartesian coordinate system or nodal coordinate system.

Solution may be nodal temperatures or nodal displacements depending on the type of the solution.

Parameters:
  • rnum (int or list) – Cumulative result number with zero based indexing, or a list containing (step, substep) of the requested result.

  • in_nodal_coord_sys (bool, optional) – When True, returns results in the nodal coordinate system. Default False.

  • nodes (str, sequence of int or str, optional) –

    Select a limited subset of nodes. Can be a nodal component or array of node numbers. For example

    • "MY_COMPONENT"

    • ['MY_COMPONENT', 'MY_OTHER_COMPONENT]

    • np.arange(1000, 2001)

Returns:

  • nnum (int np.ndarray) – Node numbers associated with the results.

  • result (float np.ndarray) – Array of nodal displacements or nodal temperatures. Array is (nnod x sumdof), the number of nodes by the number of degrees of freedom which includes numdof and nfldof

Examples

Return the nodal solution (in this case, displacement) for the first result of "file.rst".

>>> from ansys.mapdl import reader as pymapdl_reader
>>> rst = pymapdl_reader.read_binary('file.rst')
>>> nnum, data = rst.nodal_solution(0)

Return the nodal solution just for the nodal component 'MY_COMPONENT'.

>>> nnum, data = rst.nodal_solution(0, nodes='MY_COMPONENT')

Return the nodal solution just for the nodes from 20 through 50.

>>> nnum, data = rst.nodal_solution(0, nodes=range(20, 51))

Notes

Some solution results may not include results for each node. These results are removed by and the node numbers of the solution results are reflected in nnum.

nodal_elastic_strain(rnum, nodes=None)

Nodal component elastic strains. This record contains strains in the order X, Y, Z, XY, YZ, XZ, EQV.

Elastic strains can be can be nodal values extrapolated from the integration points or values at the integration points moved to the nodes.

Equivalent MAPDL command: PRNSOL, EPEL

Parameters:
  • rnum (int or list) – Cumulative result number with zero based indexing, or a list containing (step, substep) of the requested result.

  • nodes (str, sequence of int or str, optional) –

    Select a limited subset of nodes. Can be a nodal component or array of node numbers. For example

    • "MY_COMPONENT"

    • ['MY_COMPONENT', 'MY_OTHER_COMPONENT]

    • np.arange(1000, 2001)

Returns:

  • nnum (np.ndarray) – MAPDL node numbers.

  • elastic_strain (np.ndarray) – Nodal component elastic strains. Array is in the order X, Y, Z, XY, YZ, XZ, EQV.

Examples

Load the nodal elastic strain for the first result.

>>> from ansys.mapdl import reader as pymapdl_reader
>>> rst = pymapdl_reader.read_binary('file.rst')
>>> nnum, elastic_strain = rst.nodal_elastic_strain(0)

Return the nodal elastic strain just for the nodal component 'MY_COMPONENT'.

>>> nnum, elastic_strain = rst.nodal_elastic_strain(0, nodes='MY_COMPONENT')

Return the nodal elastic strain just for the nodes from 20 through 50.

>>> nnum, elastic_strain = rst.nodal_elastic_strain(0, nodes=range(20, 51))

Notes

Nodes without a strain will be NAN.

nodal_input_force(rnum)

Nodal input force for a given result number.

Nodal input force is generally set with the APDL command F. For example, F, 25, FX, 0.001

Parameters:

rnum (int or list) – Cumulative result number with zero based indexing, or a list containing (step, substep) of the requested result.

Returns:

  • nnum (np.ndarray) – Node numbers of the nodes with nodal forces.

  • dof (np.ndarray) – Array of indices of the degrees of freedom of the nodes with input force. See rst.result_dof for the degrees of freedom associated with each index.

  • force (np.ndarray) – Nodal input force.

Examples

Print the nodal input force where: - Node 25 has FX=20 - Node 26 has FY=30 - Node 27 has FZ=40

>>> rst.nodal_input_force(0)
(array([ 71,  52, 127], dtype=int32),
 array([2, 1, 3], dtype=int32),
 array([30., 20., 40.]))
nodal_plastic_strain(rnum, nodes=None)

Nodal component plastic strains.

This record contains strains in the order: X, Y, Z, XY, YZ, XZ, EQV.

Plastic strains are always values at the integration points moved to the nodes.

Parameters:
  • rnum (int or list) – Cumulative result number with zero based indexing, or a list containing (step, substep) of the requested result.

  • nodes (str, sequence of int or str, optional) –

    Select a limited subset of nodes. Can be a nodal component or array of node numbers. For example

    • "MY_COMPONENT"

    • ['MY_COMPONENT', 'MY_OTHER_COMPONENT]

    • np.arange(1000, 2001)

Returns:

  • nnum (np.ndarray) – MAPDL node numbers.

  • plastic_strain (np.ndarray) – Nodal component plastic strains. Array is in the order X, Y, Z, XY, YZ, XZ, EQV.

Examples

Load the nodal plastic strain for the first solution.

>>> from ansys.mapdl import reader as pymapdl_reader
>>> rst = pymapdl_reader.read_binary('file.rst')
>>> nnum, plastic_strain = rst.nodal_plastic_strain(0)

Return the nodal plastic strain just for the nodal component 'MY_COMPONENT'.

>>> nnum, plastic_strain = rst.nodal_plastic_strain(0, nodes='MY_COMPONENT')

Return the nodal plastic strain just for the nodes from 20 through 50.

>>> nnum, plastic_strain = rst.nodal_plastic_strain(0, nodes=range(20, 51))
nodal_reaction_forces(rnum)

Nodal reaction forces.

Parameters:

rnum (int or list) – Cumulative result number with zero based indexing, or a list containing (step, substep) of the requested result.

Returns:

  • rforces (np.ndarray) – Nodal reaction forces for each degree of freedom.

  • nnum (np.ndarray) – Node numbers corresponding to the reaction forces. Node numbers may be repeated if there is more than one degree of freedom for each node.

  • dof (np.ndarray) – Degree of freedom corresponding to each node using the MAPDL degree of freedom reference table. See rst.result_dof for the corresponding degrees of freedom for a given solution.

Examples

Get the nodal reaction forces for the first result and print the reaction forces of a single node.

>>> from ansys.mapdl import reader as pymapdl_reader
>>> rst = pymapdl_reader.read_binary('file.rst')
>>> rforces, nnum, dof = rst.nodal_reaction_forces(0)
>>> dof_ref = rst.result_dof(0)
>>> rforces[:3], nnum[:3], dof[:3], dof_ref
(array([  24102.21376091, -109357.01854005,   22899.5303263 ]),
 array([4142, 4142, 4142]),
 array([1, 2, 3], dtype=int32),
 ['UX', 'UY', 'UZ'])
nodal_solution(rnum, in_nodal_coord_sys=False, nodes=None)

Returns the DOF solution for each node in the global cartesian coordinate system or nodal coordinate system.

Solution may be nodal temperatures or nodal displacements depending on the type of the solution.

Parameters:
  • rnum (int or list) – Cumulative result number with zero based indexing, or a list containing (step, substep) of the requested result.

  • in_nodal_coord_sys (bool, optional) – When True, returns results in the nodal coordinate system. Default False.

  • nodes (str, sequence of int or str, optional) –

    Select a limited subset of nodes. Can be a nodal component or array of node numbers. For example

    • "MY_COMPONENT"

    • ['MY_COMPONENT', 'MY_OTHER_COMPONENT]

    • np.arange(1000, 2001)

Returns:

  • nnum (int np.ndarray) – Node numbers associated with the results.

  • result (float np.ndarray) – Array of nodal displacements or nodal temperatures. Array is (nnod x sumdof), the number of nodes by the number of degrees of freedom which includes numdof and nfldof

Examples

Return the nodal solution (in this case, displacement) for the first result of "file.rst".

>>> from ansys.mapdl import reader as pymapdl_reader
>>> rst = pymapdl_reader.read_binary('file.rst')
>>> nnum, data = rst.nodal_solution(0)

Return the nodal solution just for the nodal component 'MY_COMPONENT'.

>>> nnum, data = rst.nodal_solution(0, nodes='MY_COMPONENT')

Return the nodal solution just for the nodes from 20 through 50.

>>> nnum, data = rst.nodal_solution(0, nodes=range(20, 51))

Notes

Some solution results may not include results for each node. These results are removed by and the node numbers of the solution results are reflected in nnum.

nodal_static_forces(rnum, nodes=None)

Return the nodal forces averaged at the nodes.

Nodal forces are computed on an element by element basis, and this method averages the nodal forces for each element for each node.

Parameters:
  • rnum (int or list) – Cumulative result number with zero based indexing, or a list containing (step, substep) of the requested result.

  • nodes (str, sequence of int or str, optional) –

    Select a limited subset of nodes. Can be a nodal component or array of node numbers. For example

    • "MY_COMPONENT"

    • ['MY_COMPONENT', 'MY_OTHER_COMPONENT]

    • np.arange(1000, 2001)

Returns:

  • nnum (np.ndarray) – MAPDL node numbers.

  • forces (np.ndarray) – Averaged nodal forces. Array is sized [nnod x numdof] where nnod is the number of nodes and numdof is the number of degrees of freedom for this solution.

Examples

Load the nodal static forces for the first result using the example hexahedral result file.

>>> from ansys.mapdl import reader as pymapdl_reader
>>> from ansys.mapdl.reader import examples
>>> rst = pymapdl_reader.read_binary(examples.rstfile)
>>> nnum, forces = rst.nodal_static_forces(0)

Return the nodal static forces just for the nodal component 'MY_COMPONENT'.

>>> nnum, forces = rst.nodal_static_forces(0, nodes='MY_COMPONENT')

Return the nodal static forces just for the nodes from 20 through 50.

>>> nnum, forces = rst.nodal_static_forces(0, nodes=range(20, 51))

Notes

Nodes without a a nodal will be NAN. These are generally midside (quadratic) nodes.

nodal_stress(rnum, nodes=None)

Retrieves the component stresses for each node in the solution.

The order of the results corresponds to the sorted node numbering.

Computes the nodal stress by averaging the stress for each element at each node. Due to the discontinuities across elements, stresses will vary based on the element they are evaluated from.

Parameters:
  • rnum (int or list) – Cumulative result number with zero based indexing, or a list containing (step, substep) of the requested result.

  • nodes (str, sequence of int or str, optional) –

    Select a limited subset of nodes. Can be a nodal component or array of node numbers. For example

    • "MY_COMPONENT"

    • ['MY_COMPONENT', 'MY_OTHER_COMPONENT]

    • np.arange(1000, 2001)

Returns:

  • nnum (numpy.ndarray) – Node numbers of the result.

  • stress (numpy.ndarray) – Stresses at X, Y, Z, XY, YZ, XZ averaged at each corner node.

Examples

>>> from ansys.mapdl import reader as pymapdl_reader
>>> rst = pymapdl_reader.read_binary('file.rst')
>>> nnum, stress = rst.nodal_stress(0)

Return the nodal stress just for the nodal component 'MY_COMPONENT'.

>>> nnum, stress = rst.nodal_stress(0, nodes='MY_COMPONENT')

Return the nodal stress just for the nodes from 20 through 50.

>>> nnum, stress = rst.nodal_solution(0, nodes=range(20, 51))

Notes

Nodes without a stress value will be NAN. Equivalent ANSYS command: PRNSOL, S

nodal_temperature(rnum, nodes=None, **kwargs)

Retrieves the temperature for each node in the solution.

The order of the results corresponds to the sorted node numbering.

Equivalent MAPDL command: PRNSOL, TEMP

Parameters:
  • rnum (int or list) – Cumulative result number with zero based indexing, or a list containing (step, substep) of the requested result.

  • nodes (str, sequence of int or str, optional) –

    Select a limited subset of nodes. Can be a nodal component or array of node numbers. For example

    • "MY_COMPONENT"

    • ['MY_COMPONENT', 'MY_OTHER_COMPONENT]

    • np.arange(1000, 2001)

Returns:

  • nnum (numpy.ndarray) – Node numbers of the result.

  • temperature (numpy.ndarray) – Temperature at each node.

Examples

>>> from ansys.mapdl import reader as pymapdl_reader
>>> rst = pymapdl_reader.read_binary('file.rst')
>>> nnum, temp = rst.nodal_temperature(0)

Return the temperature just for the nodal component 'MY_COMPONENT'.

>>> nnum, temp = rst.nodal_stress(0, nodes='MY_COMPONENT')

Return the temperature just for the nodes from 20 through 50.

>>> nnum, temp = rst.nodal_solution(0, nodes=range(20, 51))
nodal_thermal_strain(rnum, nodes=None)

Nodal component thermal strain.

This record contains strains in the order X, Y, Z, XY, YZ, XZ, EQV, and eswell (element swelling strain). Thermal strains are always values at the integration points moved to the nodes.

Equivalent MAPDL command: PRNSOL, EPTH, COMP

Parameters:
  • rnum (int or list) – Cumulative result number with zero based indexing, or a list containing (step, substep) of the requested result.

  • nodes (str, sequence of int or str, optional) –

    Select a limited subset of nodes. Can be a nodal component or array of node numbers. For example

    • "MY_COMPONENT"

    • ['MY_COMPONENT', 'MY_OTHER_COMPONENT]

    • np.arange(1000, 2001)

Returns:

  • nnum (np.ndarray) – MAPDL node numbers.

  • thermal_strain (np.ndarray) – Nodal component plastic strains. Array is in the order X, Y, Z, XY, YZ, XZ, EQV, ESWELL

Examples

Load the nodal thermal strain for the first solution.

>>> from ansys.mapdl import reader as pymapdl_reader
>>> rst = pymapdl_reader.read_binary('file.rst')
>>> nnum, thermal_strain = rst.nodal_thermal_strain(0)

Return the nodal thermal strain just for the nodal component 'MY_COMPONENT'.

>>> nnum, thermal_strain = rst.nodal_thermal_strain(0, nodes='MY_COMPONENT')

Return the nodal thermal strain just for the nodes from 20 through 50.

>>> nnum, thermal_strain = rst.nodal_thermal_strain(0, nodes=range(20, 51))
nodal_time_history(solution_type='NSL', in_nodal_coord_sys=False)

The DOF solution for each node for all result sets.

The nodal results are returned returned in the global cartesian coordinate system or nodal coordinate system.

Parameters:
  • solution_type (str, optional) – The solution type. Must be either nodal displacements ('NSL'), nodal velocities ('VEL') or nodal accelerations ('ACC').

  • in_nodal_coord_sys (bool, optional) – When True, returns results in the nodal coordinate system. Default False.

Returns:

  • nnum (int np.ndarray) – Node numbers associated with the results.

  • result (float np.ndarray) – Nodal solution for all result sets. Array is sized rst.nsets x nnod x Sumdof, which is the number of time steps by number of nodes by degrees of freedom.

nodal_velocity(rnum, in_nodal_coord_sys=False)

Nodal velocities for a given result set.

Parameters:
  • rnum (int or list) – Cumulative result number with zero based indexing, or a list containing (step, substep) of the requested result.

  • in_nodal_coord_sys (bool, optional) – When True, returns results in the nodal coordinate system. Default False.

Returns:

  • nnum (int np.ndarray) – Node numbers associated with the results.

  • result (float np.ndarray) – Array of nodal velocities. Array is (nnod x sumdof), the number of nodes by the number of degrees of freedom which includes numdof and nfldof

Examples

>>> from ansys.mapdl import reader as pymapdl_reader
>>> rst = pymapdl_reader.read_binary('file.rst')
>>> nnum, data = rst.nodal_velocity(0)

Notes

Some solution results may not include results for each node. These results are removed by and the node numbers of the solution results are reflected in nnum.

property node_components

Dictionary of ansys node components from the result file.

Examples

>>> from ansys.mapdl import reader as pymapdl_reader
>>> from ansys.mapdl.reader import examples
>>> rst = pymapdl_reader.read_binary(examples.rstfile)
>>> rst.node_components.keys()
dict_keys(['ECOMP1', 'ECOMP2', 'ELEM_COMP'])
>>> rst.node_components['NODE_COMP']
array([ 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
      20], dtype=int32)
overwrite_element_solution_record(data, rnum, solution_type, element_id)

Overwrite element solution record.

This method replaces solution data for of an element at a result index for a given solution type. The number of items in data must match the number of items in the record.

If you are not sure how many records are in a given record, use element_solution_data to retrieve all the records for a given solution_type and check the number of items in the record.

Note: The record being replaced cannot be a compressed record. If the result file uses compression (default sparse compression as of 2019R1), you can disable this within MAPDL with: /FCOMP, RST, 0

Parameters:
  • data (list or np.ndarray) – Data that will replace the existing records.

  • rnum (int) – Zero based result number.

  • solution_type (str) –

    Element data type to overwrite.

    • EMS: misc. data

    • ENF: nodal forces

    • ENS: nodal stresses

    • ENG: volume and energies

    • EGR: nodal gradients

    • EEL: elastic strains

    • EPL: plastic strains

    • ECR: creep strains

    • ETH: thermal strains

    • EUL: euler angles

    • EFX: nodal fluxes

    • ELF: local forces

    • EMN: misc. non-sum values

    • ECD: element current densities

    • ENL: nodal nonlinear data

    • EHC: calculated heat generations

    • EPT: element temperatures

    • ESF: element surface stresses

    • EDI: diffusion strains

    • ETB: ETABLE items

    • ECT: contact data

    • EXY: integration point locations

    • EBA: back stresses

    • ESV: state variables

    • MNL: material nonlinear record

  • element_id (int) – Ansys element number (e.g. 1)

Examples

Overwrite the elastic strain record for element 1 for the first result with random data.

>>> from ansys.mapdl import reader as pymapdl_reader
>>> rst = pymapdl_reader.read_binary('file.rst')
>>> data = np.random.random(56)
>>> rst.overwrite_element_solution_data(data, 0, 'EEL', 1)
overwrite_element_solution_records(element_data, rnum, solution_type)

Overwrite element solution record.

This method replaces solution data for a set of elements at a result index for a given solution type. The number of items in data must match the number of items in the record.

If you are not sure how many records are in a given record, use element_solution_data to retrieve all the records for a given solution_type and check the number of items in the record.

Note: The record being replaced cannot be a compressed record. If the result file uses compression (default sparse compression as of 2019R1), you can disable this within MAPDL with: /FCOMP, RST, 0

Parameters:
  • element_data (dict) – Dictionary of results that will replace the existing records.

  • rnum (int) – Zero based result number.

  • solution_type (str) –

    Element data type to overwrite.

    • EMS: misc. data

    • ENF: nodal forces

    • ENS: nodal stresses

    • ENG: volume and energies

    • EGR: nodal gradients

    • EEL: elastic strains

    • EPL: plastic strains

    • ECR: creep strains

    • ETH: thermal strains

    • EUL: euler angles

    • EFX: nodal fluxes

    • ELF: local forces

    • EMN: misc. non-sum values

    • ECD: element current densities

    • ENL: nodal nonlinear data

    • EHC: calculated heat generations

    • EPT: element temperatures

    • ESF: element surface stresses

    • EDI: diffusion strains

    • ETB: ETABLE items

    • ECT: contact data

    • EXY: integration point locations

    • EBA: back stresses

    • ESV: state variables

    • MNL: material nonlinear record

Examples

Overwrite the elastic strain record for elements 1 and 2 with for the first result with random data.

>>> from ansys.mapdl import reader as pymapdl_reader
>>> rst = pymapdl_reader.read_binary('file.rst')
>>> data = {1: np.random.random(56),
            2: np.random.random(56)}
>>> rst.overwrite_element_solution_data(data, 0, 'EEL')
parse_coordinate_system()

Reads in coordinate system information from a binary result file.

Returns:

c_systems – Dictionary containing one entry for each defined coordinate system. If no non-standard coordinate systems have been defined, an empty dictionary will be returned. First coordinate system is assumed to be global cartesian.

Return type:

dict

Notes

euler angles : [THXY, THYZ, THZX]

  • First rotation about local Z (positive X toward Y).

  • Second rotation about local X (positive Y toward Z).

  • Third rotation about local Y (positive Z toward X).

PAR1 Used for elliptical, spheroidal, or toroidal systems. If KCS = 1 or 2, PAR1 is the ratio of the ellipse Y-axis radius to X-axis radius (defaults to 1.0 (circle)). If KCS = 3, PAR1 is the major radius of the torus.

PAR2 Used for spheroidal systems. If KCS = 2, PAR2 = ratio of ellipse Z-axis radius to X-axis radius (defaults to 1.0 (circle)).

Coordinate system type:
  • 0: Cartesian

  • 1: Cylindrical (circular or elliptical)

  • 2: Spherical (or spheroidal)

  • 3: Toroidal

parse_step_substep(user_input)

Converts (step, substep) to a cumulative index

property pathlib_filename: Path

Return the pathlib.Path version of the filename. This property can not be set.

plot(node_components=None, element_components=None, sel_type_all=True, **kwargs)

Plot result geometry

Parameters:
  • node_components (list, optional) – Accepts either a string or a list strings of node components to plot. For example: ['MY_COMPONENT', 'MY_OTHER_COMPONENT]

  • element_components (list, optional) – Accepts either a string or a list strings of element components to plot. For example: ['MY_COMPONENT', 'MY_OTHER_COMPONENT]

  • sel_type_all (bool, optional) – If node_components is specified, plots those elements containing all nodes of the component. Default True.

  • **kwargs (keyword arguments) – Optional keyword arguments. See help(pyvista.plot).

Returns:

cpos – List of camera position, focal point, and view up.

Return type:

list

Examples

>>> from ansys.mapdl import reader as pymapdl_reader
>>> rst = pymapdl_reader.read_binary('file.rst')
>>> rst.plot()

Plot just the element component ‘ROTOR_SHAFT’

>>> rst.plot(element_components='ROTOR_SHAFT')

Plot two node components >>> rst.plot(node_components=[‘MY_COMPONENT’, ‘MY_OTHER_COMPONENT’])

plot_cylindrical_nodal_stress(rnum, comp=None, show_displacement=False, displacement_factor=1, node_components=None, element_components=None, sel_type_all=True, treat_nan_as_zero=False, **kwargs)

Plot nodal_stress in the cylindrical coordinate system.

Parameters:
  • rnum (int) – Result number

  • comp (str, optional) – Stress component to display. Available options: - "R" - "THETA" - "Z" - "RTHETA" - "THETAZ" - "RZ"

  • show_displacement (bool, optional) – Deforms mesh according to the result.

  • displacement_factor (float, optional) – Increases or decreases displacement by a factor.

  • node_components (list, optional) – Accepts either a string or a list strings of node components to plot. For example: ['MY_COMPONENT', 'MY_OTHER_COMPONENT]

  • element_components (list, optional) – Accepts either a string or a list strings of element components to plot. For example: ['MY_COMPONENT', 'MY_OTHER_COMPONENT]

  • sel_type_all (bool, optional) – If node_components is specified, plots those elements containing all nodes of the component. Default True.

  • treat_nan_as_zero (bool, optional) – Treat NAN values (i.e. stresses at midside nodes) as zero when plotting.

  • **kwargs (keyword arguments) – Optional keyword arguments. See help(pyvista.plot)

Examples

Plot nodal stress in the radial direction.

>>> from ansys.mapdl import reader as pymapdl_reader
>>> result = pymapdl_reader.read_binary('file.rst')
>>> result.plot_cylindrical_nodal_stress(0, 'R')
plot_element_result(rnum, result_type, item_index, in_element_coord_sys=False, **kwargs)

Plot an element result.

Parameters:
  • rnum (int) – Result number.

  • result_type (str) –

    Element data type to retrieve.

    • EMS: misc. data

    • ENF: nodal forces

    • ENS: nodal stresses

    • ENG: volume and energies

    • EGR: nodal gradients

    • EEL: elastic strains

    • EPL: plastic strains

    • ECR: creep strains

    • ETH: thermal strains

    • EUL: euler angles

    • EFX: nodal fluxes

    • ELF: local forces

    • EMN: misc. non-sum values

    • ECD: element current densities

    • ENL: nodal nonlinear data

    • EHC: calculated heat generations

    • EPT: element temperatures

    • ESF: element surface stresses

    • EDI: diffusion strains

    • ETB: ETABLE items

    • ECT: contact data

    • EXY: integration point locations

    • EBA: back stresses

    • ESV: state variables

    • MNL: material nonlinear record

  • item_index (int) – Index of the data item for each node within the element.

  • in_element_coord_sys (bool, optional) – Returns the results in the element coordinate system. Default False and will return the results in the global coordinate system.

Returns:

  • nnum (np.ndarray) – ANSYS node numbers

  • result (np.ndarray) – Array of result data

plot_nodal_displacement(rnum, comp=None, show_displacement=False, displacement_factor=1.0, node_components=None, element_components=None, sel_type_all=True, treat_nan_as_zero=False, **kwargs)

Plots the nodal solution.

Parameters:
  • rnum (int or list) – Cumulative result number with zero based indexing, or a list containing (step, substep) of the requested result.

  • comp (str, optional) – Display component to display. Options are 'X', 'Y', 'Z', 'NORM', or an available degree of freedom. Result may also include other degrees of freedom, check rst.result_dof for available degrees of freedoms for a given result. Defaults to "NORM" for a structural displacement result, and "TEMP" for a thermal result.

  • show_displacement (bool, optional) – Deforms mesh according to the result.

  • displacement_factor (float, optional) – Increases or decreases displacement by a factor.

  • node_components (list, optional) – Accepts either a string or a list strings of node components to plot. For example: ['MY_COMPONENT', 'MY_OTHER_COMPONENT]

  • element_components (list, optional) – Accepts either a string or a list strings of element components to plot. For example: ['MY_COMPONENT', 'MY_OTHER_COMPONENT]

  • sel_type_all (bool, optional) – If node_components is specified, plots those elements containing all nodes of the component. Default True.

  • treat_nan_as_zero (bool, optional) – Treat NAN values (i.e. stresses at midside nodes) as zero when plotting.

  • **kwargs (keyword arguments) – Optional keyword arguments. See help(pyvista.plot).

Returns:

cpos – Camera position from vtk render window.

Return type:

list

Examples

Plot the nodal solution result 0 of verification manual example

>>> from ansys.mapdl import reader as pymapdl_reader
>>> from ansys.mapdl.reader import examples
>>> result = examples.download_verification_result(33)
>>> result.plot_nodal_solution(0)

Plot with a white background and showing edges

>>> result.plot_nodal_solution(0, background='w', show_edges=True)
plot_nodal_elastic_strain(rnum, comp, scalar_bar_args={'title': 'EQV Nodal Elastic Strain'}, show_displacement=False, displacement_factor=1, node_components=None, element_components=None, sel_type_all=True, treat_nan_as_zero=False, **kwargs)

Plot nodal elastic strain.

Parameters:
  • rnum (int) – Result number

  • comp (str, optional) – Elastic strain component to display. Available options: - "X" - "Y" - "Z" - "XY" - "YZ" - "XZ" - "EQV"

  • show_displacement (bool, optional) – Deforms mesh according to the result.

  • displacement_factor (float, optional) – Increases or decreases displacement by a factor.

  • node_components (list, optional) – Accepts either a string or a list strings of node components to plot. For example: ['MY_COMPONENT', 'MY_OTHER_COMPONENT']

  • element_components (list, optional) – Accepts either a string or a list strings of element components to plot. For example: ['MY_COMPONENT', 'MY_OTHER_COMPONENT']

  • sel_type_all (bool, optional) – If node_components is specified, plots those elements containing all nodes of the component. Default True.

  • treat_nan_as_zero (bool, optional) – Treat NAN values (i.e. stresses at midside nodes) as zero when plotting.

  • **kwargs (keyword arguments) – Optional keyword arguments. See help(pyvista.plot)

Examples

Plot nodal elastic strain for a static pontoon model

>>> from ansys.mapdl import reader as pymapdl_reader
>>> from ansys.mapdl.reader import examples
>>> result = examples.download_pontoon()
>>> result.plot_nodal_elastic_strain(0)
plot_nodal_plastic_strain(rnum, comp, scalar_bar_args={'title': 'Nodal Plastic Strain'}, show_displacement=False, displacement_factor=1, node_components=None, element_components=None, sel_type_all=True, treat_nan_as_zero=False, **kwargs)

Plot nodal component plastic strain.

Parameters:
  • rnum (int or list) – Cumulative result number with zero based indexing, or a list containing (step, substep) of the requested result.

  • comp (str, optional) – Plastic strain component to display. Available options: - "X" - "Y" - "Z" - "XY" - "YZ" - "XZ" - "EQV"

  • show_displacement (bool, optional) – Deforms mesh according to the result.

  • displacement_factor (float, optional) – Increases or decreases displacement by a factor.

  • node_components (list, optional) – Accepts either a string or a list strings of node components to plot. For example: ['MY_COMPONENT', 'MY_OTHER_COMPONENT]

  • element_components (list, optional) – Accepts either a string or a list strings of element components to plot. For example: ['MY_COMPONENT', 'MY_OTHER_COMPONENT]

  • sel_type_all (bool, optional) – If node_components is specified, plots those elements containing all nodes of the component. Default True.

  • treat_nan_as_zero (bool, optional) – Treat NAN values (i.e. stresses at midside nodes) as zero when plotting.

  • **kwargs (keyword arguments) – Optional keyword arguments. See help(pyvista.plot).

Examples

Plot plastic strain for a static pontoon model

>>> from ansys.mapdl import reader as pymapdl_reader
>>> from ansys.mapdl.reader import examples
>>> result = examples.download_pontoon()
>>> result.plot_nodal_plastic_strain(0)
plot_nodal_solution(rnum, comp=None, show_displacement=False, displacement_factor=1.0, node_components=None, element_components=None, sel_type_all=True, treat_nan_as_zero=False, **kwargs)

Plots the nodal solution.

Parameters:
  • rnum (int or list) – Cumulative result number with zero based indexing, or a list containing (step, substep) of the requested result.

  • comp (str, optional) – Display component to display. Options are 'X', 'Y', 'Z', 'NORM', or an available degree of freedom. Result may also include other degrees of freedom, check rst.result_dof for available degrees of freedoms for a given result. Defaults to "NORM" for a structural displacement result, and "TEMP" for a thermal result.

  • show_displacement (bool, optional) – Deforms mesh according to the result.

  • displacement_factor (float, optional) – Increases or decreases displacement by a factor.

  • node_components (list, optional) – Accepts either a string or a list strings of node components to plot. For example: ['MY_COMPONENT', 'MY_OTHER_COMPONENT]

  • element_components (list, optional) – Accepts either a string or a list strings of element components to plot. For example: ['MY_COMPONENT', 'MY_OTHER_COMPONENT]

  • sel_type_all (bool, optional) – If node_components is specified, plots those elements containing all nodes of the component. Default True.

  • treat_nan_as_zero (bool, optional) – Treat NAN values (i.e. stresses at midside nodes) as zero when plotting.

  • **kwargs (keyword arguments) – Optional keyword arguments. See help(pyvista.plot).

Returns:

cpos – Camera position from vtk render window.

Return type:

list

Examples

Plot the nodal solution result 0 of verification manual example

>>> from ansys.mapdl import reader as pymapdl_reader
>>> from ansys.mapdl.reader import examples
>>> result = examples.download_verification_result(33)
>>> result.plot_nodal_solution(0)

Plot with a white background and showing edges

>>> result.plot_nodal_solution(0, background='w', show_edges=True)
plot_nodal_stress(rnum, comp=None, show_displacement=False, displacement_factor=1, node_components=None, element_components=None, sel_type_all=True, treat_nan_as_zero=False, **kwargs)

Plots the stresses at each node in the solution.

Parameters:
  • rnum (int or list) – Cumulative result number with zero based indexing, or a list containing (step, substep) of the requested result.

  • comp (str, optional) – Stress component to display. Available options: - "X" - "Y" - "Z" - "XY" - "YZ" - "XZ"

  • node_components (list, optional) – Accepts either a string or a list strings of node components to plot. For example: ['MY_COMPONENT', 'MY_OTHER_COMPONENT]

  • element_components (list, optional) – Accepts either a string or a list strings of element components to plot. For example: ['MY_COMPONENT', 'MY_OTHER_COMPONENT]

  • sel_type_all (bool, optional) – If node_components is specified, plots those elements containing all nodes of the component. Default True.

  • treat_nan_as_zero (bool, optional) – Treat NAN values (i.e. stresses at midside nodes) as zero when plotting.

  • kwargs (keyword arguments) – Additional keyword arguments. See help(pyvista.plot)

Returns:

cpos – 3 x 3 vtk camera position.

Return type:

list

Examples

Plot the X component nodal stress while showing displacement.

>>> rst.plot_nodal_stress(0, comp='x', show_displacement=True)
plot_nodal_temperature(rnum, show_displacement=False, displacement_factor=1, node_components=None, element_components=None, sel_type_all=True, treat_nan_as_zero=False, **kwargs)

Plot nodal temperature

Parameters:
  • rnum (int) – Result number

  • show_displacement (bool, optional) – Deforms mesh according to the result.

  • displacement_factor (float, optional) – Increases or decreases displacement by a factor.

  • node_components (list, optional) – Accepts either a string or a list strings of node components to plot. For example: ['MY_COMPONENT', 'MY_OTHER_COMPONENT]

  • element_components (list, optional) – Accepts either a string or a list strings of element components to plot. For example: ['MY_COMPONENT', 'MY_OTHER_COMPONENT]

  • sel_type_all (bool, optional) – If node_components is specified, plots those elements containing all nodes of the component. Default True.

  • treat_nan_as_zero (bool, optional) – Treat NAN values (i.e. stresses at midside nodes) as zero when plotting.

  • **kwargs (keyword arguments) – Optional keyword arguments. See help(pyvista.plot)

Examples

Plot temperature of a result.

>>> from ansys.mapdl import reader as pymapdl_reader
>>> result = pymapdl_reader.read_binary('file.rst')
>>> result.plot_nodal_temperature(0)

Plot while showing edges and disabling lighting

>>> result.plot_nodal_temperature(0, show_edges=True, lighting=False)
plot_nodal_thermal_strain(rnum, comp=None, scalar_bar_args={'title': 'Nodal Thermal Strain'}, show_displacement=False, displacement_factor=1, node_components=None, element_components=None, sel_type_all=True, treat_nan_as_zero=False, **kwargs)

Plot nodal component thermal strains.

Equivalent MAPDL command: PLNSOL, EPTH, COMP

Parameters:
  • rnum (int) – Result number

  • comp (str, optional) – Thermal strain component to display. Available options: - "X" - "Y" - "Z" - "XY" - "YZ" - "XZ" - "EQV" - "ESWELL"

  • show_displacement (bool, optional) – Deforms mesh according to the result.

  • displacement_factor (float, optional) – Increases or decreases displacement by a factor.

  • node_components (list, optional) – Accepts either a string or a list strings of node components to plot. For example: ['MY_COMPONENT', 'MY_OTHER_COMPONENT]

  • element_components (list, optional) – Accepts either a string or a list strings of element components to plot. For example: ['MY_COMPONENT', 'MY_OTHER_COMPONENT]

  • sel_type_all (bool, optional) – If node_components is specified, plots those elements containing all nodes of the component. Default True.

  • treat_nan_as_zero (bool, optional) – Treat NAN values (i.e. stresses at midside nodes) as zero when plotting.

  • **kwargs (keyword arguments) – Optional keyword arguments. See help(pyvista.plot)

Examples

Plot thermal strain for result 0 of verification manual example 33.

>>> from ansys.mapdl import reader as pymapdl_reader
>>> from ansys.mapdl.reader import examples
>>> result = examples.download_verification_result(33)
>>> result.plot_nodal_thermal_strain(0)
plot_principal_nodal_stress(rnum, comp=None, show_displacement=False, displacement_factor=1.0, node_components=None, element_components=None, sel_type_all=True, treat_nan_as_zero=False, **kwargs)

Plot the principal stress.

Parameters:
  • rnum (int or list) – Cumulative result number with zero based indexing, or a list containing (step, substep) of the requested result.

  • comp (string) –

    Stress component to plot. S1, S2, S3 principal stresses, SINT stress intensity, and SEQV equivalent stress.

    Stress type must be a string from the following list: ['S1', 'S2', 'S3', 'SINT', 'SEQV']

  • show_displacement (bool, optional) – Deforms mesh according to the result.

  • displacement_factor (float, optional) – Increases or decreases displacement by a factor.

  • node_components (list, optional) – Accepts either a string or a list strings of node components to plot. For example: ['MY_COMPONENT', 'MY_OTHER_COMPONENT]

  • element_components (list, optional) – Accepts either a string or a list strings of element components to plot. For example: ['MY_COMPONENT', 'MY_OTHER_COMPONENT]

  • sel_type_all (bool, optional) – If node_components is specified, plots those elements containing all nodes of the component. Default True.

  • treat_nan_as_zero (bool, optional) – Treat NAN values (i.e. stresses at midside nodes) as zero when plotting.

  • kwargs (keyword arguments) – Additional keyword arguments. See help(pyvista.plot)

Returns:

cpos – VTK camera position.

Return type:

list

Examples

Plot the equivalent von mises stress.

>>> rst.plot_principal_nodal_stress(0, comp='SEQV')
principal_nodal_stress(rnum, nodes=None)

Computes the principal component stresses for each node in the solution.

Parameters:

rnum (int or list) – Cumulative result number with zero based indexing, or a list containing (step, substep) of the requested result.

Returns:

  • nodenum (numpy.ndarray) – Node numbers of the result.

  • pstress (numpy.ndarray) – Principal stresses, stress intensity, and equivalent stress. [sigma1, sigma2, sigma3, sint, seqv]

Examples

Load the principal nodal stress for the first solution.

>>> from ansys.mapdl import reader as pymapdl_reader
>>> rst = pymapdl_reader.read_binary('file.rst')
>>> nnum, stress = rst.principal_nodal_stress(0)

Notes

ANSYS equivalent of: PRNSOL, S, PRIN

which returns: S1, S2, S3 principal stresses, SINT stress intensity, and SEQV equivalent stress.

Internal averaging algorithm averages the component values from the elements at a common node and then calculates the principal using the averaged value.

See the MAPDL AVPRIN command for more details. ansys-mapdl-reader uses the default AVPRIN, 0 option.

result_dof(rnum)

Return a list of degrees of freedom for a given result number.

Parameters:

rnum (int or list) – Cumulative result number with zero based indexing, or a list containing (step, substep) of the requested result.

Returns:

dof – List of degrees of freedom.

Return type:

list

Examples

>>> rst.result_dof(0)
['UX', 'UY', 'UZ']
save_as_vtk(filename, rsets=None, result_types=['ENS'], progress_bar=True)

Writes results to a vtk readable file.

Nodal results will always be written.

The file extension will select the type of writer to use. '.vtk' will use the legacy writer, while '.vtu' will select the VTK XML writer.

Parameters:
  • filename (str, pathlib.Path) – Filename of grid to be written. The file extension will select the type of writer to use. '.vtk' will use the legacy writer, while '.vtu' will select the VTK XML writer.

  • rsets (collections.Iterable) – List of result sets to write. For example range(3) or [0].

  • result_types (list) –

    Result type to write. For example ['ENF', 'ENS'] List of some or all of the following:

    • EMS: misc. data

    • ENF: nodal forces

    • ENS: nodal stresses

    • ENG: volume and energies

    • EGR: nodal gradients

    • EEL: elastic strains

    • EPL: plastic strains

    • ECR: creep strains

    • ETH: thermal strains

    • EUL: euler angles

    • EFX: nodal fluxes

    • ELF: local forces

    • EMN: misc. non-sum values

    • ECD: element current densities

    • ENL: nodal nonlinear data

    • EHC: calculated heat generations

    • EPT: element temperatures

    • ESF: element surface stresses

    • EDI: diffusion strains

    • ETB: ETABLE items

    • ECT: contact data

    • EXY: integration point locations

    • EBA: back stresses

    • ESV: state variables

    • MNL: material nonlinear record

  • progress_bar (bool, optional) – Display a progress bar using tqdm.

Notes

Binary files write much faster than ASCII, but binary files written on one system may not be readable on other systems. Binary can only be selected for the legacy writer.

Examples

Write nodal results as a binary vtk file.

>>> rst.save_as_vtk('results.vtk')

Write using the xml writer

>>> rst.save_as_vtk('results.vtu')

Write only nodal and elastic strain for the first result

>>> rst.save_as_vtk('results.vtk', [0], ['EEL', 'EPL'])

Write only nodal results (i.e. displacements) for the first result.

>>> rst.save_as_vtk('results.vtk', [0], [])
property section_data

The section data from the result file

Returns:

section_data – Dictionary of the section data with the section numbers as keys.

Return type:

dict

Notes

There is limited documentation on how ANSYS stores the sections within a result file, and as such it may be difficult to interpret the section data for a given model.

solution_info(rnum)

Return an informative dictionary of solution data for a result.

Parameters:

rnum (int or list) – Cumulative result number with zero based indexing, or a list containing (step, substep) of the requested result.

Returns:

header – Double precision solution header data.

Return type:

dict

Examples

Extract the solution info from a sample example result file.

>>> from ansys.mapdl.reader import examples
>>> rst = examples.download_pontoon()
>>> rst.solution_info(0)
{'cgcent': [],
 'fatjack': [],
 'timfrq': 44.85185724963714,
 'lfacto': 1.0,
 'lfactn': 1.0,
 'cptime': 3586.4873046875,
 'tref': 71.6,
 'tunif': 71.6,
 'tbulk': 293.0,
 'volbase': 0.0,
 'tstep': 0.0,
 '__unused': 0.0,
 'accel_x': 0.0,
 'accel_y': 0.0,
 'accel_z': 0.0,
 'omega_v_x': 0.0,
 'omega_v_y': 0.0,
 'omega_v_z': 0.0,
 'omega_a_x': 0.0,
 'omega_a_y': 0.0,
 'omega_a_z': 0.0,
 'omegacg_v_x': 0.0,
 'omegacg_v_y': 0.0,
 'omegacg_v_z': 0.0,
 'omegacg_a_x': 0.0,
 'omegacg_a_y': 0.0,
 'omegacg_a_z': 0.0,
 'dval1': 0.0,
 'pCnvVal': 0.0}

Notes

The keys of the solution header are described below:

  • timfrqTime value (or frequency value, for a modal or

    harmonic analysis)

  • lfactothe “old” load factor (used in ramping a load

    between old and new values)

  • lfactn : The “new” load factor

  • cptime : Elapsed CPU time (in seconds)

  • tref : The reference temperature

  • tunif : The uniform temperature

  • tbulk : Bulk temp for FLOTRAN film coefs.

  • VolBase : Initial total volume for VOF

  • tstep : Time Step size for FLOTRAN analysis

  • 0.0 : Position not used

  • accel : Linear acceleration terms

  • omegaAngular velocity (first 3 terms) and angular acceleration

    (second 3 terms)

  • omegacgAngular velocity (first 3 terms) and angular

    acceleration (second 3 terms) these velocity/acceleration terms are computed about the center of gravity

  • cgcent : (X,y,z) location of center of gravity

  • fatjack : Fatjack ocean wave data (wave height and period)

  • dval1If pmeth=0: FATJACK ocean wave direction

    if pmeth=1: p-method convergence values

  • pCnvVal : P-method convergence values

text_result_table(rnum)

Returns a text result table for plotting

property version

The version of MAPDL used to generate this result file.

Examples

>>> rst.version
20.1
write_tables(filename: str | Path)

Write binary tables to ASCII. Assumes int32

Parameters:

filename (str, pathlib.Path) – Filename to write the tables to.

Examples

>>> rst.write_tables('tables.txt')