# get_source_field#

emg3d.fields.get_source_field(grid, source, frequency, **kwargs)[source]#

Return source field for provided source and frequency.

The source term is given in Equation 2 of [Muld06],

$-\mathrm{i} \omega \mu_0 \mathbf{J}_\mathrm{s} \, .$
• In the case of dipoles and wires, the source is distributed onto the cells as fraction of the source length.

• In the case of points, the adjoint of the trilinear interpolation is used to distribute it to the grid edges.

Parameters
gridTensorMesh

Model grid; a emg3d.meshes.TensorMesh instance.

source{Tx*, tuple, list, ndarray)

Any source object from emg3d.electrodes (recommended usage).

If it is a list, tuple, or ndarray it is in the case of a dipole put through to emg3d.electrodes.TxElectricDipole or, if electric=False, to emg3d.electrodes.TxMagneticDipole. If it has more than two points it is put through to emg3d.electrodes.TxElectricWire. Consult the documentation of the respective classes for the format, but it is recommended to provide directly the classes.

frequency{float, None}

Source frequency (Hz), used to compute the Laplace parameter s. Either positive or negative:

• frequency > 0: Frequency domain, hence $$s = \mathrm{i}\omega = 2\mathrm{i}\pi f$$ (complex);

• frequency < 0: Laplace domain, hence $$s = f$$ (real).

• frequency == None: Returns the real-valued, frequency-independent source vector. This basically excludes the multiplication by $$-\mathrm{i}\omega\mu_0$$.

strength{float, complex}, default: 1.0

Source strength (A), put through to emg3d.electrodes.TxElectricDipole or, if electric=False, to emg3d.electrodes.TxMagneticDipole.

Only used if the provided source is not a source instance.
lengthfloat, default: 1.0

Dipole length (m), put through to emg3d.electrodes.TxElectricDipole or, if electric=False, to emg3d.electrodes.TxMagneticDipole.

Only used if the provided source is not a source instance.
electricbool, default: True

If True, emg3d.electrodes.TxElectricDipole is used to get the source instance, else emg3d.electrodes.TxMagneticDipole.

Only used if the provided source is not a source instance.
Returns
sfieldField

Source field (or source vector, if frequency=None), a emg3d.fields.Field instance.

Examples

In [1]: import emg3d
...: import numpy as np
...:

In [2]: # Create a simple grid, 8 cells of length 100 m in each
...: # direction, centered around the origin.
...: hx = np.ones(8)*100
...: grid = emg3d.TensorMesh([hx, hx, hx], origin=(-400, -400, -400))
...: grid  # For QC
...:
Out[2]:

TensorMesh: 512 cells

MESH EXTENT             CELL WIDTH      FACTOR
dir    nC        min           max         min       max      max
---   ---  ---------------------------  ------------------  ------
x      8       -400.00        400.00    100.00    100.00    1.00
y      8       -400.00        400.00    100.00    100.00    1.00
z      8       -400.00        400.00    100.00    100.00    1.00

In [3]: # Create an electric dipole source from
...: # x1=y1=z1=0 to x2=100, y2=z2=0; strength=100 A.
...: source = emg3d.TxElectricDipole(
...:             [[0, 0, 0], [100, 0, 0]], strength=100)
...: source  # For QC
...:
Out[3]:
TxElectricDipole: 100.0 A;
e1={0.0; 0.0; 0.0} m; e2={100.0; 0.0; 0.0} m

In [4]: # Get the corresponding source field for f=0.5 Hz.
...: sfield = emg3d.get_source_field(grid, source, frequency=0.5)
...: sfield  # For QC
...:
Out[4]: Field: electric; 8 x 8 x 8; 1,944