.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/regolith_example.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_auto_examples_regolith_example.py: Regolith Sample Demo ==================== Lunar Regolith example simulation taken from JGD's 2018 Thesis. Create two impactors with non-standard grain shapes, orientations, and sizes. .. GENERATED FROM PYTHON SOURCE LINES 9-24 .. code-block:: Python import PySALESetup as pss import matplotlib.pyplot as plt regolith_top = pss.PySALEObject([(0, 0.003), (0.00125, 0.003), (0.00125, 0.006), (0, 0.006)]) regolith_bot = pss.PySALEObject([(0, 0), (0.00125, 0), (0.00125, 0.003), (0, 0.003)]) regolith_top.set_material(1) regolith_bot.set_material(1) top_domain = pss.PySALEDomain(regolith_top) bot_domain = pss.PySALEDomain(regolith_bot) .. GENERATED FROM PYTHON SOURCE LINES 25-28 Fill our two domains with grains, but let's get a random geometry from the grain library to use. .. GENERATED FROM PYTHON SOURCE LINES 28-33 .. code-block:: Python grain_library = pss.GrainLibrary() grain_library.load_builtin_library() grain = grain_library.random_grain() .. rst-class:: sphx-glr-script-out .. code-block:: none /home/runner/work/PySALESetup/PySALESetup/PySALESetup/objects.py:197: UserWarning: genfromtxt: Empty input file: "/home/runner/work/PySALESetup/PySALESetup/PySALESetup/grain_library_directory/__init__.py" coords = np.genfromtxt(file_name, delimiter=',') .. GENERATED FROM PYTHON SOURCE LINES 34-37 It's even possible to set the distribution from which the grains are taken ensuring there is the right variation of grains available. .. GENERATED FROM PYTHON SOURCE LINES 37-53 .. code-block:: Python for domain in [top_domain, bot_domain]: domain.fill_with_random_grains_to_threshold( grain, 50., rotation_distribution=pss.PySALEUniformDistribution((0., 360.)), size_distribution=pss.PySALENormalDistribution(mu=5e-5, sigma=1e-5) ) domain.optimise_materials([2, 3, 4, 5, 6, 7, 8, 9]) regolith_top.set_velocity(0, -1500.) regolith_bot.set_velocity(0, +1500.) .. rst-class:: sphx-glr-script-out .. code-block:: none /home/runner/work/PySALESetup/PySALESetup/PySALESetup/creation.py:554: UserWarning: Max insertion attempts reached (100). Object can not be placed. warnings.warn(f'Max insertion attempts ' .. GENERATED FROM PYTHON SOURCE LINES 54-57 Finally we can create the whole mesh and populate it The commands for this are simple but execution can take some time! .. GENERATED FROM PYTHON SOURCE LINES 57-66 .. code-block:: Python mesh = pss.PySALEMesh.from_dimensions((0.00125, 0.006), 5.e-6) print(mesh) mesh.project_polygons_onto_mesh([regolith_top, regolith_bot]) f, a = mesh.plot_materials() plt.show() .. image-sg:: /auto_examples/images/sphx_glr_regolith_example_001.png :alt: Materials :srcset: /auto_examples/images/sphx_glr_regolith_example_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none PySALEMesh(250, 1200, 5e-06, extension_zones=[], origin=(0.0, 0.0)) .. GENERATED FROM PYTHON SOURCE LINES 67-69 Let's also plot the velocities for completion's sake. .. GENERATED FROM PYTHON SOURCE LINES 69-72 .. code-block:: Python f1, f2, a1, a2 = mesh.plot_velocities() plt.show() .. rst-class:: sphx-glr-horizontal * .. image-sg:: /auto_examples/images/sphx_glr_regolith_example_002.png :alt: Velocity - x :srcset: /auto_examples/images/sphx_glr_regolith_example_002.png :class: sphx-glr-multi-img * .. image-sg:: /auto_examples/images/sphx_glr_regolith_example_003.png :alt: Velocity - y :srcset: /auto_examples/images/sphx_glr_regolith_example_003.png :class: sphx-glr-multi-img .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 21.477 seconds) .. _sphx_glr_download_auto_examples_regolith_example.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: regolith_example.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: regolith_example.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: regolith_example.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_