.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/structured_media/particle_families.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_structured_media_particle_families.py: Core–shell and ellipsoidal particles ==================================== Compare finite particle geometries on the same voxel grid. Refractive-index interfaces use voxel-centre sampling; refine the grid for quantitative studies. The solver retains its linearized dielectric contrast for both particle types. .. GENERATED FROM PYTHON SOURCE LINES 9-44 .. code-block:: Python import sys import numpy as np import matplotlib.pyplot as plt from bornsim import CoreShellMedium, EllipsoidMedium, Grid, Solver, Source, Rotation from bornsim.units import ureg grid = Grid( shape=(16, 16, 16), spacing=25 * ureg.nanometer, ) core_shell = CoreShellMedium( background_refractive_index=1.33, core_refractive_index=1.35, shell_refractive_index=1.34, core_radius=60 * ureg.nanometer, outer_radius=120 * ureg.nanometer, centre=np.zeros(3) * ureg.nanometer, ) rotation = Rotation( axis=(0, 1, 0), angle=35 * ureg.degree, ) ellipsoid = EllipsoidMedium( background_refractive_index=1.33, particle_refractive_index=1.34, radii=np.array([120, 80, 60]) * ureg.nanometer, centre=np.zeros(3) * ureg.nanometer, rotation=rotation, ) .. GENERATED FROM PYTHON SOURCE LINES 46-51 Inspect the core and shell -------------------------- The core replaces the shell inside core_radius; both refractive indices are absolute values relative to the same uniform exterior. The shell is sampled at voxel centres, so its thickness must be resolved by the grid. .. GENERATED FROM PYTHON SOURCE LINES 51-64 .. code-block:: Python core_shell_volume = core_shell.to_volume(grid=grid) core_shell_figure = core_shell_volume.plot_3d( backend="plotly", mode="volume", field="refractive_index", ) core_shell_figure.update_layout(title="Core–shell sphere: 60 nm core, 120 nm outer radius") if "--no-browser" not in sys.argv: core_shell_figure.show(renderer="browser") .. raw:: html .. GENERATED FROM PYTHON SOURCE LINES 65-69 Inspect an oriented ellipsoid ----------------------------- Rotation maps the local semi-axes to world coordinates. Here the long axis is tilted about y; no voxel-array rotation or interpolation is performed. .. GENERATED FROM PYTHON SOURCE LINES 69-82 .. code-block:: Python ellipsoid_volume = ellipsoid.to_volume(grid=grid) ellipsoid_figure = ellipsoid_volume.plot_3d( backend="plotly", mode="volume", field="refractive_index", ) ellipsoid_figure.update_layout(title="Ellipsoid: 120 × 80 × 60 nm semi-axes, tilted 35°") if "--no-browser" not in sys.argv: ellipsoid_figure.show(renderer="browser") .. raw:: html .. GENERATED FROM PYTHON SOURCE LINES 83-88 Compare scattering ------------------ The curves use the x-z observation meridian and cumulative first Born order. Differences reflect both geometry and material contrast; this comparison does not isolate shape alone or validate against an exact solver. .. GENERATED FROM PYTHON SOURCE LINES 88-114 .. code-block:: Python source = Source(wavelength=633 * ureg.nanometer) solver = Solver( source=source, order=1, ) angles = np.linspace(0, 180, 121) * ureg.degree figure, axis = plt.subplots(layout="constrained") for label, volume in (("Core–shell", core_shell_volume), ("Ellipsoid", ellipsoid_volume)): result = solver.solve_cut( target=volume, angles=angles, ) cross_section = result.differential_cross_section.to("nanometer**2 / steradian") axis.plot(angles.to("degree").magnitude, cross_section.magnitude[-1], label=label) axis.set(xlabel="Scattering angle (degrees)", ylabel="dσ/dΩ (nm² sr⁻¹)", title="First Born order") axis.legend(frameon=False) plt.show() .. image-sg:: /auto_examples/structured_media/images/sphx_glr_particle_families_001.png :alt: First Born order :srcset: /auto_examples/structured_media/images/sphx_glr_particle_families_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.410 seconds) .. _sphx_glr_download_auto_examples_structured_media_particle_families.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: particle_families.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: particle_families.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: particle_families.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_