.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "gallery/samples_and_meshes/cartesian_shape.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_gallery_samples_and_meshes_cartesian_shape.py: Create a Cartesian mesh from node counts ======================================== Build a regular finite-element grid by choosing the node count along each sample axis. The plot shows the grid inside the sample bounds. .. GENERATED FROM PYTHON SOURCE LINES 8-12 .. code-block:: Python import MomentRT from MomentRT import CartesianMesh, Material, StructuredMedium, ureg .. GENERATED FROM PYTHON SOURCE LINES 14-16 Define a finite sample ---------------------- .. GENERATED FROM PYTHON SOURCE LINES 16-31 .. code-block:: Python material = Material( absorption=0.02 / ureg.millimeter, reduced_scattering=1.0 / ureg.millimeter, refractive_index=1.4, anisotropy=0.8, phase_function=MomentRT.HenyeyGreenstein(), ) sample = StructuredMedium( origin=(-2, -2, 0) * ureg.millimeter, size=(4, 4, 3) * ureg.millimeter, ) sample.add_background(material=material) .. GENERATED FROM PYTHON SOURCE LINES 32-34 Create and plot the regular grid -------------------------------- .. GENERATED FROM PYTHON SOURCE LINES 34-47 .. code-block:: Python mesh = CartesianMesh.from_sample( sample=sample, shape=(9, 9, 7), ) figure = mesh.plot( length_unit="mm", show=False, ) print(f"Cartesian mesh node counts: {mesh.shape}") print(f"Cartesian mesh spacing: {mesh.spacing.to('mm')}") .. raw:: html .. rst-class:: sphx-glr-script-out .. code-block:: none Cartesian mesh node counts: (9, 9, 7) Cartesian mesh spacing: [0.5 0.5 0.5] millimeter .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.023 seconds) .. _sphx_glr_download_gallery_samples_and_meshes_cartesian_shape.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: cartesian_shape.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: cartesian_shape.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: cartesian_shape.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_