eispy2d.solvers.forward package#

Submodules#

eispy2d.solvers.forward.analytical module#

Analytical Solution for Electromagnetic Scattering by Cylinders.

This module provides the analytical solution for electromagnetic scattering by dielectric and conducting cylinders. It solves the forward problem following the Forward Solver abstract class using exact mathematical formulations based on cylindrical wave expansions.

The implementation supports both perfect dielectric and perfect conductor cylinders, providing exact solutions that can be used for validation of numerical methods and benchmarking purposes.

References

class eispy2d.solvers.forward.analytical.Analytical(contrast=None, radius=None)#

Bases: ForwardSolver

Analytical Solution for Electromagnetic Scattering by Cylinders.

This class implements analytical solutions for electromagnetic scattering by dielectric and perfectly conducting cylinders using cylindrical wave expansions. It provides exact solutions that can be used for validation of numerical methods and benchmarking purposes.

name#

Name identifier for the solver (“Analytical Solution to Cylinder Scattering”).

Type:

str

contrast#

Relative permittivity contrast of the cylinder. Used for dielectric cylinder problems.

Type:

float or None

radius#

Radius of the cylinder in wavelengths. Used for both dielectric and conductor problems.

Type:

float or None

incident_field(resolution, configuration)#

Compute the incident field matrix.

solve(inputdata, noise=None, PRINT_INFO=False, COMPUTE_SCATTERED_FIELD=True,

SAVE_INTERN_FIELD=True)

Solve the analytical scattering problem.

dielectric_cylinder(inputdata, SAVE_INTERN_FIELD=True, SAVE_MAP=False)#

Solve scattering by a dielectric cylinder analytically.

conductor_cylinder(inputdata, SAVE_INTERN_FIELD=True, SAVE_MAP=False)#

Solve scattering by a perfectly conducting cylinder analytically.

save(file_name, file_path='')#

Save the analytical solver object to file.

importdata(file_name, file_path='')#

Import analytical solver data from file.

__init__(contrast=None, radius=None)#

Create the analytical solver object.

Parameters:
  • contrast (float, optional) – Relative permittivity contrast of the dielectric cylinder. Required for perfect dielectric problems.

  • radius (float, optional) – Radius of the cylinder in wavelengths. Required for both dielectric and conductor problems.

__str__()#

Return string representation of the analytical solver.

Returns:

String description including radius and contrast if available.

Return type:

str

conductor_cylinder(inputdata, SAVE_INTERN_FIELD=True, SAVE_MAP=False)#

Solve scattering by a perfectly conducting cylinder analytically.

Computes the analytical solution for electromagnetic scattering by a perfectly conducting cylinder using cylindrical wave expansions.

Parameters:
  • inputdata (InputData) – Input data object containing configuration and problem setup.

  • SAVE_INTERN_FIELD (bool, default=True) – Save the total field in the D-domain.

  • SAVE_MAP (bool, default=False) – Save the conductivity map to the inputdata object.

Raises:

MissingAttributesError – If radius attribute is None.

dielectric_cylinder(inputdata, SAVE_INTERN_FIELD=True, SAVE_MAP=False)#

Solve scattering by a dielectric cylinder analytically.

Computes the analytical solution for electromagnetic scattering by a dielectric cylinder using cylindrical wave expansions.

Parameters:
  • inputdata (InputData) – Input data object containing configuration and problem setup.

  • SAVE_INTERN_FIELD (bool, default=True) – Save the total field in the D-domain.

  • SAVE_MAP (bool, default=False) – Save the relative permittivity map to the inputdata object.

Raises:

MissingAttributesError – If radius or contrast attributes are None.

importdata(file_name, file_path='')#

Import analytical solver data from file.

Parameters:
  • file_name (str) – Name of the file to import.

  • file_path (str, default: '') – Path of the file to import.

incident_field(resolution, configuration)#

Compute the incident field matrix.

Computes the incident field matrix for plane waves from different angles based on the configuration parameters.

