Note
Go to the end to download the full example code
Static analysis#
静态分析
本例展示了如何使用 PyDPF-Post 对静态分析的结果文件进行后处理。
Perform required imports#
执行所需的导入
from ansys.dpf import post
from ansys.dpf.post import examples
Get Solution object#
获取 ``Solution`` 对象
# 此示例加载了一个在 Ansys Mechanical 中计算的静态分析结果文件。
example_path = examples.download_all_kinds_of_complexity()
solution = post.load_solution(example_path)
print(solution)
Static Analysis Solution object.
Data Sources
------------------------------
DPF DataSources:
Result files:
result key: rst and path: C:\Users\ff\AppData\Roaming\Python\Python310\site-packages\ansys\dpf\core\examples\result_files\testing\allKindOfComplexity.rst
Secondary files:
DPF Model
------------------------------
Static analysis
Unit system: MKS: m, kg, N, s, V, A, degC
Physics Type: Mechanical
Available results:
- displacement: Nodal Displacement
- reaction_force: Nodal Force
- element_nodal_forces: ElementalNodal Element nodal Forces
- stress: ElementalNodal Stress
- elemental_volume: Elemental Volume
- stiffness_matrix_energy: Elemental Energy-stiffness matrix
- artificial_hourglass_energy: Elemental Hourglass Energy
- thermal_dissipation_energy: Elemental thermal dissipation energy
- kinetic_energy: Elemental Kinetic Energy
- co_energy: Elemental co-energy
- incremental_energy: Elemental incremental energy
- elastic_strain: ElementalNodal Strain
- thermal_strain: ElementalNodal Thermal Strains
- thermal_strains_eqv: ElementalNodal Thermal Strains eqv
- swelling_strains: ElementalNodal Swelling Strains
- structural_temperature: ElementalNodal Temperature
------------------------------
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#
获取 ``Result`` 对象
Get displacement result#
获取位移 ``Result`` 对象
disp_result = solution.displacement()
disp = disp_result.vector
print(disp)
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 number of fields#
Check the number of fields.
print(disp.num_fields)
1
Get data from field#
Get data from a field.
print(disp.get_data_at_field(0))
[[ 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#
获取所有 fields 的最大数据值
print(disp.max_data)
[[8.50619058e+04 1.04659292e+01 3.73620870e+05]]
Get minimum data value over all fields#
获取所有 fields 的最小数据值
print(disp.min_data)
[[-1.82645944e-06 -1.04473039e+01 -2.94677257e-04]]
Get maximum data value over targeted field#
获取目标 fields 的最大数据值
print(disp.get_max_data_at_field(0))
[8.50619058e+04 1.04659292e+01 3.73620870e+05]
Get minimum data value over all fields#
获取目标 fields 的最小数据值
print(disp.get_min_data_at_field(0))
[-1.82645944e-06 -1.04473039e+01 -2.94677257e-04]
Get stress result#
获取张量的应力 ``Result`` 对象
stress_result = solution.stress()
stress = stress_result.tensor
Check number of fields#
检查不同 fields 中壳单元和实体单元的数量。
print(stress.num_fields)
2
Get shell field#
Get the shell field.
shell_field = stress[0]
print(shell_field.shell_layers)
shell_layers.nonelayer
Get solid field#
Get the solid field.
solid_field = stress[1]
Plot contour#
绘制等值线图
stress.plot_contour()

Get elastic strain result#
获得弹性应变结果
elastic_strain_result = solution.elastic_strain()
elastic_strain = elastic_strain_result.tensor
Check number of fields#
检查不同 fields 中壳单元和实体单元的数量。
print(elastic_strain.num_fields)
2
如果结果文件中包含,则可以使用此方法获取弹性应变结果。
print(solution.plastic_strain())
Tensor object.
Object properties:
- location : Nodal
Plastic strain object.
您也可以使用这种方法获得温度结果。
print(solution.structural_temperature())
Scalar object.
Object properties:
- location : Nodal
Structural temperature object.
Total running time of the script: (0 minutes 0.592 seconds)