pymiediff.Particle#
- class pymiediff.Particle(r_core, mat_core, r_shell=None, mat_shell=None, mat_env=1.0, device=None)#
- __init__(r_core, mat_core, r_shell=None, mat_shell=None, mat_env=1.0, device=None)#
Initialise a single spherical particle (core‑only or core‑shell).
- Parameters:
r_core (float or torch.Tensor) – Core radius (in nm).
mat_core (pymiediff.materials.Material or float/int/complex/torch.Tensor) – Core material. If a scalar is supplied, a constant‑index material
pymiediff.materials.MatConstantis created from the value (the scalar is interpreted as the refractive index, not the permittivity).r_shell (float or torch.Tensor, optional) – Shell radius (in nm). Must be supplied together with
mat_shell; otherwise the particle is treated as homogeneous.mat_shell (pymiediff.materials.Material or float/int/complex/torch.Tensor, optional) – Shell material. Same handling as
mat_core. Ignored ifr_shellisNone.mat_env (pymiediff.materials.Material or float/int/complex/torch.Tensor, optional) – Surrounding (environment) material. Defaults to a refractive index of
1.0(air). Scalars are converted to a constant‑index material.device (str or torch.device, optional) – Torch device on which all tensors will be allocated. If omitted, defaults to
'cpu'.
Notes
The constructor validates that both
r_shellandmat_shellare either provided together or omitted together.All radii and material parameters are internally stored as
torch.Tensorobjects on the specifieddevice.Materials given as scalars are automatically wrapped in
pymiediff.materials.MatConstantwith the square of the value (i.e. converting a refractive‑indexnto permittivityε = n²).
- Raises:
AssertionError – If only one of
r_shellormat_shellis supplied.
Methods
__init__(r_core, mat_core[, r_shell, ...])Initialise a single spherical particle (core‑only or core‑shell).
get_angular_scattering(k0, theta, **kwargs)Compute angular scattering for a single particle.
get_cross_sections(k0, **kwargs)Compute far‑field cross‑section spectra.
Return spectral permittivities of core, shell and environment.
get_mie_coefficients(k0[, return_internal])Compute Mie coefficients for the particle.
get_nearfields(k0, r_probe, **kwargs)Compute electric and magnetic near-fields at probe positions
set_device(device)