Parameters:
  • resolution (2-tuple) – The image size of D-domain in pixels (y, x).

  • configuration (Configuration) – Configuration object containing problem parameters.

Returns:

ei – Incident field matrix. Rows correspond to points in the image following C-order and columns correspond to sources.

Return type:

numpy.ndarray

save(file_name, file_path='')#

Save the analytical solver object to file.

Parameters:
  • file_name (str) – Name of the file to save.

  • file_path (str, default: '') – Path where to save the file.

solve(inputdata, noise=None, PRINT_INFO=False, COMPUTE_SCATTERED_FIELD=True, SAVE_INTERN_FIELD=True)#

Solve the analytical scattering problem.

Determines the problem type (dielectric or conductor) and calls the appropriate analytical solution method.

Parameters:
  • inputdata (InputData) – Input data object containing configuration and problem setup.

  • noise (float, optional) – Noise level to add to scattered field (not used in this method).

  • PRINT_INFO (bool, default: False) – Print iteration information (not used in analytical solution).

  • COMPUTE_SCATTERED_FIELD (bool, default: True) – Compute scattered field (not used in this method).

  • SAVE_INTERN_FIELD (bool, default: True) – Save the total field in the D-domain.

Raises:

WrongValueInput – If neither perfect_dielectric nor good_conductor is True.

eispy2d.solvers.forward.analytical.cart2pol(x, y)#

Convert Cartesian coordinates to polar coordinates.

Parameters:
  • x (numpy.ndarray) – x-coordinates.

  • y (numpy.ndarray) – y-coordinates.

Returns:

  • rho (numpy.ndarray) – Radial coordinates.

  • phi (numpy.ndarray) – Angular coordinates in radians (0 to 2π).

eispy2d.solvers.forward.analytical.compute_scattered_field(xm, ym, an, n, kb, theta, magnitude)#

Compute scattered field for scattering problem.

Parameters:
  • xm (numpy.ndarray) – x-coordinates of measurement points.

  • ym (numpy.ndarray) – y-coordinates of measurement points.

  • an (numpy.ndarray) – Scattering coefficients.

  • n (numpy.ndarray) – Mode indices.

  • kb (float) – Background wavenumber [1/m].

  • theta (numpy.ndarray) – Incidence angles in radians.

  • magnitude (float) – Incident field magnitude [V/m].

Returns:

es – Scattered field at measurement points.

Return type:

numpy.ndarray

eispy2d.solvers.forward.analytical.compute_total_field(x, y, radius, an, cn, N, wavenumber_b, wavenumber_d, magnitude, theta=None)#

Compute total field for scattering problem.

Parameters:
  • x (numpy.ndarray) – x-coordinates of observation points.

  • y (numpy.ndarray) – y-coordinates of observation points.

  • radius (float) – Radius of the cylinder [m].

  • an (numpy.ndarray) – Scattering coefficients.

  • cn (numpy.ndarray) – Internal field coefficients.

  • N (numpy.ndarray) – Mode indices.

  • wavenumber_b (float) – Background wavenumber [1/m].

  • wavenumber_d (float) – Cylinder wavenumber [1/m].

  • magnitude (float) – Incident field magnitude [V/m].

  • theta (numpy.ndarray, optional) – Incidence angles in radians.

Returns:

et – Total field distribution.

Return type:

numpy.ndarray

eispy2d.solvers.forward.analytical.get_coefficients(wavenumber_b, wavenumber_d, radius, epsilon_d, epsilon_b)#

Compute scattering coefficients for a dielectric cylinder.

Parameters:
  • wavenumber_b (float) – Wavenumber of the background medium [1/m].

  • wavenumber_d (float) – Wavenumber of the dielectric cylinder [1/m].

  • radius (float) – Radius of the cylinder [m].

  • epsilon_d (float) – Permittivity of the cylinder [F/m].

  • epsilon_b (float) – Permittivity of the background [F/m].

Returns:

  • an (numpy.ndarray) – Scattering coefficients.

  • cn (numpy.ndarray) – Internal field coefficients.

  • n (numpy.ndarray) – Mode indices.

