`CoupledElectricMagneticDipoles.PostProcessing.compute_cross_sections_e`

— Method`compute_cross_sections_e(knorm,kr,e_inc,alpha_e_dl,input_field;explicit_scattering=true,verbose=true)`

Computes the extinction, absorbtion and scattering cross section $\sigma_{ext}$, $\sigma_{abs}$, $\sigma_{sca}$ of a system made out of electric dipoles, illuminated by a plane wave. Note that it should follow the optical theorem, i.e.

\[\sigma_{ext}=\sigma_{abs}+\sigma_{sca}\]

**Arguments**

`knorm`

: wave number in the medium.`kr`

: 2D float array of size $N\times 3$ containing the dimensionless position $k\mathbf{r}$ of each dipole.`e_inc`

: 2D complex array of size $N\times 3$ containing the total incident electric field $\mathbf{E}_{i}$ on each dipole.`alpha_e_dl`

: complex dimensionless electric polarizability of each dipole. See the Alphas module documentation for accepted formats.`input_field`

: 2D complex array of size $N\times 3$ containing the input field $\mathbf{E}_0(\mathbf{r}_i)$ at the position of each dipole. Note that**it must be a plane wave.**`explicit_scattering`

: boolean that says whether to compute scttering cross section explicitely (`true`

) or to deduce it from the optical theorem (`false`

). By default set to`true`

.`verbose`

: whether to output pieces of information to the standard output at runtime or not. By default set to`true`

.

**Outputs**

- a float array of length 3 containing in order: extinction, absorption and scattering cross section. Cross sections are given in units of
`knorm`

`^{-2}`

`.

`CoupledElectricMagneticDipoles.PostProcessing.compute_cross_sections_e_m`

— Method`compute_cross_sections_e_m(knorm,kr,phi_inc,alpha_dl,input_field;explicit_scattering=true,verbose=true)`

Same as `compute_cross_sections_e_m(knorm,kr,phi_inc,alpha_e_dl,alpha_m_dl,input_field;explicit_scattering=true,verbose=true)`

, but the electric and magnetic polarizabilities of each dipole are given by a single 6x6 complex matrix. See the Alphas module documentation for accepted formats.

`CoupledElectricMagneticDipoles.PostProcessing.compute_cross_sections_e_m`

— Method`compute_cross_sections_e_m(knorm,kr,phi_inc,alpha_e_dl,alpha_m_dl,input_field;explicit_scattering=true,verbose=true)`

Computes the extinction, absorbtion and scattering cross section $\sigma_{ext}$, $\sigma_{abs}$, $\sigma_{sca}$ of a system made out of electric and magnetic dipoles, illuminated by a plane wave. Note that it should follow the optical theorem, i.e.

\[\sigma_{ext}=\sigma_{abs}+\sigma_{sca}\]

**Arguments**

`knorm`

: wave number in the medium.`kr`

: 2D float array of size $N\times 3$ containing the dimensionless position $k\mathbf{r}$ of each dipole.`phi_inc`

: 2D complex array of size $N\times 6$ containing the total incident electric and magnetic field $\mathbf{\Phi}_i=(\mathbf{E}_i,\mathbf{H}_i)$ on each dipole.`alpha_e_dl`

: complex dimensionless electric polarizability of each dipole. See the Alphas module documentation for accepted formats.`alpha_m_dl`

: complex dimensionless magnetic polarizability of each dipole. See the Alphas module documentation for accepted formats.`input_field`

: 2D complex array of size $N\times 6$ containing the electric and magnetic input field $\mathbf{\Phi}_0=(\mathbf{E}_0(\mathbf{r}_i),\mathbf{H}_0(\mathbf{r}_i))$ at the position of each dipole. Note that**it should be a plane wave**.`explicit_scattering`

: boolean that says whether to compute scttering cross section explicitely (`true`

) or to deduce it from the optical theorem (`false`

). By default set to`true`

.`verbose`

: whether to output pieces of information to the standard output at runtime or not. By default set to`true`

.

**Outputs**

- a float array of length 3 containing in order: extinction, absorption and scattering cross section. Cross sections are given in units of
`knorm`

`^{-2}`

`.

`CoupledElectricMagneticDipoles.PostProcessing.compute_dipole_moment`

— Method`compute_dipole_moment(alpha,phi_inc)`

Computes the dipole moment (magnetic or electric) of a dipole with polarizability `alpha`

under an incident field `phi_inc`

. `alpha`

can be:

- a complex scalar
- a 1D complex array of size $N$
- a $3\times 3$ or $6\times 6$ complex matrix.
- a 3D complex array of size $N\times 3\times 3$ or $N\times 6\times 6$

`CoupledElectricMagneticDipoles.PostProcessing.diff_scattering_cross_section_e`

— Method`diff_scattering_cross_section_e(knorm,kr,e_inc,alpha_e_dl,input_field,ur;verbose=true)`

Computes the differential scattering cross section $d \sigma_{sca}/ d\Omega$ of a system made out of electric dipoles in direction(s) `ur`

.

**Arguments**

`knorm`

: wave number in the medium.`kr`

: 2D float array of size $N\times 3$ containing the dimensionless position $k\mathbf{r}$ of each dipole.`e_inc`

: 2D complex array of size $N\times 3$ containing the total incident electric field $\mathbf{E}_{i}$ on each dipole.`alpha_e_dl`

: complex dimensionless electric polarizability of each dipole. See the Alphas module documentation for accepted formats.`input_field`

: 2D complex array of size $N\times 3$ containing the electric input field $\mathbf{E}_0(\mathbf{r}_i)$ at the position of each dipole. Note that**it should be a plane wave**`ur`

: 1D float vector of length 3 (only one direction) or 2D float array of size $Nu\times 3$ (more thant 1 directions) containing the directions $\mathbf{u_r}$ where the diffrential scattering cross section is computed. Note that these directions vectors are normalized to 1 in the function.`verbose`

: whether to output pieces of information to the standard output at runtime or not. By default set to`true`

.

**Outputs**

- an array containing the differential cross section in each direction. Cross sections are given in units of
`knorm`

`^{-2}`

`.

`CoupledElectricMagneticDipoles.PostProcessing.diff_scattering_cross_section_e_m`

— Method`diff_scattering_cross_section_e_m(knorm,kr,phi_inc,alpha_dl,input_field,ur;verbose=true)`

Same as `diff_scattering_cross_section_e_m(knorm,kr,phi_inc,alpha_e_dl,alpha_m_dl,input_field,ur;verbose=true)`

, but the electric and magnetic polarizabilities of each dipole are given by a single 6x6 complex matrix. See the Alphas module documentation for accepted formats.

`CoupledElectricMagneticDipoles.PostProcessing.diff_scattering_cross_section_e_m`

— Method`diff_scattering_cross_section_e_m(knorm,kr,phi_inc,alpha_e_dl,alpha_m_dl,input_field,ur;verbose=true)`

Computes the differential scattering cross section $d \sigma_{sca}/ d\Omega$ of a system made out of electric and magnetic dipoles in direction(s) `ur`

.

**Arguments**

`knorm`

: wave number in the medium.`kr`

: 2D float array of size $N\times 3$ containing the dimensionless position $k\mathbf{r}$ of each dipole.`phi_inc`

: 2D complex array of size $N\times 6$ containing the total incident electric and magnetic field $\mathbf{\Phi}_i=(\mathbf{E}_i,\mathbf{H}_i)$ on each dipole.`alpha_e_dl`

: complex dimensionless electric polarizability of each dipole. See the Alphas module documentation for accepted formats.`alpha_m_dl`

: complex dimensionless magnetic polarizability of each dipole. See the Alphas module documentation for accepted formats.`input_field`

: 2D complex array of size $N\times 6$ containing the electric and magnetic input field $\mathbf{\Phi}_0=(\mathbf{E}_0(\mathbf{r}_i),\mathbf{H}_0(\mathbf{r}_i))$ at the position of each dipole. Note that**it should be a plane wave.**`ur`

: 1D float vector of length 3 (only one direction) or 2D float array of size $Nu\times 3$ (more thant 1 directions) containing the dimensionless positions $\mathbf{u_r}$ where the diffrential scattering cross section is computed. Note that these directions vectors are normalized to 1 in the function.`verbose`

: whether to output pieces of information to the standard output during at runtime or not. By default set to`true`

.

**Outputs**

- an array containing the differential cross section in each direction. Cross sections are given in units of
`knorm`

`^{-2}`

`.

`CoupledElectricMagneticDipoles.PostProcessing.emission_pattern_e`

— Method`emission_pattern_e(kr,e_inc,alpha_e_dl,ur,krd,dip;verbose=true)`

Computes the emission pattern $d P/ d\Omega$ (differential power emitted in a given direction) of a system made out of electric dipoles in direction(s) of position(s) `krf`

.

**Arguments**

`kr`

: 2D float array of size $N\times 3$ containing the dimensionless position $k\mathbf{r}$ of each dipole.`e_inc`

