DDA Core Functionalities

DDACore is the module allowing to solve DDA/CEMD problems (see the Theory pdf for definition of these problems). The problems can be solved either on the CPU (in parrallel with LAPACK) or on the GPU (With CUDA). The list of functions and how to use them is in the next section. Note that $N$ denotes the number of point dipoles in the problem.

Functions List and Documentation

Main Solver Functions

Main.CoupledElectricMagneticDipoles.DDACore.solve_DDA_eMethod
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.
source
Main.CoupledElectricMagneticDipoles.DDACore.solve_DDA_e_mMethod
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.
source
Main.CoupledElectricMagneticDipoles.DDACore.solve_DDA_e_mMethod
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.

source

Utility Functions

Main.CoupledElectricMagneticDipoles.DDACore.solve_systemMethod
 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).
source
Main.CoupledElectricMagneticDipoles.DDACore.load_dda_matrix_eMethod
 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.

source
Main.CoupledElectricMagneticDipoles.DDACore.load_dda_matrix_e_mMethod
 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.

source
Main.CoupledElectricMagneticDipoles.DDACore.load_dda_matrix_e_mMethod
 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

source