Skip to content

Change material properties of several elements in PyMapdl #3369

Answered by germa89
derne058 asked this question in Q&A
Discussion options

You must be logged in to vote

Hi @derne058

In the loop you mentioned, you are issuing several gRPC calls (mapdl.mp) per each element. That can be quite a lot. To speed up the process, avoid doing a loop per element, and try to do a loop per material.

For instance, if you are dealing with a material with variable porosity, you can select all the elements which will have similar porosity (within a range), and apply the material change in all the elements at once. You can try the following pseudocode:

grading_steps = [(0, 0.1), (0.1, 0.2), (0.2, 0.3), ...] # surely this can be more elegant.

for lower_bound, upper_bound in grading_steps:
    x_filtered__ = lower_bound < x_filtered < upper_bound
    # select elements
    m…

Replies: 3 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by germa89
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants