Skip to content

Commit 3ca6c70

Browse files
Material prop example (#425)
* added material property extraction example * removed the images
1 parent c55a98e commit 3ca6c70

File tree

1 file changed

+60
-0
lines changed

1 file changed

+60
-0
lines changed
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
"""
2+
.. _ref_get_material_properties:
3+
4+
Get material properties from the result file
5+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
6+
Material properties are assigned to each element in APDL and by default they
7+
are written out in the APDL result file. We can extract material properties
8+
of each element using PyDPF by getting the properties from the `meshed_region`.
9+
10+
The material properties are then passed onto the operator
11+
`mapdl_material_properties()`
12+
13+
Import necessary modules:
14+
"""
15+
16+
from ansys.dpf import core as dpf
17+
from ansys.dpf.core import examples
18+
19+
###############################################################################
20+
# Create a model object to establish a connection with an example result file:
21+
model = dpf.Model(examples.simple_bar)
22+
23+
###############################################################################
24+
# Get the `meshed_region` from model's metadata.
25+
mesh = model.metadata.meshed_region
26+
print(mesh)
27+
28+
###############################################################################
29+
# See available properties in the `meshed_region`
30+
print(mesh.available_property_fields)
31+
32+
###############################################################################
33+
# Get all the material properties
34+
mats = mesh.property_field("mat")
35+
36+
###############################################################################
37+
# Use the DPF operator `mapdl_material_properties` to extract data for the
38+
# materials - `mats`. For the input `properties_name`, you need the correct
39+
# material property string. To see what all strings are supported, you can
40+
# print the operator help.
41+
mat_prop = model.operator("mapdl_material_properties")
42+
mat_prop.inputs.materials.connect(mats)
43+
44+
###############################################################################
45+
# For the input `properties_name`, you need the correct
46+
# material property string. To see what all strings are supported, you can
47+
# print the operator help.
48+
print(mat_prop)
49+
50+
###############################################################################
51+
# Let us extract the Young's modulus for element ID 1
52+
mat_prop.inputs.properties_name.connect("EX")
53+
mat_field = mat_prop.outputs.properties_value.get_data()[0]
54+
print(mat_field.get_entity_data_by_id(1))
55+
56+
###############################################################################
57+
# Extract Poisson's ratio for element ID 1
58+
mat_prop.inputs.properties_name.connect("NUXY")
59+
mat_field = mat_prop.outputs.properties_value.get_data()[0]
60+
print(mat_field.get_entity_data_by_id(1))

0 commit comments

Comments
 (0)