Note
Go to the end to download the full example code
Modal 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_modal()
solution = post.load_solution(example_path)
print(solution)
Modal 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\modal_allKindOfComplexity.rst
Secondary files:
DPF Model
------------------------------
Modal 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
- structural_temperature: ElementalNodal Temperature
------------------------------
DPF Meshed Region:
2388 nodes
1824 elements
Unit: m
With solid (3D) elements, shell (2D) elements, shell (3D) elements, beam (1D) elements
------------------------------
DPF Time/Freq Support:
Number of sets: 45
Cumulative Frequency (Hz) LoadStep Substep
1 4800.665229 1 1
2 6472.119402 1 2
3 10094.813112 1 3
4 15408.070193 1 4
5 19935.616102 1 5
6 30659.224027 1 6
7 33485.028985 1 7
8 40514.020302 1 8
9 41144.836724 1 9
10 41696.364343 1 10
11 42568.142453 1 11
12 48803.935725 1 12
13 51557.014600 1 13
14 54829.807966 1 14
15 55121.065060 1 15
16 55481.661956 1 16
17 55779.054274 1 17
18 56346.453210 1 18
19 56598.396154 1 19
20 57504.056787 1 20
21 57768.209089 1 21
22 60135.893137 1 22
23 62336.016111 1 23
24 62809.029190 1 24
25 64186.171203 1 25
26 64911.479227 1 26
27 66488.724651 1 27
28 66728.182829 1 28
29 67521.333063 1 29
30 68699.230845 1 30
31 70108.268581 1 31
32 71432.124756 1 32
33 71784.765113 1 33
34 73189.275762 1 34
35 74862.553459 1 35
36 75051.318416 1 36
37 76335.025905 1 37
38 76631.728520 1 38
39 76956.786796 1 39
40 77754.144888 1 40
41 78460.122703 1 41
42 78721.878185 1 42
43 79330.520798 1 43
44 80301.992725 1 44
45 80835.840814 1 45
This may contain complex results.
Get Result objects#
获取 ``Result`` 对象
Get displacement result#
获取位移结果
获取位移 Result 对象。它包含一个实数值域和一个虚数值域。
disp_result = solution.displacement()
disp = disp_result.vector
Check number of fields#
Check the number of fields
disp.num_fields # `num_fields` 属性通常表示数据的维度或字段的数量。
1
Get data from a field
disp.get_data_at_field(0)
DPFArray([[-1.17102876, -1.30206342, -1.1938849 ],
[-1.69750554, -1.68258886, -0.76327262],
[-2.24465543, -2.66699745, -1.36365734],
...,
[ 0. , 0. , -0. ],
[ 0. , 0. , -0. ],
[ 0. , 0. , -0. ]])
Get maximum data value over all fields#
获取所有 fields 的最大数据值
disp.max_data
DPFArray([[3.63870030e+05, 8.31378342e+20, 5.99358159e+21]])
Get minimum data value over all fields#
获取所有 fields 的最小数据值
disp.min_data
DPFArray([[-3.55151557e+05, -8.31378342e+20, -5.99358159e+21]])
Get maximum data value over targeted field#
获取目标 fields 的最大数据值
disp.get_max_data_at_field(0)
DPFArray([3.63870030e+05, 8.31378342e+20, 5.99358159e+21])
Get minimum data value over all fields#
获取目标 fields 的最小数据值
disp.get_min_data_at_field(0)
DPFArray([-3.55151557e+05, -8.31378342e+20, -5.99358159e+21])
Get stress result#
获取应力结果
获取处理振幅的应力结果。它包含一个实值域和一个虚值域。
stress_result = solution.stress()
Check if support has complex frequencies#
检查是否支持复频率
stress_result.has_complex_frequencies()
False
Get tensor result#
获取张量结果
stress = stress_result.tensor
stress.num_fields
2
Get shell field#
获取 shell_field 的壳层信息
shell_field = stress[0]
shell_field.shell_layers
<shell_layers.nonelayer: 5>
Get solid field#
Get the solid field.
solid_field = stress[1]
print(solid_field)
DPF stress_4800.665229Hz Field
Location: Nodal
Unit: Pa
156 entities
Data:6 components and 468 elementary data
Plot amplitude contour#
绘制振幅等值线图
amplitude = stress_result.tensor_amplitude # (ˈæmplɪˌtjuːd,振幅)
stress.plot_contour()

Get elastic strain result#
获得处理相位的弹性应变结果
它包含一个实值字段和一个虚值字段。
elastic_strain_result = solution.elastic_strain()
elastic_strain = elastic_strain_result.tensor
检查不同 fields 中壳单元和实体单元的数量。
elastic_strain.num_fields
2
如果结果文件中包含,则可以使用此方法获取弹性应变结果。
print(solution.plastic_strain())
Complex tensor object.
Tensor object.
Object properties:
- location : Nodal
Complex plastic strain object.
Total running time of the script: (0 minutes 3.774 seconds)