.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "gallery/sources_and_detectors/surface_detector.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_sources_and_detectors_surface_detector.py: Collect light with finite apertures ============================================================ Place two circular contact detectors on a finite optical phantom. Each aperture samples escaping power over a disk and accepts outgoing rays within an explicit cone. Collection uses a Lambertian escape assumption; it does not model angle-dependent Fresnel transmission or detector back-action. .. GENERATED FROM PYTHON SOURCE LINES 10-28 .. code-block:: Python import os import numpy as np import MomentRT from MomentRT import ( P1, CartesianMesh, Material, RobinBoundary, Simulation, StructuredMedium, SurfaceDetector, SurfaceSource, ureg, ) show_figures = os.environ.get("MOMENTRT_SPHINX_GALLERY") != "1" .. GENERATED FROM PYTHON SOURCE LINES 30-34 Define a monochromatic phantom and incoming diffuse spot ------------------------------------------------------------ The optical coefficients are illustrative at 800 nm. Positive z points into the sample, so reflected light exits toward negative z. .. GENERATED FROM PYTHON SOURCE LINES 34-71 .. code-block:: Python material = Material( phase_function=MomentRT.phase_function.HenyeyGreenstein(), absorption=0.02 / ureg.mm, reduced_scattering=1.0 / ureg.mm, refractive_index=1.4, ) sample = StructuredMedium( origin=(-4, -3, 0) * ureg.mm, size=(8, 6, 4) * ureg.mm, ) sample.add_background(material=material) source = SurfaceSource( face="z_min", position=np.array([-1.5, 0, 0]) * ureg.mm, radius=0.8 * ureg.mm, wavelength=800 * ureg.nm, optical_power=1 * ureg.mW, ) mesh = CartesianMesh.from_sample( sample=sample, shape=(17, 13, 13), ) boundary = RobinBoundary(effective_reflectance=0.4) solver = P1( boundaries={ face: boundary for face in ("x_min", "x_max", "y_min", "y_max", "z_min", "z_max") }, ) .. GENERATED FROM PYTHON SOURCE LINES 72-78 Specify aperture geometry and angular acceptance ------------------------------------------------ collection_axis points along accepted ray propagation, out of the sample. The radius describes a disk in the face plane. acceptance_angle is the half-angle around that axis. A normal 30-degree cone collects one quarter of Lambertian escaping power from its sampled aperture. .. GENERATED FROM PYTHON SOURCE LINES 78-110 .. code-block:: Python reflection_detector = SurfaceDetector( face="z_min", position=np.array([1.5, 0, 0]) * ureg.mm, radius=0.75 * ureg.mm, collection_axis=np.array([0, 0, -1]), acceptance_angle=30 * ureg.degree, ) transmission_detector = SurfaceDetector( face="z_max", position=np.array([0, 0, 4]) * ureg.mm, radius=0.9 * ureg.mm, collection_axis=np.array([0, 0, 1]), acceptance_angle=60 * ureg.degree, ) simulation = Simulation( medium=sample, source=source, mesh=mesh, solver=solver, detectors={ "reflection": reflection_detector, "transmission": transmission_detector, }, ) system_figure = simulation.plot_system( show=show_figures, ) .. raw:: html .. GENERATED FROM PYTHON SOURCE LINES 111-118 Solve, inspect power, and check aperture sampling ------------------------------------------------- Detector power is a passive readout of the solved boundary field. It does not reduce the escaping power in the energy balance. The sampled aperture area should approach the geometric area under mesh refinement. The volume plot reuses the same source and detector geometry through overlays. Legend entries toggle each object; the opacity slider controls only fluence. .. GENERATED FROM PYTHON SOURCE LINES 118-136 .. code-block:: Python result = simulation.run() for name, measurement in result.detectors.items(): print(f"{name} collected power: {measurement.collected_power.to('mW'):~P}") print(f"{name} sampled area: {measurement.sampled_area.to('mm^2'):~P}") print(f"{name} geometric area: {measurement.geometric_area.to('mm^2'):~P}") fluence_figure = result.fluence.plot( view="volume", scale="log", overlays=[source, reflection_detector, transmission_detector], show=show_figures, ) .. raw:: html .. rst-class:: sphx-glr-script-out .. code-block:: none reflection collected power: 0.0023266510337788663 mW reflection sampled area: 1.8333333333333337 mm² reflection geometric area: 1.7671458676442586 mm² transmission collected power: 0.006764921136876683 mW transmission sampled area: 2.416666666666667 mm² transmission geometric area: 2.5446900494077327 mm² .. GENERATED FROM PYTHON SOURCE LINES 137-140 Inspect the modeled geometry ---------------------------- This view shows the configured geometry and instrument footprints. .. GENERATED FROM PYTHON SOURCE LINES 140-142 .. code-block:: Python gallery_system_figure = simulation.plot_system(show=False) .. raw:: html .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.233 seconds) .. _sphx_glr_download_gallery_sources_and_detectors_surface_detector.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: surface_detector.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: surface_detector.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: surface_detector.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_