simpeg.fields.Fields#

class simpeg.fields.Fields(simulation, knownFields=None, aliasFields=None, dtype=None)[source]#

Bases: object

Base class for storing fields.

Fields classes are used to store the discrete field solution for a corresponding simulation object; see simpeg.simulation.BaseSimulation. Generally only one field solution (e.g. 'eSolution', 'phiSolution', 'bSolution') is stored. However, it may be possible to extract multiple field types (e.g. 'e', 'b', 'j', 'h') on the fly from the fields object. The field solution that is stored and the field types that can be extracted depend on the formulation used by the associated simulation. See the example below to learn how fields are extracted from fields objects.

Parameters:
simulationsimpeg.simulation.BaseSimulation

The simulation object used to compute the discrete field solution.

knownFieldsdict of {key: str}, optional

Dictionary defining the field solutions that are stored and where on the mesh they are discretized. E.g. {'eSolution': 'E', 'bSolution': 'F'} would store the eSolution on edges and bSolution on faces. The str must be one of {'CC', 'N', 'E', 'F'}.

aliasFieldsdict of {key: list}, optional

Set aliases to extract different field types from the field solutions that are stored by the fields object. The key defines the name you would like to use when extracting a given field type from the fields object. In order, the list contains:

  • the key for the known field solution that is used to compute the field type

  • where the output field type lives {'CC', 'N', 'E', 'F'}

  • the name of the method used to compute the output field.

E.g. {'b': ['eSolution', 'F', '_b']} is an alias that would allow you to extract a field type ('b') that lives on mesh faces ('F') from the E-field solution ('eSolution') by calling a method ('_b').

dtypedtype or dict of {strdtype}, optional

Set the Python data type for each numerical field solution that is stored in the fields object. E.g. float, complex, {'eSolution': complex, 'bSolution': complex}.

Attributes

aliasFields

The aliased fields of the object.

approxSize

Approximate cost of storing all of the known fields in MB.

dtype

Python data type(s) used to store the fields.

knownFields

The field solutions and where they are discretized on the mesh.

mesh

Mesh used by the simulation.

simulation

The simulation object used to compute the field solution.

survey

Survey used by the simulation.

Methods

startup()

Run startup to connect the simulation's discrete attributes to the fields object.

Examples

We want to access the fields for a discrete solution with \(\mathbf{e}\) discretized to edges and \(\mathbf{b}\) discretized to faces. To extract the fields for all sources:

f = simulation.fields(m)
e = f[:,'e']
b = f[:,'b']

The array e returned will have shape (n_edges, n_sources). And the array b returned will have shape (n_faces, n_sources). We can also extract the fields for a subset of the source list used for the simulation as follows:

f = simulation.fields(m)
e = f[source_list,'e']
b = f[source_list,'b']