Cyclic Result Class#

class ansys.mapdl.reader.cyclic_reader.CyclicResult(filename)

Adds cyclic functionality to the result class

animate_nodal_displacement(rnum, comp='norm', displacement_factor=0.1, n_frames=180, add_text=True, loop=True, movie_filename=None, **kwargs)

Animate nodal solution. Assumes nodal solution is a displacement array from a modal solution.

rnumint or list

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

compstr, optional

Component of displacement to display. Options are ‘x’, ‘y’, ‘z’, or ‘norm’, which correspond to the x , y, z, or the normalized direction (x**2 + y**2 + z**2)**0.5

displacement_factorfloat, optional

Increases or decreases displacement by a factor.

n_framesint, optional

Number of “frames” between each full cycle.

show_phasebool, optional

Shows the phase at each frame.

add_textbool, optional

Includes result information at the bottom left-hand corner of the plot.

interpolate_before_mapbool, optional

Leaving this at default generally results in a better plot.

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.

kwargsoptional keyword arguments, optional

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

animate_nodal_solution(rnum, comp='norm', displacement_factor=0.1, n_frames=180, add_text=True, loop=True, movie_filename=None, **kwargs)

Animate nodal solution. Assumes nodal solution is a displacement array from a modal solution.

rnumint or list

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

compstr, optional

Component of displacement to display. Options are ‘x’, ‘y’, ‘z’, or ‘norm’, which correspond to the x , y, z, or the normalized direction (x**2 + y**2 + z**2)**0.5

displacement_factorfloat, optional

Increases or decreases displacement by a factor.

n_framesint, optional

Number of “frames” between each full cycle.

show_phasebool, optional

Shows the phase at each frame.

add_textbool, optional

Includes result information at the bottom left-hand corner of the plot.

interpolate_before_mapbool, optional

Leaving this at default generally results in a better plot.

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.

kwargsoptional keyword arguments, optional

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

property full_rotor

UnstructuredGrid of the full replicated rotor

harmonic_index_to_cumulative(hindex, mode)

Converts a harmonic index and a 0 index mode number to a cumulative result index.

Harmonic indices are stored as positive and negative pairs for modes other than 0 and N/nsectors.

Parameters:
  • hindex (int) – Harmonic index. Must be less than or equal to nsectors/2. May be positive or negative

  • mode (int) – Mode number. 0 based indexing. Access mode pairs by with a negative/positive harmonic index.

Returns:

rnum – Cumulative index number. Zero based indexing.

Return type:

int

property harmonic_indices

Harmonic indices of the result file.

Harmonic index is simply the Nodal Diameter of the mode. This is defined as the number of complete sine waves that pass through the circumference.

Examples

>>> rst.harmonic_indices
array([ 0,  0,  0,  0,  0,  0, -1,  1, -1,  1,  1, -1,
       -2,  2, -2,  2, -2,  2,  3,  3,  3,  3,  3,  3], dtype=int32)
property mode_table

Unique modes for cyclic results

nodal_displacement(rnum, phase=0, full_rotor=False, as_complex=False)

Return the DOF solution for each node in the global cartesian coordinate system.

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

  • phase (float, optional) – Phase to rotate sector result in radians.

  • full_rotor (bool, optional) – Expands the single sector solution for the full rotor. Sectors are rotated counter-clockwise about the axis of rotation. Default False.

  • as_complex (bool, optional) – Returns result as a complex number, otherwise as the real part rotated by phase. Default False.

Returns:

  • nnum (numpy.ndarray) – Node numbers of master sector.

  • result (numpy.ndarray) – Result is (nnod x numdof), nnod is the number of nodes in a sector and numdof is the number of degrees of freedom. When full_rotor is True the array will be (nSector x nnod x numdof).

Examples

Visualize the 1st nodal diameter mode.

>>> from ansys.mapdl import reader as pymapdl_reader
>>> from ansys.mapdl.reader import examples
>>> result = examples.download_academic_rotor()
>>> result.nodal_solution((2, 1))

Same result but uses Python (zero based) cumulative indexing

>>> result.nodal_solution(2)

Notes

Somewhere between v15.0 and v18.2 ANSYS stopped writing the duplicate sector to the result file and instead records results in pairs (i.e. harmonic index 1, -1).

nodal_elastic_strain(rnum, phase=0, as_complex=False, full_rotor=False)

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.

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

  • phase (float) – Phase adjustment of the stress in radians.

  • as_complex (bool, optional) – Reports stress as a complex result. Real and imaginary stresses correspond to the stress of the main and repeated sector. Stress can be “rotated” using the phase parameter.

  • full_rotor (bool, optional) – Expands the results to the full rotor when True. Default False.

