.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "examples\basic_examples\particle_wall_interaction.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code. .. rst-class:: sphx-glr-example-title .. _sphx_glr_examples_basic_examples_particle_wall_interaction.py: .. _ref_particle_wall_interaction: Particle simulation with wall interaction ----------------------------------------- This example sets up and solves a simulation of particles interacting with a cylinder wall. .. GENERATED FROM PYTHON SOURCE LINES 33-36 .. image:: /_static/open_cylinder_result.png :width: 400pt :align: center .. GENERATED FROM PYTHON SOURCE LINES 38-41 Perform imports and create a project ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Perform the required imports and create an empty project. .. GENERATED FROM PYTHON SOURCE LINES 41-56 .. code-block:: Python import os.path import tempfile import ansys.rocky.core as pyrocky from ansys.rocky.core import examples # Create a temp directory to save the project. project_dir = tempfile.mkdtemp(prefix="pyrocky_") # Launch Rocky and open a project. rocky = pyrocky.launch_rocky() project = rocky.api.CreateProject() project.SaveProject(os.path.join(project_dir, "rocky-testing.rocky")) .. GENERATED FROM PYTHON SOURCE LINES 57-59 Configure the study ~~~~~~~~~~~~~~~~~~~ .. GENERATED FROM PYTHON SOURCE LINES 59-77 .. code-block:: Python study = project.GetStudy() # Download the STL file that will imported into Rocky to represent a Wall. file_name = "open_cylinder.stl" file_path = examples.download_file(project_dir, file_name, "pyrocky/geometries") study.ImportWall(file_path) # Create a sphero-cylinder shape particle with the default size distribution (single # distribution with sieve size of 0.1 m). particle = study.CreateParticle() particle.SetShape("sphero_cylinder") # Create circular surface with a max radius of 0.3 m and default center coordinates # values (0.0, 0.0, 0.0). circular_surface = study.CreateCircularSurface() circular_surface.SetMaxRadius(0.3, "m") particle_inlet = study.CreateParticleInlet(circular_surface, particle) .. rst-class:: sphx-glr-script-out .. code-block:: none Download successful. File path: C:\Users\ansys\AppData\Local\Temp\pyrocky_727r71up\open_cylinder.stl .. GENERATED FROM PYTHON SOURCE LINES 78-80 Set up the solver and run the simulation ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .. GENERATED FROM PYTHON SOURCE LINES 80-85 .. code-block:: Python solver = study.GetSolver() solver.SetSimulationDuration(2, unit="s") study.StartSimulation() .. rst-class:: sphx-glr-script-out .. code-block:: none True .. GENERATED FROM PYTHON SOURCE LINES 86-90 Postprocess ~~~~~~~~~~~ Obtain the particle count curve over the entire particle domain and in a half-cylinder domain selection, as shown in the following figure: .. GENERATED FROM PYTHON SOURCE LINES 92-95 .. image:: /_static/open_cylinder_result_selection.png :width: 400pt :align: center .. GENERATED FROM PYTHON SOURCE LINES 95-107 .. code-block:: Python processes = project.GetUserProcessCollection() particles = study.GetParticles() cylinder_selection = processes.CreateCylinderProcess(particles) cylinder_selection.SetSize(2, 0.74, 2, unit="m") cylinder_selection.SetCenter(0, -0.37, 0, unit="m") cylinder_selection.SetFinalAngle(180) times, all_particles_count = particles.GetNumpyCurve("Particles Count") times, selection_count = cylinder_selection.GetNumpyCurve("Particles Count") .. GENERATED FROM PYTHON SOURCE LINES 108-110 Plot curves +++++++++++ .. GENERATED FROM PYTHON SOURCE LINES 110-124 .. code-block:: Python import matplotlib.pyplot as plt fig, ax = plt.subplots(1) ax.plot(times, all_particles_count, "b", label="All Particles") ax.plot(times, selection_count, "r", label="Selection Particles") ax.set_xlabel("Time [s]") ax.set_ylabel("Count [-]") ax.legend(loc="upper left") plt.draw() rocky.close() .. image-sg:: /examples/basic_examples/images/sphx_glr_particle_wall_interaction_001.png :alt: particle wall interaction :srcset: /examples/basic_examples/images/sphx_glr_particle_wall_interaction_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 39.052 seconds) .. _sphx_glr_download_examples_basic_examples_particle_wall_interaction.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: particle_wall_interaction.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: particle_wall_interaction.py ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_