: 2D complex array of size $N\times 3$ containing the total incident electric field $\mathbf{E}_{i}$ on each dipole. The user is required to first solve the DDA problem for`e_inc`

in the presence of a point dipole source placed at`krd`

.`alpha_e_dl`

: complex dimensionless electric polarizability of each dipole. See the Alphas module documentation for accepted formats.`ur`

: 1D float vector of length 3 (only one direction) or 2D float array of size $Nu\times 3$ (more thant 1 directions) containing the dimensionless positions $\mathbf{u_r}$ where the diffrential scattering cross section is computed. Note that these directions vectors are normalized to 1 in the function.`krd`

: float vector of length 3 containing the dimensionless position of the point electric dipole source.`dip`

: integer defining the dipole moment (`dip = 1,2,3`

is an electric dipole along x,y,z respectively)

or complex array of size 3 with the components for the electric dipole moment.

`verbose`

: whether to output pieces of information to the standard output at runtime or not. By default set to`true`

.

**Outputs**

- an array containing the differential emitted power in directions
`ur`

in units of the power emitted by the emitter $P_0$ without any scatterers.

`CoupledElectricMagneticDipoles.PostProcessing.emission_pattern_e_m`

— Method`emission_pattern_e_m(kr,phi_inc,alpha_dl,ur,krd,dip;verbose=true)`

Same as `emission_pattern_e_m(kr,phi_inc,alpha_e_dl,alpha_m_dl,ur,krd,dip;verbose=true)`

, but the electric and magnetic polarizabilities of each dipole are given by a single 6x6 complex matrix. See the Alphas module documentation for accepted formats.

`CoupledElectricMagneticDipoles.PostProcessing.emission_pattern_e_m`

— Method`emission_pattern_e_m(kr,phi_inc,alpha_e_dl,alpha_m_dl,ur,krd,dip;verbose=true)`

Computes the emission pattern $d \P/ d\Omega$ of a system made out of electric and magnetic dipoles in direction(s) of position(s) `krf`

.

**Arguments**

`kr`

: 2D float array of size $N\times 3$ containing the dimensionless position $k\mathbf{r}$ of each dipole.`phi_inc`

: 2D complex array of size $N\times 6$ containing the total incident electric and magnetic field $\mathbf{\Phi}_i=(\mathbf{E}_i,\mathbf{H}_i)$ on each dipole.`alpha_e_dl`

: complex dimensionless electric polarizability of each dipole. See the Alphas module documentation for accepted formats.`alpha_m_dl`

: complex dimensionless magnetic polarizability of each dipole. See the Alphas module documentation for accepted formats.`ur`

: 1D float vector of length 3 (only one direction) or 2D float array of size $Nu\times 3$ (more thant 1 directions) containing the dimensionless positions $\mathbf{u_r}$ where the diffrential scattering cross section is computed. Note that these directions vectors are normalized to 1 in the function.`krd`

: float vector of length 3 containing the dimensionless position of the point electric and/or magnetic dipole source.`dip`

: integer defining the dipole moment (`dip = 1,2,3`

is an electric dipole along x,y,z respectively and`dip = 4,5,6`

is a magnetic dipole along x,y,z respectively)

or complex array of size 6 with the first 3 components for the electric dipole moment and the last 3 components for the magnetic dipole moment.

`verbose`

: whether to output pieces of information to the standard output at runtime or not. By default set to`true`

.

**Outputs**

- an array containing the differential emitted power in directions
`ur`

in units of the power emitted by the emitter $P_0$ without any scatterers.

`CoupledElectricMagneticDipoles.PostProcessing.far_field_sca_e`

— Method`function far_field_sca_e(kr,e_inc,alpha_e_dl,krf)`

Computes the scattered field from a system made out of electric dipoles in the far field approximation. Note that the term $e^{ikr}/kr$ is retained, so `krf`

has to be finite.

**Arguments**

`kr`

: 2D float array of size $N\times 3$ containing the dimensionless position $k\mathbf{r}$ of each dipole. Note that these positions have to be far away from the dipoles positions.`alpha_e_dl`

: complex dimensionless electric polarizability of each dipole. See the Alphas module documentation for accepted formats.`e_inc`

: 2D complex array of size $N\times 3$ containing the incident electric field $\mathbf{E}_{i}$ on each dipole.`krf`

: 1D float vector of length 3 (only one position) or 2D float array of size $Nu\times 3$ (more thant 1 position) containing the dimensionless positions $k\mathbf{r}_f$ at which the scattered field is computed.

**Outputs**

`field_r`

: 2D complex array of size $Nf\times 6$ containing the scattered field by the dipoles at every $k\mathbf{r_f}$. Note that the term $e^{ikr}/kr$ is retained, so`krf`

has to be finite.

`CoupledElectricMagneticDipoles.PostProcessing.far_field_sca_e_m`

— Method`function far_field_sca_e_m(kr,e_inc,alpha_dl,krf)`

Same as `far_field_sca_e_m(kr, alpha_e_dl, alpha_m_dl, phi_inc, krf)`

, but the electric and magnetic polarizabilities of each dipole are given by a single 6x6 complex matrix. See the Alphas module documentation for accepted formats.

`CoupledElectricMagneticDipoles.PostProcessing.far_field_sca_e_m`

— Method`function far_field_sca_e_m(kr,e_inc,alpha_e_dl,alpha_m_dl,krf)`

Computes the scattered field from a system made out of electric and magnetic dipoles in the far field approximation. Note that the term $e^{ikr}/kr$ is retained, so `krf`

has to be finite.

**Arguments**

`kr`

: 2D float array of size $N\times 3$ containing the dimensionless position $k\mathbf{r}$ of each dipole. Note that these positions have to be far away from the dipoles positions.`alpha_e_dl`

: complex dimensionless electric polarizability of each dipole. See the Alphas module documentation for accepted formats.`alpha_m_dl`

: complex dimensionless magnetic polarizability of each dipole. See the Alphas module documentation for accepted formats.`phi_inc`

: 2D complex array of size $N\times 6$ containing the incident electric and magnetic field $\mathbf{\Phi}_i=(\mathbf{E}_i,\mathbf{H}_i)$ on each dipole.`krf`

: 1D float vector of length 3 (only one position) or 2D float array of size $Nu\times 3$ (more thant 1 position) containing the dimensionless positions $k\mathbf{r}_f$ at which the scattered field is computed.

**Outputs**

`field_r`

: 2D complex array of size $Nf\times 6$ containing the scattered field by the dipoles at every $k\mathbf{r_f}$. Note that the term $e^{ikr}/kr$ is retained, so`krf`

has to be finite.

`CoupledElectricMagneticDipoles.PostProcessing.field_sca_e`

— Method`function field_sca_e(kr, alpha_e_dl, e_inc, krf)`

Computes the scattered field from a system made out of electric dipoles. Note that the term $e^{ikr}/kr$ is retained, so `krf`

has to be finite.

**Arguments**

`kr`

: 2D float array of size $N\times 3$ containing the dimensionless position $k\mathbf{r}$ of each dipole.`alpha_e_dl`

: complex dimensionless electric polarizability of each dipole. See the Alphas module documentation for accepted formats.`e_inc`

: 2D complex array of size $N\times 3$ containing the total incident electric field $\mathbf{E}_{i}$ on each dipole.`krf`

: 1D float vector of length 3 (only one position) or 2D float array of size $Nu\times 3$ (more thant 1 position) containing the dimensionless positions $k\mathbf{r}_f$ at which the scattered field is computed.`verbose`

: whether to output pieces of information to the standard output at runtime or not. By default set to`true`

.

**Outputs**

`field_r`

: 2D complex array of size $Nf\times 6$ containing the scattered electric and magnetic fields by the dipoles at every $k\mathbf{r_f}$. Note that the term $e^{ikr}/kr$ is retained, so`krf`

has to be finite.

`CoupledElectricMagneticDipoles.PostProcessing.field_sca_e_m`

— Method`field_sca_e_m(kr, alpha_dl, phi_inc, krf)`

Same as `field_sca_e_m(kr, alpha_e_dl, alpha_m_dl, phi_inc, krf)`

, but the electric and magnetic polarizabilities of each dipole are given by a single 6x6 complex matrix. See the Alphas module documentation for accepted formats.

`CoupledElectricMagneticDipoles.PostProcessing.field_sca_e_m`

— Method`field_sca_e_m(kr, alpha_e_dl, alpha_m_dl, phi_inc, krf; verbose=true)`

Computes the scattered field from a system made out of electric and magnetic dipoles.

**Arguments**

`kr`

: 2D float array of size $N\times 3$ containing the dimensionless position $k\mathbf{r}$ of each dipole.`alpha_e_dl`

: complex dimensionless electric polarizability of each dipole. See the Alphas module documentation for accepted formats.`alpha_m_dl`

: complex dimensionless magnetic polarizability of each dipole. See the Alphas module documentation for accepted formats.`phi_inc`