eispy2d.solvers.forward.analytical.get_map(x, y, radius, epsilon_rb, epsilon_rd)#

Create dielectric property map for a cylinder.

Parameters:
  • x (numpy.ndarray) – x-coordinates of the mesh.

  • y (numpy.ndarray) – y-coordinates of the mesh.

  • radius (float) – Radius of the cylinder [m].

  • epsilon_rb (float) – Background relative permittivity.

  • epsilon_rd (float) – Cylinder relative permittivity.

Returns:

  • epsilon_r (numpy.ndarray) – Relative permittivity map.

  • sigma (numpy.ndarray) – Conductivity map (zeros for dielectric).

eispy2d.solvers.forward.analytical.rotate_axis(theta, x, y)#

Rotate coordinates by angle theta.

Parameters:
  • theta (float) – Rotation angle in radians.

  • x (numpy.ndarray) – x-coordinates to rotate.

  • y (numpy.ndarray) – y-coordinates to rotate.

Returns:

xp, yp – Rotated coordinates.

Return type:

numpy.ndarray

eispy2d.solvers.forward.forward module#

eispy2d.solvers.forward.mom_cg_fft module#

Method of Moments - Conjugate-Gradient FFT Method.

This module provides the implementation of Method of Moments (MoM) with the Conjugated-Gradient FFT formulation. It solves the forward problem following the Forward Solver abstract class.

References

class eispy2d.solvers.forward.mom_cg_fft.MoM_CG_FFT(tolerance=0.001, maximum_iterations=5000, parallelization=True)#

Bases: ForwardSolver

Method of Moments with Conjugated-Gradient FFT method.

This class implements the Method of Moments following the Conjugated-Gradient FFT formulation for solving electromagnetic scattering problems.

TOL#

Tolerance level for convergence.

Type:

float

MAX_IT#

Maximum number of iterations.

Type:

int

name#

Solver name (“Method of Moments - CG-FFT”).

Type:

str

incident_field(resolution, configuration)#

Compute the incident field matrix.

solve(inputdata, noise=None, PRINT_INFO=False,

COMPUTE_SCATTERED_FIELD=True, SAVE_INTERN_FIELD=True)

Solve the forward problem.

save(file_name, file_path='')#

Save solver state to file.

importdata(file_name, file_path='')#

Import solver state from file.

CG_FFT(G, b, NX, NY, NS, Xr, MAX_IT, TOL, PRINT_CONVERGENCE)#

Apply the Conjugated-Gradient Method to the forward problem.

Parameters:
  • G (numpy.ndarray) – Extended matrix, (2NX-1)x(2NY-1)

  • b (numpy.ndarray) – Excitation source, (NX.NY)xNi

  • NX (int) – Contrast map in x-axis.

  • NY (int) – Contrast map in x-axis.

  • NS (int) – Number of incidences.

  • Xr (numpy.ndarray) – Contrast map, NX x NY

  • MAX_IT (int) – Maximum number of iterations

  • TOL (float) – Error tolerance

  • PRINT_CONVERGENCE (boolean) – Print error information per iteration.

Returns:

Jnumpy:ndarray

Current density, (NX.NY)xNS

__init__(tolerance=0.001, maximum_iterations=5000, parallelization=True)#

Create the object.

Parameters:
  • configuration (string or Configuration:Configuration) – Either a configuration object or a string with the name of file in which the configuration is saved. In this case, the file path may also be provided.

  • configuration_filepath (string, optional) – A string with the path to the configuration file (when the file name is provided).

  • tolerance (float, default: 1e-6) – Minimum error tolerance.

  • maximum_iteration (int, default: 10000) – Maximum number of iterations.

__str__()#

Print method parametrization.

importdata(file_name, file_path='')#
incident_field(resolution, configuration)#

Compute the incident field matrix.

Given the configuration information stored in the object, it computes the incident field matrix considering plane waves in different from different angles.

Parameters:

resolution (2-tuple) – The image size of D-domain in pixels (y and x).

Returns:

einumpy.ndarray

