DPF-Post overview#

This example provides an overview of how you use DPF-Post.

Perform required imports#

Perform required imports. # This example uses a supplied file that you can get by importing the DPF examples package.

from ansys.dpf import post
from ansys.dpf.post import examples

Get Solution object#

Get the Solution object that allows access to the result. The Solution object must be instantiated with the path for the result file. For example, "C:/Users/user/my_result.rst" on Windows or "/home/user/my_result.rst" on Linux.

solution = post.load_solution(examples.multishells_rst)

Get mesh and time frequency support#

Get the mesh and time frequency support. The mesh is the support of the model. The time frequency support is the time/frequency representation of the model.

mesh = solution.mesh
time_freq_support = solution.time_freq_support

Get Result object#

Get a Result object from the Solution object. The Result object can be a stress, plastic strain, elastic strain, temperature, or displacement.

post.print_available_keywords()
stress = solution.stress(location=post.locations.nodal, time_scoping=[1])

# Both location and ``time_scoping`` are available in the definition of
# the stress result.

stress.definition.location
stress.definition.time_scoping

print(stress)
element_scoping: list, int or dpf.core.Scoping
grouping: str. Use post.grouping.(...) as helper.
location: str. Use post.locations.(...) as helper.
mapdl_grouping: int. Write 186 to get mapdl_elements solid_186.
named_selection: str. Name of named_selection.
node_scoping: list, int or dpf.core.Scoping
path: DpfPath object that
            contains a list of coordinates,
            e.g. [[0.1, 0.0, 0.0],
            [0.0, 0.1, 0.0]].
set: int
time: float
time_scoping: list, int or dpf.core.Scoping

Stress Tensor object.

Object properties:
 - location   : Nodal
 - time_scoping : [1]

Compute data#

Compute data.

SX subresult

This code gets the subresult SX, which is the stress tensor in the XX direction.

sx = stress.xx
sx.num_fields
sx_field = sx[0]
sx_data = sx.get_data_at_field(0)
print("Length of the data:", len(sx_data))
print()
print("Maximum Stress Field:\n", sx.max)
print()
print("Maximum data at stress field:", sx.max_data)
print("Maximum SX at Field 0:", sx.get_max_data_at_field(0))
Length of the data: 6854

Maximum Stress Field:
 DPF stress_1.s0 Field
  Location: Nodal
  Unit: Pa
  2 entities
  Data:1 components and 2 elementary data


Maximum data at stress field: [1.e-323 4.e-323]
Maximum SX at Field 0: 4.6755861317363e-310

Stress tensor result

This code gets the minimum and maximum stresses at a field for all directions (XX, XY, XZ, XY, YZ, and XZ.

s = stress.tensor
s_field = s[0]
s_data = sx.get_data_at_field(0)
print("Length of the data:", len(s_data))
print()
print("Maximum stress field:\n", s.max)
print()
print("Maximum data at stress field:", s.max_data)
print("Maximum stress tensors at field 0:\n", s.get_max_data_at_field(0))

print("Minimum stress field:\n", s.min)
print()
print("Minimum data at stress field:", s.min_data)
print("Minimum stress tensors at field 0:\n", s.get_min_data_at_field(0))
Length of the data: 6854

Maximum stress field:
 DPF stress_1.s Field
  Location: Nodal
  Unit: Pa
  2 entities
  Data:6 components and 2 elementary data


Maximum data at stress field: [[4.67558662e-310 8.74460905e+011 4.95394439e+011 6.01889079e+011
  1.10325826e+011 1.85580244e+011]
 [1.53671424e+013 4.21781549e+008 3.78202198e+012 2.07950475e+011
  1.57995981e+011 1.09972131e+012]]
Maximum stress tensors at field 0:
 [4.67558623e-310 8.74460905e+011 4.95394439e+011 6.01889079e+011
 1.10325826e+011 1.85580244e+011]
Minimum stress field:
 DPF stress_1.s Field
  Location: Nodal
  Unit: Pa
  2 entities
  Data:6 components and 2 elementary data


Minimum data at stress field: [[ 4.67558643e-310 -7.35604867e+011 -2.41200931e+011 -2.98145939e+011
  -2.42143056e+011 -3.09138563e+011]
 [-1.49601458e+013 -2.63695614e+008 -3.77945626e+012 -3.35432675e+011
  -1.57190152e+011 -9.66123233e+011]]
Minimum stress tensors at field 0:
 [ 4.67558621e-310 -7.35604867e+011 -2.41200931e+011 -2.98145939e+011
 -2.42143056e+011 -3.09138563e+011]

Plot result#

Plot a result by using the plot_contour() method.

s.plot_contour()
00 overview example

Total running time of the script: ( 0 minutes 3.663 seconds)

Gallery generated by Sphinx-Gallery