Skip to content

Commit

Permalink
Typo + to_numpy() (#1387)
Browse files Browse the repository at this point in the history
Description
Granu-heap and plate discharge examples
  • Loading branch information
OGaboriault authored Nov 26, 2024
1 parent b921fcf commit b9ebebc
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 13 deletions.
4 changes: 2 additions & 2 deletions doc/source/examples/dem/plate-discharge/plate-discharge.rst
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,7 @@ Angle of Repose

The angles of repose are calculated from the data extracted from the VTU output files. The 2 angles of repose are calculated from the pile of particles on the plate for comparison with the literature, and from the piles formed by the discharge for curiosity.

The configuration of the case gives a symmetrical formation of the piles, meaning that there are 2 angles of repose to calculate for the pile at the top of the plate and for the 2 piles at the bottom. The angles of repose are calculated by linear regressions from the highest particle positions in y-axis from :math:`-0.35 \ \text{m}` to :math:`-0.15 \ \text{m}` for the left angles and from :math:`0.15 \ \text{m}` to :math`0.35 \ \text{m}` for the right angles along the x-axis. The following figure shows the areas where the angles are calculated. The areas where the angle of repose is calculated for the left (blue) and right (red) sides of the piles.
The configuration of the case gives a symmetrical formation of the piles, meaning that there are 2 angles of repose to calculate for the pile at the top of the plate and for the 2 piles at the bottom. The angles of repose are calculated by linear regressions from the highest particle positions in y-axis from :math:`-0.35 \ \text{m}` to :math:`-0.15 \ \text{m}` for the left angles and from :math:`0.15 \ \text{m}` to :math:`0.35 \ \text{m}` for the right angles along the x-axis. The following figure shows the areas where the angles are calculated. The areas where the angle of repose is calculated for the left (blue) and right (red) sides of the piles.


.. figure:: images/angle-areas.png
Expand All @@ -468,7 +468,7 @@ The given angles of repose are the linear regressions from the positions with ab

The angles of repose calculated from the simulation data. The solid lines are the angles computed from the highest particles on both side, while the shaded areas represent the angles for the left and the right.

According to Zhou *et al.* [#zhou2002]_, the angle of repose for this type of configuration is calculated with the following theoretical formula:
According to Zhou *et al.* [#zhou2002]_, the angle of repose for this type of configuration is calculated with the following empirical formula:

.. math::
\phi = 68.61 \mu_{\text{f,pp}}^{0.27} \mu_{\text{f,pw}}^{0.22} \mu_{\text{r,pp}}^{0.06} \mu_{\text{r,pw}}^{0.12} d_p^{-0.2}
Expand Down
23 changes: 12 additions & 11 deletions examples/dem/3d-plate-discharge/plate-discharge_post-processing.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,21 +103,21 @@
angle_top_plot.plot(time, postprocessing.theoritical_angle * np.ones(len(time)), '--', color='k', label='Theoretical angle', linewidth=1.00)

for k in range(0, len(names)):
time = data_list[k]['time'].values
mass_plot.plot(time, data_list[k]['mass'], '--', color='C' + str(k),
time = data_list[k]['time'].to_numpy() #values
mass_plot.plot(time, data_list[k]['mass'].to_numpy(), '--', color='C' + str(k),
label=f'{dict_names[names[k]]}', linewidth=1.00)

angle_top_plot.plot(time, abs(data_list[k]['angle_top']), color='C' + str(k), label=f'{dict_names[names[k]]}', linewidth=1.00)
angle_top_plot.plot(time, abs(data_list[k]['angle_top'].to_numpy()), color='C' + str(k), label=f'{dict_names[names[k]]}', linewidth=1.00)
angle_top_plot.fill_between(time,
abs(data_list[k]['left_angle_top'].values).astype(float),
abs(data_list[k]['right_angle_top'].values).astype(float), color='C' + str(k), alpha=0.5)
abs(data_list[k]['left_angle_top'].to_numpy()).astype(float),
abs(data_list[k]['right_angle_top'].to_numpy()).astype(float), color='C' + str(k), alpha=0.5)

angle_bottom_plot.plot(time, abs(data_list[k]['angle_bottom']),
angle_bottom_plot.plot(time, abs(data_list[k]['angle_bottom'].to_numpy()),
color='C' + str(k), label=f'{dict_names[names[k]]}', linewidth=1.00)
angle_bottom_plot.fill_between(time,
abs(pd.to_numeric(data_list[k]['left_angle_bottom'].values,
abs(pd.to_numeric(data_list[k]['left_angle_bottom'].to_numpy(),
errors='coerce')),
abs(pd.to_numeric(data_list[k]['right_angle_bottom'].values,
abs(pd.to_numeric(data_list[k]['right_angle_bottom'].to_numpy(),
errors='coerce')), color='C' + str(k), alpha=0.5)

start = 10
Expand Down Expand Up @@ -152,15 +152,16 @@
fig_angle.savefig(f'./plate-discharge-angle-data.png', bbox_inches='tight', dpi=300)

if process_log:
time = log_list[0]['time'].values
time = log_list[0]['time'].to_numpy()
#print(time)
for k in range(0, len(names)):
performance_plot.plot(time, log_list[k]['dem_walltime'].rolling(3).mean(),
performance_plot.plot(time, log_list[k]['dem_walltime'].rolling(3).mean().to_numpy(),
color='C' + str(k), label=f'{dict_names[names[k]]}', linewidth=1.00)

if k != 0:
speedup = log_list[0]['dem_walltime']/log_list[k]['dem_walltime']
speedup[0] = 0.0
speedup_plot.plot(time, speedup.rolling(5).mean(), '--', color='C' + str(k), label=f'{dict_names[names[k]]}', linewidth=1.00)
speedup_plot.plot(time, speedup.rolling(5).mean().to_numpy(), '--', color='C' + str(k), label=f'{dict_names[names[k]]}', linewidth=1.00)
speedup_plot.plot(time[-1], speedup.iat[-1], 'o', color='C' + str(k), markersize=5)
speedup_plot.annotate(f'{speedup.iat[-1]:.2f}x', (time[-1], speedup.iat[-1]), textcoords="offset points", xytext=(-31, 1.75), color='C' + str(k))

Expand Down

0 comments on commit b9ebebc

Please sign in to comment.