Incident field matrix. The rows correspond to the points in the image following C-order and the columns corresponds to the sources.

save(file_name, file_path='')#

Save simulation data.

solve(inputdata, noise=None, PRINT_INFO=False, COMPUTE_SCATTERED_FIELD=True, SAVE_INTERN_FIELD=True)#

Solve the forward problem.

Parameters:
  • inputdata (inputdata:InputData) – An object describing the dielectric property map.

  • PRINT_INFO (boolean, default: False) – Print iteration information.

  • COMPUTE_INTERN_FIELD (boolean, default: True) – Compute the total field in D-domain.

Returns:

es, et, einumpy:ndarray

Matrices with the scattered, total and incident field information.

Examples

>>> solver = MoM_CG_FFT(configuration)
>>> es, et, ei = solver.solve(inputdata)
>>> es, ei = solver.solve(inputdata, COMPUTE_INTERN_FIELD=False)
eispy2d.solvers.forward.mom_cg_fft.get_contrast_map(epsilon_r, sigma, epsilon_rb, sigma_b, omega)#

Compute the contrast function for a given image.

Parameters:
  • epsilon_r (:class:numpy.ndarray) – A matrix with the relative permittivity map.

  • sigma (:class:numpy.ndarray) – A matrix with the conductivity map [S/m].

  • epsilon_rb (float) – Background relative permittivity of the medium.

  • sigma_b (float) – Background conductivity of the medium [S/m].

  • omega (float or array) – Angular frequency of operation [Hz].

eispy2d.solvers.forward.mom_cg_fft.get_greenfunction(xm, ym, x, y, kb)#

Compute the Green function matrix for pulse basis discre.

The routine computes the Green function based on a discretization of the integral equation using pulse basis functions [1]_.

Parameters:
  • xm (numpy.ndarray) – A 1-d array with the x-coordinates of measumerent points in the S-domain [m].

  • ym (numpy.ndarray) – A 1-d array with the y-coordinates of measumerent points in the S-domain [m].

  • x (numpy.ndarray) – A meshgrid matrix of x-coordinates in the D-domain [m].

  • y (numpy.ndarray) – A meshgrid matrix of y-coordinates in the D-domain [m].

  • kb (float or complex) – Wavenumber of background medium [1/m].

Returns:

Gnumpy.ndarray, complex

A matrix with the evaluation of Green function at D-domain for each measument point, considering pulse basis discretization. The shape of the matrix is NM x (Nx.Ny), where NM is the number of measurements (size of xm, ym) and Nx and Ny are the number of points in each axis of the discretized D-domain (shape of x, y).

References

Module contents#

Forward solvers for electromagnetic scattering problems.

Implements methods for computing scattered fields from known material distributions: - MoM_CG_FFT: Method of Moments with Conjugate Gradient FFT - Analytical: Analytical solution for cylindrical scatterers - FFTProduct: FFT-based convolution for Green’s function

class eispy2d.solvers.forward.Analytical(contrast=None, radius=None)#

Bases: ForwardSolver

Analytical Solution for Electromagnetic Scattering by Cylinders.

This class implements analytical solutions for electromagnetic scattering by dielectric and perfectly conducting cylinders using cylindrical wave expansions. It provides exact solutions that can be used for validation of numerical methods and benchmarking purposes.

name#

Name identifier for the solver (“Analytical Solution to Cylinder Scattering”).

Type:

str

contrast#

Relative permittivity contrast of the cylinder. Used for dielectric cylinder problems.

Type:

float or None

radius#

Radius of the cylinder in wavelengths. Used for both dielectric and conductor problems.

Type:

float or None

incident_field(resolution, configuration)#

Compute the incident field matrix.

solve(inputdata, noise=None, PRINT_INFO=False, COMPUTE_SCATTERED_FIELD=True,

SAVE_INTERN_FIELD=True)

Solve the analytical scattering problem.

dielectric_cylinder(inputdata, SAVE_INTERN_FIELD=True, SAVE_MAP=False)#

Solve scattering by a dielectric cylinder analytically.

