gradient

emg3d.optimize.gradient(simulation)[source]

Compute the discrete gradient using the adjoint-state method.

The discrete adjoint-state gradient for a single source at a single frequency is given by Equation (10) in [PlMu08],

\[\begin{split}\nabla_p \phi(\textbf{p}) = -&\sum_{k,l,m}\mathbf{\bar{\lambda}}_{x; k+\frac{1}{2}, l, m} \frac{\partial S_{k+\frac{1}{2}, l, m}}{\partial \textbf{p}} \textbf{E}_{x; k+\frac{1}{2}, l, m}\\ -&\sum_{k,l,m}\mathbf{\bar{\lambda}}_{y; k, l+\frac{1}{2}, m} \frac{\partial S_{k, l+\frac{1}{2}, m}}{\partial \textbf{p}} \textbf{E}_{y; k, l+\frac{1}{2}, m}\\ -&\sum_{k,l,m}\mathbf{\bar{\lambda}}_{z; k, l, m+\frac{1}{2}} \frac{\partial S_{k, l, m+\frac{1}{2}}}{\partial \textbf{p}} \textbf{E}_{z; k, l, m+\frac{1}{2}}\, ,\end{split}\]

where \(\textbf{E}\) is the electric (forward) field and \(\mathbf{\lambda}\) is the back-propagated residual field (from electric and magnetic receivers); \(\bar{~}\) denotes conjugate. The \(\partial S\)-part takes care of the volume-averaged model parameters.

Warning

To obtain the proper adjoint-state gradient you have to choose linear interpolation for the receiver responses: emg3d.Simulation(..., receiver_interpolation='linear'). The reason is that the point-source is the adjoint of a tri-linear interpolation, so the residual should come from a linear interpolation.

Also, the adjoint test for magnetic receivers does not yet pass. Electric receivers are good to go.

Note

The currently implemented gradient is only for isotropic models without relative electric permittivity nor relative magnetic permeability.

Parameters
simulationSimulation

The simulation; a emg3d.simulations.Simulation instance.

Returns
gradndarray

Adjoint-state gradient (same shape as simulation.model).