ANSYS DPF-POST Use result keywords

This tutorial shows how to get more precise result with keywords while calling a result from a solution object.

Get started

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

Get the solution object

solution = post.load_solution(examples.multishells_rst)

Get the keyword list

post.print_available_keywords()

Out:

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
set: int
time: float
time_scoping: list, int or dpf.core.Scoping

Use a scoping on result

# default location is nodal
displacement_result = solution.displacement(location=post.locations.nodal,
                                            node_scoping=[1, 2, 3])
displacement = displacement_result.vector

displacement.get_data_at_field(0)

stress_with_elem_scop_result = solution.stress(location=post.locations.elemental_nodal,
                                               element_scoping=[1])
stress_with_elem_scop = stress_with_elem_scop_result.tensor

stress_with_elem_scop.get_data_at_field(0)

Out:

array([[-1.89351567e+10, -1.76835359e+10, -1.23315384e+10,
         1.27527844e+10,  5.75103130e+09,  4.30928026e+09],
       [ 2.26888166e+09, -1.98936699e+10, -4.28985472e+09,
         3.73483930e+10,  1.28815250e+07,  2.29405491e+09],
       [ 4.62267494e+09,  4.15775621e+10,  1.28377395e+10,
         1.36264980e+10,  5.61091738e+09,  4.14261606e+09],
       [ 3.07029586e+10,  6.01620111e+10,  9.52341402e+09,
         2.26091377e+10, -1.73616087e+10, -4.64480973e+09],
       [ 3.09432279e+10, -2.77392410e+09, -6.13098650e+09,
         9.00784538e+09,  3.47990848e+08, -2.41304392e+10],
       [ 2.80970793e+10,  5.10227200e+09,  4.87711840e+08,
         1.04294881e+10,  1.77319514e+09, -3.26250573e+09],
       [-3.35771187e+09, -7.58900634e+09, -5.19623475e+09,
        -9.62379008e+08,  7.06462080e+07, -8.84417984e+08],
       [-1.66533110e+10, -5.39330662e+09, -1.18382500e+10,
        -3.91451443e+09,  7.81984448e+08,  1.12681376e+08]])

Use a named selection on result

stress_on_ns_result = solution.stress(location=post.locations.elemental_nodal,
                                      named_selection="SELECTION")
stress_on_ns = stress_on_ns_result.tensor
stress_on_ns.num_fields

len(stress_on_ns[0])

Out:

5040

Get a subresult

disp_x = displacement_result.x

stress_yz = stress_with_elem_scop_result.yz

stress_principal_1 = stress_on_ns_result.principal_3
stress_principal_1

Out:

<ansys.dpf.post.result_data.ResultData object at 0x000001D5369C8880>

Filter on a time / time_scoping / a set

print(solution.time_freq_support)

stress_on_time_1s_result = solution.stress(time=1.)
stress_on_time_1s = stress_on_time_1s_result.tensor

displacement_on_set_1_result = solution.displacement(set=1)
displacement_on_set_1 = displacement_on_set_1_result.vector

elastic_strain_with_time_scoping_result = solution.elastic_strain(time_scoping=[1, 3])
elastic_strain_with_time_scoping = elastic_strain_with_time_scoping_result.tensor
elastic_strain_with_time_scoping

Out:

DPF  Time/Freq Support:
  Number of sets: 1
Cumulative     Time (s)       LoadStep       Substep
1              1.000000       1              1


<ansys.dpf.post.result_data.ResultData object at 0x000001D5379B4F70>

Make a grouping

displacement_result = solution.displacement(grouping=post.grouping.by_el_shape)
displacement_by_el_shape = displacement_result.vector

# filter only MAPDL elements of type solid 186
stress_result = solution.stress(mapdl_grouping=186)
stress_on_solid_186 = stress_result.tensor
stress_on_solid_186

Out:

<ansys.dpf.post.result_data.ResultData object at 0x000001D5379DB1F0>

Manipulate the result object and change its definition

print(stress_on_ns_result)
print(stress_on_ns_result.definition.location)

stress_on_ns_result.definition.location = post.locations.elemental
stress_on_ns_result.definition.time = 1.
stress_on_ns_elemental = stress_on_ns_result.tensor

print(stress_on_ns_result)

Out:

Stress Tensor object.

Object properties:
 - location   : ElementalNodal
 - named_selection : SELECTION

ElementalNodal
Stress Tensor object.

Object properties:
 - location   : Elemental
 - named_selection : SELECTION
 - time       : 1.0

Use the misc. results Same keywords can be used here. For complex result, the keyword “phase” (float) can also be used.

stress_ratio = solution.misc.elemental_stress_ratio(node_scoping=[1, 32], time=1.)
print(stress_ratio)

Out:

Stress result.

This result has been computed using dpf.core.Operator objects, which
have been chained together according to the following list:
- ENL_SRAT: Result operator. Compute the desired result.
- to_elemental_fc: This operator will compute the elemental averaging of a fields container.

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

Gallery generated by Sphinx-Gallery