pymiediff.Particle

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.MatConstant is 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 if r_shell is None.

  • 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_shell and mat_shell are either provided together or omitted together.

  • All radii and material parameters are internally stored as torch.Tensor objects on the specified device.

  • Materials given as scalars are automatically wrapped in pymiediff.materials.MatConstant with the square of the value (i.e. converting a refractive‑index n to permittivity ε = ).

Raises:

AssertionError – If only one of r_shell or mat_shell is 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.

get_material_permittivities(k0)

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)