.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/results/phase_normalization.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_results_phase_normalization.py: Phase density and polar-angle probability ========================================= A phase function is a density per steradian. After explicit azimuth averaging, 2*pi*p(theta)*sin(theta) is the polar-angle probability density per radian. Full solid-angle sampling supplies normalization separately at each Born order. An angular cut alone cannot provide this normalization. .. GENERATED FROM PYTHON SOURCE LINES 10-40 .. code-block:: Python import matplotlib.pyplot as plt import numpy as np from bornsim import Grid, Solver, Source, Sphere, StructuredMedium from bornsim.units import ureg grid = Grid( shape=(12, 12, 12), spacing=20 * ureg.nanometer, ) sphere = Sphere( radius=70 * ureg.nanometer, refractive_index=1.35, ) medium = StructuredMedium() medium.add_background(refractive_index=1.33) medium.add_structures(sphere) volume = medium.to_volume(grid=grid) volume_figure = volume.plot_3d( field="refractive_index", ) .. raw:: html .. GENERATED FROM PYTHON SOURCE LINES 42-76 .. code-block:: Python source = Source(wavelength=633 * ureg.nanometer) solver = Solver( source=source, order=3, ) result = solver.solve(target=volume) averaged = result.azimuth_average() theta = averaged.angles.to("radian").magnitude phase_density = averaged.phase_function.to("1 / steradian").magnitude figure, axes = plt.subplots(1, 2, figsize=(10, 4), layout="constrained") for order in (1, 2, 3): polar_density = 2 * np.pi * phase_density[order - 1] * np.sin(theta) axes[0].plot(theta, phase_density[order - 1], label=f"Order {order}") axes[1].plot(theta, polar_density, label=f"Order {order}") axes[0].set(ylabel="Phase density (sr⁻¹)") axes[1].set(ylabel="Polar-angle density (rad⁻¹)") for axis in axes: axis.set(xlabel="Polar angle (radians)") axis.legend() plt.show() .. image-sg:: /auto_examples/results/images/sphx_glr_phase_normalization_001.png :alt: phase normalization :srcset: /auto_examples/results/images/sphx_glr_phase_normalization_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.668 seconds) .. _sphx_glr_download_auto_examples_results_phase_normalization.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: phase_normalization.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: phase_normalization.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: phase_normalization.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_