Skip to content

Commit

Permalink
Added use of GridFunctions to an example (#59)
Browse files Browse the repository at this point in the history
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
fingeraugusto and pre-commit-ci[bot] authored May 23, 2024
1 parent c844a4a commit 3b5b30d
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 6 deletions.
1 change: 1 addition & 0 deletions CONTRIBUTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
## Individual Contributors

* [Alejandro Fernández Luces](https://github.com/AlejandroFernandezLuces)
* [Augusto Finger Pacheco](https://github.com/fingeraugusto)
* [Gustavo Corrêa Martins](https://github.com/gcmartins)
* [Jorge Martínez Garrido](https://github.com/jorgepiloto)
* [Roberto Pastor Muela](https://github.com/RobPasMue)
30 changes: 24 additions & 6 deletions examples/basic_examples/particle_wall_interaction_with_motion.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,20 +114,38 @@
times, mass_flow_in = particles.GetNumpyCurve("Particles Mass Flow In", unit="t/h")
times, mass_flow_out = particles.GetNumpyCurve("Particles Mass Flow Out", unit="t/h")

# Obtain the maximum and minimum velocities of the particles at each time step.
import numpy as np

simulation_times = study.GetTimeSet()
velocity_gf = particles.GetGridFunction("Velocity : Translational : Absolute")
velocity_max = np.array(
[velocity_gf.GetMax(unit="m/s", time_step=i) for i in range(len(simulation_times))]
)
velocity_min = np.array(
[velocity_gf.GetMin(unit="m/s", time_step=i) for i in range(len(simulation_times))]
)


#################################################################################
# Plot curves
# +++++++++++

import matplotlib.pyplot as plt

fig, ax = plt.subplots(1)
fig, (ax1, ax2) = plt.subplots(2, 1)

ax1.plot(times, mass_flow_in, "b", label="Mass Flow In")
ax1.plot(times, mass_flow_out, "r", label="Mass Flow Out")
ax1.set_xlabel("Time [s]")
ax1.set_ylabel("Mass Flow [t/h]")
ax1.legend(loc="upper left")

ax.plot(times, mass_flow_in, "b", label="Mass Flow In")
ax.plot(times, mass_flow_out, "r", label="Mass Flow Out")
ax.set_xlabel("Time [s]")
ax.set_ylabel("Mass Flow [t/h]")
ax.legend(loc="upper left")
ax2.plot(simulation_times, velocity_max, "b", label="Max Velocity")
ax2.plot(simulation_times, velocity_min, "r", label="Min Velocity")
ax2.set_xlabel("Time [s]")
ax2.set_ylabel("Velocity [m/s]")
ax2.legend(loc="upper left")

plt.draw()

Expand Down

0 comments on commit 3b5b30d

Please sign in to comment.