: 2D complex array of size $N\times 6$ containing the total incident electric and magnetic field $\mathbf{\Phi}_i=(\mathbf{E}_i,\mathbf{H}_i)$ on each dipole.`krf`

: 1D float vector of length 3 (only one position) or 2D float array of size $Nu\times 3$ (more thant 1 position) containing the dimensionless positions $k\mathbf{r}_f$ at which the scattered field is computed.`verbose`

: whether to output pieces of information to the standard output at runtime or not. By default set to`true`

.

**Outputs**

`field_r`

: 2D complex array of size $Nf\times 6$ containing the scattered electric and magnetic fields by the dipoles at every $k\mathbf{r_f}$.

`CoupledElectricMagneticDipoles.PostProcessing.ldos_e`

— Method`ldos_e(kr, alpha_e_dl, Ainv, krd; dip=nothing, verbose=true)`

It Computes local density of states (LDOS) of a system made out of electric dipoles normalized by the LDOS in the host medium without scatterers.

**Arguments**

`kr`

: 2D float array of size $N\times 3$ containing the dimensionless position $k\mathbf{r}$ of each dipole.`alpha_e_dl`

: complex dimensionless electric polarizability of each dipole. See the Alphas module documentation for accepted formats.`Ainv`

: (inverse) DDA matrix.`krd`

: 2D float array of size $Nd\times 3$ containing the dimentionless positions $k\mathbf{r_d}$ where the LDOS is calculated.`dip`

: integer defining the dipole moment (`dip = 1,2,3`

is an electric dipole along x,y,z respectively)

or complex array of size 3 with the components for the electric dipole moment.

`verbose`

: whether to output pieces of information to the standard output at runtime or not. By default set to`true`

.

**Outputs**

`LDOS`

: float array with the LDOS normalized by the LDOS in the host medium without scatterers.

`CoupledElectricMagneticDipoles.PostProcessing.ldos_e_m`

— Method`ldos_e_m(kr, alpha_dl, Ainv, krd; dip=nothing, verbose=true)`

Same as `ldos_e_m(kr, alpha_e_dl, alpha_m_dl, Ainv, krd; dip=nothing, verbose=true)`

, but the electric and magnetic polarizabilities of each dipole are given by a single 6x6 complex matrix. See the Alphas module documentation for accepted formats.

`CoupledElectricMagneticDipoles.PostProcessing.ldos_e_m`

— Method`ldos_e_m(kr, alpha_e_dl, alpha_m_dl, Ainv, krd; dip=nothing, verbose=true)`

Computes local density of states (LDOS) of a system made out of electric and magnetic dipoles normalized by the LDOS in the host medium without scatterers.

**Arguments**

`kr`

: 2D float array of size $N\times 3$ containing the dimensionless position $k\mathbf{r}$ of each dipole.`alpha_e_dl`

: complex dimensionless electric polarizability of each dipole. See the Alphas module documentation for accepted formats.`alpha_m_dl`

: complex dimensionless magnetic polarizability of each dipole. See the Alphas module documentation for accepted formats.`Ainv`

: (inverse) CEMD matrix.`krd`

: 2D float array of size $Nd\times 3$ containing the dimentionless positions $k\mathbf{r_d}$ where the LDOS is calculated.`dip`

: integer defining the dipole moment (`dip = 1,2,3`

is an electric dipole along x,y,z respectively and`dip = 4,5,6`

is a magnetic dipole along x,y,z respectively)

or complex array of size 6 with the first 3 components for the electric dipole moment and the last 3 components for the magnetic dipole moment.

`verbose`

: whether to output pieces of information to the standard output at runtime or not. By default set to`true`

.

**Outputs**

`LDOS`

: float array with the LDOS normalized by the LDOS in the host medium without scatterers.

`CoupledElectricMagneticDipoles.PostProcessing.nonrad_ldos_e`

— Method`nonrad_ldos_e(p,e_inc,dip;verbose=true)`

Computes the non-radiative part of the LDOS of a system of electric point dipoles scatterers normalized by the LDOS in the host medium without scatterers. Note that the scattering problem has to be solved previously using a point dipole source as input field.

**Arguments**

`p`

: 2D complex array of size$Nd\times 3$ containing the electric dipole moments of the dipoles. It has to be previously computed by one of the DDACore functions and`compute_dipole_moment`

.`e_inc`

: 2D complex array of size $N\times 3$ containing the total incident electric field $\mathbf{E}_{i}$ on each dipole. It has to be previously computed by one of the DDACore functions, setting the input field to be a point dipole source.`dip`

: integer defining the dipole moment (`dip = 1,2,3`

is an electric dipole along x,y,z respectively)

or complex array of size 3 with the components for the electric dipole moment.

`verbose`

: whether to output pieces of information to the standard output at runtime or not. By default set to`true`

.

**Outputs**

- float array containing the normalized non-radiative LDOS at everey position of
`krd`

.

`CoupledElectricMagneticDipoles.PostProcessing.nonrad_ldos_e_m`

— Method`nonrad_ldos_e_m(p,m,phi_inc,dip;verbose=true)`

Computes the non-radiative part of the LDOS of a system of electric and magnetic point dipoles scatterers normalized by the LDOS in the host medium without scatterers. Note that the scattering problem has to be solved previously using a point dipole source as input field.

**Arguments**

`p`

: 2D complex array of size$Nd\times 3$ containing the electric dipole moments of the dipoles. It has to be previously computed by one of the DDACore functions and`compute_dipole_moment`

.`m`

: 2D complex array of size$Nd\times 3$ containing the magnetic dipole moments of the dipoles. It has to be previously computed by one of the DDACore functions, setting the input field to be a point dipole source.`phi_inc`

: 2D complex array of size $N\times 6$ containing the total incident electric and magnetic field $\mathbf{\Phi}_i=(\mathbf{E}_i,\mathbf{H}_i)$ on each dipole.`dip`

: integer defining the dipole moment (`dip = 1,2,3`

is an electric dipole along x,y,z respectively and`dip = 4,5,6`

is a magnetic dipole along x,y,z respectively)

or complex array of size 6 with the first 3 components for the electric dipole moment and the last 3 components for the magnetic dipole moment.

`verbose`

: whether to output pieces of information to the standard output at runtime or not. By default set to`true`

.

**Outputs**

- 1D float array containing the normalized non-radiative LDOS at everey position of
`krd`

.

`CoupledElectricMagneticDipoles.PostProcessing.poynting_vector`

— Method`poynting_vector(phi)`

Computes the poynting vector of an electromagnetic field. Input is an electric and magnetic field `phi`

(1D complex Array of length 6). Outputs a 1D float array of length 3 in units of electriqc field squared.

`CoupledElectricMagneticDipoles.PostProcessing.rad_ldos_e`

— Method`rad_ldos_e(kr,krd,p,dip;verbose=true)`

Computes the radiative part of the LDOS of a system of electric point dipoles scatterers normalized by the LDOS in the host medium without scatterers.

**Arguments**

`kr`

: 2D float array of size $N\times 3$ containing the dimensionless position $k\mathbf{r}$ of each dipole.`krd`

: float array of size 3 containing the dimentionless position $k\mathbf{r_d}$ where the radiative part of the LDOS is calculated.`p`

: 2D complex array of size$Nd\times 3$ containing the electric dipole moments of the dipoles.`dip`

: integer defining the dipole moment (`dip = 1,2,3`

is an electric dipole along x,y,z respectively)

or complex array of size 3 with the components for the electric dipole moment.

`verbose`

: whether to output pieces of information to the standard output during running or not. By default set to`true`

.

**Outputs**

- float containing the normalized (by the LDOS in the host medium without scatterers) radiative LDOS at the position
`krd`

.

`CoupledElectricMagneticDipoles.PostProcessing.rad_ldos_e_m`

— Method`rad_ldos_e_m(kr,krd,p,m,dip;verbose=true)`

Computes the radiative part of the LDOS of a system of electric and magnetic point dipoles scatterers normalized by the LDOS in the host medium without scatterers.

**Arguments**

`kr`

: 2D float array of size $N\times 3$ containing the dimensionless position $k\mathbf{r}$ of each dipole.`krd`

: float array of size 3 containing the dimentionless position $k\mathbf{r_d}$ where the LDOS is calculated.`p`

: 2D complex array of size$Nd\times 3$ containing the electric dipole moments of the dipoles.`m`

: 2D complex array of size$Nd\times 3$ containing the magnetic dipole moments of the dipoles.`dip`

: integer defining the dipole moment (`dip = 1,2,3`

is an electric dipole along x,y,z respectively and`dip = 4,5,6`

is a magnetic dipole along x,y,z respectively)

`verbose`

: whether to output pieces of information to the standard output at runtime or not. By default set to`true`

.

**Outputs**

- float containing the normalized (by the LDOS in the host medium without scatterers) radiative LDOS at the position
`krd`

.

