Closed vnamdeo closed 9 months ago
Hello @vnamdeo,
The error raised is due to the fact that you are trying to plot a result which is ElementalNodal
, meaning there is a value for each node of each element. This is currently not supported for plotting, so instead you should request the result on nodes (Nodal
) or on elements (Elemental
) with:
eqv_thermal_strain = simulation.thermal_strain_eqv_nodal(set_ids=[10])
or
eqv_thermal_strain = simulation.thermal_strain_eqv_elemental(set_ids=[10])
The possibility to plot ElementalNodal
results is in our backlog here https://github.com/ansys/pydpf-core/issues/373, so I'll link it here and see if this can be put higher in our development priority list.
The fact that you can extract the thermal strain despite it being zero everywhere is due to the way the result file is built and is the expected behavior.
@PProfizi with the given result file, I able to extract thermal strain in Mechanical. However, for the same *.rst file, in PyDPF-Post, we are getting zero values. Please refer attached images for reference and let me know.
Used below command line to extract thermal strain quantities for reference.
nodal_eqv_thermal_strain = simulation.thermal_strain_equivalent_nodal(set_ids=[10]) print(nodal_eqv_thermal_strain)
@vnamdeo It seems there is indeed an issue with the thermal_strain_equivalent_nodal()
and thermal_strain_eqv()
methods.
I ran the following script on the .rst
file of the static structural analysis of the Workbench example on thermal-stress analysis (here) and got the following results:
Reference:
When considering only one component
from ansys.dpf import post
rst_path = r"path_to_project_folder"
rst_path += r"Thermal-Stress_analysis_of_a_cooled_turbine_blade_files\\dp0\\SYS-5\MECH\\"
rst_path += r"file.rst"
simulation = post.StaticMechanicalSimulation(rst_path)
thermal_strain_nodal_XX = simulation.thermal_strain_nodal(components=["XX"])
print(thermal_strain_nodal_XX)
thermal_strain_nodal_XX.plot(text="Thermal strain nodal X")
We obtain the following field
results ETH_XX
set_ids 1
node_ids
14337 2.9156e-03
22378 2.9160e-03
22379 2.9160e-03
14360 2.9156e-03
20888 2.9156e-03
22858 2.9160e-03
... ...
The plot is correct
Working with the complete result
thermal_strain_nodal = simulation.thermal_strain_nodal()
print(thermal_strain_nodal)
thermal_strain_nodal.plot(text="Thermal strain nodal")
results ETH
set_ids 1
node_ids components
14337 XX 2.9156e-03
YY 2.9156e-03
ZZ 2.9156e-03
XY 0.0000e+00
YZ 0.0000e+00
XZ 0.0000e+00
... ... ...
The plot shows the norm, which is not what we want
thermal_strain_equivalent_nodal = simulation.thermal_strain_equivalent_nodal()
print(thermal_strain_equivalent_nodal)
thermal_strain_equivalent_nodal.plot(text="Thermal strain equivalent nodal")
Gives an empty field (not expected here)
results ETH_VM
set_ids 1
node_ids
14337 0.0000e+00
22378 0.0000e+00
22379 0.0000e+00
14360 0.0000e+00
20888 0.0000e+00
22858 0.0000e+00
... ...
thermal_strain_eqv = simulation.thermal_strain_eqv()
print(thermal_strain_eqv)
thermal_strain_eqv.plot(text="Thermal strain eqv")
Also gives an empty field.
results ETH_VM ...
set_ids 1 ...
node 0 1 2 3 4 5 ...
element_ids ...
22849 0.0000e+00 0.0000e+00 0.0000e+00 0.0000e+00 0.0000e+00 0.0000e+00 ...
22850 0.0000e+00 0.0000e+00 0.0000e+00 0.0000e+00 0.0000e+00 0.0000e+00 ...
22851 0.0000e+00 0.0000e+00 0.0000e+00 0.0000e+00 0.0000e+00 0.0000e+00 ...
22852 0.0000e+00 0.0000e+00 0.0000e+00 0.0000e+00 0.0000e+00 0.0000e+00 ...
22853 0.0000e+00 0.0000e+00 0.0000e+00 0.0000e+00 0.0000e+00 0.0000e+00 ...
22854 0.0000e+00 0.0000e+00 0.0000e+00 0.0000e+00 0.0000e+00 0.0000e+00 ...
... ... ... ... ... ... ... ...
Plotting it results in an expected error since it is ElementalNodal
:
ValueError: Only elemental, nodal or faces location are supported for plotting.
I will need to investigate this further.
I just realized that the XX
, YY
, and ZZ
values are always the same, which actually does result in a null VM equivalent (see here).
@vnamdeo I think the original issue is that the comparison is between the result shown in Mechanical (which is the Thermal Strain along either X, Y or Z) and the result of simulation.thermal_strain_eqv(set_ids=[10])
which is the equivalent thermal strain.
As shown above, when comparing the directional values, the result is indeed the same as in Mechanical.
Thanks @PProfizi
Before submitting the issue
Description of the bug
I have tried extracting thermal strain quantity using below code, it gives all zero values but no error
eqv_thermal_strain = simulation.thermal_strain_eqv(set_ids=[10]) print(eqv_thermal_strain)
however, while plotting it throws error with the traceback as attached.
eqv_thermal_strain.plot(title="Equivalent Thermal Strain")
Steps To Reproduce
Please use following code with the static analysis and having thermal strains in it.
extract equivalent thermal strain results from the simulation
eqv_thermal_strain = simulation.thermal_strain_eqv(set_ids=[10]) print(eqv_thermal_strain) eqv_thermal_strain.plot(title="Equivalent Thermal Strain")
Which Operating System are you using?
Windows
Which DPF/Ansys version are you using?
Ansys 2024 R1
Which Python version are you using?
3.8
Installed packages