Returns:

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

  • elastic_strain (numpy.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.

>>> nnum, elastic_strain = rst.nodal_stress(0)

Notes

Nodes without a strain will be NAN.

nodal_plastic_strain(rnum, phase=0, as_complex=False, full_rotor=False)

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

Plastic strains can be can be nodal values extrapolated from the integration points or 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.

  • phase (float) – Phase adjustment of the stress in degrees.

  • as_complex (bool, optional) – Reports stress as a complex result. Real and imaginary stresses correspond to the stress of the main and repeated sector. Stress can be “rotated” using the phase parameter.

  • full_rotor (bool, optional) – Expands the results to the full rotor when True. Default False.

Returns:

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

  • plastic_strain (numpy.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 result.

>>> nnum, plastic_strain = rst.nodal_stress(0)

Notes

Nodes without a strain will be NAN.

nodal_solution(rnum, phase=0, full_rotor=False, as_complex=False)

Return the DOF solution for each node in the global cartesian coordinate system.

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

  • phase (float, optional) – Phase to rotate sector result in radians.

  • full_rotor (bool, optional) – Expands the single sector solution for the full rotor. Sectors are rotated counter-clockwise about the axis of rotation. Default False.

  • as_complex (bool, optional) – Returns result as a complex number, otherwise as the real part rotated by phase. Default False.

Returns:

  • nnum (numpy.ndarray) – Node numbers of master sector.

  • result (numpy.ndarray) – Result is (nnod x numdof), nnod is the number of nodes in a sector and numdof is the number of degrees of freedom. When full_rotor is True the array will be (nSector x nnod x numdof).

Examples

Visualize the 1st nodal diameter mode.

>>> from ansys.mapdl import reader as pymapdl_reader
>>> from ansys.mapdl.reader import examples
>>> result = examples.download_academic_rotor()
>>> result.nodal_solution((2, 1))

Same result but uses Python (zero based) cumulative indexing

>>> result.nodal_solution(2)

Notes

Somewhere between v15.0 and v18.2 ANSYS stopped writing the duplicate sector to the result file and instead records results in pairs (i.e. harmonic index 1, -1).

nodal_stress(rnum, phase=0, as_complex=False, full_rotor=False)

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.

  • phase (float) – Phase adjustment of the stress in degrees.

  • as_complex (bool, optional) – Reports stress as a complex result. Real and imaginary stresses correspond to the stress of the main and repeated sector. Stress can be “rotated” using the phase parameter.

  • full_rotor (bool, optional) – Expands the results to the full rotor when True. Default False.

Returns:

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

  • stress (numpy.ndarray) – Stresses at Sx Sy Sz Sxy Syz Sxz averaged at each corner node. For the corresponding node numbers, see where result is the result object.

Examples

>>> nnum, stress = rst.nodal_stress(0)

Notes

Nodes without a stress value will be NAN.

nodal_temperature(rnum, full_rotor=False)

Retrieves the temperature for each node in the solution.

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

Equivalent MAPDL commands: PRNSOL, TEMP PRNSOL, BFE

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

  • full_rotor (bool, optional) – Expand sector solution to full rotor.

Returns:

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

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

Examples

>>> nnum, stress = rst.nodal_temperature(0)
nodal_thermal_strain(rnum, phase=0, as_complex=False, full_rotor=False)

Nodal component thermal strains. 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.

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

  • phase (float) – Phase adjustment of the stress in degrees.

  • as_complex (bool, optional) – Reports stress as a complex result. Real and imaginary stresses correspond to the stress of the main and repeated sector. Stress can be “rotated” using the phase parameter.

  • full_rotor (bool, optional) – Expands the results to the full rotor when True. Default False.

Returns:

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

  • 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 result.

>>> nnum, thermal_strain = rst.nodal_thermal_strain(0)

Notes

Nodes without a strain will be NAN.

plot(**kwargs)

Plot the full rotor geometry.

Parameters:

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

Returns:

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

Return type:

list

Examples

>>> from ansys.mapdl.reader import examples
>>> rst = examples.download_academic_rotor()
>>> rst.plot()

Save a screenshot of the rotor

>>> rst.plot(screenshot='rotor.png')
plot_nodal_elastic_strain(rnum, comp=None, phase=0, full_rotor=True, show_displacement=False, displacement_factor=1, node_components=None, element_components=None, sel_type_all=True, add_text=True, overlay_wireframe=False, treat_nan_as_zero=False, **kwargs)

Plot nodal elastic 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) – Elastic strain component to display. Available options: - "X" - "Y" - "Z" - "XY" - "YZ" - "XZ"

  • phase (float, optional) – Phase angle of the modal result in radians. Only valid when full_rotor is True. Default 0

  • full_rotor (bool, optional) – Expand the sector solution to the full rotor.

  • 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.

Returns:

cpos – Camera position from vtk render window.

Return type:

list

Examples

Plot nodal elastic strain for an academic rotor.

>>> result.plot_nodal_elastic_strain(0, 'X')
plot_nodal_plastic_strain(rnum, comp=None, phase=0, full_rotor=True, show_displacement=False, displacement_factor=1, node_components=None, element_components=None, sel_type_all=True, add_text=True, overlay_wireframe=False, treat_nan_as_zero=False, **kwargs)

Plot nodal 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"

  • phase (float, optional) – Phase angle of the modal result in radians. Only valid when full_rotor is True. Default 0

  • full_rotor (bool, optional) – Expand the sector solution to the full rotor.

  • 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.

Returns:

cpos – Camera position from vtk render window.

Return type:

list

Examples

Plot nodal plastic strain for an academic rotor

>>> result.plot_nodal_plastic_strain(0)
plot_nodal_solution(rnum, comp='norm', phase=0, full_rotor=True, show_displacement=False, displacement_factor=1.0, node_components=None, element_components=None, overlay_wireframe=False, add_text=True, sel_type_all=True, treat_nan_as_zero=False, **kwargs)

Plot the nodal solution (generally displacement).

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’, and ‘norm’, corresponding to the x direction, y direction, z direction, and the normalized direction: (x**2 + y**2 + z**2)**0.5

  • full_rotor (bool, optional) – Expand sector solution to full rotor.

  • phase (float, optional) – Phase angle of the modal result in radians. Only valid when full_rotor is True. Default 0

  • 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.

Returns:

cpos – Camera position from vtk render window.

Return type:

list

Examples

Plot the displacement of the first cyclic result.

>>> result.plot_nodal_solution(0)
plot_nodal_stress(rnum, comp=None, phase=0, full_rotor=True, show_displacement=False, displacement_factor=1, node_components=None, element_components=None, overlay_wireframe=False, add_text=True, sel_type_all=True, treat_nan_as_zero=False, **kwargs)

Plot nodal stress of a given component

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"

  • phase (float, optional) – Phase angle of the modal result in radians. Only valid when full_rotor is True. Default 0

  • full_rotor (bool, optional) – Expand the sector solution to the full rotor.

  • 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.

Returns:

cpos – Camera position from vtk render window.

Return type:

list

Examples

Plot the "Z" nodal stress of the first cyclic result.

>>> result.plot_nodal_stress(0, comp="Z")
plot_nodal_temperature(rnum, phase=0, full_rotor=True, show_displacement=False, displacement_factor=1.0, node_components=None, overlay_wireframe=False, add_text=True, element_components=None, sel_type_all=True, treat_nan_as_zero=False, **kwargs)

Plot the nodal temperature.

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

  • full_rotor (bool, optional) – Expand the sector solution and plot the full rotor.

  • phase (float, optional) – Phase angle of the modal result in radians. Only valid when full_rotor is True. Default 0

  • 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.

Returns:

cpos – Camera position from vtk render window.

Return type:

list

Examples

Plot the nodal temperature of a rotor for the first result.

>>> result.plot_nodal_temperature(0)
plot_nodal_thermal_strain(rnum, comp=None, phase=0, full_rotor=True, show_displacement=False, displacement_factor=1, node_components=None, element_components=None, sel_type_all=True, add_text=True, overlay_wireframe=False, treat_nan_as_zero=False, **kwargs)

Plot nodal thermal 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) – Thermal strain component to display. Available options: - "X" - "Y" - "Z" - "XY" - "YZ" - "XZ" - "EQV" - "ESWELL" (element swelling strain)

  • phase (float, optional) – Phase angle of the modal result in radians. Only valid when full_rotor is True. Default 0.

  • full_rotor (bool, optional) – Expand the sector solution to the full rotor.

  • 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.

