Result keywords#

This example shows how to you can get more precise result with keywords while calling a Result object from a Solution object.

Perform required imports#

Perform required imports.

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

Get Solution object#

Get the Solution object.

solution = post.load_solution(examples.multishells_rst)

Get keyword list#

Get the keyword list.

post.print_available_keywords()
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

Get Result objects#

Get displacement result using scoping#

Get the displacement Result object using scoping. The default location is nodal.

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

Get information on result#

Get information on the displacement result.

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)
DPFArray([[-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 named selection on result#

Use a named selection on the displacement 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])
5040

Get a subresult#

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
<ansys.dpf.post.result_data.ResultData object at 0x7f5a4df03850>

Filter result#

Filter the result on a time, time scoping, and a set.

print(solution.time_freq_support)

stress_on_time_1s_result = solution.stress(time=1.0)
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
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 0x7f5a7ed6caf0>

Make grouping#

Make a grouping.

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

Filter MAPDL elements#

Filter for 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
<ansys.dpf.post.result_data.ResultData object at 0x7f5a7ed6d3c0>

Manipulate result and change its definition#

Manipulate the result 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.0
stress_on_ns_elemental = stress_on_ns_result.tensor

print(stress_on_ns_result)
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 miscellaneous results#

Use miscellaneous results. You can use the same keywords here. For a complex result, you can also use the keyword phase, which has a float value.

stress_ratio = solution.misc.elemental_stress_ratio(node_scoping=[1, 32], time=1.0)
print(stress_ratio)
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 computes the elemental averaging of a fields container.

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

Gallery generated by Sphinx-Gallery