.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/born_orders/contrast_sensitivity.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_born_orders_contrast_sensitivity.py: Contrast sensitivity of successive Born corrections =================================================== Compare positive and negative refractive index offsets at fixed geometry. The first intensity is even in contrast; higher orders can break that symmetry. All orders use linearized dielectric contrast and the spherical Green self cell. These small examples illustrate corrections, not a universal convergence bound. .. GENERATED FROM PYTHON SOURCE LINES 10-22 .. code-block:: Python import matplotlib.pyplot as plt from bornsim import Grid, Solver, Source, Sphere, StructuredMedium from bornsim.units import ureg grid = Grid( shape=(12, 12, 12), spacing=20 * ureg.nanometer, ) .. GENERATED FROM PYTHON SOURCE LINES 24-59 .. code-block:: Python source = Source(wavelength=633 * ureg.nanometer) solver = Solver( source=source, order=4, ) scattering_areas = [] for delta_refractive_index in (-0.04, -0.02, 0.02, 0.04): sphere = Sphere( radius=70 * ureg.nanometer, refractive_index=1.33 + delta_refractive_index, ) 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", ) volume_figure.update_layout(title=f"Refractive index offset {delta_refractive_index:+.2f}") result = solver.solve(target=volume) scattering_area = (result.mu_s * result.sample_volume).to("nanometer**2") scattering_areas.append(scattering_area) .. raw:: html .. GENERATED FROM PYTHON SOURCE LINES 60-61 Compare cumulative cross sections on the same scale. .. GENERATED FROM PYTHON SOURCE LINES 61-71 .. code-block:: Python figure, axis = plt.subplots(layout="constrained") for delta_refractive_index, scattering_area in zip((-0.04, -0.02, 0.02, 0.04), scattering_areas, strict=True): axis.plot(range(1, 5), scattering_area.magnitude, "o-", label=f"Offset {delta_refractive_index:+.2f}") axis.set(xlabel="Cumulative Born order", ylabel="Scattering cross section (nm²)", xticks=range(1, 5)) axis.legend() plt.show() .. image-sg:: /auto_examples/born_orders/images/sphx_glr_contrast_sensitivity_001.png :alt: contrast sensitivity :srcset: /auto_examples/born_orders/images/sphx_glr_contrast_sensitivity_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 2.517 seconds) .. _sphx_glr_download_auto_examples_born_orders_contrast_sensitivity.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: contrast_sensitivity.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: contrast_sensitivity.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: contrast_sensitivity.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_