Returns:

cpos – Camera position from vtk render window.

Return type:

list

Examples

Plot nodal thermal strain for an academic rotor

>>> rst.plot_nodal_thermal_strain(0)
plot_principal_nodal_stress(rnum, comp=None, phase=0, full_rotor=True, show_displacement=False, displacement_factor=1, node_components=None, element_components=None, sel_type_all=True, add_text=True, overlay_wireframe=False, treat_nan_as_zero=False, **kwargs)

Plot the nodal 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']

  • phase (float, optional) – Phase angle of the modal result in radians. Only valid when full_rotor is True. Default 0

  • full_rotor (bool, optional) – Expand sector solution to full rotor.

  • 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]

  • 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 von Mises stress of the first cyclic result.

>>> result.plot_principal_nodal_stress(0, comp='SEQV')
plot_sectors(**kwargs)

Plot the full rotor and individually color the sectors.

Parameters:

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

Examples

>>> from ansys.mapdl.reader import examples
>>> rst = examples.download_academic_rotor()
>>> rst.plot_sectors()

Save a screenshot of the sectors

>>> rst.plot_sectors(screenshot='sectors.png')
principal_nodal_stress(rnum, phase=0, as_complex=False, full_rotor=False)

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.

  • phase (float) – Phase adjustment of the stress in degrees.

  • as_complex (bool, optional) – Returns result as a complex number, otherwise as the real part rotated by phase. Default False.

  • full_rotor (bool, optional) – Expand sector solution to full rotor.

Returns:

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

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

Notes

ANSYS equivalent of: PRNSOL, S, PRIN

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