conductor_cylinder(inputdata, SAVE_INTERN_FIELD=True, SAVE_MAP=False)#

Solve scattering by a perfectly conducting cylinder analytically.

save(file_name, file_path='')#

Save the analytical solver object to file.

importdata(file_name, file_path='')#

Import analytical solver data from file.

__init__(contrast=None, radius=None)#

Create the analytical solver object.

Parameters:
  • contrast (float, optional) – Relative permittivity contrast of the dielectric cylinder. Required for perfect dielectric problems.

  • radius (float, optional) – Radius of the cylinder in wavelengths. Required for both dielectric and conductor problems.

__str__()#

Return string representation of the analytical solver.

Returns:

String description including radius and contrast if available.

Return type:

str

conductor_cylinder(inputdata, SAVE_INTERN_FIELD=True, SAVE_MAP=False)#

Solve scattering by a perfectly conducting cylinder analytically.

Computes the analytical solution for electromagnetic scattering by a perfectly conducting cylinder using cylindrical wave expansions.

Parameters:
  • inputdata (InputData) – Input data object containing configuration and problem setup.

  • SAVE_INTERN_FIELD (bool, default=True) – Save the total field in the D-domain.

  • SAVE_MAP (bool, default=False) – Save the conductivity map to the inputdata object.

Raises:

MissingAttributesError – If radius attribute is None.

dielectric_cylinder(inputdata, SAVE_INTERN_FIELD=True, SAVE_MAP=False)#

Solve scattering by a dielectric cylinder analytically.

Computes the analytical solution for electromagnetic scattering by a dielectric cylinder using cylindrical wave expansions.

Parameters:
  • inputdata (InputData) – Input data object containing configuration and problem setup.

  • SAVE_INTERN_FIELD (bool, default=True) – Save the total field in the D-domain.

  • SAVE_MAP (bool, default=False) – Save the relative permittivity map to the inputdata object.

Raises:

MissingAttributesError – If radius or contrast attributes are None.

importdata(file_name, file_path='')#

Import analytical solver data from file.

Parameters:
  • file_name (str) – Name of the file to import.

  • file_path (str, default: '') – Path of the file to import.

incident_field(resolution, configuration)#

Compute the incident field matrix.

Computes the incident field matrix for plane waves from different angles based on the configuration parameters.

Parameters:
  • resolution (2-tuple) – The image size of D-domain in pixels (y, x).

  • configuration (Configuration) – Configuration object containing problem parameters.

Returns:

ei – Incident field matrix. Rows correspond to points in the image following C-order and columns correspond to sources.

Return type:

numpy.ndarray

save(file_name, file_path='')#

Save the analytical solver object to file.

Parameters:
  • file_name (str) – Name of the file to save.

  • file_path (str, default: '') – Path where to save the file.

solve(inputdata, noise=None, PRINT_INFO=False, COMPUTE_SCATTERED_FIELD=True, SAVE_INTERN_FIELD=True)#

Solve the analytical scattering problem.

Determines the problem type (dielectric or conductor) and calls the appropriate analytical solution method.

Parameters:
  • inputdata (InputData) – Input data object containing configuration and problem setup.

  • noise (float, optional) – Noise level to add to scattered field (not used in this method).

  • PRINT_INFO (bool, default: False) – Print iteration information (not used in analytical solution).

  • COMPUTE_SCATTERED_FIELD (bool, default: True) – Compute scattered field (not used in this method).

  • SAVE_INTERN_FIELD (bool, default: True) – Save the total field in the D-domain.

Raises:

WrongValueInput – If neither perfect_dielectric nor good_conductor is True.

class eispy2d.solvers.forward.FFTProduct(discretization=None, adjoint=False, conjugate=False)#

Bases: object

Fast Fourier Transform-based convolution product for Green’s function.

This class computes the matrix-vector product using FFT-based convolution for efficient implementation of the Method of Moments.

discretization#

Discretization object containing the Green’s function matrix.

Type:

Discretization

G#

Extended Green’s function matrix for FFT convolution.

