I am trying to get the strain energy from a result-file using pyAnsys dpf-core. Actually I do not see a direct access to this result (maybe there is but I just cannot find it). So I tried to acess the strain energy density so that I can calculate the strain energy using the element volumes.
However, as a result from my Python code I get an empty array, even though the results do exist - at least I can see them (print and plot) in the in the ANSYS Mechanical GUI (ANSYS Classic).
The Python code I am using is
from ansys.dpf import core as dpf
rst_file = 'path_to_my_result_file.rst'
data_sources = dpf.DataSources()
data_sources.set_result_file_path(rst_file)
data_sources.result_files
loadcases = [1]
elem_ids = np.arange(1,3061)
lc_scoping = dpf.Scoping()
lc_scoping.ids = loadcases
elem_scoping = dpf.Scoping()
elem_scoping.ids=elem_ids
sene_op = dpf.operators.result.elastic_strain_energy_density()
sene_op.inputs.data_sources.connect(data_sources)
sene_op.inputs.time_scoping(lc_scoping)
sene_op.inputs.mesh_scoping(elem_scoping)
sene_op.inputs.bool_rotate_to_global(False)
sene_op.inputs.requested_location('Elemental')
sene_fc = sene_op.outputs.fields_container()
sene_f = sene_fc.get_field_by_time_id(1)
sene_data = sene_f.data
scoping_ids = sene_fc[0].scoping.ids
print(" strain energy ".center(40,'*'))
print(sene_data)
print(" scoping_ids ".center(40,'*'))
print(scoping_ids)
leading to the following output:
************ strain energy *************
[]
************* scoping_ids **************
[]
I am using ANSYS 2022R2 to solve my model and dpf-version 0.13.8 with Python 3.10.14.
Does anyone know how to resolve this issue? or maybe know how to directly access strain energy?
Thanks a lot in advance