How to get plate thickness based on element id?

Options
Nathanvanthof
Nathanvanthof Member Posts: 4
First Comment
edited October 2023 in Structures

Hi everyone,

I have a plate model with several plates of different thicknesses. In postprocessing I'd like to know the thickness of an element based on its id. Does anybody know how to calculate/retrieve it?

from ansys.dpf import post

simulation = post.load_simulation('file.rst')
elemental_stress = simulation.stress_eqv_von_mises_elemental()
selection_ids = elemental_stress.index[0].values
selection_id_0 = selection_ids[0]

# How to get the thickness of the selected element?
print(selection_id_0)

Thank you!

Answers

  • Peter
    Peter Member Posts: 6
    First Anniversary Name Dropper First Comment
    Options

    I currently use the dpf

    op = dpf.operators.result.mapdl_section()               # operator instantiation
    op.inputs.properties_name.Connect("Thickness")
    op.inputs.data_sources.Connect(data_source)
    mmv = op.outputs.properties_value.GetData()
    
  • Nathanvanthof
    Nathanvanthof Member Posts: 4
    First Comment
    edited October 2023
    Options

    Hi Peter,

    Thanks for your quick answer.
    I changed the Connect to connect in your line 2 because I was getting this error:

    AttributeError: 'properties_name' object has no attribute 'Connect'

    Now my code looks like this:

    from ansys.dpf import post
    from ansys.dpf import core as dpf
    
    simulation = post.load_simulation('file.rst')
    elemental_stress = simulation.stress_eqv_von_mises_elemental()
    selection_ids = elemental_stress.index[0].values
    selection_id_0 = selection_ids[0]
    
    op = dpf.operators.result.mapdl_section()
    op.inputs.properties_name.connect("Thickness")
    op.inputs.data_sources.connect(data_source)
    mmv = op.outputs.properties_value.GetData()
    

    Now I'm getting this error:

    op.inputs.data_sources.connect(data_source)
    NameError: name 'data_source' is not defined

    Just to be sure we're talking about the same thing: I have an rst file I wish to analyze outside of the workbench environment. I think that might be causing the data_source error?

  • Pernelle Marone-Hitz
    Pernelle Marone-Hitz Member, Moderator, Employee Posts: 804
    First Comment First Anniversary Ansys Employee Solution Developer Community of Practice Member
    Options

    Hi both!
    @Peter seems to be using Mechanical DPF (Iron Python convention -hence the capital C in Connect) whereas @Nathanvanthof you are using PyDPF (CPython convention - hence small c in connect).
    @Nathanvanthof , you've referenced your result file to use in DPF Post line 4, but starting from line 9 it is DPF Core that you are using. The error message with missing data_sources is that you have not linked your result file here.

  • Peter
    Peter Member Posts: 6
    First Anniversary Name Dropper First Comment
    Options

    Hi Nathan,
    as @Pernelle Marone-Hitz mentioned I am using Iron Python within mechanical.
    The data_source error is not causing the error because it is outside from mechanical, it is because it is not defined.