Type:

numpy.ndarray

adjoint#

Whether to use the adjoint operator.

Type:

bool

conjugate#

Whether to use the conjugate operator.

Type:

bool

compute(J)#

Compute the convolution product.

compute(J)#

Compute the convolution product.

Parameters:

J (numpy.ndarray) – Current density matrix with shape (N, NS) where N is the number of discretization elements and NS is the number of sources.

Returns:

Result of the convolution product.

Return type:

numpy.ndarray

property discretization#
class eispy2d.solvers.forward.MoM_CG_FFT(tolerance=0.001, maximum_iterations=5000, parallelization=True)#

Bases: ForwardSolver

Method of Moments with Conjugated-Gradient FFT method.

This class implements the Method of Moments following the Conjugated-Gradient FFT formulation for solving electromagnetic scattering problems.

TOL#

Tolerance level for convergence.

Type:

float

MAX_IT#

Maximum number of iterations.

Type:

int

name#

Solver name (“Method of Moments - CG-FFT”).

Type:

str

incident_field(resolution, configuration)#

Compute the incident field matrix.

solve(inputdata, noise=None, PRINT_INFO=False,

COMPUTE_SCATTERED_FIELD=True, SAVE_INTERN_FIELD=True)

Solve the forward problem.

save(file_name, file_path='')#

Save solver state to file.

importdata(file_name, file_path='')#

Import solver state from file.

CG_FFT(G, b, NX, NY, NS, Xr, MAX_IT, TOL, PRINT_CONVERGENCE)#

Apply the Conjugated-Gradient Method to the forward problem.

Parameters:
  • G (numpy.ndarray) – Extended matrix, (2NX-1)x(2NY-1)

  • b (numpy.ndarray) – Excitation source, (NX.NY)xNi

  • NX (int) – Contrast map in x-axis.

  • NY (int) – Contrast map in x-axis.

  • NS (int) – Number of incidences.

  • Xr (numpy.ndarray) – Contrast map, NX x NY

  • MAX_IT (int) – Maximum number of iterations

  • TOL (float) – Error tolerance

  • PRINT_CONVERGENCE (boolean) – Print error information per iteration.

Returns:

Jnumpy:ndarray

Current density, (NX.NY)xNS

__init__(tolerance=0.001, maximum_iterations=5000, parallelization=True)#

Create the object.

Parameters:
  • configuration (string or Configuration:Configuration) – Either a configuration object or a string with the name of file in which the configuration is saved. In this case, the file path may also be provided.

  • configuration_filepath (string, optional) – A string with the path to the configuration file (when the file name is provided).

  • tolerance (float, default: 1e-6) – Minimum error tolerance.

  • maximum_iteration (int, default: 10000) – Maximum number of iterations.

__str__()#

Print method parametrization.

importdata(file_name, file_path='')#
incident_field(resolution, configuration)#

Compute the incident field matrix.

Given the configuration information stored in the object, it computes the incident field matrix considering plane waves in different from different angles.

Parameters:

resolution (2-tuple) – The image size of D-domain in pixels (y and x).

Returns:

einumpy.ndarray

Incident field matrix. The rows correspond to the points in the image following C-order and the columns corresponds to the sources.

save(file_name, file_path='')#

Save simulation data.

solve(inputdata, noise=None, PRINT_INFO=False, COMPUTE_SCATTERED_FIELD=True, SAVE_INTERN_FIELD=True)#

Solve the forward problem.

Parameters:
  • inputdata (inputdata:InputData) – An object describing the dielectric property map.

  • PRINT_INFO (boolean, default: False) – Print iteration information.

  • COMPUTE_INTERN_FIELD (boolean, default: True) – Compute the total field in D-domain.

Returns:

es, et, einumpy:ndarray

Matrices with the scattered, total and incident field information.

Examples

>>> solver = MoM_CG_FFT(configuration)
>>> es, et, ei = solver.solve(inputdata)
>>> es, ei = solver.solve(inputdata, COMPUTE_INTERN_FIELD=False)