.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "examples\basic_examples\minimal.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_minimal.py: .. _ref_minimal: Simple particle simulation -------------------------- This example sets up and solves a simple particle simulation workflow. .. GENERATED FROM PYTHON SOURCE LINES 32-35 Perform imports and create a project ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Perform the required imports and create an empty project. .. GENERATED FROM PYTHON SOURCE LINES 35-48 .. code-block:: Python import os.path import tempfile import ansys.rocky.core as pyrocky # 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() .. GENERATED FROM PYTHON SOURCE LINES 49-52 Configure the study ~~~~~~~~~~~~~~~~~~~ Create a particle entity and then inject it through a circular surface. .. GENERATED FROM PYTHON SOURCE LINES 52-71 .. code-block:: Python study = project.GetStudy() # The default particle entity has a spherical shape and just one size distribution with # the sieve size of 0.1 m. particle = study.CreateParticle() # The default circular surface is defined in the XZ plane and has a maximum radius # of 1.0 m and center in the Cartesian coordinates of (0.0, 0.0, 0.0). circular_surface = study.CreateCircularSurface() study.CreateParticleInlet(entry_point=circular_surface, particle=particle) # The domain settings define the domain limits where the particles are enabled to be # computed in the simulation. domain = study.GetDomainSettings() domain.DisableUseBoundaryLimits() domain.SetCoordinateLimitsMaxValues((10, 1, 10)) .. GENERATED FROM PYTHON SOURCE LINES 72-74 Set up the solver and run the simulation ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .. GENERATED FROM PYTHON SOURCE LINES 74-81 .. code-block:: Python solver = study.GetSolver() solver.SetSimulationDuration(2) # Simulate for 2 sec. project.SaveProject(os.path.join(project_dir, "rocky-testing.rocky")) study.StartSimulation() .. rst-class:: sphx-glr-script-out .. code-block:: none True .. GENERATED FROM PYTHON SOURCE LINES 82-84 Postprocess ~~~~~~~~~~~ .. GENERATED FROM PYTHON SOURCE LINES 84-92 .. code-block:: Python # Get the particles count curve that shows the number of particles inside the domain at # each time step of the simulation. times, particles_count = study.GetParticles().GetNumpyCurve("Particles Count") for time, count in zip(times, particles_count): print(f"Time: {time}s, Count: {count}") rocky.close() .. rst-class:: sphx-glr-script-out .. code-block:: none Time: 0.0s, Count: 0 Time: 0.05s, Count: 1 Time: 0.1s, Count: 2 Time: 0.15s, Count: 3 Time: 0.2s, Count: 4 Time: 0.25s, Count: 5 Time: 0.3s, Count: 6 Time: 0.35s, Count: 7 Time: 0.4s, Count: 8 Time: 0.45s, Count: 9 Time: 0.5s, Count: 10 Time: 0.55s, Count: 11 Time: 0.6s, Count: 12 Time: 0.65s, Count: 13 Time: 0.7s, Count: 14 Time: 0.75s, Count: 15 Time: 0.8s, Count: 16 Time: 0.85s, Count: 17 Time: 0.9s, Count: 18 Time: 0.95s, Count: 19 Time: 1.0s, Count: 20 Time: 1.05s, Count: 21 Time: 1.1s, Count: 22 Time: 1.15s, Count: 23 Time: 1.2s, Count: 24 Time: 1.25s, Count: 25 Time: 1.3s, Count: 26 Time: 1.35s, Count: 27 Time: 1.4s, Count: 28 Time: 1.45s, Count: 28 Time: 1.5s, Count: 28 Time: 1.55s, Count: 28 Time: 1.6s, Count: 28 Time: 1.65s, Count: 27 Time: 1.7s, Count: 27 Time: 1.75s, Count: 27 Time: 1.8s, Count: 28 Time: 1.85s, Count: 27 Time: 1.9s, Count: 27 Time: 1.95s, Count: 27 Time: 2.0s, Count: 28 .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 38.895 seconds) .. _sphx_glr_download_examples_basic_examples_minimal.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: minimal.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: minimal.py ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_