`CoupledElectricMagneticDipoles.Geometries.discretize_cube`

— Method`discretize_cube(L,N)`

Discretizes the volume of a cube of edge `L`

in small cubes of edge `dx=L/N`

. Let $N_d$ be the obtained number of cubes, the output is a tuple with an $N_d \times 4$ array containing the 3D position of the centers of the cubes (first three entries) and their filling fraction (fourth entry), as well as the size of the edge of the cubes `dx`

.

`CoupledElectricMagneticDipoles.Geometries.discretize_sphere`

— Method`discretize_sphere(a,N;N_sub=10)`

Discretizes the volume of a sphere of radius `a`

in small cubes of edge `dx=2*a/N`

. `N_sub`

is a parameter to set the super sampling anti-aliasing accuracy of the discretization. It is by default set to 10. Let $N_d$ be the obtained number of cubes, the output is a tuple with an $N_d \times 4$ array containing the 3D position of the centers of the cubes (first three entries) and their filling fraction (fourth entry), as well as the size of the edge of the cubes `dx`

.

`CoupledElectricMagneticDipoles.GreenTensors.G_e_renorm`

— Method`G_e_renorm(kr1,kr2)`

Computes the renormalized (dimensionless) electric Green's tensor between two positions `r1`

and `r2`

, where the inputs are the positions multiplied by the host medium wave number `kr1`

and `kr2`

. The output is a dimensionless 3x3 complex matrix.

`CoupledElectricMagneticDipoles.GreenTensors.G_em_far_field_renorm`

— Method`G_em_far_field_renorm(kr1,kr2)`

Computes the renormalized (dimensionless) electric and magnetic Green's in the far field approximation tensors between two positions `r1`

and `r2`

, where the inputs are the positions multiplied by the host medium wave number `kr1`

and `kr2`

