.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/results/angular_cut_and_full.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_angular_cut_and_full.py: Angular cuts and full directional results ========================================= Compare a meridian cut with the matching meridian of a full solve through second order. The cut keeps complex amplitudes but has no integrated scattering coefficient. Full quadrature additionally supplies finite-sample coefficients. Changing observation sampling does not change the internal Born field. .. GENERATED FROM PYTHON SOURCE LINES 10-40 .. code-block:: Python import matplotlib.pyplot as plt import numpy as np from bornsim import AngularSampling, 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-78 .. code-block:: Python source = Source(wavelength=633 * ureg.nanometer) solver = Solver( source=source, order=2, ) sampling = AngularSampling( n_points=91, polar_samples=24, azimuth_samples=16, ) full_result = solver.solve( target=volume, sampling=sampling, ) cut_result = solver.solve_cut( target=volume, angles=full_result.angles, ) meridian = full_result.meridian(azimuth=0 * ureg.degree) relative_difference = np.max(abs(cut_result.differential.magnitude - meridian.differential.magnitude)) / np.max( abs(cut_result.differential.magnitude) ) print(f"Maximum relative meridian difference: {relative_difference:.3e}") print(f"Full-solve finite-sample scattering coefficient: {full_result.mu_s}") cut_result.plot_cross_section() plt.show() .. image-sg:: /auto_examples/results/images/sphx_glr_angular_cut_and_full_001.png :alt: Finite-sample differential cross section :srcset: /auto_examples/results/images/sphx_glr_angular_cut_and_full_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none Maximum relative meridian difference: 0.000e+00 Full-solve finite-sample scattering coefficient: [127.53522857977589 126.14371039974394] / meter .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.647 seconds) .. _sphx_glr_download_auto_examples_results_angular_cut_and_full.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: angular_cut_and_full.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: angular_cut_and_full.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: angular_cut_and_full.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_