Iterate over measurement circles for stress

Hi everyone,
I am trying to visualize the results of measurement circles (in 2D) that I have distributed in a container (box consisting of four walls) .

Visualizing the porosities that I have represented within a numpy array seems to work fine (see picture) but unfortunately this isnt the case for the stresses.

The lines below I have used to create the arrays (for positions in X and Y direction as well as porosities and stress_xx) . What I have noticed is that the array for the stresses would only be represented by one element (the stress component of the last measurement circle) and not by an array consisting of the stress components of all measurement circles. There must be something wrong with the last line here - mabe someone has an idea how to fix this issue…

Defines the range for total number of measurement spheres

b = range(it.measure.maxid())

Introduces the numpy arrays that have no values before iteration

X_all = np.array([]) # for x coordinate of measurement sphere
Y_all = np.array([]) # for y coordinate of measurement sphere
P_all = np.array([]) # for porosities of measurement spheres
S_all = np.array ([]) # for stress components of measurement sphreres

for loop to create numpy arrays for contourplot

for a in b:
x_a = ma.Measure.pos_x(it.measure.find(a+1)) # iterate x positions
X_all = np.concatenate((X_all, [x_a])) # concatenate to a numpy array

y_a = ma.Measure.pos_y(it.measure.find(a+1)) # iterate y positions
Y_all = np.concatenate((Y_all, [y_a])) # concatenate to a numpy array

p_a = ma.Measure.porosity(it.measure.find(a+1)) # iterate porosities
P_all = np.concatenate((P_all, [p_a])) # concatenate to a numpy array

s_11_a = ma.Measure.stress(it.measure.find(a+1))[0,0] # iterate stress_xx
S_11_all = np.concatenate((S_all, [s_11_a])) # concatenate to a numpy array

1 Like

Dear Mussie,
I am in contact with our developers and will get back to you as soon as possible.
Regards,
Nils

Thank you very much Nils!

Regards
Mussie

Hello Mussie,

In the last line,
S_11_all = np.concatenate((S_all, [s_11_a])) # concatenate to a numpy array
You need to use the same numpy array you declared earlier. So the line should look like this,
S_all = np.concatenate((S_all, [s_11_a])) # concatenate to a numpy array

Also, I am not sure it would be helpful, but if you wish to plot the stress components there is a ball plot item that does this. From the ball plot item select Color By: Numeric Val: stress-xx.

Thank you very much dblanksma!

Thank you also very much for the hint on the ball plot item.

My application here is a penetration problem (pile shaped wall-box is penetrating the balls from the left upper side).

My first idea was to display the plots for porosities and stresses right next to each other (see figures below: left side PFC2D plotting pane, right side python; at the top is before, bottom is after penetration) which led to the usage of python/matplotlib.

If I may add another question to this topic: Are there any improvements planned for the display of results from measurement spheres for the future? - I thought creating contour plots from a large group of measurement sphres might be a good addition to the plotting pane.

You are welcome Mussie. To my knowledge I don’t think there is any plans to have a plot item that generates contours from measurement spheres (circles in 2D). I’ll run the idea by our developers though.