Static Analysis

This tutorial shows how post-process a static analysis result file using API of the POST module.

Get started

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

Get the solution object

The following file is the result of a static analysis computed using Ansys Mechanical.

Here we load the solution

example_path = examples.download_all_kinds_of_complexity()
solution = post.load_solution(example_path)
print(solution)

Out:

Static solution object.


Data Sources
------------------------------
DPF  DataSources:
  Result files:
     result key: rst and path: C:\Users\VssAdministrator\AppData\Local\ansys-dpf-core\ansys-dpf-core\examples\testing\allKindOfComplexity.rst
  Secondary files:


DPF Model
------------------------------
DPF Result Info
  Analysis: static
  Physics Type: mecanic
  Unit system: MKS: m, kg, N, s, V, A, degC
  Available results:
    U Displacement :nodal displacements
    RF Force :nodal reaction forces
    ENF Element nodal Forces :element nodal forces
    S Stress :element nodal component stresses
    ENG_VOL Volume :element volume
    ENG_SE Energy-stiffness matrix :element energy associated with the stiffness matrix
    ENG_AHO Hourglass Energy :artificial hourglass energy
    ENG_TH thermal dissipation energy :thermal dissipation energy
    ENG_KE Kinetic Energy :kinetic energy
    ENG_CO co-energy :co-energy (magnetics)
    ENG_INC incremental energy :incremental energy (magnetics)
    EPEL Strain :element nodal component elastic strains
    ETH Thermal Strains :element nodal component thermal strains
    ETH_EQV Thermal Strains eqv :element nodal equivalent component thermal strains
    ETH_SWL Swelling Strains :element nodal swelling strains
    BFE Temperature :element structural nodal temperatures
------------------------------
DPF  Meshed Region:
  15129 nodes
  10292 elements
  Unit: m
  With solid (3D) elements, shell (2D) elements, shell (3D) elements, beam (1D) elements
------------------------------
DPF  Time/Freq Support:
  Number of sets: 1
Cumulative     Time (s)       LoadStep       Substep
1              1.000000       1              1

Get result objects

Get a displacement result

Get the result

disp_result = solution.displacement()
disp = disp_result.vector
print(disp)

Out:

Displacement result.

This result has been computed using dpf.core.Operator objects, which
have been chained together according to the following list:
- U: Result operator. Compute the desired result.

Check the number of fields

disp.num_fields

Out:

1

Get data from a field

disp.get_data_at_field(0)

Out:

array([[ 9.84182297e-06,  5.13025031e-06, -6.66435651e-07],
       [ 9.95996777e-06,  4.93526360e-06, -6.25236961e-07],
       [ 9.93154893e-06,  5.88552090e-06, -7.83251832e-07],
       ...,
       [ 5.00000000e-03, -1.54556837e-04,  0.00000000e+00],
       [ 5.00000000e-03, -1.56813550e-04,  0.00000000e+00],
       [ 5.00000000e-03, -1.66125455e-04,  0.00000000e+00]])

Get maximum data value over all fields

disp.max_data

Out:

array([[8.50619058e+04, 1.04659292e+01, 3.73620870e+05]])

Get minimum data value over all fields

disp.min_data

Out:

array([[-1.82645944e-06, -1.04473039e+01, -2.94677257e-04]])

Get maximum data value over a targeted field

disp.get_max_data_at_field(0)

Out:

array([8.50619058e+04, 1.04659292e+01, 3.73620870e+05])

Get minimum data value over all fields

disp.get_min_data_at_field(0)

Out:

array([-1.82645944e-06, -1.04473039e+01, -2.94677257e-04])

Get a stress result

Get the result

stress_result = solution.stress()
stress = stress_result.tensor
# shell and solid elements are in distinct fields.
stress.num_fields

Out:

2

Get the shell field

shell_field = stress[0]
shell_field.shell_layers

Out:

<shell_layers.topbottommid: 4>

Get the solid field field

solid_field = stress[1]

Plot the contour

stress.plot_contour()
01 static analysis

Get an elastic_strain result

Get the result

elastic_strain_result = solution.elastic_strain()
elastic_strain = elastic_strain_result.tensor
# shell and solid elements are in distinct fields.
elastic_strain.num_fields

Out:

2

It is also possible to deal with plastic_strain and temperature this way. The result file must contain those results.

Here is the plastic strain result

print(solution.plastic_strain())

Out:

Tensor object.

Object properties:
 - location   : Nodal

This is a plastic strain object.

and the temperature result

print(solution.structural_temperature())

Out:

Scalar object.

Object properties:
 - location   : Nodal

This is a temperature object.

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

Gallery generated by Sphinx-Gallery