Source code structures#
- class PyMieSim.single.source.PlaneWave(*, wavelength: float, polarization_value: float, polarization_type: str = 'linear', amplitude: float | None = None)#
Bases:
LightSource
Represents a plane wave light source for light scattering simulations.
Inherits from LightSource and specifies amplitude directly.
- amplitude: float | None = None#
- generate_polarization_attribute() None #
Generates the polarization attribute based on the specified polarization_type and polarization_value.
- interpret_circular_polarization(value: str)#
Interprets the given value as circular polarization.
- Parameters:
value (str): ‘right’ or ‘left’ indicating the circular polarization direction.
- Returns:
polarization.RightCircular or polarization.LeftCircular: The circular polarization object.
- interpret_jones_vector(value: Iterable) JonesVector #
Interprets the given value as a Jones vector.
- Parameters:
value (Iterable): A size 2 iterable representing the Jones vector.
- Returns:
polarization.JonesVector: The Jones vector representation of the polarization.
- plot() SceneList #
Plots the structure of the PlaneWave source.
- Returns:
SceneList3D: A 3D plotting scene object.
- polarization_type: str = 'linear'#
- polarization_value: float#
- wavelength: float#
- class PyMieSim.single.scatterer.Sphere(diameter: float, source: PlaneWave | Gaussian, index: complex = None, medium_index: float = 1.0, material: DataMeasurement | Sellmeier | None = None)#
Bases:
GenericScatterer
Class representing a homogeneous spherical scatterer
- property Cabs: float#
Absorption cross-section.
- property Cback: float#
Backscattering cross-section.
- property Cext: float#
Extinction cross-section.
- property Cpr: float#
Radiation pressure cross-section.
- property Cratio: float#
Ratio of backscattering cross-section over total scattering.
- property Csca: float#
Scattering cross-section.
- property Qabs: float#
Absorption efficiency.
- property Qback: float#
Backscattering efficiency.
- property Qext: float#
Extinction efficiency.
- property Qpr: float#
Radiation pressure efficiency.
- property Qratio: float#
Efficiency: Ratio of backscattering over total scattering.
- property Qsca: float#
Scattering efficiency.
- an(max_order: int = None) array #
Compute \(a_n\) coefficient as defined in Eq:III.88 of B&B:
\[a_n = \frac{ \mu_{sp} \Psi_n(\alpha) \Psi_n^\prime(\beta) - \mu M \Psi_n^\prime(\alpha) \Psi_n(\beta)} {\mu_{sp} \xi_n(\alpha) \Psi_n^\prime(\beta)- \mu M \xi_n^\prime (\alpha) \Psi_n(\beta)}\]With \(M = \frac{k_{sp}}{k}\) (Eq:I.103)
- property area: float#
- bn(max_order: int = None) array #
Compute \(b_n\) coefficient as defined in Eq:III.89 of B&B:
\[b_n = \frac{ \mu M \Psi_n(\alpha) \Psi_n^\prime(\beta) - \mu_{sp} \Psi_n^\prime(\alpha) \Psi_n(\beta)} {\mu M \xi_n(\alpha) \Psi_n^\prime(\beta)- \mu_{sp} \xi_n^\prime (\alpha) \Psi_n(\beta)}\]With \(M = \frac{k_{sp}}{k}\) (Eq:I.103)
- cn(max_order: int = None) array #
Compute \(c_n\) coefficient as defined in Eq:III.90 of B&B:
\[c_n = \frac{ \mu_{sp} M \big[ \xi_n(\alpha) \Psi_n^\prime(\alpha) - \xi_n^\prime(\alpha) \Psi_n(\alpha) \big]} {\mu_{sp} \xi_n(\alpha) \Psi_n^\prime(\beta)- \mu M \xi_n^\prime (\alpha) \Psi_n(\beta)}\]With \(M = \frac{k_{sp}}{k}\) (Eq:I.103)
- diameter: float#
diameter of the single scatterer in unit of meter.
- dn(max_order: int = None) array #
Compute \(d_n\) coefficient as defined in Eq:III.91 of B&B:
\[d_n = \frac{ \mu M^2 \big[ \xi_n(\alpha) \Psi_n^\prime(\alpha) - \xi_n^\prime(\alpha) \Psi_n(\alpha) \big]} {\mu M \xi_n(\alpha) \Psi_n^\prime(\beta)- \mu_{sp} M \xi_n^\prime (\alpha) \Psi_n(\beta)}\]With \(M = \frac{k_{sp}}{k}\) (Eq:I.103)
- property g: float#
Anisotropy factor.
- get_cross_section()#
- get_energy_flow(mesh: FibonacciMesh) float #
Returns energy flow defined as:
\[\begin{split}W_a &= \sigma_{sca} * I_{inc} \\[10pt] P &= \int_{A} I dA \\[10pt] I &= \frac{c n \epsilon_0}{2} |E|^2 \\[10pt]\end{split}\]With:I : Energy densityn : Refractive index of the medium\(\epsilon_0\) : Vaccum permitivityE : Electric fieldsigma_{sca}: Scattering cross section.More info on wikipedia link (see ref[6]).
- Parameters:
Mesh (FibonacciMesh) – The mesh
- Returns:
The energy flow.
- Return type:
float
- get_far_field(**kwargs) FarField #
Returns the scattering far-fields defined as.
\[\text{Fields} = E_{||}(\phi,\theta)^2, E_{\perp}(\phi,\theta)^2\]The Fields are up to a constant phase value:
\[\exp{\big(-i k r \big)}\]- Parameters:
kwargs (dictionary) – The keywords arguments
- Returns:
The far field.
- Return type:
FarField
- get_farfields_array(phi: ndarray, theta: ndarray, r: ndarray) array #
Method Compute scattering Far Field for unstructured coordinate.
\[\text{Fields} = E_{||}(\phi,\theta), E_{\perp}(\phi,\theta)\]The Fields are up to a constant phase value.
\[\exp{\big(-i k r \big)}\]- Parameters:
phi (numpy.ndarray) – The phi array
theta (numpy.ndarray) – The theta array
r (numpy.ndarray) – The radial array
structured (bool) – Indicates if computing mesh is structured or not
- Returns:
The far fields
- Return type:
numpy.ndarray
- get_footprint(detector) Footprint #
Return the footprint of the scattererd light coupling with the detector as computed as:
\[\big| \mathscr{F}^{-1} \big\{ \tilde{ \psi } (\xi, \nu),\ \tilde{ \phi}_{l,m}(\xi, \nu) \big\} (\delta_x, \delta_y) \big|^2\]Where:\(\Phi_{det}\) is the capturing field of the detector and\(\Psi_{scat}\) is the scattered field.- Parameters:
detector (GenericDetector) – The detector
- Returns:
The scatterer footprint.
- Return type:
Footprint
- get_poynting_vector(mesh: FibonacciMesh) float #
Method return the Poynting vector norm defined as:
\[\vec{S} = \epsilon c^2 \vec{E} \times \vec{B}\]- Parameters :
Mesh : Number of voxel in the 4 pi space to compute energy flow.
- get_s1s2(**kwargs) S1S2 #
Method compute \(S_1(\phi)\) and \(S_2(\phi)\). For spherical Scatterer such as here S1 and S2 are computed as follow:
\[ \begin{align}\begin{aligned}\begin{split}S_1=\sum\limits_{n=1}^{n_{max}} \frac{2n+1}{n(n+1)}(a_n \pi_n+b_n \tau_n) \\[10pt]\end{split}\\\begin{split}S_2=\sum\limits_{n=1}^{n_{max}}\frac{2n+1}{n(n+1)}(a_n \tau_n+b_n \pi_n) \\[10pt]\end{split}\end{aligned}\end{align} \]- Parameters:
kwargs (dictionary) – The keywords arguments
- Returns:
The S1 and S2 parameters
- Return type:
S1S2
- get_spf(**kwargs) SPF #
Returns the scattering phase function.
\[\text{SPF} = \sqrt{ E_{\parallel}(\phi,\theta)^2 + E_{\perp}(\phi,\theta)^2 }\]- Parameters:
kwargs (dictionary) – The keywords arguments
- Returns:
The scattering phase function.
- Return type:
SPF
- get_stokes(**kwargs) Stokes #
Returns the four Stokes components. The method compute the Stokes parameters: I, Q, U, V. Those parameters are defined as:
- Parameters:
kwargs (dictionary) – The keywords arguments
- Returns:
The stokes.
- Return type:
Stokes
- index: complex = None#
Refractive index of scatterer.
- material: DataMeasurement | Sellmeier | None = None#
Material of which the scatterer is made of. Only if index is not specified.
- medium_index: float = 1.0#
Refractive index of scatterer medium.
- print_properties() None #
- set_cpp_binding() None #
Method call and bind c++ scatterer class
- property size_parameter: float#
- class PyMieSim.single.scatterer.Cylinder(diameter: float, source: PlaneWave | Gaussian, index: complex = None, medium_index: float = 1.0, material: DataMeasurement | Sellmeier | None = None)#
Bases:
GenericScatterer
Class representing a right angle cylindrical scatterer.
- property Cabs: float#
Absorption cross-section.
- property Cback: None#
Backscattering cross-section.
- property Cext: float#
Extinction cross-section.
- property Cpr: None#
Radiation pressure cross-section.
- property Cratio: None#
Ratio of backscattering cross-section over total scattering.
- property Csca: float#
Scattering cross-section.
- property Qabs: float#
Absorption efficiency.
- property Qback: None#
Backscattering efficiency.
- property Qext: float#
Extinction efficiency.
- property Qpr: None#
Radiation pressure efficiency.
- property Qratio: None#
Efficiency: Ratio of backscattering over total scattering.
- property Qsca: float#
Scattering efficiency.
- a1n(max_order: int = None) array #
Compute \(a_n\) coefficient as defined ref[5]:
\[a_n = \frac{ m_t J_n(m_t x) J_n^\prime (m x) - m J_n^\prime (m_t x) J_n(m x) } { m_t J_n(m_t x) H_n^\prime (m x) - m J_n^\prime (m_t x) H_n(m x) }\]With \(m\) being the refractive index of the medium and\(m_t\) being the refractive index of the index.- Parameters:
max_order (int) – The maximum order
- Returns:
The first electric mutlipole amplitude
- Return type:
numpy.array
- a2n(max_order: int = None) array #
Compute \(a_n\) coefficient as defined ref[5]:
\[a_n = \frac{ m_t J_n(m_t x) J_n^\prime (m x) - m J_n^\prime (m_t x) J_n(m x) } { m_t J_n(m_t x) H_n^\prime (m x) - m J_n^\prime (m_t x) H_n(m x) }\]With \(m\) being the refractive index of the medium and\(m_t\) being the refractive index of the index.- Parameters:
max_order (int) – The maximum order
- Returns:
The second electric mutlipole amplitude
- Return type:
numpy.array
- property area: float#
- b1n(max_order: int = None) array #
Compute \(b_n\) coefficient as defined in ref[5]:
\[b_n = \frac{ m J_n(m_t x) J_n^\prime (m x) - m_t J_n^\prime (m_t x) J_n(m x) } { m J_n(m_t x) H_n^\prime (m x) - m_t J_n^\prime (m_t x) H_n(m x) }\]With \(m\) being the refractive index of the medium and\(m_t\) being the refractive index of the index.- Parameters:
max_order (int) – The maximum order
- Returns:
The first magnetic mutlipole amplitude
- Return type:
numpy.array
- b2n(max_order: int = None) array #
Compute \(b_n\) coefficient as defined in ref[5]:
\[b_n = \frac{ m J_n(m_t x) J_n^\prime (m x) - m_t J_n^\prime (m_t x) J_n(m x) } { m J_n(m_t x) H_n^\prime (m x) - m_t J_n^\prime (m_t x) H_n(m x) }\]With \(m\) being the refractive index of the medium and\(m_t\) being the refractive index of the index.- Parameters:
max_order (int) – The maximum order
- Returns:
The second magnetic mutlipole amplitude
- Return type:
numpy.array
- diameter: float#
diameter of the single scatterer in unit of meter.
- property g: float#
Anisotropy factor.
- get_cross_section()#
- get_energy_flow(mesh: FibonacciMesh) float #
Returns energy flow defined as:
\[\begin{split}W_a &= \sigma_{sca} * I_{inc} \\[10pt] P &= \int_{A} I dA \\[10pt] I &= \frac{c n \epsilon_0}{2} |E|^2 \\[10pt]\end{split}\]With:I : Energy densityn : Refractive index of the medium\(\epsilon_0\) : Vaccum permitivityE : Electric fieldsigma_{sca}: Scattering cross section.More info on wikipedia link (see ref[6]).
- Parameters:
Mesh (FibonacciMesh) – The mesh
- Returns:
The energy flow.
- Return type:
float
- get_far_field(**kwargs) FarField #
Returns the scattering far-fields defined as.
\[\text{Fields} = E_{||}(\phi,\theta)^2, E_{\perp}(\phi,\theta)^2\]The Fields are up to a constant phase value:
\[\exp{\big(-i k r \big)}\]- Parameters:
kwargs (dictionary) – The keywords arguments
- Returns:
The far field.
- Return type:
FarField
- get_farfields_array(phi: ndarray, theta: ndarray, r: ndarray) array #
Method Compute scattering Far Field for unstructured coordinate.
\[\text{Fields} = E_{||}(\phi,\theta), E_{\perp}(\phi,\theta)\]The Fields are up to a constant phase value.
\[\exp{\big(-i k r \big)}\]- Parameters:
phi (numpy.ndarray) – The phi array
theta (numpy.ndarray) – The theta array
r (numpy.ndarray) – The radial array
structured (bool) – Indicates if computing mesh is structured or not
- Returns:
The far fields
- Return type:
numpy.ndarray
- get_footprint(detector) Footprint #
Return the footprint of the scattererd light coupling with the detector as computed as:
\[\big| \mathscr{F}^{-1} \big\{ \tilde{ \psi } (\xi, \nu),\ \tilde{ \phi}_{l,m}(\xi, \nu) \big\} (\delta_x, \delta_y) \big|^2\]Where:\(\Phi_{det}\) is the capturing field of the detector and\(\Psi_{scat}\) is the scattered field.- Parameters:
detector (GenericDetector) – The detector
- Returns:
The scatterer footprint.
- Return type:
Footprint
- get_poynting_vector(mesh: FibonacciMesh) float #
Method return the Poynting vector norm defined as:
\[\vec{S} = \epsilon c^2 \vec{E} \times \vec{B}\]- Parameters :
Mesh : Number of voxel in the 4 pi space to compute energy flow.
- get_s1s2(**kwargs) S1S2 #
Method compute \(S_1(\phi)\) and \(S_2(\phi)\). For spherical Scatterer such as here S1 and S2 are computed as follow:
\[ \begin{align}\begin{aligned}\begin{split}S_1=\sum\limits_{n=1}^{n_{max}} \frac{2n+1}{n(n+1)}(a_n \pi_n+b_n \tau_n) \\[10pt]\end{split}\\\begin{split}S_2=\sum\limits_{n=1}^{n_{max}}\frac{2n+1}{n(n+1)}(a_n \tau_n+b_n \pi_n) \\[10pt]\end{split}\end{aligned}\end{align} \]- Parameters:
kwargs (dictionary) – The keywords arguments
- Returns:
The S1 and S2 parameters
- Return type:
S1S2
- get_spf(**kwargs) SPF #
Returns the scattering phase function.
\[\text{SPF} = \sqrt{ E_{\parallel}(\phi,\theta)^2 + E_{\perp}(\phi,\theta)^2 }\]- Parameters:
kwargs (dictionary) – The keywords arguments
- Returns:
The scattering phase function.
- Return type:
SPF
- get_stokes(**kwargs) Stokes #
Returns the four Stokes components. The method compute the Stokes parameters: I, Q, U, V. Those parameters are defined as:
- Parameters:
kwargs (dictionary) – The keywords arguments
- Returns:
The stokes.
- Return type:
Stokes
- index: complex = None#
Refractive index of scatterer.
- material: DataMeasurement | Sellmeier | None = None#
Refractive index of scatterer medium.
- medium_index: float = 1.0#
Material of which the scatterer is made of. Only if index is not specified.
- print_properties() None #
- set_cpp_binding() None #
Binds the Python representation of the cylinder to its C++ counterpart using provided properties.
- property size_parameter: float#
- class PyMieSim.single.scatterer.CoreShell(core_diameter: float, shell_width: float, source: PlaneWave | Gaussian, core_index: complex = None, shell_index: complex = None, core_material: DataMeasurement | Sellmeier | None = None, shell_material: DataMeasurement | Sellmeier | None = None, medium_index: float = 1.0)#
Bases:
GenericScatterer
Class representing a core/shell spherical scatterer.
- property Cabs: float#
Absorption cross-section.
- property Cback: float#
Backscattering cross-section.
- property Cext: float#
Extinction cross-section.
- property Cpr: float#
Radiation pressure cross-section.
- property Cratio: float#
Ratio of backscattering cross-section over total scattering.
- property Csca: float#
Scattering cross-section.
- property Qabs: float#
Absorption efficiency.
- property Qback: float#
Backscattering efficiency.
- property Qext: float#
Extinction efficiency.
- property Qpr: float#
Radiation pressure efficiency.
- property Qratio: float#
Efficiency: Ratio of backscattering over total scattering.
- property Qsca: float#
Scattering efficiency.
- an(max_order: int = None) array #
Compute \(a_n\) coefficient
- property area: float#
- bn(max_order: int = None) array #
Compute \(b_n\) coefficient.
- core_diameter: float#
diameter of the core of the single scatterer [m].
- core_index: complex = None#
Refractive index of the core of the scatterer.
- core_material: DataMeasurement | Sellmeier | None = None#
Core material of which the scatterer is made of. Only if core_index is not specified.
- property g: float#
Anisotropy factor.
- get_cross_section()#
- get_energy_flow(mesh: FibonacciMesh) float #
Returns energy flow defined as:
\[\begin{split}W_a &= \sigma_{sca} * I_{inc} \\[10pt] P &= \int_{A} I dA \\[10pt] I &= \frac{c n \epsilon_0}{2} |E|^2 \\[10pt]\end{split}\]With:I : Energy densityn : Refractive index of the medium\(\epsilon_0\) : Vaccum permitivityE : Electric fieldsigma_{sca}: Scattering cross section.More info on wikipedia link (see ref[6]).
- Parameters:
Mesh (FibonacciMesh) – The mesh
- Returns:
The energy flow.
- Return type:
float
- get_far_field(**kwargs) FarField #
Returns the scattering far-fields defined as.
\[\text{Fields} = E_{||}(\phi,\theta)^2, E_{\perp}(\phi,\theta)^2\]The Fields are up to a constant phase value:
\[\exp{\big(-i k r \big)}\]- Parameters:
kwargs (dictionary) – The keywords arguments
- Returns:
The far field.
- Return type:
FarField
- get_farfields_array(phi: ndarray, theta: ndarray, r: ndarray) array #
Method Compute scattering Far Field for unstructured coordinate.
\[\text{Fields} = E_{||}(\phi,\theta), E_{\perp}(\phi,\theta)\]The Fields are up to a constant phase value.
\[\exp{\big(-i k r \big)}\]- Parameters:
phi (numpy.ndarray) – The phi array
theta (numpy.ndarray) – The theta array
r (numpy.ndarray) – The radial array
structured (bool) – Indicates if computing mesh is structured or not
- Returns:
The far fields
- Return type:
numpy.ndarray
- get_footprint(detector) Footprint #
Return the footprint of the scattererd light coupling with the detector as computed as:
\[\big| \mathscr{F}^{-1} \big\{ \tilde{ \psi } (\xi, \nu),\ \tilde{ \phi}_{l,m}(\xi, \nu) \big\} (\delta_x, \delta_y) \big|^2\]Where:\(\Phi_{det}\) is the capturing field of the detector and\(\Psi_{scat}\) is the scattered field.- Parameters:
detector (GenericDetector) – The detector
- Returns:
The scatterer footprint.
- Return type:
Footprint
- get_poynting_vector(mesh: FibonacciMesh) float #
Method return the Poynting vector norm defined as:
\[\vec{S} = \epsilon c^2 \vec{E} \times \vec{B}\]- Parameters :
Mesh : Number of voxel in the 4 pi space to compute energy flow.
- get_s1s2(**kwargs) S1S2 #
Method compute \(S_1(\phi)\) and \(S_2(\phi)\). For spherical Scatterer such as here S1 and S2 are computed as follow:
\[ \begin{align}\begin{aligned}\begin{split}S_1=\sum\limits_{n=1}^{n_{max}} \frac{2n+1}{n(n+1)}(a_n \pi_n+b_n \tau_n) \\[10pt]\end{split}\\\begin{split}S_2=\sum\limits_{n=1}^{n_{max}}\frac{2n+1}{n(n+1)}(a_n \tau_n+b_n \pi_n) \\[10pt]\end{split}\end{aligned}\end{align} \]- Parameters:
kwargs (dictionary) – The keywords arguments
- Returns:
The S1 and S2 parameters
- Return type:
S1S2
- get_spf(**kwargs) SPF #
Returns the scattering phase function.
\[\text{SPF} = \sqrt{ E_{\parallel}(\phi,\theta)^2 + E_{\perp}(\phi,\theta)^2 }\]- Parameters:
kwargs (dictionary) – The keywords arguments
- Returns:
The scattering phase function.
- Return type:
SPF
- get_stokes(**kwargs) Stokes #
Returns the four Stokes components. The method compute the Stokes parameters: I, Q, U, V. Those parameters are defined as:
- Parameters:
kwargs (dictionary) – The keywords arguments
- Returns:
The stokes.
- Return type:
Stokes
- medium_index: float = 1.0#
Refractive index of scatterer medium.
- print_properties() None #
- set_cpp_binding() None #
Method call and bind c++ scatterer class
- shell_index: complex = None#
Refractive index of the shell of the scatterer.
- shell_material: DataMeasurement | Sellmeier | None = None#
Shell material of which the scatterer is made of. Only if shell_index is not specified.
- shell_width: float#
diameter of the shell of the single scatterer [m].
- property size_parameter: float#
- class PyMieSim.single.detector.Photodiode(NA: float, gamma_offset: float, phi_offset: float, sampling: int = 200, polarization_filter: float = None)#
Bases:
GenericDetector
Detector type class representing a photodiode, light coupling mechanism is non-coherent and thus independent of the phase of the impinging scattered light field.
- NA: float#
Numerical aperture of imaging system.
- coherent: bool = False#
Indicate if the coupling mechanism is coherent or not
- coupling(scatterer: Sphere | CoreShell | Cylinder) float #
Calculate the light coupling between the detector and a scatterer.
\[|\iint_{\Omega} \Phi_{det} \,\, \Psi_{scat}^* \, d \Omega|^2\]Where:\(\Phi_{det}\) is the capturing field of the detector and\(\Psi_{scat}\) is the scattered field.- Args:
scatterer (Sphere|CoreShell|Cylinder): The scatterer object.
- Returns:
float: The coupling in watts.
- gamma_offset: float#
Angle [Degree] offset of detector in the direction perpendicular to polarization.
- get_footprint(scatterer: Sphere | CoreShell | Cylinder) Footprint #
Generate the footprint of the scattered light coupling with the detector.
\[\big| \mathscr{F}^{-1} \big\{ \tilde{ \psi } (\xi, \nu),\ \tilde{ \phi}_{l,m}(\xi, \nu) \big\} (\delta_x, \delta_y) \big|^2\]Where:\(\Phi_{det}\) is the capturing field of the detector and\(\Psi_{scat}\) is the scattered field.- Args:
scatterer (Sphere|CoreShell|Cylinder): The scatterer object.
- Returns:
Footprint: The scatterer footprint with this detector.
- get_structured_scalarfield(sampling: int = 100) ndarray #
- mean_coupling: bool = False#
Indicate if the coupling mechanism is point-wise or mean-wise. Value is either point or mean.
- phi_offset: float#
Angle [Degree] offset of detector in the direction parallel to polarization.
- plot() SceneList #
Plot the real and imaginary parts of the scattered fields.
- Returns:
SceneList3D: The 3D plotting scene containing the field plots.
- polarization_filter: float = None#
Angle [Degree] of polarization filter in front of detector.
- rotation: str = 0#
Indicate the rotation of the field in the axis of propagation.
- sampling: int = 200#
Sampling of the farfield distribution
- class PyMieSim.single.detector.CoherentMode(mode_number: str, NA: float, gamma_offset: float, phi_offset: float, sampling: int = 200, polarization_filter: float = None, mean_coupling: bool = False, rotation: float = 90)#
Bases:
GenericDetector
Detector type class representing a laser Hermite-Gauss mode, light coupling mechanism is coherent and thus, dependent of the phase of the impinging scattered light field.
- NA: float#
Numerical aperture of imaging system.
- coherent: bool = True#
Indicate if the coupling mechanism is coherent or not.
- coupling(scatterer: Sphere | CoreShell | Cylinder) float #
Calculate the light coupling between the detector and a scatterer.
\[|\iint_{\Omega} \Phi_{det} \,\, \Psi_{scat}^* \, d \Omega|^2\]Where:\(\Phi_{det}\) is the capturing field of the detector and\(\Psi_{scat}\) is the scattered field.- Args:
scatterer (Sphere|CoreShell|Cylinder): The scatterer object.
- Returns:
float: The coupling in watts.
- gamma_offset: float#
Angle [Degree] offset of detector in the direction perpendicular to polarization.
- get_footprint(scatterer: Sphere | CoreShell | Cylinder) Footprint #
Generate the footprint of the scattered light coupling with the detector.
\[\big| \mathscr{F}^{-1} \big\{ \tilde{ \psi } (\xi, \nu),\ \tilde{ \phi}_{l,m}(\xi, \nu) \big\} (\delta_x, \delta_y) \big|^2\]Where:\(\Phi_{det}\) is the capturing field of the detector and\(\Psi_{scat}\) is the scattered field.- Args:
scatterer (Sphere|CoreShell|Cylinder): The scatterer object.
- Returns:
Footprint: The scatterer footprint with this detector.
- get_structured_scalarfield(sampling: int = 100) ndarray #
- mean_coupling: bool = False#
indicate if the coupling mechanism is point-wise (if setted True) or mean-wise (if setted False).
- mode_number: str#
String representing the HG mode to be initialized (e.g. ‘LP01’, ‘HG11’, ‘LG22’ etc)
- phi_offset: float#
Angle [Degree] offset of detector in the direction parallel to polarization.
- plot() SceneList #
Plot the real and imaginary parts of the scattered fields.
- Returns:
SceneList3D: The 3D plotting scene containing the field plots.
- polarization_filter: float = None#
Angle [Degree] of polarization filter in front of detector.
- rotation: float = 90#
Indicate the rotation of the field in the axis of propagation.
- sampling: int = 200#
Sampling of the farfield distribution
- class PyMieSim.mesh.FibonacciMesh(max_angle: float = 1.5, sampling: int = 1000, phi_offset: float = 0.0, gamma_offset: float = 0.0, rotation_angle: float = 0)#
Bases:
object
Represents an angular mesh using a Fibonacci sphere distribution where each point covers an equivalent solid angle. This setup is designed to simulate angular distributions in light scattering experiments.
- get_axis_vector() ndarray #
Returns the axis vector that correspond ot the phi and gamma offset
- Returns:
The axis vector.
- Return type:
numpy.ndarray
- initialize_properties()#
Initializes additional mesh properties based on the Fibonacci distribution generated by the cpp_binding.
- plot() SceneList #
Plots the Fibonacci mesh using 3D rendering.
- Returns:
SceneList3D: The 3D scene list object containing the mesh plot.
- rotate_around_axis(rotation_angle: float) None #
Rotate the mesh around its principal axis.
- Parameters:
rotation_angle (float) – The rotation angle [degree]
- Returns:
No returns
- Return type:
None
- class PyMieSim.experiment.scatterer.Sphere(source: Gaussian | PlaneWave, diameter: Iterable, medium_index: Iterable | None = None, medium_material: Iterable | None = None, index: Iterable | None = None, material: Iterable | None = None)#
Bases:
BaseScatterer
A data class that represents a spherical scatterer configuration used in PyMieSim simulations.
This class provides specific implementations for setting up and binding spherical scatterers with their properties to a simulation environment. It extends the
BaseScatterer
class by adding spherical-specific attributes and methods for handling simulation setups.- Attributes:
diameter (Iterable): Diameter(s) of the spherical scatterers in meters. medium_index (Iterable, optional): Refractive index or indices of the medium surrounding the scatterers. medium_material (Iterable, optional): Material(s) defining the medium, used if
medium_index
is not provided. index (Iterable, optional): Refractive index or indices of the spherical scatterers themselves. material (Iterable, optional): Material(s) of the scatterers, used ifindex
is not provided. name (str): Name identifier for the scatterer type, defaulted to ‘sphere’ and not intended for initialization.
- add_material_index_to_binding_kwargs(name: str, data_type: type) NoReturn #
Adds either material properties or a refractive index to the binding keyword arguments for the experiment. This method validates and processes the material or index information, converting it into a format suitable for simulation use, and ensuring that either a material or an index is provided but not both.
- Parameters:
- name (str): The base name for the material or index. This name helps identify the property and is used
to handle multiple materials or indices.
- data_type (type): The expected Python data type (e.g., float, numpy.ndarray) to which the material
or index values should be converted for simulation purposes.
- Raises:
ValueError: If both a material and an index are provided, or if neither is provided.
- add_material_index_to_mapping(name: str = None) NoReturn #
Adds material or refractive index details to a mapping dictionary used for visualization or further processing. This method is used to create a mapping of material properties to human-readable and accessible formats for UI or data outputs.
- Parameters:
- name (str, optional): The base name to use for the keys in the mapping dictionary. This name is used
to differentiate between different materials or indices if multiple exist within the same scatterer.
- bind_to_experiment(experiment: Setup) NoReturn #
Binds this scatterer instance to a given experimental setup. This method is crucial for integrating the scatterer into the simulation environment, allowing its optical properties to be evaluated within the context of the specified experiment.
- Parameters:
- experiment (Setup): The experimental setup to which the scatterer will be bound. The setup
should be capable of integrating scatterers and managing their interactions with defined light sources and measurement configurations.
- build_binding_kwargs() NoReturn #
Constructs the keyword arguments necessary for the C++ binding interface, specifically tailored for spherical scatterers. This includes processing material indices and organizing them into a structured dictionary for simulation interaction.
This method automatically configures the binding_kwargs attribute with appropriately formatted values.
- get_datavisual_table() NoReturn #
Constructs a table of the scatterer’s properties formatted for data visualization. This method populates the mapping dictionary with user-friendly descriptions and formats of the scatterer properties.
- Returns:
list: A list of visual representations for each property in the mapping dictionary that has been populated.
- class PyMieSim.experiment.scatterer.Cylinder(source: Gaussian | PlaneWave, diameter: Iterable, medium_index: Iterable | None = None, medium_material: Iterable | None = None, index: Iterable | None = None, material: Iterable | None = None)#
Bases:
BaseScatterer
Represents a cylindrical scatterer configuration for PyMieSim simulations.
- Attributes:
diameter (Iterable): Diameter(s) of the cylinder in meters. height (Iterable): Height(s) of the cylinder in meters. index (Iterable, optional): Refractive index of the cylinder. material (Iterable, optional): Material(s) of the cylinder, used if
index
is not provided.
- add_material_index_to_binding_kwargs(name: str, data_type: type) NoReturn #
Adds either material properties or a refractive index to the binding keyword arguments for the experiment. This method validates and processes the material or index information, converting it into a format suitable for simulation use, and ensuring that either a material or an index is provided but not both.
- Parameters:
- name (str): The base name for the material or index. This name helps identify the property and is used
to handle multiple materials or indices.
- data_type (type): The expected Python data type (e.g., float, numpy.ndarray) to which the material
or index values should be converted for simulation purposes.
- Raises:
ValueError: If both a material and an index are provided, or if neither is provided.
- add_material_index_to_mapping(name: str = None) NoReturn #
Adds material or refractive index details to a mapping dictionary used for visualization or further processing. This method is used to create a mapping of material properties to human-readable and accessible formats for UI or data outputs.
- Parameters:
- name (str, optional): The base name to use for the keys in the mapping dictionary. This name is used
to differentiate between different materials or indices if multiple exist within the same scatterer.
- bind_to_experiment(experiment: Setup) NoReturn #
Binds this scatterer instance to a given experimental setup. This method is crucial for integrating the scatterer into the simulation environment, allowing its optical properties to be evaluated within the context of the specified experiment.
- Parameters:
- experiment (Setup): The experimental setup to which the scatterer will be bound. The setup
should be capable of integrating scatterers and managing their interactions with defined light sources and measurement configurations.
- build_binding_kwargs() NoReturn #
Prepares the keyword arguments for the C++ binding based on the scatterer’s properties. This involves evaluating material indices and organizing them into a dictionary for the C++ interface.
- Returns:
None
- get_datavisual_table() NoReturn #
Appends the scatterer’s properties to a given table for visualization purposes. This enables the representation of scatterer properties in graphical formats.
- Parameters:
table (list): The table to which the scatterer’s properties will be appended.
- Returns:
list: The updated table with the scatterer’s properties included.
- class PyMieSim.experiment.scatterer.CoreShell(source: Gaussian | PlaneWave, core_diameter: Iterable, shell_width: Iterable, medium_index: Iterable | None = None, medium_material: Iterable | None = None, core_index: Iterable | None = None, shell_index: Iterable | None = None, core_material: Iterable | None = None, shell_material: Iterable | None = None)#
Bases:
BaseScatterer
A data class representing a core-shell scatterer configuration used in PyMieSim simulations.
This class facilitates the setup and manipulation of core-shell scatterers by providing structured attributes and methods that ensure the scatterers are configured correctly for simulations. It extends the BaseScatterer class, adding specific attributes and methods relevant to core-shell geometries.
- Attributes:
core_diameter (Iterable): Diameters of the core components in meters. shell_width (Iterable): Thicknesses of the shell components in meters. medium_index (Iterable, optional): Refractive index or indices of the medium where the scatterers are placed. medium_material (Iterable, optional): Material(s) defining the medium, used if
medium_index
is not provided. core_index (Iterable, optional): Refractive index or indices of the core. shell_index (Iterable, optional): Refractive index or indices of the shell. core_material (Iterable, optional): Material(s) of the core, used ifcore_index
is not provided. shell_material (Iterable, optional): Material(s) of the shell, used ifshell_index
is not provided. name (str): An identifier for the scatterer type, defaulted to ‘coreshell’ and not intended for initialization.
- add_material_index_to_binding_kwargs(name: str, data_type: type) NoReturn #
Adds either material properties or a refractive index to the binding keyword arguments for the experiment. This method validates and processes the material or index information, converting it into a format suitable for simulation use, and ensuring that either a material or an index is provided but not both.
- Parameters:
- name (str): The base name for the material or index. This name helps identify the property and is used
to handle multiple materials or indices.
- data_type (type): The expected Python data type (e.g., float, numpy.ndarray) to which the material
or index values should be converted for simulation purposes.
- Raises:
ValueError: If both a material and an index are provided, or if neither is provided.
- add_material_index_to_mapping(name: str = None) NoReturn #
Adds material or refractive index details to a mapping dictionary used for visualization or further processing. This method is used to create a mapping of material properties to human-readable and accessible formats for UI or data outputs.
- Parameters:
- name (str, optional): The base name to use for the keys in the mapping dictionary. This name is used
to differentiate between different materials or indices if multiple exist within the same scatterer.
- bind_to_experiment(experiment: Setup) NoReturn #
Binds this scatterer instance to a given experimental setup. This method is crucial for integrating the scatterer into the simulation environment, allowing its optical properties to be evaluated within the context of the specified experiment.
- Parameters:
- experiment (Setup): The experimental setup to which the scatterer will be bound. The setup
should be capable of integrating scatterers and managing their interactions with defined light sources and measurement configurations.
- build_binding_kwargs() NoReturn #
Assembles the keyword arguments necessary for C++ binding, tailored for core-shell scatterers. Prepares structured data from scatterer properties for efficient simulation integration.
This function populates binding_kwargs with values formatted appropriately for the C++ backend used in simulations.
- get_datavisual_table() NoReturn #
Generates a list of data visualizations for the scatterer’s properties, which can be used in user interfaces or reports. Each property is formatted into a user-friendly structure, making it easier to visualize and understand.
- Returns:
list: A collection of formatted representations for the scatterer properties.
- class PyMieSim.experiment.source.Gaussian(wavelength: Iterable, polarization_value: Iterable, NA: Iterable, optical_power: float, polarization_type: str = 'linear')#
Bases:
BaseSource
Represents a Gaussian light source with a specified numerical aperture and optical power.
Inherits from BaseSource and adds specific attributes for Gaussian sources.
- Attributes:
NA (Iterable): The numerical aperture(s) of the Gaussian source. optical_power (float): The optical power of the source, in Watts. polarization_type (str): The type of polarization, defaults to ‘linear’.
- bind_to_experiment(experiment: Setup)#
Binds the source set to an experiment.
- Parameters:
experiment (Setup): The experiment setup to bind the source to.
- format_inputs()#
Formats input wavelengths and polarization values into numpy arrays.
- generate_amplitude()#
Generates the amplitude of the Gaussian source based on its optical power and numerical aperture.
- generate_binding() NoReturn #
Prepares the keyword arguments for the C++ binding based on the scatterer’s properties. This involves evaluating material indices and organizing them into a dictionary for the C++ interface.
- Returns:
None
- get_datavisual_table() NoReturn #
Appends the scatterer’s properties to a given table for visualization purposes. This enables the representation of scatterer properties in graphical formats.
- Parameters:
table (list): The table to which the scatterer’s properties will be appended.
- Returns:
list: The updated table with the scatterer’s properties included.
- class PyMieSim.experiment.source.PlaneWave(wavelength: Iterable, polarization_value: Iterable, amplitude: float, polarization_type: str = 'linear')#
Bases:
BaseSource
Represents a Plane Wave light source with a specified amplitude.
Inherits from BaseSource and specifies amplitude directly.
- Attributes:
amplitude (float): The amplitude of the plane wave, in Watts. polarization_type (str): The type of polarization, defaults to ‘linear’.
- bind_to_experiment(experiment: Setup)#
Binds the source set to an experiment.
- Parameters:
experiment (Setup): The experiment setup to bind the source to.
- format_inputs()#
Formats input wavelengths and polarization values into numpy arrays.
- generate_amplitude()#
Sets the amplitude of the plane wave as a numpy array.
- generate_binding() NoReturn #
Prepares the keyword arguments for the C++ binding based on the scatterer’s properties. This involves evaluating material indices and organizing them into a dictionary for the C++ interface.
- Returns:
None
- get_datavisual_table() NoReturn #
Appends the scatterer’s properties to a given table for visualization purposes. This enables the representation of scatterer properties in graphical formats.
- Parameters:
table (list): The table to which the scatterer’s properties will be appended.
- Returns:
list: The updated table with the scatterer’s properties included.