residual

emg3d.solver.residual(grid, model, sfield, efield, norm=False)[source]

Computing the residual.

Returns the complete residual as given in [Muld06], page 636, middle of the right column:

\[\mathbf{r} = V \left( \mathrm{i}\omega\mu_0\mathbf{J_s} + \mathrm{i}\omega\mu_0 \tilde{\sigma} \mathbf{E} - \nabla \times \mu_\mathrm{r}^{-1} \nabla \times \mathbf{E} \right) .\]

This is a simple wrapper for the jitted computation in emg3d.core.amat_x() (@njit can not [yet] access class attributes). See emg3d.core.amat_x() for more details and corresponding theory.

This function is called by multigrid().

Parameters:
grid : emg3d.meshes.TensorMesh

Input grid.

model : emg3d.models.VolumeModel

Input model.

sfield : emg3d.fields.SourceField

Input source field.

efield : emg3d.fields.Field

Input electric field.

norm : bool

If True, the error (l2-norm) of the residual is returned, not the residual.

Returns:
residual : Field

Returned if norm=False. The residual field; emg3d.fields.Field instance.

norm : float

Returned if norm=True. The error (l2-norm) of the residual