Module 3 - Inverse

class module3_inverse.InverseProblem(mesh, data, I_all, z=None, select_pot_method=0)

Inverse Object EIT 2D.

Class for solving inverse object electrical impedance tomography (EIT) problems in 2D. The inverse problem aims to reconstruct the electrical conductivity distribution within a domain based on measured electrical potentials at the boundary (electrodes).

Parameters:
  • mesh (mesh) – Any mesh from the Fenics module. We recommend using MyMesh().

  • data (array) – Vector with the potentials measured at the electrodes or any other vector.

  • I_all (current_method() or list of arrays) – Current density in each electrode for each measurement. It can be a function generated using current_method() or a list of arrays.

  • z (array) – Vector of impedances in electrodes.

  • select_pot_method (int) – Method to select the potential in the array. 0 - None, 1 - Select method. (Optional, Default: 0)

Example:

Initialize the inverse problem and solve it:

>>> InverseObject = InverseProblem(mesh_inverse, list_U0_noised, I_all, z)
>>> InverseObject.solve_inverse()
>>> gamma_k = InverseObject.gamma_k
solve_inverse()

Solve the inverse problem using a Newton-based method.

This method is the main solver of the inverse problem. It iteratively solves the inverse EIT problem using a Newton-based method. The solution is stored in the gamma_k attribute.

Example:

>>> InverseObject = InverseProblem(mesh_inverse, list_U0_noised, I_all, z)
>>> InverseObject.solve_inverse()
solve_innerNewton(Jacobiana_all, b0)

Solve the inner step of the Newton method.

This method is used to solve the inner step of the Newton method. It iteratively updates the solution gamma_k using different regularization methods.

Parameters:
  • Jacobiana_all (ndarray) – Derivative Matrix generated by Jacobian_calc().

  • b0 (array) – Vector containing the difference between the measured potentials and the potentials calculated with the current guess.

Returns:

(Array, int, float) – Returns sk (the result of the inner step to add to gamma_k), inner_step (number of inner steps taken), mu (regularization parameter used in the method).

weight_func(Jacobiana)

Determine the weights for the derivative matrix and apply them.

This method determines the weights for the derivative matrix and applies them. The weights are used to improve the convergence of the Newton-based method.

Parameters:

Jacobiana (ndarray) – Derivative Matrix generated by Jacobian_calc().

Returns:

(ndarray) – Returns the derivative matrix with weights.

set_answer(gamma0, mesh0)

Set the exact solution for gamma.

This method sets the exact solution (gamma0) and its corresponding mesh (mesh0) to be used for comparison and error calculation. This is useful to determine the best solution reached.

Parameters:
  • gamma0 (Function) – Finite Element Function representing the exact solution for gamma.

  • mesh0 (MyMesh()) – Mesh

Example:

>>> InverseObject=InverseProblem(mesh_inverse, list_U0_noised, I_all, z)
>>> InverseObject.set_answer(gamma0, mesh_refined)
set_NewtonParameters(**kwargs)

Set Newton Parameters for the inverse problem.

Kwargs:
  • mu_i (float): Initial value for mu (0, 1].

  • mumax (float): Maximum value for mu (0, 1].

  • nu (float): Factor to decrease the last mu_n.

  • R (float): Minimal value for mu_n.

Default Parameters:
>>> self.mu_i = 0.9
>>> self.mumax = 0.999
>>> self.nu = 0.99
>>> self.R = 0.9
Example:

>>> InverseObject = InverseProblem(mesh_inverse, list_U0_noised, I_all, l, z)
>>> InverseObject.set_NewtonParameters(mu_i=0.90, mumax=0.999, nu=0.985, R=0.90)
set_NoiseParameters(tau, noise_level)

Set Noise Parameters for stopping with the Discrepancy Principle.

Parameters:
  • tau (float) – Tau value for the discrepancy principle [0, ∞).

  • noise_level (float) – Noise level (%) in the data [0, 1).

Default Parameters:
>>> self.tau = 0
>>> self.noise_level = 0
Example:

>>> InverseObject = InverseProblem(mesh_inverse, list_U0_noised, I_all, l, z)
>>> InverseObject.set_NoiseParameters(tau=5, noise_level=0.01)
set_firstguess(Cellsgamma_k)

Set default parameters for the first guess in the external step Newton.

Parameters:

Cellsgamma_k (array) – A vector representing the initial values of gamma in each cell.

Default Parameters:
>>> self.Cellsgamma_k = np.ones(self.mesh.num_cells()) * 0.9
Example:

>>> InverseObject = InverseProblem(mesh_inverse, list_U0_noised, I_all, l, z)
>>> InverseObject.set_firstguess(np.ones(mesh_inverse.num_cells()) * 5)
set_solverconfig(**kwargs)

Set Solver configuration for the inverse problem.

Kwargs:
  • weight_value (bool): Use a weight function in the Jacobian matrix.

  • step_limit (float): Step limit while solving.

  • min_v (float): Minimal value in an element for gamma_k.

Default Parameters:
>>> self.weight_value = True
>>> self.step_limit = 5
>>> self.min_v = 0.05
Example:

>>> InverseObject = InverseProblem(mesh_inverse, list_U0_noised, I_all, l, z)
>>> InverseObject.set_solverconfig(weight_value=True, step_limit=200, min_v=0.01)
set_InnerParameters(**kwargs)

Set Inner-step Newton Parameters for the inverse problem.

Kwargs:
  • inner_method (str): Method to solve the inner step Newton. Options: ‘Landweber’, ‘CG’, ‘ME’, ‘LM’, ‘Tikhonov’.

  • land_a (int): Step-size for Landweber method.

  • ME_reg (float): Minimal value in an element for gamma_k.

  • Tik_c0 (float): Regularization parameter for Iterative Tikhonov.

  • Tik_q (float): Regularization parameter for Iterative Tikhonov.

  • LM_c0 (float): Regularization parameter for Levenberg-Marquardt.

  • LM_q (float): Regularization parameter for Levenberg-Marquardt.

Default Parameters:
>>> self.inner_method = 'Landweber'
>>> self.land_a = 1
>>> self.ME_reg = 5E-4
>>> self.Tik_c0 = 1
>>> self.Tik_q = 0.95
>>> self.LM_c0 = 1
>>> self.LM_q = 0.95
Example:

>>> InverseObject = InverseProblem(mesh_inverse, list_U0_noised, I_all, l, z)
>>> InverseObject.set_InnerParameters(inner_method='ME', ME_reg=5E-4)