.Note that is is only valid for $kr_1>>kr_2$ and $kr_1>>1$. The outputs are two dimensionless 3x3 complex matrix (electric and magnetic Green's tensor respectively).

`CoupledElectricMagneticDipoles.GreenTensors.G_em_renorm`

— Method`G_em_renorm(kr1,kr2)`

Computes the renormalized (dimensionless) electric and magnetic Green's tensors between two positions `r1`

and `r2`

, where the inputs are the positions multiplied by the host medium wave number `kr1`

and `kr2`

. The outputs are two dimensionless 3x3 complex matrix (electric and magnetic Green's tensor respectively).

`CoupledElectricMagneticDipoles.GreenTensors.G_m_renorm`

— Method`G_m_renorm(kr1,kr2)`

Computes the renormalized (dimensionless) magnetic Green's tensor between two position `r1`

and `r2`

, where the inputs are the positions multiplied by the host medium wave number `kr1`

and `kr2`

. The output is a dimensionless 3x3 complex matrix.

`CoupledElectricMagneticDipoles.GreenTensors.denormalize_G_e`

— Method`denormalize_G_e(Ge,knorm)`

Passes from a dimensionless electric Green's tensor `Ge`

to a Green's tensor with units of length⁻¹ by multiplying by a factor $k/(4\pi)$. `knorm`

is the wavenumber in the host medium $k$.

`CoupledElectricMagneticDipoles.GreenTensors.denormalize_G_m`

— Method`denormalize_G_m(Gm,knorm)`

Passes from a dimensionless magnetic Green's tensor `Gm`

to a Green's tensor with units of length⁻² by multiplying by a factor $k^2/(4\pi)$. `knorm`

is the wavenumber in the host medium $k$.

`CoupledElectricMagneticDipoles.GreenTensors.dxG_e_renorm`

— Method`dxG_e_renorm(kr1,kr2)`

Computes the derivative of the renormalized (dimensionless) electric Green's tensor with respect to the `kx`

component of `kr1`

between two positions (multiplied by the host medium wavenumber) `kr1`

and `kr2`

. The output is a dimensionless 3x3 complex matrix.

`CoupledElectricMagneticDipoles.GreenTensors.dxG_em_renorm`

— Method```
dxG_em_renorm(kr1,kr2)
Computes the derivative of the renormalized (dimensionless) electric and magnetic Green's tensors with respect to the `kx` component of `kr1` between two positions (multiplied by the host medium wavenumber) `kr1` and `kr2`.
The output is a dimensionless 3x3 complex matrix (electric and magnetic Green's tensor respectively).
```

`CoupledElectricMagneticDipoles.GreenTensors.dxG_m_renorm`

— Method`dxG_m_renorm(kr1,kr2)`

Computes the derivative of the renormalized (dimensionless) magnetic Green's tensor with respect to the `kx`

component of `kr1`

between two positions (multiplied by the host medium wavenumber) `kr1`

and `kr2`

. The output is a dimensionless 3x3 complex matrix.

`CoupledElectricMagneticDipoles.GreenTensors.dyG_e_renorm`

— Method`dyG_e_renorm(kr1,kr2)`

Computes the derivative of the renormalized (dimensionless) electric Green's tensor with respect to the `ky`

component of `kr1`

between two positions (multiplied by the host medium wavenumber) `kr1`

and `kr2`

. The output is a dimensionless 3x3 complex matrix.

`CoupledElectricMagneticDipoles.GreenTensors.dyG_em_renorm`

— Method`dyG_em_renorm(kr1,kr2)`

Computes the derivative of the renormalized (dimensionless) electric and magnetic Green's tensors with respect to the `ky`

component of `kr1`

between two positions (multiplied by the host medium wavenumber) `kr1`

and `kr2`

. The output is a dimensionless 3x3 complex matrix (electric and magnetic Green's tensor respectively).

`CoupledElectricMagneticDipoles.GreenTensors.dyG_m_renorm`

— Method`dyG_m_renorm(kr1,kr2)`

Computes the derivative of the renormalized (dimensionless) magnetic Green's tensor with respect to the `ky`

component of `kr1`

between two positions (multiplied by the host medium wavenumber) `kr1`

and `kr2`

. The output is a dimensionless 3x3 complex matrix.

`CoupledElectricMagneticDipoles.GreenTensors.dzG_e_renorm`

— Method`dzG_e_renorm(kr1,kr2)`

Computes the derivative of the renormalized (dimensionless) electric Green's tensor with respect to the `kz`

component of `kr1`

between two positions (multiplied by the host medium wavenumber) `kr1`

and `kr2`

. The output is a dimensionless 3x3 complex matrix.

`CoupledElectricMagneticDipoles.GreenTensors.dzG_em_renorm`

— Method`dzG_em_renorm(kr1,kr2)`

Computes the derivative of the renormalized (dimensionless) electric and magnetic Green's tensors with respect to the `kz`

component of `kr1`

between two positions (multiplied by the host medium wavenumber) `kr1`

and `kr2`

. The output is a dimensionless 3x3 complex matrix (electric and magnetic Green's tensor respectively).

`CoupledElectricMagneticDipoles.GreenTensors.dzG_m_renorm`

— Method`dzG_m_renorm(kr1,kr2)`

Computes the derivative of the renormalized (dimensionless) magnetic Green's tensor with respect to the `kz`

component of `kr1`

between two positions (multiplied by the host medium wavenumber) `kr1`

and `kr2`

. The output is a dimensionless 3x3 complex matrix.

`CoupledElectricMagneticDipoles.Forces.force_e`

— Method`force_e(kr,alpha_e_dl, Ainv, e_0, dxe_0, dye_0, dze_0)`

Computes the optical forces on a system made out of electric dipoles for deterministic input fields. The output force has units of the input electric field squared. To get unit of forces, it is necessary to multiply by a factor $\epsilon_0\epsilon_h 4\pi/k^2$, taking care that the units of the field, the vacuum permittivity and the wavevector are in accordance.

**Arguments**

`kr`

: 2D float array of size $N\times 3$ containing the dimensionless position $k\mathbf{r}$ of each dipole.`alpha_e_dl`

: complex dimensionless electric polarizability of each dipole. See the Alphas module documentation for accepted formats.`Ainv`

: (inverse) DDA matrix.`e_0`

: 2D complex array of size $N\times 3$ containing the external input field.`dxe_0`

: 2D complex array of size $N\times 3$ containing the derivative with regard to the $k*x$ argument of the external input field.`dye_0`

: 2D complex array of size $N\times 3$ containing the derivative with regard to the $k*y$ argument of the external input field.`dze_0`

: 2D complex array of size $N\times 3$ containing the derivative with regard to the $k*z$ argument of the external input field.

**Outputs**

`fx`

: float array of Size $N$ with the value of the force along the $x$-axis at each dipole.`fy`

: float array of Size $N$ with the value of the force along the $y$-axis at each dipole.`fz`

: float array of Size $N$ with the value of the force along the $z$-axis at each dipole.

`CoupledElectricMagneticDipoles.Forces.force_e_m`

— Method`force_e_m(kr,alpha_dl, Ainv, e_0, dxe_0, dye_0, dze_0)`

Same as `force_e_m(knorm,kr,alpha_e_dl, alpha_m_dl, Ainv, e_0, dxe_0, dye_0, dze_0)`

, but the electric and magnetic polarizabilities of each dipole are given by a single 6x6 complex matrix. See the Alphas module documentation for accepted formats. The output force has units of the input electric field squared. To get unit of forces, it is necessary to multiply by a factor $\epsilon_0\epsilon_h 4\pi/k^2$, taking care that the units of the field, the vacuum permittivity and the wavevector are in accordance.

`CoupledElectricMagneticDipoles.Forces.force_e_m`

— Method`force_e_m(kr,alpha_e_dl, alpha_m_dl, Ainv, e_0, dxe_0, dye_0, dze_0)`

Computes the optical forces on a system made out of electric and magnetic dipoles for deterministic input fields. The output force has units of the input electric field squared. To get unit of forces, it is necessary to multiply by a factor $\epsilon_0\epsilon_h 4\pi/k^2$, taking care that the units of the field, the vacuum permittivity and the wavevector are in accordance.

**Arguments**

`kr`

: 2D float array of size $N\times 3$ containing the dimensionless position $k\mathbf{r}$ of each dipole.`alpha_e_dl`

: complex dimensionless electric polarizability of each dipole. See the Alphas module documentation for accepted formats.`alpha_m_dl`

: complex dimensionless magnetic polarizability of each dipole. See the Alphas module documentation for accepted formats.`Ainv`

: (inverse) DDA matrix.`e_0`

: 2D complex array of size $N\times 6$ containing the external input field.`dxe_0`

: 2D complex array of size $N\times 6$ containing the derivative with regard to the $k*x$ argument of the external input field.`dye_0`

: 2D complex array of size $N\times 6$ containing the derivative with regard to the $k*y$ argument of the external input field.`dze_0`

: 2D complex array of size $N\times 6$ containing the derivative with regard to the $k*z$ argument of the external input field.

**Outputs**

`fx`

: float array of Size $N$ with the value of the force along the $x$-axis at each dipole.`fy`

: float array of Size $N$ with the value of the force along the $y$-axis at each dipole.`fz`

: float array of Size $N$ with the value of the force along the $z$-axis at each dipole.

`CoupledElectricMagneticDipoles.Forces.force_factor_gaussianbeams`

— Method`force_factor_gaussianbeams(kbw0,power,eps_h;n=0,m=0,,kind="hermite", e0 = 1, paraxial=true, kmax = nothing, maxe=Int(1e4), int_size = 5)`

Computes the proportionality factor to get the forces in units of Newtons when the forces are calculated using the Gaussian beams (Hermite and Laguerre) implemented in the library. By default, the factor is calculated for a Gaussian Beam in the paraxial approximation.

**Arguments**

`kbw0`

: float with the dimensionless beam waist radius ($kw_0$, where $w_0$ is the beam waist radius).`power`

: float with the power of the beam.`eps_h`

: float with the relative permittivity of the host medium.`n`

: non-negative integer with the radial order of the beam.`m`

: integer with the azimuthal order of the beam.`e0`

: float with the modulus of the electric field used in the calculation of the beam profile.`kind`

: string with the kind of beam ("hermite" or "laguerre"). By default set to "hermite".`paraxial`

: boolean setting if the calculation is done in the paraxial approximation.`kmax`

: float setting the limit of the radial integration (it should be`kmax < 1`

).`maxe`

: maximum number of evaluations in the adaptative integral (see Cubature.jl for more details).`int_size`

: size of the integration area in units of`kbw0`

. For high-order beams this parameter should be adjusted.

**Outputs**

`force_factor`

: proportionality factor to get the forces in units of Newtons.

`CoupledElectricMagneticDipoles.MieCoeff.mie_ab1`

— Method`mie_ab1(ka, eps, eps_h; mu=1, mu_h=1)`

Computes the first mie coefficient $a_1$ and $b_1$ of a sphere with size parameter `ka`

, dielectric permittivity `eps`

and magnetic permeability `mu`

, in a host medium with dielectric permittivity `eps_h`

and magnetic permeability `mu_h`

. Returns a tuple with two complex scalar, $a_1$ and $b_1$, respectively.

`CoupledElectricMagneticDipoles.MieCoeff.mie_absorption`

— Method`mie_absorption(ka,eps,eps_h;mu=1,mu_h=1,cutoff=20)`

Computes the extinction efficiency $Q_{abs}$ of a sphere with size parameter `ka`

, dielectric permittivity `eps`

and magnetic permeability `mu`

, in a host medium with dielectric permittivity `eps_h`

and magnetic permeability `mu_h`

. For this, we use:

\[Q_{abs} =Q_{ext}-Q_{sca}\]

where corresponding sums are cut to `cutoff`

which is set to 20 by default.

Returns a float.

`CoupledElectricMagneticDipoles.MieCoeff.mie_an`

— Method`mie_an(ka, eps, eps_h; mu=1, mu_h=1, n=1)`

Computes the `n`

-th mie coefficient $a_n$ of a sphere with size parameter `ka`

, dielectric permittivity `eps`

and magnetic permeability `mu`

, in a host medium with dielectric permittivity `eps_h`

and magnetic permeability `mu_h`

. Returns a complex scalar.

`CoupledElectricMagneticDipoles.MieCoeff.mie_bn`

— Method`mie_bn(ka, eps, eps_h; mu=1, mu_h=1, n=1)`

Computes the `n`

-th mie coefficient $b_n$ of a sphere with size parameter `ka`

, dielectric permittivity `eps`

and magnetic permeability `mu`

, in a host medium with dielectric permittivity `eps_h`

and magnetic permeability `mu_h`

. Returns a complex scalar.

`CoupledElectricMagneticDipoles.MieCoeff.mie_extinction`

— Method`mie_extinction(ka,eps,eps_h;cutoff=20)`

Computes the extinction efficiency $Q_{ext}$ of a sphere with size parameter `ka`

, dielectric permittivity `eps`

and magnetic permeability `mu`

, in a host medium with dielectric permittivity `eps_h`

and magnetic permeability `mu_h`

. For this, we use the finite sum:

\[Q_{ext} =\frac{2}{(ka)^2}\sum^{\text{cutoff}}_{n=1}\left(2n+1\right)Re\left(a_n+b_n\right)\]

where `cutoff`

is set to 20 by default.

Returns a float.

`CoupledElectricMagneticDipoles.MieCoeff.mie_scattering`

— Method`mie_scattering(ka,eps,eps_h;mu=1, mu_h=1, cutoff=20)`

Computes the scattering efficiency $Q_{sca}$ of a sphere with size parameter `ka`

, dielectric permittivity `eps`

and magnetic permeability `mu`

, in a host medium with dielectric permittivity `eps_h`

and magnetic permeability `mu_h`

. For this, we use the finite sum:

\[Q_{sca} =\frac{2}{ka^2}\sum^{\text{cutoff}}_{n=1}\left(2n+1\right)\left(|a_n|^2+|b_n|^2\right)\]

where `cutoff`

is set to 20 by default.

Returns a float.

`CoupledElectricMagneticDipoles.Alphas.alpha0_parallelepiped`

— Method`alpha0_parallelepiped(lx,ly,lz,eps,eps_h)`

Computes the quasistatic polarizability tensor of a parallelepiped of dimensions `lx,ly,lz`

and permittivity `eps`

in a host medium with permittivity `eps_h`

. Outputs a $3\times 3$ float matrix with units of volume.

`CoupledElectricMagneticDipoles.Alphas.alpha0_sphere`

— Method`alpha0_sphere(a,eps,eps_h)`

Computes the quasistatic polarizability of a sphere of radius `a`

and permittivity `eps`

in a host medium with permittivity `eps_h`

. Outputs a float with units of volume.

`CoupledElectricMagneticDipoles.Alphas.alpha0_volume`

— Method`alpha0_volume(V,eps,eps_h)`

Computes the quasistatic polarizability of any isotropic object with volume `V`

and permittivity `eps`

in a host medium with permittivity `eps_h`

. Outputs a float with units of volume.

`CoupledElectricMagneticDipoles.Alphas.alpha_e_m_mie`

— Method`alpha_e_m_mie(ka,eps,eps_h)`

Computes the electric and magnetic polarizabilities from the mie coefficients $a_1$ and $b_1$ of a particle with size parameter `ka`

(wave number times radius), and permittivity `eps`

, in a host medium with permittivity `eps_h`

. Outputs two dimensionless scalars that are respectively the electric and the magnetic polarizability.

`CoupledElectricMagneticDipoles.Alphas.alpha_radiative`

— Method`alpha_radiative(alpha0,knorm)`

Applies the radiative correction to the polarizability matrix or scalar `alpha0`

(with units of volume). Outputs a complex dimensionless scalar or a (3x3) complex dimensionless matrix.

`CoupledElectricMagneticDipoles.Alphas.denorm_alpha`

— Method`denorm_alpha(knorm,alpha)`

Denormalizes any dimensionless polarizability `alpha`

in a polarizability with units of volume by multiplying by $4\pi /k^3$. `knorm`

is the wave number in the medium.

`CoupledElectricMagneticDipoles.Alphas.dispatch_e`

— Method`dispatch_e(alpha_e_dl,n_particles)`

Creates an iterable with the polarizability of all particles in order to facilitate the syntax for multuplying a Green's tensor by polarizability of a particle.

**Arguments**

`alpha_e_dl`

: electric polarizability, see the Alphas module's documentation for the accepted formats.`n_particles`

: number of particles (integer)

**Outputs**

`alp_e`

: iterable electric polarizability

`CoupledElectricMagneticDipoles.Alphas.dispatch_e_m`

— Method`dispatch_e_m(alpha_e_dl,alpha_m_dl,n_particles)`

Creates an iterable with the polarizability of all particles in order to facilitate the syntax for multuplying a Green's tensor by the polarizability of a particle.

**Arguments**

`alpha_e_dl`

: electric polarizability, see the Alphas module's documentation for the accepted formats.`alpha_m_dl`

: magnetic polarizability, see the Alphas module's documentation for the accepted formats.`n_particles`

: number of particles (integer)

**Outputs**

`alp_e`

: iterable electric polarizability`alp_m`

: iterable magnetic polarizability

`CoupledElectricMagneticDipoles.Alphas.dispatch_e_m`

— Method`dispatch_e_m(alpha_dl,n_particles)`

Creates an iterable with the polarizability of all particles in order to facilitate the syntax for multuplying a Green's tensor by the polarizability of a particle.

**Arguments**

`alpha_dl`

: polarizability 6x6 complex matrix, see the Alphas module's documentation for the accepted formats.`n_particles`

: number of particles (integer)

**Outputs**

`alp`

: iterable polarizability

`CoupledElectricMagneticDipoles.Alphas.renorm_alpha`

— Method`renorm_alpha(knorm,alpha)`

Renormalizes any polarizability `alpha`

with units of volume in a dimensionless polarizability by multiplying by $k^3/4\pi$. `knorm`

is the wave number in the medium.

`CoupledElectricMagneticDipoles.InputFields.create_f_gauss_kind`

— Method`create_f_gauss_kind(kbw0,n,m,kind)`

Create the function to calculate the fourier transform components for the specific beam (gaussian, hermite-gaussian or legendre-gaussian) used in the functions that calculate the field and the derivatives.

**Arguments**

`kbw0`

: float with the dimensionless beam waist radius ($k\omega_0$, where $\omega_0$ is the beam waist radius).`n`

: int with the order of the beam.`m`

: int with the degree of the beam.`kind`

: string with the kind of beam ("hermite" or "laguerre").

**Outputs**

`lp`

: generalized Laguerre polynomials of argument $x$ and order $n$ and $a$.

`CoupledElectricMagneticDipoles.InputFields.d_gaussian_beam_e`

— Method`d_gaussian_beam_e(krf, kbw0; n = 0, m = 0, kind = "hermite", e0 = 1, kmax = nothing, maxe=Int(5e3))`

Computes the spatial derivatives of an electric field generated with `gaussian_beam_e`

(the arguments are the same as for `gaussian_beam_e_m`

). Outputs three 2D arrays of size $N\times 3$ containing the electric field derivatives with respect `k*x`

, `k*y`

and `k*z`

.

`CoupledElectricMagneticDipoles.InputFields.d_gaussian_beam_e_m`

— Method`d_gaussian_beam_e_m(krf, kbw0; n = 0, m = 0, kind = "hermite", e0 = 1, kmax = nothing, maxe=Int(5e3))`

Computes the spatial derivatives of an electromagnetic field generated with `gaussian_beam_e_m`

(the arguments are the same as for `gaussian_beam_e_m`

). Outputs three 2D arrays of size $N\times 6$ containing the electric and magnetic field derivatives with respect of `k*x`

, `k*y`

and `k*z`

.

`CoupledElectricMagneticDipoles.InputFields.d_plane_wave_e`

— Method`d_plane_wave_e(kr;khat=[0,0,1],e0=[1,0,0])`

Computes the spatial derivatives of an electric field generated with `plane_wave_e`

(the arguments are the same as for `plane_wave_e`

). Outputs three 2D arrays of size $N\times 3$ containing the electric field derivatives with respect `k*x`

, `k*y`

and `k*z`

.

`CoupledElectricMagneticDipoles.InputFields.d_plane_wave_e_m`

— Method`d_plane_wave_e_m(kr;khat=[0,0,1],e0=[1,0,0])`

Computes the spatial derivatives of an electromagnetic field generated with `plane_wave_e_m`

(the arguments are the same as for `plane_wave_e_m`

). Outputs three 2D arrays of size $N\times 6$ containing the electric and magnetic fields derivatives with respect of `k*x`

, `k*y`

and `k*z`

.

`CoupledElectricMagneticDipoles.InputFields.d_point_dipole_e`

— Method`d_point_dipole_e(krf, krd, dip, e0=1)`

Computes the spatial derivatives of an electric field generated with `point_dipole_e`

(the arguments are the same as for `point_dipole_e`

). Outputs three 2D arrays of size $N\times 3$ containing the electric field derivatives with respect `k*x`

, `k*y`

and `k*z`

.

`CoupledElectricMagneticDipoles.InputFields.d_point_dipole_e_m`

— Method`d_point_dipole_e_m(krf, krd, dip, e0=1)`

Computes the spatial derivatives of an electromagnetic field generated with `point_dipole_e_m`

(the arguments are the same as for `point_dipole_e_m`

). Outputs three 2D arrays of size $N\times 6$ containing the electric and magnetic fields derivatives with respect of `k*x`

, `k*y`

and `k*z`

.

`CoupledElectricMagneticDipoles.InputFields.gaussian_beam_e`

— Method`gaussian_beam_e(krf, kbw0,n,m; n = 0, m = 0, kind = "hermite", e0 = 1, kmax = nothing, maxe=Int(5e3))`

Computes the electric field distribution of a Gaussian, Hermite-Gaussian and Laguerre-Gaussian beam that propagates along the z-axis and where the electric field is polarized along the x-axis (polarized electric). By default, the Gaussian beam profile is calculated. For another polarization just rotate the field in the xy-plane. Also, for a polarized magnetic field, exchange E with ZH and H with -E.

**Arguments**

`krf`

: 2D float array of size $N\times 3$ containing the dimensionless positions $k\mathbf{r}$ where the field is computed.`kbw0`

: float with the dimensionless beam waist radius ($k\omega_0$, where $\omega_0$ is the beam waist radius).`n`

: int with the order of the beam.`m`

: int with the degree of the beam.`kind`

: string with the kind of beam ("hermite" or "laguerre").`e0`

: float with the modulus of the electric field at the origin of coordinates of the theoretical field (including evanescent waves).`kmax`

: float setting the limit of the radial integration (it should be`kmax < 1`

).`maxe`

: maximum number of evaluations in the adaptive integral (see Cubature.jl for more details).

**Outputs**

`e_gauss`

: 2D complex array of size $N\times 3$ with the value of the electric field at each positions.

`CoupledElectricMagneticDipoles.InputFields.gaussian_beam_e_m`

— Method`gaussian_beam_e_m(krf, kbw0,n,m; n = 0, m = 0, kind = "hermite", e0 = 1, kmax = nothing, maxe=Int(5e3))`

Computes the electromagnetic field distribution of a Gaussian, Hermite-Gaussian and Laguerre-Gaussian beam that propagates along the z-axis and where the electric field is polarized along the x-axis (polarized electric). By default, the Gaussian beam profile is calculated. For another polarization just rotate the field in the xy-plane. Also, for a polarized magnetic field, exchange E with ZH and H with -E.

**Arguments**

`krf`

: 2D float array of size $N\times 3$ containing the dimensionless positions $k\mathbf{r}$ where the field is computed.`kbw0`

: float with the dimensionless beam waist radius ($k\omega_0$, where $\omega_0$ is the beam waist radius).`n`

: int with the order of the beam.`m`

: int with the degree of the beam.`kind`

: string with the kind of beam ("hermite" or "laguerre").`e0`

: float with the modulus of the electric field at the origin of coordinates of the theoretical field (including evanescent waves).`kmax`

: float setting the limit of the radial integration (it should be`kmax < 1`

).`maxe`

: maximum number of evaluations in the adaptive integral (see Cubature.jl for more details).

**Outputs**

`phi_gauss`

: 2D complex array of size $N\times 6$ with the value of the electric and magnetic fields at each positions.

`CoupledElectricMagneticDipoles.InputFields.ghermite_amp`

— Method`ghermite_amp(kbw0,n,m; kmax = nothing, maxe=Int(1e4), int_size = 5)`

Computes the integral of the field amplitude (|E|^2) of the Hermite-Gaussian beam at the focal plane.

**Arguments**

`kbw0`

: float with the dimensionless beam waist radius ($k\omega_0$, where $\omega_0$ is the beam waist radius).`n`

: non-negative int with the radial order of the beam.`m`

: int with the azimuthal order of the beam.`kmax`

: float setting the limit of the radial integration (it should be`kmax < 1`

).`maxe`

: maximum number of evaluations in the adaptive integral (see Cubature.jl for more details).`int_size`

: size of the integration area in units of $kbw0$. For high-order beams this parameter should be adjusted.

**Outputs**

`int_amplitude`

: integral of the field amplitude (|E|^2) in the area defined by int*size (x = [-kbw0*int*size, kbw0*int_size], y = [-kbw0*int*size, kbw0*int*size]).

`CoupledElectricMagneticDipoles.InputFields.glaguerre_amp`

— Method`glaguerre_amp(kbw0,n,m; kmax = nothing, maxe=Int(1e4), int_size = 5)`

Computes the integral of the field amplitude (|E|^2) of the Laguerre-Gaussian beam at the focal plane.

**Arguments**

`kbw0`

: float with the dimensionless beam waist radius ($k\omega_0$, where $\omega_0$ is the beam waist radius).`n`

: non-negative int with the radial order of the beam.`m`

: int with the azimuthal order of the beam.`kmax`

: float setting the limit of the radial integration (it should be`kmax < 1`

).`maxe`

: maximum number of evaluations in the adaptive integral (see Cubature.jl for more details).`int_size`

: size of the integration area in units of $kbw0$. For high-order beams this parameter should be adjusted.

**Outputs**

`int_amplitude`

: integral of the field amplitude (|E|^2) in the area defined by int*size (x = [-kbw0*int*size, kbw0*int_size], y = [-kbw0*int*size, kbw0*int*size]).

`CoupledElectricMagneticDipoles.InputFields.hermite_e_pol`

— Method`hermite_e_pol(x,n)`

Computes probabilist's Hermite polynomials.

**Arguments**

`x`

: float with the argument.`n`

: int with the order.

**Outputs**

`hp`

: probabilist's Hermite polynomials of argument $x$ and order $n$.

`CoupledElectricMagneticDipoles.InputFields.laguerre_pol`

— Method`laguerre_pol(x,n,a)`

Computes generalized Laguerre polynomials.

**Arguments**

`x`

: float with the argument.`n`

: int with the order.`a`

: int with the second order.

**Outputs**

`lp`

: generalized Laguerre polynomials of argument $x$ and order $n$ and $a$.

`CoupledElectricMagneticDipoles.InputFields.plane_wave_e`

— Method`plane_wave_e(krf;khat=[0,0,1],e0=[1,0,0])`

Computes the electric field of a monochromatic plane wave evaluated at a set of dimensionless positions `krf`

. `khat`

is the direction of propagation and `e0`

is the polarization. The user is responsible for using physical inputs. `krf`

is a $N\times 3$ float array. The output is a $N\times 3$ complex array representing the electric field at each of the positions in the `krf`

array.

`CoupledElectricMagneticDipoles.InputFields.plane_wave_e_m`

— Method`plane_wave_e_m(krf;khat=[0,0,1],e0=[1,0,0])`

Computes the electric and magnetic fields of a monochromatic plane wave evaluated at a set of dimensionless positions `krf`

. `khat`

is the direction of propagation and `e0`

is the polarization. The user is responsible for using physical inputs. `krf`

is a $N\times 3$ float array. The output is a $N\times 6$ complex array representing the electric and magnetic fields at each of the positions in the `krf`

array.

`CoupledElectricMagneticDipoles.InputFields.point_dipole_e`

— Method`point_dipole_e(krf, krd, dip, e0_const=1)`

Computes the electric field emitted by an electric point dipole.

**Arguments**

`krf`

: 2D float array of size $N\times 3$ containing the dimensionless positions $k\mathbf{r}$ where the field is computed.`krd`

: 1D float array of size 3 containing the dimensionless position $k\mathbf{r_d}$ where the source is located.`dip`

: integer defining the dipole moment (`dip = 1,2,3`

is an electric dipole along x,y,z respectively)

or complex array of size 3 with the components for the electric dipole moment.

`e0`

: float with the modulus of`dip`

.

**Outputs**

`e_dipole`

: 2D $N\times 3$ complex array with the electromagnetic field.

`CoupledElectricMagneticDipoles.InputFields.point_dipole_e_m`

— Method`point_dipole_e_m(krf, krd, dip, e0=1)`

Computes the electric and magnetic fields emitted by an electric and/or magnetic point dipole.

**Arguments**

`krf`

: 2D float array of size $N\times 3$ containing the dimensionless positions $k\mathbf{r}$ where the field is computed.`krd`

: 1D float array of size 3 containing the dimensionless position $k\mathbf{r_d}$ where the source is located.`dip`

: integer defining the dipole moment (`dip = 1,2,3`

is an electric dipole along x,y,z respectively and`dip = 4,5,6`

is a magnetic dipole along x,y,z respectively)

`e0`

: float with the modulus of`dip`

.

**Outputs**

`phi_dipole`

: 2D $N\times 6$complex array with the electromagnetic fields at each position.

`CoupledElectricMagneticDipoles.DDACore.load_dda_matrix_e`

— Method` load_dda_matrix_e(kr,alpha_e_dl,verbose)`

Builds the electric only DDA matrix $A=[I-G\alpha]$ with dimensionless positions `kr`

(2D array of size $N\times3$) and dimensionless polarizabilities `alpha_e_dl`

(see format rules in the Alphas module documentation). Returns $3N\times 3N$ complex DDA matrix.

`CoupledElectricMagneticDipoles.DDACore.load_dda_matrix_e_m`

— Method` load_dda_matrix_e_m(kr,alpha_e_dl,alpha_m_dl,verbose)`

Builds the electric and magnetic CEMD matrix $A=[I-G\alpha]$ with dimensionless positions `kr`

(2D array of size $N\times 3$) and dimensionless electric and magnetic polarizabilities `alpha_e_dl`

and `alpha_m_dl`

(see format rules in the Alphas module documentation). Returns the $6N\times 6N$ complex CEMD matrix.

`CoupledElectricMagneticDipoles.DDACore.load_dda_matrix_e_m`

— Method` load_dda_matrix_e_m(kr,alpha_dl,verbose)`

Builds the electric and magnetic CEMD matrix $A=[I-G\alpha]$ with dimensionless positions `kr`

(two dimensional arrays of size $N\times 3$) and dimensionless polarizability `alpha_dl`

(see format rules in the Alphas module documentation). Return $6N\times 6N$ complex DDA matrix

`CoupledElectricMagneticDipoles.DDACore.solve_DDA_e`

— Method`solve_DDA_e(kr,alpha_e_dl;input_field=nothing,solver="CPU",verbose=true)`

Builds and solves the DDA equations under a given input field for a group of $N$ only electric dipoles and returns the total incident field on each of the dipoles.

**Arguments**

`kr`

: 2D float array of size $N\times 3$ containing the dimensionless position $k\mathbf{r}$ of each dipole.`alpha_e_dl`

: complex dimensionless electric polarizability of each dipole. See the Alphas module documentation for accepted formats.`input_field`

: 2D complex array of size $N\times 3$ containing the electric input field $\mathbf{E}_0(\mathbf{r}_i)$ at the position of each dipole. It can also be a 3D array of size $N_f\times N\times 3$, allowing to solve the problem for several input fields without re-inverting the matrix. This is a keyword argument. If`input_field=nothing`

, the output of the function will be the inverse of the DDA matrix.`solver`

: string that contains the name of the solver to be used. For this, check the`DDACore.solve_system`

function documentation. By default set to "CPU".`verbose`

: whether to output informations to the standard output during runtime or not. By default set to`true`

.

**Outputs**

Depending on the value of `input field`

, it can be:

`e_inc`

: 2D complex array of size $N\times 3$ containing the incident electric field $\mathbf{E}_{i}$ on each dipole. if`input_field`

is a 2D array.`e_inc`

: 3D complex array of size $N_f\times N\times 3$ containing the incident electric field $\mathbf{E}_{i}$ on each dipole for each input field, if`input_field`

is a 3D array.`Ainv`

: complex matrix of size $3N\times 3N$, if`input_field=nothing`

.

`CoupledElectricMagneticDipoles.DDACore.solve_DDA_e_m`

— Method`solve_DDA_e_m(kr,alpha_e_dl,alpha_m_dl;input_field=nothing,solver="CPU",verbose=true)`

Builds and solves the CEMD equations with dimensionless inputs under a given input field for a group of $N$ electric and magnetic dipoles and return the total incident field on every dipole.

**Arguments**

`kr`

: 2D float array of size $N\times 3$ containing the dimensionless position $k\mathbf{r}$ of each dipole.`alpha_e_dl`

: complex dimensionless electric polarizability of each dipole. See the Alphas module documentation for accepted formats.`alpha_m_dl`

: complex dimensionless magnetic polarizability of each dipole. See the Alphas module documentation for accepted formats.`input_field`

: 2D complex array of size $N\times 6$ containing the electric and magnetic input field $\mathbf{\Phi}_0=(\mathbf{E}_0(\mathbf{r}_i),\mathbf{H}_0(\mathbf{r}_i))$ at the position of each dipole. It can also be a 3D array of size $N_f\times N\times 6$, allowing to solve the problem for several input fields without re-inverting the matrix. This is a keyword argument. If`input_field=nothing`

(default value), the output of the function will be the inverse of the CEMD matrix.`solver`

:string that contains the name of the solver to be used. For this, check the`DDACore.solve_system`

function documentation. By default set to "CPU".`verbose`

: whether to output pieces of information to the standard output during runtime or not. By default set to`true`

.

**Outputs**

Depending on the value of `input field`

, it can be:

`phi_inc`

: 2D complex array of size $N\times 6$ containing the incident electric and magnetic field $\mathbf{\Phi}_i=(\mathbf{E}_i,\mathbf{H}_i)$ on each dipole, if`input_field`

is a 2D array.`phi_inc`

: 3D complex array of size $N_f\times N\times 6$ containing the incident electric and magnetic field $\mathbf{\Phi}_i=(\mathbf{E}_i,\mathbf{H}_i)$ on each dipole for each input field, if`input_field`

is a 3D array.`Ainv`

: complex matrix of size $6N\times 6N$, if`input_field=nothing`

.

`CoupledElectricMagneticDipoles.DDACore.solve_DDA_e_m`

— Method`function solve_DDA_e_m(kr,alpha_dl;input_field=nothing,solver="CPU",verbose=true)`

Same as `solve_DDA_e_m(kr,alpha_e_dl,alpha_m_dl;input_field=nothing,solver="CPU",verbose=true)`

, but the electric and magnetic polarizabilities of each dipole are given by a single 6x6 complex matrix. See the Alphas module documentation for accepted formats.

`CoupledElectricMagneticDipoles.DDACore.solve_system`

— Method` solve_system(A,b,solver,verbose)`

Solves a system of equations of the type $Ax=b$ using the method `solver`

and returns `x`

. `x`

can be a 1D column vector or a 2D matrix. In this second case, the function is going to solve for each column of the matrix as a different problem (without re-inverting `A`

). The `solver`

flag can be set to

`CPU`

: In this case, the system is solved using LAPACK on the CPU.`GPU`

: In this case, the system is solved using CUSOLVE on the GPU (if available).

`CoupledElectricMagneticDipoles.InputFields.GreenTensors.G_e_renorm`

— Method`G_e_renorm(kr1,kr2)`

Computes the renormalized (dimensionless) electric Green's tensor between two positions `r1`

and `r2`

, where the inputs are the positions multiplied by the host medium wave number `kr1`

and `kr2`

. The output is a dimensionless 3x3 complex matrix.

`CoupledElectricMagneticDipoles.InputFields.GreenTensors.G_em_far_field_renorm`

— Method`G_em_far_field_renorm(kr1,kr2)`

Computes the renormalized (dimensionless) electric and magnetic Green's in the far field approximation tensors between two positions `r1`

and `r2`

, where the inputs are the positions multiplied by the host medium wave number `kr1`

and `kr2`

.Note that is is only valid for $kr_1>>kr_2$ and $kr_1>>1$. The outputs are two dimensionless 3x3 complex matrix (electric and magnetic Green's tensor respectively).

`CoupledElectricMagneticDipoles.InputFields.GreenTensors.G_em_renorm`

— Method`G_em_renorm(kr1,kr2)`

Computes the renormalized (dimensionless) electric and magnetic Green's tensors between two positions `r1`

and `r2`

, where the inputs are the positions multiplied by the host medium wave number `kr1`

and `kr2`

. The outputs are two dimensionless 3x3 complex matrix (electric and magnetic Green's tensor respectively).

`CoupledElectricMagneticDipoles.InputFields.GreenTensors.G_m_renorm`

— Method`G_m_renorm(kr1,kr2)`

Computes the renormalized (dimensionless) magnetic Green's tensor between two position `r1`

and `r2`

, where the inputs are the positions multiplied by the host medium wave number `kr1`

and `kr2`

. The output is a dimensionless 3x3 complex matrix.

`CoupledElectricMagneticDipoles.InputFields.GreenTensors.denormalize_G_e`

— Method`denormalize_G_e(Ge,knorm)`

Passes from a dimensionless electric Green's tensor `Ge`

to a Green's tensor with units of length⁻¹ by multiplying by a factor $k/(4\pi)$. `knorm`

is the wavenumber in the host medium $k$.

`CoupledElectricMagneticDipoles.InputFields.GreenTensors.denormalize_G_m`

— Method`denormalize_G_m(Gm,knorm)`

Passes from a dimensionless magnetic Green's tensor `Gm`

to a Green's tensor with units of length⁻² by multiplying by a factor $k^2/(4\pi)$. `knorm`

is the wavenumber in the host medium $k$.

`CoupledElectricMagneticDipoles.InputFields.GreenTensors.dxG_e_renorm`

— Method`dxG_e_renorm(kr1,kr2)`

Computes the derivative of the renormalized (dimensionless) electric Green's tensor with respect to the `kx`

component of `kr1`

between two positions (multiplied by the host medium wavenumber) `kr1`

and `kr2`

. The output is a dimensionless 3x3 complex matrix.

`CoupledElectricMagneticDipoles.InputFields.GreenTensors.dxG_em_renorm`

— Method```
dxG_em_renorm(kr1,kr2)
Computes the derivative of the renormalized (dimensionless) electric and magnetic Green's tensors with respect to the `kx` component of `kr1` between two positions (multiplied by the host medium wavenumber) `kr1` and `kr2`.
The output is a dimensionless 3x3 complex matrix (electric and magnetic Green's tensor respectively).
```

`CoupledElectricMagneticDipoles.InputFields.GreenTensors.dxG_m_renorm`

— Method`dxG_m_renorm(kr1,kr2)`

Computes the derivative of the renormalized (dimensionless) magnetic Green's tensor with respect to the `kx`

component of `kr1`

between two positions (multiplied by the host medium wavenumber) `kr1`

and `kr2`

. The output is a dimensionless 3x3 complex matrix.

`CoupledElectricMagneticDipoles.InputFields.GreenTensors.dyG_e_renorm`

— Method`dyG_e_renorm(kr1,kr2)`

Computes the derivative of the renormalized (dimensionless) electric Green's tensor with respect to the `ky`

component of `kr1`

between two positions (multiplied by the host medium wavenumber) `kr1`

and `kr2`

. The output is a dimensionless 3x3 complex matrix.

`CoupledElectricMagneticDipoles.InputFields.GreenTensors.dyG_em_renorm`

— Method`dyG_em_renorm(kr1,kr2)`

Computes the derivative of the renormalized (dimensionless) electric and magnetic Green's tensors with respect to the `ky`

component of `kr1`

between two positions (multiplied by the host medium wavenumber) `kr1`

and `kr2`

. The output is a dimensionless 3x3 complex matrix (electric and magnetic Green's tensor respectively).

`CoupledElectricMagneticDipoles.InputFields.GreenTensors.dyG_m_renorm`

— Method`dyG_m_renorm(kr1,kr2)`

Computes the derivative of the renormalized (dimensionless) magnetic Green's tensor with respect to the `ky`

component of `kr1`

between two positions (multiplied by the host medium wavenumber) `kr1`

and `kr2`

. The output is a dimensionless 3x3 complex matrix.

`CoupledElectricMagneticDipoles.InputFields.GreenTensors.dzG_e_renorm`

— Method`dzG_e_renorm(kr1,kr2)`

Computes the derivative of the renormalized (dimensionless) electric Green's tensor with respect to the `kz`

component of `kr1`

between two positions (multiplied by the host medium wavenumber) `kr1`

and `kr2`

. The output is a dimensionless 3x3 complex matrix.

`CoupledElectricMagneticDipoles.InputFields.GreenTensors.dzG_em_renorm`

— Method`dzG_em_renorm(kr1,kr2)`

Computes the derivative of the renormalized (dimensionless) electric and magnetic Green's tensors with respect to the `kz`

component of `kr1`

between two positions (multiplied by the host medium wavenumber) `kr1`

and `kr2`

. The output is a dimensionless 3x3 complex matrix (electric and magnetic Green's tensor respectively).

`CoupledElectricMagneticDipoles.InputFields.GreenTensors.dzG_m_renorm`

— Method`dzG_m_renorm(kr1,kr2)`

Computes the derivative of the renormalized (dimensionless) magnetic Green's tensor with respect to the `kz`

component of `kr1`

between two positions (multiplied by the host medium wavenumber) `kr1`

and `kr2`

. The output is a dimensionless 3x3 complex matrix.