SimPEG Documentation
Transcription
SimPEG Documentation
SimPEG Documentation Release 0.1.9 Rowan Cockett January 10, 2016 Contents 1 About SimPEG 1.1 Why SimPEG? . . . . . 1.2 License . . . . . . . . . 1.3 Authors . . . . . . . . . 1.4 Projects Using SimPEG . . . . 3 4 5 5 5 2 Getting Started with SimPEG 2.1 Installation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 7 3 Discretization 3.1 SimPEG Meshes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3.2 Differential Operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3.3 Inner Products . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 9 29 32 4 Forward Problems 4.1 Forward Problem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39 39 5 Inversion 5.1 Data Misfit . . 5.2 Regularization 5.3 Optimize . . . 5.4 Directives . . . 5.5 Inversion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47 47 49 52 60 61 Utility Codes 6.1 Solver . . . . . . 6.2 SimPEG Maps . 6.3 Utilities . . . . . 6.4 Testing SimPEG . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63 63 64 70 79 7 Packages 7.1 Electromagnetics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7.2 Richards Equation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83 83 90 8 Developer’s Documentation 93 9 Project Index & Search 95 6 10 Examples 97 i 10.1 Examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Python Module Index ii 97 121 SimPEG Documentation, Release 0.1.9 SimPEG: Simulation and Parameter Estimation in Geophysics SimPEG is a framework and a collection of tools that aid in the development of large-scale geophysical inversion codes. The vision is to create a modular and extensible package for finite volume simulation and parameter estimation with applications to geophysical imaging and subsurface flow. To enable these goals, this package has the following features: • is modular with respect to ... everything! • is built with the (large-scale) inverse problem in mind • provides a framework for geophysical and hydrogeologic problems • supports 1D, 2D and 3D problems • provides a set of commonly used visualization utilities Contents 1 SimPEG Documentation, Release 0.1.9 2 Contents 3 SimPEG Documentation, Release 0.1.9 CHAPTER 1 About SimPEG 1.1 Why SimPEG? 1.1.1 The Big Picture 4 Chapter 1. About SimPEG SimPEG Documentation, Release 0.1.9 1.1.2 Explaining The Big Picture 1.2 License The MIT License (MIT) Copyright (c) 2013-2015 SimPEG Developers Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 1.3 Authors • Luz Angelica Caudillo-Mata, (@lacmajedrez) • Rowan Cockett, (@rowanc1) • Eldad Haber, (@ehaber99) • Lindsey Heagy, (@lheagy) • Seogi Kang, (@sgkang) • Dave Marchant, (@dwfmarchant) • Gudni Rosenkjaer, (@grosenkj) • Lars Ruthotto, (@lruthotto) • Mike Wathen, (@mrwathen) 1.4 Projects Using SimPEG • Electromagnetics (simpegEM) • Potential Fields (simpegPF) • Ground Water Flow (simpegFLOW) • Direct Current Resistivity (simpegDC) • Electromagnetics 1D (simpegEM1D) • Magnetotellurics (simpegMT) 1.2. License 5 SimPEG Documentation, Release 0.1.9 6 Chapter 1. About SimPEG CHAPTER 2 Getting Started with SimPEG 2.1 Installation 2.1.1 Dependencies • Python 2.7 • NumPy 1.8 (or greater) • SciPy 0.13 (or greater) • matplotlib 1.3 (or greater) • Cython 0.20 (or greater) 2.1.2 Installing Python Python is available on all major operating systems, but if you are getting started with python it is best to use a package manager such as Continuum Anaconda or Enthought Canopy. You can download the package manager and use it to install the dependencies above. 2.1.3 Installing SimPEG SimPEG is on pip!!: pip install SimPEG Installing from Source First (you need git): git clone https://github.com/simpeg/simpeg Second (from the root of the simpeg repository): python setup.py install 7 SimPEG Documentation, Release 0.1.9 2.1.4 Useful Links An enormous amount of information (including tutorials and examples) can be found on the official websites of the packages • Python Website • Numpy Website • SciPy Website • Matplotlib Python for scientific computing • Python for Scientists Links to commonly used packages, Matlab to Python comparison • Python Wiki Lists packages and resources for scientific computing in Python Numpy and Matlab • NumPy for Matlab Users • Python vs Matlab Lessons in Python • Software Carpentry • Introduction to NumPy and Matplotlib Editing Python There are numerous ways to edit and test Python (see PythonWiki for an overview) and in our group at least the following options are being used: • Sublime • iPython Notebook • iPython • Enthought Canopy 8 Chapter 2. Getting Started with SimPEG CHAPTER 3 Discretization 3.1 SimPEG Meshes The Mesh objects in SimPEG provide a numerical grid on which to solve differential equations. Each mesh type has a similar API to make switching between different meshes relatively simple. 3.1.1 Overview of Meshes Available The following meshes are available for use: Tensor Mesh class SimPEG.Mesh.TensorMesh.BaseTensorMesh(h_in, x0_in=None) Bases: SimPEG.Mesh.BaseMesh.BaseMesh h h is a list containing the cell widths of the tensor mesh in each dimension. hx Width of cells in the x direction hy Width of cells in the y direction hz Width of cells in the z direction vectorNx Nodal grid vector (1D) in the x direction. vectorNy Nodal grid vector (1D) in the y direction. vectorNz Nodal grid vector (1D) in the z direction. vectorCCx Cell-centered grid vector (1D) in the x direction. vectorCCy Cell-centered grid vector (1D) in the y direction. 9 SimPEG Documentation, Release 0.1.9 vectorCCz Cell-centered grid vector (1D) in the z direction. gridCC Cell-centered grid. gridN Nodal grid. gridFx Face staggered grid in the x direction. gridFy Face staggered grid in the y direction. gridFz Face staggered grid in the z direction. gridEx Edge staggered grid in the x direction. gridEy Edge staggered grid in the y direction. gridEz Edge staggered grid in the z direction. getTensor(key) Returns a tensor list. Parameters key (str) – What tensor (see below) Return type list Returns list of the tensors that make up the mesh. key can be: 'CC' 'N' 'Fx' 'Fy' 'Fz' 'Ex' 'Ey' 'Ez' -> -> -> -> -> -> -> -> scalar field defined scalar field defined x-component of field y-component of field z-component of field x-component of field y-component of field z-component of field on cell centers on nodes defined on faces defined on faces defined on faces defined on edges defined on edges defined on edges isInside(pts, locType=’N’) Determines if a set of points are inside a mesh. Parameters pts (numpy.ndarray) – Location of points to test :rtype numpy.ndarray :return inside, numpy array of booleans getInterpolationMat(loc, locType, zerosOutside=False) Produces interpolation matrix Parameters • loc (numpy.ndarray) – Location of points to interpolate to • locType (str) – What to interpolate (see below) Return type scipy.sparse.csr.csr_matrix Returns M, the interpolation matrix 10 Chapter 3. Discretization SimPEG Documentation, Release 0.1.9 locType can be: 'Ex' 'Ey' 'Ez' 'Fx' 'Fy' 'Fz' 'N' 'CC' -> -> -> -> -> -> -> -> x-component of field y-component of field z-component of field x-component of field y-component of field z-component of field scalar field defined scalar field defined defined on edges defined on edges defined on edges defined on faces defined on faces defined on faces on nodes on cell centers class SimPEG.Mesh.TensorMesh.TensorMesh(h_in, x0=None) Bases: SimPEG.Mesh.TensorMesh.BaseTensorMesh, SimPEG.Mesh.BaseMesh.BaseRectangularMesh, SimPEG.Mesh.View.TensorView, SimPEG.Mesh.DiffOperators.DiffOperators, SimPEG.Mesh.InnerProducts.InnerProducts TensorMesh is a mesh class that deals with tensor product meshes. Any Mesh that has a constant width along the entire axis such that it can defined by a single width vector, called ‘h’. hx = np.array([1,1,1]) hy = np.array([1,2]) hz = np.array([1,1,1,1]) mesh = Mesh.TensorMesh([hx, hy, hz]) Example of a padded tensor mesh using SimPEG.Utils.meshutils.meshTensor(): from SimPEG import Mesh, Utils M = Mesh.TensorMesh([[(10,10,-1.3),(10,40),(10,10,1.3)], [(10,10,-1.3),(10,20)]]) M.plotGrid() 3.1. SimPEG Meshes 11 SimPEG Documentation, Release 0.1.9 800 700 600 x2 500 400 300 200 100 0 0 200 400 600 800 x1 1000 1200 1400 1600 For a quick tensor mesh on a (10x12x15) unit cube: mesh = Mesh.TensorMesh([10, 12, 15]) vol Construct cell volumes of the 3D model as 1d array. area Construct face areas of the 3D model as 1d array. edge Construct edge legnths of the 3D model as 1d array. faceBoundaryInd Find indices of boundary faces in each direction cellBoundaryInd Find indices of boundary faces in each direction Tree Mesh class SimPEG.Mesh.TreeMesh.TreeMesh(h, x0=None, levels=None) Bases: SimPEG.Mesh.TensorMesh.BaseTensorMesh, SimPEG.Mesh.InnerProducts.InnerProducts levels 12 Chapter 3. Discretization SimPEG Documentation, Release 0.1.9 fill How filled is the mesh compared to a TensorMesh? As a fraction: [0,1]. maxLevel The maximum level used, which may be less than levels. nC nN nF nFx nFy nFz nE nEx nEy nEz nhN nhF nhFx nhFy nhFz nhE nhEx nhEy nhEz ntN ntF vntF ntFx ntFy ntFz ntE vntE ntEx ntEy ntEz permuteCC permuteF permuteE 3.1. SimPEG Meshes 13 SimPEG Documentation, Release 0.1.9 refine(function=None, recursive=True, cells=None, balance=True, verbose=False, _inRecursion=False) corsen(function=None, recursive=True, cells=None, balance=True, verbose=False, _inRecursion=False) balance(recursive=True, cells=None, verbose=False, _inRecursion=False) gridCC gridN gridFx gridFy gridFz gridEx gridEy gridEz vol area edge number(balance=True, force=False) faceDiv edgeCurl Construct the 3D curl operator. nodalGrad aveEx2CC aveEy2CC Construct the averaging operator on cell edges to cell centers. aveEz2CC Construct the averaging operator on cell edges to cell centers. aveE2CC Construct the averaging operator on cell edges to cell centers. aveE2CCV Construct the averaging operator on cell edges to cell centers. aveFx2CC aveFy2CC aveFz2CC aveF2CC Construct the averaging operator on cell faces to cell centers. aveF2CCV Construct the averaging operator on cell faces to cell centers. aveN2CC point2index(locs) 14 Chapter 3. Discretization SimPEG Documentation, Release 0.1.9 getInterpolationMat(locs, locType, zerosOutside=False) Produces interpolation matrix Parameters • locs (numpy.ndarray) – Location of points to interpolate to • locType (str) – What to interpolate (see below) Return type scipy.sparse.csr.csr_matrix Returns M, the interpolation matrix locType can be: 'Ex' 'Ey' 'Ez' 'Fx' 'Fy' 'Fz' 'N' 'CC' -> -> -> -> -> -> -> -> x-component of field y-component of field z-component of field x-component of field y-component of field z-component of field scalar field defined scalar field defined defined on edges defined on edges defined on edges defined on faces defined on faces defined on faces on nodes on cell centers plotGrid(ax=None, showIt=False, grid=True, cells=False, cellLine=False, nodes=False, facesX=False, facesY=False, facesZ=False, edgesX=False, edgesY=False, edgesZ=False) plotImage(I, ax=None, showIt=False, grid=False, clim=None) plotSlice(v, vType=’CC’, normal=’Z’, ind=None, grid=True, view=’real’, ax=None, clim=None, showIt=False, pcolorOpts={}, streamOpts={‘color’: ‘k’}, gridOpts={‘color’: ‘k’, ‘alpha’: 0.5}) Curvilinear Mesh Cylindrical Mesh class SimPEG.Mesh.CylMesh.CylMesh(h, x0=None, cartesianOrigin=None) Bases: SimPEG.Mesh.TensorMesh.BaseTensorMesh, SimPEG.Mesh.BaseMesh.BaseRectangularMesh, SimPEG.Mesh.InnerProducts.InnerProducts, SimPEG.Mesh.View.CylView CylMesh is a mesh class for cylindrical problems Note: for a cylindrically symmetric mesh use [hx, 1, hz] cs, nc, npad = 20., 30, 8 hx = Utils.meshTensor([(cs,npad+10,-0.7), (cs,nc), (cs,npad,1.3)]) hz = Utils.meshTensor([(cs,npad ,-1.3), (cs,nc), (cs,npad,1.3)]) mesh = Mesh.CylMesh([hx,1,hz], [0.,0,-hz.sum()/2.]) isSymmetric nNx Number of nodes in the x-direction Return type int Returns nNx nNy Number of nodes in the y-direction 3.1. SimPEG Meshes 15 SimPEG Documentation, Release 0.1.9 Return type int Returns nNy vnFx Number of x-faces in each direction Return type numpy.array (dim, ) Returns vnFx vnEy Number of y-edges in each direction Return type numpy.array (dim, ) Returns vnEy or None if dim < 2 vnEz Number of z-edges in each direction Return type numpy.array (dim, ) Returns vnEz or None if nCy > 1 nEz Number of z-edges Return type int Returns nEz vectorCCx Cell-centered grid vector (1D) in the x direction. vectorCCy Cell-centered grid vector (1D) in the y direction. vectorNx Nodal grid vector (1D) in the x direction. vectorNy Nodal grid vector (1D) in the y direction. edge Edge lengths area Face areas vol Volume of each cell faceDiv Construct divergence operator (face-stg to cell-centres). faceDivx Construct divergence operator in the x component (face-stg to cell-centres). faceDivy Construct divergence operator in the y component (face-stg to cell-centres). faceDivz Construct divergence operator in the z component (face-stg to cell-centres). 16 Chapter 3. Discretization SimPEG Documentation, Release 0.1.9 cellGrad The cell centered Gradient, takes you to cell faces. nodalGrad Construct gradient operator (nodes to edges). nodalLaplacian Construct laplacian operator (nodes to edges). edgeCurl The edgeCurl property. aveE2CC Construct the averaging operator on cell edges to cell centers. aveE2CCV Construct the averaging operator on cell edges to cell centers. aveF2CC Construct the averaging operator on cell faces to cell centers. aveF2CCV Construct the averaging operator on cell faces to cell centers. getInterpolationMatCartMesh(Mrect, locType=’CC’) Takes a cartesian mesh and returns a projection to translate onto the cartesian grid. Each mesh code follows the guiding principles that are present in this tutorial, but the details, advantages and disadvantages differ between the implementations. 3.1.2 Variable Locations and Terminology We will go over the basics of using a TensorMesh, but these skills are transferable to the other meshes available in SimPEG. All of the mesh generation code is located in the Mesh package in SimPEG (i.e. SimPEG.Mesh). To create a TensorMesh we need to create mesh tensors, the widths of each cell of the mesh in each dimension. We will call these tensors h, and these will be define the constant widths of cells in each dimension of the TensorMesh. from SimPEG import Mesh, np import matplotlib.pyplot as plt hx = np.r_[3,2,1,1,1,1,2,3] hy = np.r_[3,1,1,3] M = Mesh.TensorMesh([hx, hy]) M.plotGrid(centers=True) plt.show() 3.1. SimPEG Meshes 17 SimPEG Documentation, Release 0.1.9 8 7 6 x2 5 4 3 2 1 0 0 2 4 6 x1 8 10 12 14 In this simple mesh, the hx vector defines the widths of the cell in the x dimension, and starts counting from the origin (0,0). The resulting mesh is divided into cells, and the cell-centers are plotted above as red circles. Other terminology for this mesh are: • cell-centers • nodes • faces • edges from SimPEG import Mesh, np import matplotlib.pyplot as plt hx = np.r_[3,2,1,1,1,1,2,3] hy = np.r_[3,1,1,3] M = Mesh.TensorMesh([hx, hy]) M.plotGrid(faces=True, nodes=True) plt.title('Cell faces in the x- and y-directions.') plt.legend(('Nodes', 'X-Faces', 'Y-Faces')) plt.show() 18 Chapter 3. Discretization SimPEG Documentation, Release 0.1.9 Cell faces in the x- and y-directions. 8 Nodes X-Faces Y-Faces 7 6 x2 5 4 3 2 1 0 0 2 4 6 x1 8 10 12 14 Generally, the faces are used to discretize fluxes, quantities that leave or enter the cells. As such, these fluxes have a direction to them, which is normal to the cell (i.e. directly out of the cell face). The plot above shows that x-faces point in the x-direction, and y-faces point in the y-direction. The nodes are shown in blue, and lie at the intersection of the grid lines. In a two-dimensional mesh, the edges actually live in the same location as the faces, however, they align (or are tangent to) the face. This is easier to see in 3D, when the edges do not live in the same location as the faces. In the 3D plot below, the edge variables are seen as black triangles, and live on the edges(!) of the cell. from SimPEG import Mesh Mesh.TensorMesh([1,1,1]).plotGrid(faces=True, edges=True, centers=True, showIt=True) 3.1. SimPEG Meshes 19 SimPEG Documentation, Release 0.1.9 1.0 0.8 0.6 x3 0.4 0.2 0.0 0.2 0.4 x1 0.6 0.8 1.0 0.0 0.2 0.6 0.4 x2 0.8 0.0 1.0 How many of each? When making variables that live in each of these locations, it is important to know how many of each variable type you are dealing with. SimPEG makes this pretty easy: In [1]: print M ---- 2-D TensorMesh ---x0: 0.00 y0: 0.00 nCx: 8 nCy: 4 hx: 3.00, 2.00, 4*1.00, 2.00, 3.00 hy: 3.00, 2*1.00, 3.00 In [2]: count = {'numCells': M.nC, ....: 'numCells_xDir': M.nCx, ....: 'numCells_yDir': M.nCy, ....: 'numCells_vector': M.vnC} In [3]: print 'This mesh has %(numCells)d cells, which is %(numCells_xDir)d*%(numCells_yDir)d!!' % co This mesh has 32 cells, which is 8*4!! In [4]: print count 20 Chapter 3. Discretization SimPEG Documentation, Release 0.1.9 { 'numCells_vector': array([8, 4]), 'numCells_yDir': 4, 'numCells_xDir': 8, 'numCells': 32 } SimPEG also counts the nodes, faces, and edges. Nodes: M.nN, M.nNx, M.nNy, M.nNz, M.vnN Faces: M.nF, M.nFx, M.nFy, M.nFz, M.vnF, M.vnFx, M.vnFy, M.vnFz Edges: M.nE, M.nEx, M.nEy, M.nEz, M.vnE, M.vnEx, M.vnEy, M.vnEz Face and edge variables have different counts depending on the dimension of the direction that you are interested in. In a 4x5 mesh, for example, there is a 5x5 grid of x-faces, and a 4x6 grid of y-faces. You can count them below! As such, the vnF(x,y,z) and vnE(x,y,z) properties give the vector grid size. from SimPEG import Mesh Mesh.TensorMesh([4,5]).plotGrid(faces=True, showIt=True) 1.0 0.8 x2 0.6 0.4 0.2 0.0 0.0 0.2 0.4 x1 0.6 0.8 1.0 Making Tensors For tensor meshes, there are some additional functions that can come in handy. For example, creating mesh tensors can be a bit time consuming, these can be created speedily by just giving numbers and sizes of padding. See the example below, that follows this notation: 3.1. SimPEG Meshes 21 SimPEG Documentation, Release 0.1.9 h1 = ( (cellSize, numPad, [, increaseFactor]), (cellSize, numCore), (cellSize, numPad, [, increaseFactor]) ) from SimPEG import Mesh, Utils h1 = [(10, 5, -1.3), (5, 20), (10, 3, 1.3)] M = Mesh.TensorMesh([h1, h1], x0='CN') M.plotGrid(showIt=True) 0 50 x2 100 150 200 250 300 150 100 50 0 x1 50 100 150 Note: You can center your mesh by passing a ‘C’ for the x0[i] position. A ‘N’ will make the entire mesh negative, and a ‘0’ (or a 0) will make the mesh start at zero. Hopefully, you now know how to create TensorMesh objects in SimPEG, and by extension you are also familiar with how to create and use other types of meshes in this SimPEG framework. 3.1.3 The API class SimPEG.Mesh.BaseMesh.BaseMesh(n, x0=None) BaseMesh does all the counting you don’t want to do. BaseMesh should be inherited by meshes with a regular structure. Parameters 22 Chapter 3. Discretization SimPEG Documentation, Release 0.1.9 • n (numpy.array,list) – number of cells in each direction (dim, ) • x0 (numpy.array,list) – Origin of the mesh (dim, ) x0 Origin of the mesh Return type numpy.array (dim, ) Returns x0 dim The dimension of the mesh (1, 2, or 3). Return type int Returns dim nC Total number of cells in the mesh. Return type int Returns nC from SimPEG import Mesh, np Mesh.TensorMesh([np.ones(n) for n in [2,3]]).plotGrid(centers=True,showIt=True) 3.0 2.5 x2 2.0 1.5 1.0 0.5 0.0 0.0 0.5 1.0 x1 1.5 2.0 nN Total number of nodes Return type int Returns nN 3.1. SimPEG Meshes 23 SimPEG Documentation, Release 0.1.9 from SimPEG import Mesh, np Mesh.TensorMesh([np.ones(n) for n in [2,3]]).plotGrid(nodes=True,showIt=True) 3.0 2.5 x2 2.0 1.5 1.0 0.5 0.0 0.0 0.5 1.0 x1 1.5 2.0 nEx Number of x-edges Return type int Returns nEx nEy Number of y-edges Return type int Returns nEy nEz Number of z-edges Return type int Returns nEz vnE Total number of edges in each direction Return type numpy.array (dim, ) Returns [nEx, nEy, nEz] from SimPEG import Mesh, np Mesh.TensorMesh([np.ones(n) for n in [2,3]]).plotGrid(edges=True,showIt=True) 24 Chapter 3. Discretization SimPEG Documentation, Release 0.1.9 3.0 2.5 x2 2.0 1.5 1.0 0.5 0.0 0.0 0.5 1.0 x1 1.5 2.0 nE Total number of edges. Return type int Returns sum([nEx, nEy, nEz]) nFx Number of x-faces Return type int Returns nFx nFy Number of y-faces Return type int Returns nFy nFz Number of z-faces Return type int Returns nFz vnF Total number of faces in each direction Return type numpy.array (dim, ) Returns [nFx, nFy, nFz] 3.1. SimPEG Meshes 25 SimPEG Documentation, Release 0.1.9 from SimPEG import Mesh, np Mesh.TensorMesh([np.ones(n) for n in [2,3]]).plotGrid(faces=True,showIt=True) 3.0 2.5 x2 2.0 1.5 1.0 0.5 0.0 0.0 0.5 1.0 x1 1.5 2.0 nF Total number of faces. Return type int Returns sum([nFx, nFy, nFz]) normals Face Normals Return type numpy.array (sum(nF), dim) Returns normals tangents Edge Tangents Return type numpy.array (sum(nE), dim) Returns normals projectFaceVector(fV) Given a vector, fV, in cartesian coordinates, this will project it onto the mesh using the normals Parameters fV (numpy.array) – face vector with shape (nF, dim) Return type numpy.array with shape (nF, ) Returns projected face vector 26 Chapter 3. Discretization SimPEG Documentation, Release 0.1.9 projectEdgeVector(eV) Given a vector, eV, in cartesian coordinates, this will project it onto the mesh using the tangents Parameters eV (numpy.array) – edge vector with shape (nE, dim) Return type numpy.array with shape (nE, ) Returns projected edge vector class SimPEG.Mesh.BaseMesh.BaseRectangularMesh(n, x0=None) nCx Number of cells in the x direction Return type int Returns nCx nCy Number of cells in the y direction Return type int Returns nCy or None if dim < 2 nCz Number of cells in the z direction Return type int Returns nCz or None if dim < 3 vnC Total number of cells in each direction Return type numpy.array (dim, ) Returns [nCx, nCy, nCz] nNx Number of nodes in the x-direction Return type int Returns nNx nNy Number of nodes in the y-direction Return type int Returns nNy or None if dim < 2 nNz Number of nodes in the z-direction Return type int Returns nNz or None if dim < 3 vnN Total number of nodes in each direction Return type numpy.array (dim, ) Returns [nNx, nNy, nNz] 3.1. SimPEG Meshes 27 SimPEG Documentation, Release 0.1.9 vnEx Number of x-edges in each direction Return type numpy.array (dim, ) Returns vnEx vnEy Number of y-edges in each direction Return type numpy.array (dim, ) Returns vnEy or None if dim < 2 vnEz Number of z-edges in each direction Return type numpy.array (dim, ) Returns vnEz or None if dim < 3 vnFx Number of x-faces in each direction Return type numpy.array (dim, ) Returns vnFx vnFy Number of y-faces in each direction Return type numpy.array (dim, ) Returns vnFy or None if dim < 2 vnFz Number of z-faces in each direction Return type numpy.array (dim, ) Returns vnFz or None if dim < 3 nC Total number of cells Return type int Returns nC nN Total number of nodes Return type int Returns nN nEx Number of x-edges Return type int Returns nEx nEy Number of y-edges Return type int 28 Chapter 3. Discretization SimPEG Documentation, Release 0.1.9 Returns nEy nEz Number of z-edges Return type int Returns nEz nFx Number of x-faces Return type int Returns nFx nFy Number of y-faces Return type int Returns nFy nFz Number of z-faces Return type int Returns nFz r(x, xType=’CC’, outType=’CC’, format=’V’) Mesh.r is a quick reshape command that will do the best it can at giving you what you want. For example, you have a face variable, and you want the x component of it reshaped to a 3D matrix. Mesh.r can fulfil your dreams: mesh.r(V, 'F', 'Fx', 'M') | | | { How: 'M' or ['V'] for a matrix (ndgrid style) or a vector (n x dim) | | { What you want: ['CC'], 'N', 'F', 'Fx', 'Fy', 'Fz', 'E', 'Ex', 'Ey', or 'E | { What is it: ['CC'], 'N', 'F', 'Fx', 'Fy', 'Fz', 'E', 'Ex', 'Ey', or 'Ez' } { The input: as a list or ndarray } For example: Xex, Yex, Zex = r(mesh.gridEx, 'Ex', 'Ex', 'M') XedgeVector = r(edgeVector, 'E', 'Ex', 'V') eX, eY, eZ = r(edgeVector, 'E', 'E', 'V') # Separates each component of the Ex grid i # Given an edge vector, this will return just t # Separates each component of the edgeVector into 3.2 Differential Operators SimPEG.Mesh.DiffOperators.checkBC(bc) Checks if boundary condition ‘bc’ is valid. Each bc must be either ‘dirichlet’ or ‘neumann’ SimPEG.Mesh.DiffOperators.ddxCellGrad(n, bc) Create 1D derivative operator from cell-centers to nodes this means we go from n to n+1 For Cell-Centered Dirichlet, use a ghost point: 3.2. Differential Operators 29 SimPEG Documentation, Release 0.1.9 (u_1 - u_g)/hf = grad u_g * u_1 * | ^ 0 u_2 * | ... u_g = - u_1 grad = 2*u1/dx negitive on the other side. For Cell-Centered Neumann, use a ghost point: (u_1 - u_g)/hf = 0 u_g * u_g = u_1 grad = 0; u_1 * | u_2 * | ... put a zero in. SimPEG.Mesh.DiffOperators.ddxCellGradBC(n, bc) Create 1D derivative operator from cell-centers to nodes this means we go from n to n+1 For Cell-Centered Dirichlet, use a ghost point: (u_1 - u_g)/hf = grad u_g * | ^ u_b u_1 * | u_2 * ... We know the value at the boundary (u_b): (u_g+u_1)/2 = u_b u_g = 2*u_b - u_1 (the average) So plug in to gradient: (u_1 - (2*u_b - u_1))/hf = grad 2*(u_1-u_b)/hf = grad Separate, because BC are known (and can move to RHS later): ( 2/hf )*u_1 + ( -2/hf )*u_b = grad ( ^ ) JUST RETURN THIS class SimPEG.Mesh.DiffOperators.DiffOperators Class creates the differential operators that you need! faceDiv Construct divergence operator (face-stg to cell-centres). faceDivx Construct divergence operator in the x component (face-stg to cell-centres). faceDivy Construct divergence operator in the y component (face-stg to cell-centres). 30 Chapter 3. Discretization SimPEG Documentation, Release 0.1.9 faceDivz Construct divergence operator in the z component (face-stg to cell-centres). nodalGrad Construct gradient operator (nodes to edges). nodalLaplacian Construct laplacian operator (nodes to edges). setCellGradBC(BC) Function that sets the boundary conditions for cell-centred derivative operators. Examples: BC = 'neumann' # Neumann in all directions BC = ['neumann', 'dirichlet', 'neumann'] # 3D, Dirichlet in y Neumann else BC = [['neumann', 'dirichlet'], 'dirichlet', 'dirichlet'] # 3D, Neumann in x on bottom of do # Dirichlet else cellGrad The cell centered Gradient, takes you to cell faces. cellGradBC The cell centered Gradient boundary condition matrix cellGradx Cell centered Gradient in the x dimension. Has neumann boundary conditions. cellGrady Cell centered Gradient in the x dimension. Has neumann boundary conditions. cellGradz Cell centered Gradient in the x dimension. Has neumann boundary conditions. edgeCurl Construct the 3D curl operator. getBCProjWF(BC, discretization=’CC’) The weak form boundary condition projection matrices. Examples: BC = 'neumann' # Neumann in all directions BC = ['neumann', 'dirichlet', 'neumann'] # 3D, Dirichlet in y Neumann else BC = [['neumann', 'dirichlet'], 'dirichlet', 'dirichlet'] # 3D, Neumann in x on bottom of do # Dirichlet else aveF2CC Construct the averaging operator on cell faces to cell centers. aveF2CCV Construct the averaging operator on cell faces to cell centers. aveFx2CC Construct the averaging operator on cell faces in the x direction to cell centers. aveFy2CC Construct the averaging operator on cell faces in the y direction to cell centers. aveFz2CC Construct the averaging operator on cell faces in the z direction to cell centers. aveCC2F Construct the averaging operator on cell cell centers to faces. 3.2. Differential Operators 31 SimPEG Documentation, Release 0.1.9 aveE2CC Construct the averaging operator on cell edges to cell centers. aveE2CCV Construct the averaging operator on cell edges to cell centers. aveEx2CC Construct the averaging operator on cell edges in the x direction to cell centers. aveEy2CC Construct the averaging operator on cell edges in the y direction to cell centers. aveEz2CC Construct the averaging operator on cell edges in the z direction to cell centers. aveN2CC Construct the averaging operator on cell nodes to cell centers. aveN2E Construct the averaging operator on cell nodes to cell edges, keeping each dimension separate. aveN2F Construct the averaging operator on cell nodes to cell faces, keeping each dimension separate. 3.3 Inner Products By using the weak formulation of many of the PDEs in geophysical applications, we can rapidly develop discretizations. Much of this work, however, needs a good understanding of how to approximate inner products on our discretized meshes. We will define the inner product as: ∫︁ (𝑎, 𝑏) = 𝑎 · 𝑏𝜕𝑣 Ω where a and b are either scalars or vectors. Note: The InnerProducts class is a base class providing inner product matrices for meshes and cannot run on its own. 3.3.1 Example problem for DC resistivity We will start with the formulation of the Direct Current (DC) resistivity problem in geophysics. 1⃗ 𝑗 = ∇𝜑 𝜎 ∇ · ⃗𝑗 = 𝑞 In the following discretization, \( \sigma \) and \( \phi \) will be discretized on the cell-centers and the flux, \(\vec{j}\), will be on the faces. We will use the weak formulation to discretize the DC resistivity equation. We can define in weak form by integrating with a general face function \(\vec{f}\): ∫︁ ∫︁ 𝜎 −1⃗𝑗 · 𝑓⃗ = ∇𝜑 · 𝑓⃗ Ω Ω Here we can integrate the right side by parts, ∇ · (𝜑𝑓⃗) = ∇𝜑 · 𝑓⃗ + 𝜑∇ · 𝑓⃗ 32 Chapter 3. Discretization SimPEG Documentation, Release 0.1.9 and rearrange it, and apply the Divergence theorem. ∫︁ ∫︁ ∫︁ 𝜎 −1⃗𝑗 · 𝑓⃗ = − (𝜑∇ · 𝑓⃗) + Ω Ω 𝜑𝑓⃗ · n 𝜕Ω We can then discretize for every cell: 𝑣cell 𝜎 −1 (J𝑥 F𝑥 + J𝑦 F𝑦 + J𝑧 F𝑧 ) = −𝜑⊤ 𝑣cell Dcell F + BC Note: We have discretized the dot product above, but remember that we do not really have a single vector \(\mathbf{J}\), but approximations of \(\vec{j}\) on each face of our cell. In 2D that means 2 approximations of \(\mathbf{J}_x\) and 2 approximations of \(\mathbf{J}_y\). In 3D we also have 2 approximations of \(\mathbf{J}_z\). Regardless of how we choose to approximate this dot product, we can represent this in vector form (again this is for every cell), and will generalize for the case of anisotropic (tensor) sigma. √ −1 √ 𝑣cell )J𝑐 = −𝜑⊤ 𝑣cell Dcell F) + BC F⊤ 𝑐 ( 𝑣cell Σ We multiply by square-root of volume on each side of the tensor conductivity to keep symmetry in the system. Here \(\mathbf{J}_c\) is the Cartesian \(\mathbf{J}\) (on the faces that we choose to use in our approximation) and must be calculated differently depending on the mesh: J𝑐 = Q(𝑖) JTENSOR J𝑐 = N−1 (𝑖) Q(𝑖) JCurv Here the \(i\) index refers to where we choose to approximate this integral, as discussed in the note above. We will approximate this integral by taking the fluxes clustered around every node of the cell, there are 8 combinations in 3D, and 4 in 2D. We will use a projection matrix \( \mathbf{Q}_{(i)} \) to pick the appropriate fluxes. So, now that we have 8 approximations of this integral, we will just take the average. For the TensorMesh, this looks like: (︃ 8 )︃ ∑︁ ⊤1 ⊤ √ −1 √ F Q 𝑣cell Σ 𝑣cell Q(𝑖) J = −F⊤ D⊤ cell 𝑣cell 𝜑 + BC 8 𝑖=1 (𝑖) Or, when generalizing to the entire mesh and dropping our general face function: M𝑓Σ−1 J = −D⊤ diag(v)𝜑 + BC By defining the faceInnerProduct (8 combinations of fluxes in 3D, 4 in 2D, 2 in 1D) to be: 𝑑 M𝑓Σ−1 = 2 ∑︁ −1 P⊤ P(𝑖) (𝑖) Σ 𝑖=1 Where \(d\) is the dimension of the mesh. The \( \mathbf{M}^f \) is returned when given the input of \( \Sigma^{-1} \). Here each \( \mathbf{P} \in \mathbb{R}^{(d*nC, nF)} \) is a combination of the projection, volume, and any normalization to Cartesian coordinates (where the dot product is well defined): Curv only √︂ P(𝑖) = ⏞ ⏟ 1 𝑑 −1 I ⊗ diag(v) N (𝑖) Q(𝑖) 2𝑑 Note: This is actually completed for each cell in the mesh at the same time, and the full matrices are returned. If returnP=True is requested in any of these methods the projection matrices are returned as a list ordered by nodes around which the fluxes were approximated: 3.3. Inner Products 33 SimPEG Documentation, Release 0.1.9 # P # P # P In 3D = [P000, P100, P010, P110, P001, P101, P011, P111] In 2D = [P00, P10, P01, P11] In 1D = [P0, P1] The derivation for edgeInnerProducts is exactly the same, however, when we approximate the integral using the fields around each node, the projection matrices look a bit different because we have 12 edges in 3D instead of just 6 faces. The interface to the code is exactly the same. 3.3.2 Defining Tensor Properties For 3D: Depending on the number of columns (either 1, 3, or 6) of mu, the material property is interpreted as follows: ⎡ ⎤ 𝜇1 0 0 𝜇 ⃗ = ⎣ 0 𝜇1 0 ⎦ 0 0 𝜇1 ⎡ ⎤ 𝜇1 0 0 𝜇 ⃗ = ⎣ 0 𝜇2 0 ⎦ 0 0 𝜇3 ⎡ ⎤ 𝜇1 𝜇4 𝜇5 𝜇 ⃗ = ⎣𝜇4 𝜇2 𝜇6 ⎦ 𝜇5 𝜇6 𝜇3 For 2D: Depending on the number of columns (either 1, 2, or 3) of mu, the material property is interpreted as follows: [︂ 𝜇1 0 0 𝜇1 ]︂ [︂ 𝜇1 0 [︂ 𝜇 𝜇 ⃗= 1 𝜇3 0 𝜇2 ]︂ 𝜇3 𝜇2 ]︂ 𝜇 ⃗= 𝜇 ⃗= 3.3.3 Structure of Matrices Both the isotropic, and anisotropic material properties result in a diagonal mass matrix. Which is nice and easy to invert if necessary, however, in the fully anisotropic case which is not aligned with the grid, the matrix is not diagonal. This can be seen for a 3D mesh in the figure below. 34 Chapter 3. Discretization SimPEG Documentation, Release 0.1.9 Isotropic Material Property Anisotropic Material Property Tensor Material Property 3.3.4 Taking Derivatives We will take the derivative of the fully anisotropic tensor for a 3D mesh, the other cases are easier and will not be discussed here. Let us start with one part of the sum which makes up \(\mathbf{M}^f_\Sigma\) and take the derivative when this is multiplied by some vector \(\mathbf{v}\): P⊤ ΣPv Here we will let \( \mathbf{Pv} = \mathbf{y} \) and \(\mathbf{y}\) will have the form: ⎡ ⎤ y1 y = Pv = ⎣y2 ⎦ y3 ⎡ 𝜎1 P⊤ Σy = P⊤ ⎣𝜎 4 𝜎5 𝜎4 𝜎2 𝜎6 ⎤⎡ ⎤ ⎡ ⎤ 𝜎5 y1 𝜎 1 ∘ y1 + 𝜎 4 ∘ y2 + 𝜎 5 ∘ y3 𝜎 6 ⎦ ⎣y2 ⎦ = P⊤ ⎣𝜎 4 ∘ y1 + 𝜎 2 ∘ y2 + 𝜎 6 ∘ y3 ⎦ 𝜎3 y3 𝜎 5 ∘ y1 + 𝜎 6 ∘ y2 + 𝜎 3 ∘ y3 Now it is easy to take the derivative with respect to any one of the parameters, \(\frac{\partial}{\partial\boldsymbol{\sigma}_1}\) ⎤ ⎡ diag(y1 ) 𝜕 (︀ ⊤ )︀ ⎦ 0 P Σy = P⊤ ⎣ 𝜕𝜎 1 0 for example, Whereas \(\frac{\partial}{\partial\boldsymbol{\sigma}_4}\), for example, is: ⎡ ⎤ diag(y2 ) 𝜕 (︀ ⊤ )︀ P Σy = P⊤ ⎣diag(y1 )⎦ 𝜕𝜎 4 0 These are computed for each of the 8 projections, horizontally concatenated, and returned. 3.3.5 The API class SimPEG.Mesh.InnerProducts.InnerProducts This is a base for the SimPEG.Mesh classes. This mixIn creates the all the inner product matrices that you need! 3.3. Inner Products 35 SimPEG Documentation, Release 0.1.9 getFaceInnerProduct(prop=None, invProp=False, invMat=False, doFast=True) Parameters • prop (numpy.array) – material property (tensor properties are possible) at each cell center (nC, (1, 3, or 6)) • invProp (bool) – inverts the material property • invMat (bool) – inverts the matrix • doFast (bool) – do a faster implementation if available. Return type scipy.csr_matrix Returns M, the inner product matrix (nF, nF) getEdgeInnerProduct(prop=None, invProp=False, invMat=False, doFast=True) Parameters • prop (numpy.array) – material property (tensor properties are possible) at each cell center (nC, (1, 3, or 6)) • invProp (bool) – inverts the material property • invMat (bool) – inverts the matrix • doFast (bool) – do a faster implementation if available. Return type scipy.csr_matrix Returns M, the inner product matrix (nE, nE) getFaceInnerProductDeriv(prop, doFast=True, invProp=False, invMat=False) Parameters • prop (numpy.array) – material property (tensor properties are possible) at each cell center (nC, (1, 3, or 6)) • doFast (bool) – do a faster implementation if available. • invProp (bool) – inverts the material property • invMat (bool) – inverts the matrix Return type function Returns dMdmu(u), the derivative of the inner product matrix (u) Given u, dMdmu returns (nF, nC*nA) Parameters u (np.ndarray) – vector that multiplies dMdmu Return type scipy.csr_matrix Returns dMdmu, the derivative of the inner product matrix for a certain u getEdgeInnerProductDeriv(prop, doFast=True, invProp=False, invMat=False) Parameters • prop (numpy.array) – material property (tensor properties are possible) at each cell center (nC, (1, 3, or 6)) • doFast (bool) – do a faster implementation if available. • invProp (bool) – inverts the material property 36 Chapter 3. Discretization SimPEG Documentation, Release 0.1.9 • invMat (bool) – inverts the matrix Return type scipy.csr_matrix Returns dMdm, the derivative of the inner product matrix (nE, nC*nA) 3.3. Inner Products 37 SimPEG Documentation, Release 0.1.9 38 Chapter 3. Discretization CHAPTER 4 Forward Problems 4.1 Forward Problem 4.1.1 Problem Class The problem is a partial differential equation of the form: 𝑐(𝑚, 𝑢) = 0 Here, \(m\) is the model and u is the field (or fields). Given the model, \(m\), we can calculate the fields \(u(m)\), however, the data we collect is a subset of the fields, and can be defined by a linear projection, \(P\). 𝑑pred = 𝑃 𝑢(𝑚) For the inverse problem, we are interested in how changing the model transforms the data, as such we can take write the Taylor expansion: 𝑃 𝑢(𝑚 + ℎ𝑣) = 𝑃 𝑢(𝑚) + ℎ𝑃 𝜕𝑢(𝑚) 𝑣 + 𝒪(ℎ2 ‖𝑣‖) 𝜕𝑚 We can linearize and define the sensitivity matrix as: 𝐽 =𝑃 𝜕𝑢 𝜕𝑚 The sensitivity matrix, and it’s transpose will be used in the inverse problem to (locally) find how model parameters change the data, and optimize! Working with the general PDE, \(c(m, u) = 0\), where m is the model and u is the field, the sensitivity is defined as: 𝐽 =𝑃 𝜕𝑢 𝜕𝑚 We can take the derivative of the PDE: ∇𝑚 𝑐(𝑚, 𝑢)𝜕𝑚 + ∇𝑢 𝑐(𝑚, 𝑢)𝜕𝑢 = 0 If the forward problem is invertible, then we can rearrange for \(\frac{\partial u}{\partial m}\): 𝐽 = −𝑃 (∇𝑢 𝑐(𝑚, 𝑢)) −1 ∇𝑚 𝑐(𝑚, 𝑢) This can often be computed given a vector (i.e. \(J(v)\)) rather than stored, as \(J\) is a large dense matrix. 𝑢(𝑚) 39 SimPEG Documentation, Release 0.1.9 4.1.2 The API Problem class SimPEG.Problem.BaseProblem(mesh, mapping=None, **kwargs) Problem is the base class for all geophysical forward problems in SimPEG. counter = None A SimPEG.Utils.Counter object surveyPair A SimPEG.Survey Class alias of BaseSurvey mapPair A SimPEG.Map Class alias of IdentityMap Solver A SimPEG Solver class. alias of spsolve_Wrapped solverOpts = {} Sovler options as a kwarg dict PropMap = None A SimPEG PropertyMap class. mesh = None A SimPEG.Mesh instance. mapping A SimPEG.Map instance or a property map is PropMap is not None survey The survey object for this problem. pair(d) Bind a survey to this problem instance using pointers. unpair() Unbind a survey from this problem instance. deleteTheseOnModelUpdate = [] curModel Sets the current model, and removes dependent mass matrices. ispaired True if the problem is paired to a survey. Jvec(m, v, u=None) Effect of J(m) on a vector v. Parameters • m (numpy.array) – model • v (numpy.array) – vector to multiply • u (numpy.array) – fields 40 Chapter 4. Forward Problems SimPEG Documentation, Release 0.1.9 Return type numpy.array Returns Jv Jtvec(m, v, u=None) Effect of transpose of J(m) on a vector v. Parameters • m (numpy.array) – model • v (numpy.array) – vector to multiply • u (numpy.array) – fields Return type numpy.array Returns JTv Jvec_approx(m, v, u=None) Approximate effect of J(m) on a vector v Parameters • m (numpy.array) – model • v (numpy.array) – vector to multiply • u (numpy.array) – fields Return type numpy.array Returns approxJv Jtvec_approx(m, v, u=None) Approximate effect of transpose of J(m) on a vector v. Parameters • m (numpy.array) – model • v (numpy.array) – vector to multiply • u (numpy.array) – fields Return type numpy.array Returns JTv fields(m) The field given the model. Parameters m (numpy.array) – model Return type numpy.array Returns u, the fields class SimPEG.Problem.BaseTimeProblem(mesh, mapping=None, **kwargs) Sets up that basic needs of a time domain problem. timeSteps Sets/gets the timeSteps for the time domain problem. You can set as an array of dt’s or as a list of tuples/floats. Tuples must be length two with [..., (dt, repeat), ...] For example, the following setters are the same: 4.1. Forward Problem 41 SimPEG Documentation, Release 0.1.9 prob.timeSteps = [(1e-6, 3), 1e-5, (1e-4, 2)] prob.timeSteps = np.r_[1e-6,1e-6,1e-6,1e-5,1e-4,1e-4] nT Number of time steps. t0 times Modeling times timeMesh Survey class SimPEG.Survey.BaseRx(locs, rxType, **kwargs) SimPEG Receiver Object knownRxTypes = None Set this to a list of strings to ensure that srcType is known projGLoc = ‘CC’ Projection grid location, default is CC storeProjections = True Store calls to getP (organized by mesh) locs = None Locations (nRx x nDim) rxType Receiver Type nD Number of data in the receiver. getP(mesh) Returns the projection matrices as a list for all components collected by the receivers. Note: Projection matrices are stored as a dictionary listed by meshes. class SimPEG.Survey.BaseTimeRx(locs, times, rxType, **kwargs) SimPEG Receiver Object times = None Times when the receivers were active. nD Number of data in the receiver. getSpatialP(mesh) Returns the spatial projection matrix. Note: This is not stored in memory, but is created on demand. getTimeP(timeMesh) Returns the time projection matrix. Note: This is not stored in memory, but is created on demand. 42 Chapter 4. Forward Problems SimPEG Documentation, Release 0.1.9 getP(mesh, timeMesh) Returns the projection matrices as a list for all components collected by the receivers. Note: Projection matrices are stored as a dictionary (mesh, timeMesh) if storeProjections is True class SimPEG.Survey.BaseSrc(rxList, **kwargs) SimPEG Source Object loc = None Location [x,y,z] rxPair alias of BaseRx rxList = None SimPEG Receiver List nD Number of data vnD Vector number of data class SimPEG.Survey.Data(survey, v=None) Fancy data storage by Src and Rx class SimPEG.Survey.BaseSurvey(**kwargs) Survey holds the observed data, and the standard deviations. std = None Estimated Standard Deviations dobs = None Observed data dtrue = None True data, if data is synthetic mtrue = None True model, if data is synthetic counter = None A SimPEG.Utils.Counter object srcPair Source Pair alias of BaseSrc srcList Source List prob The geophysical problem that explains this survey, use: survey.pair(prob) mesh Mesh of the paired problem. pair(p) Bind a problem to this survey instance using pointers 4.1. Forward Problem 43 SimPEG Documentation, Release 0.1.9 unpair() Unbind a problem from this survey instance nD Number of data vnD Vector number of data nSrc Number of Sources dpred(m, u=None) Create the projected data from a model. The field, u, (if provided) will be used for the predicted data instead of recalculating the fields (which may be expensive!). 𝑑pred = 𝑃 (𝑢(𝑚)) Where P is a projection of the fields onto the data space. Note: To use survey.dpred(), SimPEG requires that a problem be bound to the survey. If a problem has not been bound, an Exception will be raised. To bind a problem to the Data object: survey.pair(myProblem) projectFields(u) This function projects the fields onto the data space. 𝑑pred = P𝑢(𝑚) projectFieldsDeriv(u) This function s the derivative of projects the fields onto the data space. 𝜕𝑑pred =P 𝜕𝑢 residual(m, u=None) Parameters • m (numpy.array) – geophysical model • u (numpy.array) – fields Return type numpy.array Returns data residual The data residual: 𝜇data = dpred − dobs isSynthetic Check if the data is synthetic. makeSyntheticData(m, std=0.05, u=None, force=False) Make synthetic data given a model, and a standard deviation. Parameters • m (numpy.array) – geophysical model 44 Chapter 4. Forward Problems SimPEG Documentation, Release 0.1.9 • std (numpy.array) – standard deviation • u (numpy.array) – fields for the given model (if pre-calculated) • force (bool) – force overwriting of dobs 4.1. Forward Problem 45 SimPEG Documentation, Release 0.1.9 46 Chapter 4. Forward Problems CHAPTER 5 Inversion 5.1 Data Misfit The data misfit using an l_2 norm is: 1 2 |W𝑑 (dpred − dobs )|2 2 𝜇data = If the field, u, is provided, the calculation of the data is fast: dpred = Pu(m) R = W𝑑 (dpred − dobs ) Where P is a projection matrix that brings the field on the full domain to the data measurement locations; u is the field of interest; d_obs is the observed data; and \(\mathbf{W}_d\) is the weighting matrix. The derivative of this, with respect to the model, is: 𝜕𝜇data = J ⊤ W𝑑 R 𝜕m The second derivative is: 𝜕 2 𝜇data = J ⊤ W𝑑 W𝑑 J 𝜕2m 5.1.1 The API class SimPEG.DataMisfit.BaseDataMisfit(survey, **kwargs) Note: You should inherit from this class to create your own data misfit term. debug = False Print debugging information counter = None Set this to a SimPEG.Utils.Counter() if you want to count things eval(m, u=None) Parameters • m (numpy.array) – geophysical model 47 SimPEG Documentation, Release 0.1.9 • u (numpy.array) – fields Return type float Returns data misfit evalDeriv(m, u=None) Parameters • m (numpy.array) – geophysical model • u (numpy.array) – fields Return type numpy.array Returns data misfit derivative eval2Deriv(m, v, u=None) Parameters • m (numpy.array) – geophysical model • v (numpy.array) – vector to multiply • u (numpy.array) – fields Return type numpy.array Returns data misfit derivative 5.1.2 Common Data Misfits l2 norm class SimPEG.DataMisfit.l2_DataMisfit(survey, **kwargs) The data misfit with an l_2 norm: 𝜇data = 1 2 |W𝑑 (dpred − dobs )|2 2 Wd getWd(survey) The data weighting matrix. The default is based on the norm of the data plus a noise floor. Return type scipy.sparse.csr_matrix Returns Wd eval(m, u=None) evalDeriv(m, u=None) eval2Deriv(m, v, u=None) 48 Chapter 5. Inversion SimPEG Documentation, Release 0.1.9 5.2 Regularization class SimPEG.Regularization.BaseRegularization(mesh, mapping=None, **kwargs) Bases: object Base Regularization Class This is used to regularize the model space: reg = Regularization(mesh) counter = None mapPair A SimPEG.Map Class alias of IdentityMap mref = None Reference model. mesh = None A SimPEG.Mesh instance. mapping = None A SimPEG.Map instance. parent This is the parent of the regularization. inv invProb reg opt prob survey W Full regularization weighting matrix W. eval(*args, **kwargs) evalDeriv(*args, **kwargs) The regularization is: 𝑅(𝑚) = 1 (m − mref )⊤ W⊤ W(m − mref ) 2 So the derivative is straight forward: 𝑅(𝑚) = W⊤ W(m − mref ) eval2Deriv(*args, **kwargs) param numpy.array m geophysical model param numpy.array v vector to multiply rtype scipy.sparse.csr_matrix or numpy.ndarray 5.2. Regularization 49 SimPEG Documentation, Release 0.1.9 return WtW or WtW*v The regularization is: 𝑅(𝑚) = 1 (m − mref )⊤ W⊤ W(m − mref ) 2 So the second derivative is straight forward: 𝑅(𝑚) = W⊤ W class SimPEG.Regularization.Tikhonov(mesh, mapping=None, **kwargs) Bases: SimPEG.Regularization.BaseRegularization Tikhonov Regularization Here we will define regularization of a model, m, in general however, this should be thought of as (m-m_ref) but otherwise it is exactly the same: ∫︁ 𝑅(𝑚) = Ω 𝛼𝑥 2 (︂ 𝜕𝑚 𝜕𝑥 )︂2 𝛼𝑦 + 2 (︂ 𝜕𝑚 𝜕𝑦 )︂2 𝜕𝑣 Our discrete gradient operator works on cell centers and gives the derivative on the cell faces, which is not where we want to be evaluating this integral. We need to average the values back to the cell-centers before we integrate. To avoid null spaces, we square first and then average. In 2D with ij notation it looks like this: [︃ [︃(︂ ]︃ [︃ )︂2 (︂ )︂2 ]︃]︃ ∑︁ 𝛼𝑥 (︂ 𝑚𝑖+1,𝑗 − 𝑚𝑖,𝑗 )︂2 (︂ 𝑚𝑖,𝑗 − 𝑚𝑖−1,𝑗 )︂2 𝑚𝑖,𝑗+1 − 𝑚𝑖,𝑗 𝑚𝑖,𝑗 − 𝑚𝑖,𝑗−1 𝛼𝑦 + + + ℎ2 𝑅(𝑚) ≈ 2 ℎ ℎ 2 ℎ ℎ 𝑖𝑗 If we let D_1 be the derivative matrix in the x direction D1 = I2 ⊗ d1 D2 = d2 ⊗ I1 Where d_1 is the one dimensional derivative: ⎡ d1 = 𝑅(𝑚) ≈ v⊤ [︁ 𝛼 𝑥 1⎢ ⎣ ℎ −1 1 .. . ⎤ .. . −1 A1 (D1 𝑚) ⊙ (D1 𝑚) + 2 ⎥ ⎦ 1 ]︁ 𝛼𝑦 A2 (D2 𝑚) ⊙ (D2 𝑚) 2 Recall that this is really a just point wise multiplication, or a diagonal matrix times a vector. When we multiply by something in a diagonal we can interchange and it gives the same results (i.e. it is point wise) a ⊙ b = diag(a)b = diag(b)a = b ⊙ a and the transpose also is true (but the sizes have to make sense...): a⊤ diag(b) = b⊤ diag(a) So R(m) can simplify to: 𝑅(𝑚) ≈ m⊤ 50 [︁ 𝛼 𝑥 2 ⊤ D⊤ 1 diag(A1 v)D1 + ]︁ 𝛼𝑦 ⊤ D2 diag(A⊤ 2 v)D2 m 2 Chapter 5. Inversion SimPEG Documentation, Release 0.1.9 We will define W_x as: W𝑥 = √ 𝛼𝑥 diag (︂√︁ )︂ A⊤ v D1 1 And then W as a tall matrix of all of the different regularization terms: ⎡ ⎤ W𝑠 W = ⎣ W𝑥 ⎦ W𝑦 Then we can write 𝑅(𝑚) ≈ 1 ⊤ ⊤ m W Wm 2 smoothModel = True SMOOTH and SMOOTH_MOD_DIF options alpha_s Smallness weight alpha_x Weight for the first derivative in the x direction alpha_y Weight for the first derivative in the y direction alpha_z Weight for the first derivative in the z direction alpha_xx Weight for the second derivative in the x direction alpha_yy Weight for the second derivative in the y direction alpha_zz Weight for the second derivative in the z direction Ws Regularization matrix Ws Wx Regularization matrix Wx Wy Regularization matrix Wy Wz Regularization matrix Wz Wxx Regularization matrix Wxx Wyy Regularization matrix Wyy Wzz Regularization matrix Wzz Wsmooth Full smoothness regularization matrix W 5.2. Regularization 51 SimPEG Documentation, Release 0.1.9 W Full regularization matrix W eval(*args, **kwargs) evalDeriv(*args, **kwargs) The regularization is: 𝑅(𝑚) = 1 (m − mref )⊤ W⊤ W(m − mref ) 2 So the derivative is straight forward: 𝑅(𝑚) = W⊤ W(m − mref ) 5.3 Optimize class SimPEG.Optimization.StoppingCriteria Bases: object docstring for StoppingCriteria iteration = {‘stopType’: ‘critical’, ‘right’: <function <lambda> at 0x7f66544802a8>, ‘str’: ‘%d : maxIter = %3d <= ite iterationLS = {‘stopType’: ‘critical’, ‘right’: <function <lambda> at 0x7f6654480398>, ‘str’: ‘%d : maxIterLS = %3d armijoGoldstein = {‘stopType’: ‘optimal’, ‘right’: <function <lambda> at 0x7f6654480488>, ‘str’: ‘%d : ft = %1.4e < tolerance_f = {‘stopType’: ‘optimal’, ‘right’: <function <lambda> at 0x7f6654480578>, ‘str’: ‘%d : |fc-fOld| = %1.4e moving_x = {‘stopType’: ‘optimal’, ‘right’: <function <lambda> at 0x7f6654480668>, ‘str’: ‘%d : |xc-x_last| = %1.4e <= tolerance_g = {‘stopType’: ‘optimal’, ‘right’: <function <lambda> at 0x7f6654480758>, ‘str’: ‘%d : |proj(x-g)-x| = %1 norm_g = {‘stopType’: ‘critical’, ‘right’: <function <lambda> at 0x7f6654480848>, ‘str’: ‘%d : |proj(x-g)-x| = %1.4e <= 1 bindingSet = {‘stopType’: ‘critical’, ‘right’: <function <lambda> at 0x7f6654480938>, ‘str’: ‘%d : probSize = %3d <= bindingSet_LS = {‘stopType’: ‘critical’, ‘right’: <function <lambda> at 0x7f6654480a28>, ‘str’: ‘%d : probSize = %3d phi_d_target_Minimize = {‘stopType’: ‘critical’, ‘right’: <function <lambda> at 0x7f6654480b18>, ‘str’: ‘%d : phi_ phi_d_target_Inversion = {‘stopType’: ‘critical’, ‘right’: <function <lambda> at 0x7f6654480c08>, ‘str’: ‘%d : ph class SimPEG.Optimization.IterationPrinters Bases: object docstring for IterationPrinters iteration = {‘width’: 5, ‘format’: ‘%3d’, ‘value’: <function <lambda> at 0x7f6654480c80>, ‘title’: ‘#’} f = {‘width’: 10, ‘format’: ‘%1.2e’, ‘value’: <function <lambda> at 0x7f6654480cf8>, ‘title’: ‘f’} norm_g = {‘width’: 15, ‘format’: ‘%1.2e’, ‘value’: <function <lambda> at 0x7f6654480d70>, ‘title’: ‘|proj(x-g)-x|’} totalLS = {‘width’: 5, ‘format’: ‘%d’, ‘value’: <function <lambda> at 0x7f6654480de8>, ‘title’: ‘LS’} iterationLS = {‘width’: 5, ‘format’: ‘%3d.%d’, ‘value’: <function <lambda> at 0x7f6654480e60>, ‘title’: ‘#’} LS_ft = {‘width’: 10, ‘format’: ‘%1.2e’, ‘value’: <function <lambda> at 0x7f6654480ed8>, ‘title’: ‘ft’} LS_t = {‘width’: 10, ‘format’: ‘%0.5f’, ‘value’: <function <lambda> at 0x7f6654480f50>, ‘title’: ‘t’} LS_armijoGoldstein = {‘width’: 16, ‘format’: ‘%1.2e’, ‘value’: <function <lambda> at 0x7f6654483050>, ‘title’: ‘f + itType = {‘width’: 8, ‘format’: ‘%s’, ‘value’: <function <lambda> at 0x7f66544830c8>, ‘title’: ‘itType’} 52 Chapter 5. Inversion SimPEG Documentation, Release 0.1.9 aSet = {‘width’: 8, ‘format’: ‘%d’, ‘value’: <function <lambda> at 0x7f6654483140>, ‘title’: ‘aSet’} bSet = {‘width’: 8, ‘format’: ‘%d’, ‘value’: <function <lambda> at 0x7f66544831b8>, ‘title’: ‘bSet’} comment = {‘width’: 12, ‘format’: ‘%s’, ‘value’: <function <lambda> at 0x7f6654483230>, ‘title’: ‘Comment’} beta = {‘width’: 10, ‘format’: ‘%1.2e’, ‘value’: <function <lambda> at 0x7f66544832a8>, ‘title’: ‘beta’} phi_d = {‘width’: 10, ‘format’: ‘%1.2e’, ‘value’: <function <lambda> at 0x7f6654483320>, ‘title’: ‘phi_d’} phi_m = {‘width’: 10, ‘format’: ‘%1.2e’, ‘value’: <function <lambda> at 0x7f6654483398>, ‘title’: ‘phi_m’} class SimPEG.Optimization.Minimize(**kwargs) Bases: object Minimize is a general class for derivative based optimization. name = ‘General Optimization Algorithm’ The name of the optimization algorithm maxIter = 20 Maximum number of iterations maxIterLS = 10 Maximum number of iterations for the line-search maxStep = inf Maximum step possible, used in scaling before the line-search. LSreduction = 0.0001 Expected decrease in the line-search LSshorten = 0.5 Line-search step is shortened by this amount each time. tolF = 0.1 Tolerance on function value decrease tolX = 0.1 Tolerance on norm(x) movement tolG = 0.1 Tolerance on gradient norm eps = 1e-05 Small value stopNextIteration = False Stops the optimization program nicely. debug = False Print debugging information debugLS = False Print debugging information for the line-search comment = ‘’ Used by some functions to indicate what is going on in the algorithm counter = None Set this to a SimPEG.Utils.Counter() if you want to count things parent = None This is the parent of the optimization routine. callback 5.3. Optimize 53 SimPEG Documentation, Release 0.1.9 minimize(evalFunction, x0) Minimizes the function (evalFunction) starting at the location x0. Parameters • evalFunction (def ) – function handle that evaluates: f, g, H = F(x) • x0 (numpy.ndarray) – starting location Return type numpy.ndarray Returns x, the last iterate of the optimization algorithm evalFunction is a function handle: (f[, g][, H]) = evalFunction(x, return_g=False, return_H=False ) def evalFunction(x, return_g=False, return_H=False): out = (f,) if return_g: out += (g,) if return_H: out += (H,) return out if len(out) > 1 else out[0] The algorithm for general minimization is as follows: startup(x0) printInit() while True: doStartIteration() f, g, H = evalFunction(xc) printIter() if stoppingCriteria(): break p = findSearchDirection() p = scaleSearchDirection(p) xt, passLS = modifySearchDirection(p) if not passLS: xt, caught = modifySearchDirectionBreak(p) if not caught: return xc doEndIteration(xt) printDone() finish() return xc startup(*args, **kwargs) startup is called at the start of any new minimize call. This will set: x0 = x0 xc = x0 iter = iterLS = 0 Parameters x0 (numpy.ndarray) – initial x Return type None Returns None 54 Chapter 5. Inversion SimPEG Documentation, Release 0.1.9 If you have things that also need to run in the method startup, you can create a method: def _startup*(self, ... ): pass Where the * can be any string. If present, _startup* will be called at the start of the default startup call. You may also completely overwrite this function. doStartIteration() doStartIteration is called at the start of each minimize iteration. Return type None Returns None If you have things that also need to run in the method doStartIteration, you can create a method: def _doStartIteration*(self, ... ): pass Where the * can be any string. If present, _doStartIteration* will be called at the start of the default doStartIteration call. You may also completely overwrite this function. printInit(inLS=False) printInit is called at the beginning of the optimization routine. If there is a parent object, printInit will check for a parent.printInit function and call that. printIter(*args, **kwargs) printIter is called directly after function evaluations. If there is a parent object, printIter will check for a parent.printIter function and call that. If you have things that also need to run in the method printIter, you can create a method: def _printIter*(self, ... ): pass Where the * can be any string. If present, _printIter* will be called at the start of the default printIter call. You may also completely overwrite this function. printDone(inLS=False) printDone is called at the end of the optimization routine. If there is a parent object, printDone will check for a parent.printDone function and call that. finish() finish is called at the end of the optimization. Return type None Returns None If you have things that also need to run in the method finish, you can create a method: def _finish*(self, ... ): pass Where the * can be any string. If present, _finish* will be called at the start of the default finish call. You may also completely overwrite this function. stoppingCriteria(inLS=False) projection(p) projects the search direction. 5.3. Optimize 55 SimPEG Documentation, Release 0.1.9 by default, no projection is applied. Parameters p (numpy.ndarray) – searchDirection Return type numpy.ndarray Returns p, projected search direction If you have things that also need to run in the method projection, you can create a method: def _projection*(self, ... ): pass Where the * can be any string. If present, _projection* will be called at the start of the default projection call. You may also completely overwrite this function. findSearchDirection() findSearchDirection should return an approximation of: 𝐻𝑝 = −𝑔 Where you are solving for the search direction, p The default is: 𝐻=𝐼 𝑝 = −𝑔 And corresponds to SteepestDescent. The latest function evaluations are present in: self.f, self.g, self.H Return type numpy.ndarray Returns p, Search Direction scaleSearchDirection(p) scaleSearchDirection should scale the search direction if appropriate. Set the parameter maxStep in the minimize object, to scale back the gradient to a maximum size. Parameters p (numpy.ndarray) – searchDirection Return type numpy.ndarray Returns p, Scaled Search Direction nameLS = ‘Armijo linesearch’ The line-search name modifySearchDirection(p) modifySearchDirection changes the search direction based on some sort of linesearch or trust-region criteria. By default, an Armijo backtracking linesearch is preformed with the following parameters: •maxIterLS, the maximum number of linesearch iterations •LSreduction, the expected reduction expected, default: 1e-4 •LSshorten, how much the step is reduced, default: 0.5 56 Chapter 5. Inversion SimPEG Documentation, Release 0.1.9 If the linesearch is completed, and a descent direction is found, passLS is returned as True. Else, a modifySearchDirectionBreak call is preformed. Parameters p (numpy.ndarray) – searchDirection Return type numpy.ndarray,bool Returns (xt, passLS) modifySearchDirectionBreak(p) Code is called if modifySearchDirection fails to find a descent direction. The search direction is passed as input and this function must pass back both a new searchDirection, and if the searchDirection break has been caught. By default, no additional work is done, and the evalFunction returns a False indicating the break was not caught. Parameters p (numpy.ndarray) – searchDirection Return type numpy.ndarray,bool Returns (xt, breakCaught) doEndIteration(xt) doEndIteration is called at the end of each minimize iteration. By default, function values and x locations are shuffled to store 1 past iteration in memory. self.xc must be updated in this code. Parameters xt (numpy.ndarray) – tested new iterate that ensures a descent direction. Return type None Returns None If you have things that also need to run in the method doEndIteration, you can create a method: def _doEndIteration*(self, ... ): pass Where the * can be any string. If present, _doEndIteration* will be called at the start of the default doEndIteration call. You may also completely overwrite this function. save(group) class SimPEG.Optimization.Remember Bases: object This mixin remembers all the things you tend to forget. You can remember parameters directly, naming the str in Minimize, or pass a tuple with the name and the function that takes Minimize. For Example: opt.remember('f',('norm_g', lambda M: np.linalg.norm(M.g))) opt.minimize(evalFunction, x0) opt.recall('f') The param name (str) can also be located in the parent (if no conflicts), and it will be looked up by default. _rememberThese = [] 5.3. Optimize 57 SimPEG Documentation, Release 0.1.9 remember(*args) recall(param) _startupRemember(x0) _doEndIterationRemember(*args) class SimPEG.Optimization.ProjectedGradient(**kwargs) Bases: SimPEG.Optimization.Minimize, SimPEG.Optimization.Remember name = ‘Projected Gradient’ maxIterCG = 5 tolCG = 0.1 lower = -inf upper = inf _startup(x0) projection(x) Make sure we are feasible. activeSet(x) If we are on a bound inactiveSet(x) The free variables. bindingSet(x) If we are on a bound and the negative gradient points away from the feasible set. Optimality condition. (Satisfies Kuhn-Tucker) MoreToraldo91 findSearchDirection() Finds the search direction based on either CG or steepest descent. _doEndIteration_ProjectedGradient(xt) class SimPEG.Optimization.BFGS(**kwargs) Bases: SimPEG.Optimization.Minimize, SimPEG.Optimization.Remember name = ‘BFGS’ nbfgs = 10 bfgsH0 Approximate Hessian used in preconditioning the problem. Must be a SimPEG.Solver _startup_BFGS(x0) bfgs(d) bfgsrec(k, n, nn, S, Y, d) BFGS recursion findSearchDirection() _doEndIteration_BFGS(xt) class SimPEG.Optimization.GaussNewton(**kwargs) Bases: SimPEG.Optimization.Minimize, SimPEG.Optimization.Remember 58 Chapter 5. Inversion SimPEG Documentation, Release 0.1.9 name = ‘Gauss Newton’ findSearchDirection(*args, **kwargs) class SimPEG.Optimization.InexactGaussNewton(**kwargs) Bases: SimPEG.Optimization.BFGS, SimPEG.Optimization.Minimize, SimPEG.Optimization.Remember Minimizes using CG as the inexact solver of Hp = −g By default BFGS is used as the preconditioner. Use nbfgs to set the memory limitation of BFGS. To set the initial H0 to be used in BFGS, set bfgsH0 to be a SimPEG.Solver name = ‘Inexact Gauss Newton’ maxIterCG = 5 tolCG = 0.1 approxHinv The approximate Hessian inverse is used to precondition CG. Default uses BFGS, with an initial H0 of bfgsH0. Must be a scipy.sparse.linalg.LinearOperator findSearchDirection(*args, **kwargs) class SimPEG.Optimization.SteepestDescent(**kwargs) Bases: SimPEG.Optimization.Minimize, SimPEG.Optimization.Remember name = ‘Steepest Descent’ findSearchDirection(*args, **kwargs) class SimPEG.Optimization.NewtonRoot(**kwargs) Bases: object Newton Method - Root Finding root = newtonRoot(fun,x); Where fun is the function that returns the function value as well as the gradient. For iterative solving of dh = -Jr, use O.solveTol = TOL. For direct solves, use SOLVETOL = 0 (default) Rowan Cockett 16-May-2013 16:29:51 University of British Columbia [email protected] tol = 1e-06 maxIter = 20 stepDcr = 0.5 maxLS = 30 comments = False doLS = True Solver alias of spsolve_Wrapped solverOpts = {} 5.3. Optimize 59 SimPEG Documentation, Release 0.1.9 root(fun, x) Function Should have the form: def evalFunction(x, return_g=False): out = (f,) if return_g: out += (g,) return out if len(out) > 1 else out[0] 5.4 Directives class SimPEG.Directives.InversionDirective(**kwargs) Bases: object debug = False Print debugging information inversion This is the inversion of the InversionDirective instance. invProb opt reg dmisfit survey prob initialize() endIter() finish() class SimPEG.Directives.DirectiveList(*directives, **kwargs) Bases: object dList = None The list of Directives debug inversion This is the inversion of the InversionDirective instance. call(ruleType) class SimPEG.Directives.BetaEstimate_ByEig(**kwargs) Bases: SimPEG.Directives.InversionDirective BetaEstimate beta0 = None The initial Beta (regularization parameter) beta0_ratio = 100.0 estimateBeta0 is used with this ratio 60 Chapter 5. Inversion SimPEG Documentation, Release 0.1.9 initialize() The initial beta is calculated by comparing the estimated eigenvalues of JtJ and WtW. To estimate the eigenvector of A, we will use one iteration of the Power Method: x1 = Ax0 Given this (very course) approximation of the eigenvector, we can use the Rayleigh quotient to approximate the largest eigenvalue. 𝜆0 = x⊤ Ax x⊤ x We will approximate the largest eigenvalue for both JtJ and WtW, and use some ratio of the quotient to estimate beta0. 𝛽0 = 𝛾 x⊤ J⊤ Jx x⊤ W⊤ Wx Return type float Returns beta0 class SimPEG.Directives.BetaSchedule(**kwargs) Bases: SimPEG.Directives.InversionDirective coolingFactor = 8.0 coolingRate = 3 endIter() class SimPEG.Directives.TargetMisfit(**kwargs) Bases: SimPEG.Directives.InversionDirective target endIter() class SimPEG.Directives.SaveModelEveryIteration(**kwargs) Bases: SimPEG.Directives._SaveEveryIteration initialize() endIter() class SimPEG.Directives.SaveOutputEveryIteration(**kwargs) Bases: SimPEG.Directives._SaveEveryIteration SaveModelEveryIteration initialize() endIter() 5.5 Inversion class SimPEG.Inversion.BaseInversion(invProb, directiveList=[], **kwargs) Bases: object Inversion Class. name = ‘BaseInversion’ 5.5. Inversion 61 SimPEG Documentation, Release 0.1.9 debug = False Print debugging information counter = None Set this to a SimPEG.Utils.Counter() if you want to count things directiveList run(m0) Runs the inversion! 62 Chapter 5. Inversion CHAPTER 6 Utility Codes 6.1 Solver 6.1.1 BYOS The numerical linear algebra solver that you use will ultimately be the bottleneck of your large scale inversion. To be the most flexible, SimPEG provides wrappers rather than a comprehensive set of solvers (i.e. BYOS). The interface is as follows: A # Where A is a sparse matrix (or linear operator) Ainv = Solver(A, **solverOpts) # Create a solver object with key word arguments x = Ainv * b # Where b is a numpy array of shape (n,) or (n,*) Ainv.clean() # This cleans the memory footprint (if any) Note: This is somewhat an abuse of notation for solvers as we never actually create A inverse. Instead we are creating an object that acts like A inverse, whether that be a Krylov subspace solver or an LU decomposition. To wrap up solvers in scipy.sparse.linalg it takes one line of code: Solver = SolverWrapD(sp.linalg.spsolve, factorize=False) SolverLU = SolverWrapD(sp.linalg.splu, factorize=True) SolverCG = SolverWrapI(sp.linalg.cg) Note: The above solvers are loaded into the base name space of SimPEG. See also: • https://bitbucket.org/petsc/petsc4py • https://github.com/bfroehle/pymumps • https://github.com/rowanc1/pymatsolver 6.1.2 The API SimPEG.Utils.SolverUtils.SolverWrapD(fun, factorize=True, accuracyTol=1e-06) Wraps a direct Solver. checkAccuracy=True, 63 SimPEG Documentation, Release 0.1.9 Solver = SolverUtils.SolverWrapD(sp.linalg.spsolve, factorize=False) SolverLU = SolverUtils.SolverWrapD(sp.linalg.splu, factorize=True) SimPEG.Utils.SolverUtils.SolverWrapI(fun, checkAccuracy=True, accuracyTol=1e-05) Wraps an iterative Solver. SolverCG = SolverUtils.SolverWrapI(sp.linalg.cg) 6.2 SimPEG Maps 6.2.1 That’s not a map...?! A SimPEG Map operates on a vector and transforms it to another space. We will use an example commonly applied in electromagnetics (EM) of the log-conductivity model. 𝑚 = log(𝜎) Here we require a mapping to get from \(m\) to \(\sigma\), we will call this map \(\mathcal{M}\). 𝜎 = ℳ(𝑚) = exp(𝑚) In SimPEG, we use a (SimPEG.Maps.ExpMap) to describe how to map back to conductivity. This is a relatively trivial example (we are just taking the exponential!) but by defining maps we can start to combine and manipulate exactly what we think about as our model, \(m\). In code, this looks like M = Mesh.TensorMesh([100]) expMap = Maps.ExpMap(M) m = np.zeros(M.nC) m[M.vectorCCx>0.5] = 1.0 sig = expMap * m print m # [ 0. 0. 0. 1. print sig # [ 1. 1. 1. 2.718 # # # # # Create a mesh Create a mapping Create a model vector Set half of it to 1.0 Apply the mapping using * 1. 2.718 1. ] 2.718] 6.2.2 Combining Maps We will use an example where we want a 1D layered earth as our model, but we want to map this to a 2D discretization to do our forward modeling. We will also assume that we are working in log conductivity still, so after the transformation we want to map to conductivity space. To do this we will introduce the vertical 1D map (SimPEG.Maps.Vertical1DMap), which does the first part of what we just described. The second part will be done by the SimPEG.Maps.ExpMap described above. M = Mesh.TensorMesh([7,5]) v1dMap = Maps.Vertical1DMap(M) expMap = Maps.ExpMap(M) myMap = expMap * v1dMap m = np.r_[0.2,1,0.1,2,2.9] # only 5 model parameters! sig = myMap * m 64 Chapter 6. Utility Codes SimPEG Documentation, Release 0.1.9 1.0 Model 1.0 Physical Property 18 0.8 0.6 0.6 0.4 14 12 σ =exp(Pm) 0.8 Depth, y Depth, y 16 10 0.4 8 6 0.2 0.2 0.0 0.0 0.5 1.0 1.5 2.0 2.5 3.0 Value, mi 0.0 0.0 0.2 0.4 0.6 0.8 1.0 x 4 2 If you noticed, it was pretty easy to combine maps. What is even cooler is that the derivatives also are made for you (if everything goes right). Just to be sure that the derivative is correct, you should always run the test on the mapping that you create. 6.2.3 Taking Derivatives Now that we have wrapped up the mapping, we can ensure that it is easy to take derivatives (or at least have access to them!). In the SimPEG.Maps.ExpMap there are no dependencies between model parameters, so it will be a diagonal matrix: (︂ )︂ 𝜕ℳ(𝑚) 𝜕 exp(𝑚𝑖 ) = = exp(𝑚𝑖 ) 𝜕𝑚 𝜕𝑚 𝑖𝑖 Or equivalently: 𝜕ℳ(𝑚) = diag(exp(𝑚)) 𝜕𝑚 The mapping API makes this really easy to test that you have got the derivative correct. When these are used in the inverse problem, this is extremely important!! from SimPEG import * import matplotlib.pyplot as plt M = Mesh.TensorMesh([100]) expMap = Maps.ExpMap(M) 6.2. SimPEG Maps 65 SimPEG Documentation, Release 0.1.9 m = np.zeros(M.nC) m[M.vectorCCx>0.5] = 1.0 expMap.test(m, plotIt=True) Check Derivative - PASSED :) 101 100 10-1 Error 10-2 10-3 10-4 10-5 10-6 10-7 -4 10 10-3 f(x + h∆x)−f(x)−hg(x)∆x−O(h2 ) =0 O(h) O(h2 ) h 10-2 10-1 6.2.4 The API class SimPEG.Maps.IdentityMap(mesh, **kwargs) SimPEG Map mesh = None A SimPEG Mesh nP Return type int Returns number of parameters in the model shape The default shape is (mesh.nC, nP). Return type (int,int) Returns shape of the operator as a tuple inverse(D) Changes the physical property into the model. 66 Chapter 6. Utility Codes SimPEG Documentation, Release 0.1.9 Note: The transformInverse may not be easy to create in general. Parameters D (numpy.array) – physical property Return type numpy.array Returns model deriv(m) The derivative of the transformation. Parameters m (numpy.array) – model Return type scipy.csr_matrix Returns derivative of transformed model test(m=None, **kwargs) Test the derivative of the mapping. Parameters • m (numpy.array) – model • kwargs – key word arguments of SimPEG.Tests.checkDerivative() Return type bool Returns passed the test? 6.2.5 Common Maps Exponential Map Electrical conductivity varies over many orders of magnitude, so it is a common technique when solving the inverse problem to parameterize and optimize in terms of log conductivity. This makes sense not only because it ensures all conductivities will be positive, but because this is fundamentally the space where conductivity lives (i.e. it varies logarithmically). class SimPEG.Maps.ExpMap(mesh, **kwargs) Changes the model into the physical property. A common example of this is to invert for electrical conductivity in log space. In this case, your model will be log(sigma) and to get back to sigma, you can take the exponential: 𝑚 = log 𝜎 exp 𝑚 = exp log 𝜎 = 𝜎 inverse(D) Parameters D (numpy.array) – physical property Return type numpy.array Returns model The transformInverse changes the physical property into the model. 𝑚 = log 𝜎 6.2. SimPEG Maps 67 SimPEG Documentation, Release 0.1.9 deriv(m) Parameters m (numpy.array) – model Return type scipy.csr_matrix Returns derivative of transformed model The transform changes the model into the physical property. The transformDeriv provides the derivative of the transform. If the model transform is: 𝑚 = log 𝜎 exp 𝑚 = exp log 𝜎 = 𝜎 Then the derivative is: 𝜕 exp 𝑚 = sdiag(exp 𝑚) 𝜕𝑚 Vertical 1D Map class SimPEG.Maps.Vertical1DMap(mesh, **kwargs) Given a 1D vector through the last dimension of the mesh, this will extend to the full model space. nP Number of model properties. The number of cells in the last dimension of the mesh. deriv(m) Parameters m (numpy.array) – model Return type scipy.csr_matrix Returns derivative of transformed model Map 2D Cross-Section to 3D Model class SimPEG.Maps.Map2Dto3D(mesh, **kwargs) Given a 2D vector, this will extend to the full 3D model space. normal = ‘Y’ The normal nP Number of model properties. The number of cells in the last dimension of the mesh. deriv(m) Parameters m (numpy.array) – model Return type scipy.csr_matrix Returns derivative of transformed model 68 Chapter 6. Utility Codes SimPEG Documentation, Release 0.1.9 Mesh to Mesh Map 1.0Fine Mesh (Original)1.0 Course Mesh Fine 1.0 Mesh (Interpolated) 0.6 0.6 0.6 y 0.8 y 0.8 y 0.8 0.4 0.4 0.4 0.2 0.2 0.2 0.0 0.0 0.0 0.0 0.2 0.4 0.6 0.8 1.0 0.0 0.2 0.4 0.6 0.8 1.0 0.0 0.2 0.4 0.6 0.8 1.0 x x x class SimPEG.Maps.Mesh2Mesh(meshes, **kwargs) Takes a model on one mesh are translates it to another mesh. shape Number of parameters in the model. nP Number of parameters in the model. deriv(m) 6.2.6 Some Extras Combo Map The ComboMap holds the information for multiplying and combining maps. It also uses the chain rule to create the derivative. Remember, any time that you make your own combination of mappings be sure to test that the derivative is correct. class SimPEG.Maps.ComboMap(maps, **kwargs) Combination of various maps. shape 6.2. SimPEG Maps 69 SimPEG Documentation, Release 0.1.9 nP Number of model properties. The number of cells in the last dimension of the mesh. deriv(m) 6.3 Utilities 6.3.1 Matrix Utilities SimPEG.Utils.matutils.mkvc(x, numDims=1) Creates a vector with the number of dimension specified e.g.: a = np.array([1, 2, 3]) mkvc(a, 1).shape > (3, ) mkvc(a, 2).shape > (3, 1) mkvc(a, 3).shape > (3, 1, 1) SimPEG.Utils.matutils.sdiag(h) Sparse diagonal matrix SimPEG.Utils.matutils.sdInv(M) Inverse of a sparse diagonal matrix SimPEG.Utils.matutils.speye(n) Sparse identity SimPEG.Utils.matutils.kron3(A, B, C) Three kron prods SimPEG.Utils.matutils.spzeros(n1, n2) SimPEG.Utils.matutils.ddx(n) Define 1D derivatives, inner, this means we go from n+1 to n SimPEG.Utils.matutils.av(n) Define 1D averaging operator from nodes to cell-centers. SimPEG.Utils.matutils.avExtrap(n) Define 1D averaging operator from cell-centers to nodes. SimPEG.Utils.matutils.ndgrid(*args, **kwargs) Form tensorial grid for 1, 2, or 3 dimensions. Returns as column vectors by default. To return as matrix input: ndgrid(..., vector=False) 70 Chapter 6. Utility Codes SimPEG Documentation, Release 0.1.9 The inputs can be a list or separate arguments. e.g.: a = np.array([1, 2, 3]) b = np.array([1, 2]) XY = ndgrid(a, b) > [[1 1] [2 1] [3 1] [1 2] [2 2] [3 2]] X, Y = ndgrid(a, b, vector=False) > X = [[1 1] [2 2] [3 3]] > Y = [[1 2] [1 2] [1 2]] SimPEG.Utils.matutils.ind2sub(shape, inds) From the given shape, returns the subscripts of the given index SimPEG.Utils.matutils.sub2ind(shape, subs) From the given shape, returns the index of the given subscript SimPEG.Utils.matutils.getSubArray(A, ind) subArray SimPEG.Utils.matutils.inv3X3BlockDiagonal(a11, a12, a13, a21, a22, a23, a31, a32, a33, returnMatrix=True) B = inv3X3BlockDiagonal(a11, a12, a13, a21, a22, a23, a31, a32, a33) inverts a stack of 3x3 matrices Input: A - a11, a12, a13, a21, a22, a23, a31, a32, a33 Output: B - inverse SimPEG.Utils.matutils.inv2X2BlockDiagonal(a11, a12, a21, a22, returnMatrix=True) B = inv2X2BlockDiagonal(a11, a12, a21, a22) Inverts a stack of 2x2 matrices by using the inversion formula inv(A) = (1/det(A)) * cof(A)^T Input: A - a11, a12, a21, a22 Output: B - inverse class SimPEG.Utils.matutils.TensorType(M, tensor) SimPEG.Utils.matutils.makePropertyTensor(M, tensor) SimPEG.Utils.matutils.invPropertyTensor(M, tensor, returnMatrix=False) SimPEG.Utils.matutils.diagEst(matFun, n, k=None, approach=’Probing’) Estimate the diagonal of a matrix, A. Note that the matrix may be a function which returns A times a vector. Three different approaches have been implemented, 1. Probing : uses cyclic permutations of vectors with ones and zeros (default) 6.3. Utilities 71 SimPEG Documentation, Release 0.1.9 2. Ones : random +/- 1 entries 3. Random : random vectors Parameters • (numpy.array) matFun (lambda) – matrix to estimate the diagonal of • n (int64) – size of the vector that should be used to compute matFun(v) • k (int64) – number of vectors to be used to estimate the diagonal • approach (str) – approach to be used for getting vectors Return type numpy.array Returns est_diag(A) Based on Saad http://www-users.cs.umn.edu/~saad/PDF/umsi-2005-082.pdf, http://www.cita.utoronto.ca/~niels/diagonal.pdf and class SimPEG.Utils.matutils.Zero class SimPEG.Utils.matutils.Identity(positive=True) 6.3.2 Solver Utilities SimPEG.Utils.SolverUtils.SolverWrapD(fun, factorize=True, accuracyTol=1e-06) Wraps a direct Solver. checkAccuracy=True, Solver = SolverUtils.SolverWrapD(sp.linalg.spsolve, factorize=False) SolverLU = SolverUtils.SolverWrapD(sp.linalg.splu, factorize=True) SimPEG.Utils.SolverUtils.SolverWrapI(fun, checkAccuracy=True, accuracyTol=1e-05) Wraps an iterative Solver. SolverCG = SolverUtils.SolverWrapI(sp.linalg.cg) SimPEG.Utils.SolverUtils.Solver alias of spsolve_Wrapped SimPEG.Utils.SolverUtils.SolverLU alias of splu_Wrapped SimPEG.Utils.SolverUtils.SolverCG alias of cg_Wrapped class SimPEG.Utils.SolverUtils.SolverDiag(A) docstring for SolverDiag clean() 6.3.3 Curv Utilities SimPEG.Utils.curvutils.volTetra(xyz, A, B, C, D) Returns the volume for tetrahedras volume specified by the indexes A to D. Parameters • xyz (numpy.array) – X,Y,Z vertex vector 72 Chapter 6. Utility Codes SimPEG Documentation, Release 0.1.9 • A,B,C,D (numpy.array) – vert index of the tetrahedra Return type numpy.array Returns V, volume of the tetrahedra Algorithm http://en.wikipedia.org/wiki/Tetrahedron#Volume 𝑉 = 𝑉 = 1 𝐴ℎ 3 1 |(𝑎 − 𝑑) · ((𝑏 − 𝑑)(𝑐 − 𝑑))| 6 SimPEG.Utils.curvutils.indexCube(nodes, gridSize, n=None) Returns the index of nodes on the mesh. Input: nodes - string of which nodes to return. e.g. ‘ABCD’ gridSize - size of the nodal grid n - number of nodes each i,j,k direction: [ni,nj,nk] Output: index - index in the order asked e.g. ‘ABCD’ –> (A,B,C,D) TWO DIMENSIONS: node(i,j) node(i,j+1) A -------------- B | | | cell(i,j) | | I | | | D -------------- C node(i+1,j) node(i+1,j+1) THREE DIMENSIONS: node(i,j,k+1) node(i,j+1,k+1) E --------------- F /| / | / | / | / | / | node(i,j,k) node(i,j+1,k) A -------------- B | | H ----------|---- G | /cell(i,j) | / | / I | / | / | / D -------------- C node(i+1,j,k) node(i+1,j+1,k) SimPEG.Utils.curvutils.faceInfo(xyz, A, B, C, D, average=True, normalizeNormals=True) function [N] = faceInfo(y,A,B,C,D) Returns the averaged normal, area, and edge lengths for a given set of faces. If average option is FALSE then N is a cell array {nA,nB,nC,nD} Input: xyz - X,Y,Z vertex vector A,B,C,D - vert index of the face (counter clockwize) Options: average - [true]/false, toggles returning all normals or the average Output: N - average face normal or {nA,nB,nC,nD} if average = false area - average face area edgeLengths exact edge Lengths, 4 column vector [AB, BC, CD, DA] 6.3. Utilities 73 SimPEG Documentation, Release 0.1.9 see also testFaceNormal testFaceArea @author Rowan Cockett Last modified on: 2013/07/26 6.3.4 Mesh Utilities SimPEG.Utils.meshutils.exampleLrmGrid(nC, exType) SimPEG.Utils.meshutils.meshTensor(value) meshTensor takes a list of numbers and tuples that have the form: mT = [ float, (cellSize, numCell), (cellSize, numCell, factor) ] For example, a time domain mesh code needs many time steps at one time: [(1e-5, 30), (1e-4, 30), 1e-3] Means take 30 steps at 1e-5 and then 30 more at 1e-4, and then one step of 1e-3. Tensor meshes can also be created by increase factors: [(10.0, 5, -1.3), (10.0, 50), (10.0, 5, 1.3)] When there is a third number in the tuple, it refers to the increase factor, if this number is negative this section of the tensor is flipped right-to-left. 1000 800 x2 600 400 200 0 0 200 400 600 800 x1 1000 1200 1400 1600 SimPEG.Utils.meshutils.closestPoints(mesh, pts, gridLoc=’CC’) Move a list of points to the closest points on a grid. 74 Chapter 6. Utility Codes SimPEG Documentation, Release 0.1.9 Parameters • mesh (simpeg.Mesh.BaseMesh) – The mesh • pts (numpy.ndarray) – Points to move • gridLoc (string) – [’CC’, ‘N’, ‘Fx’, ‘Fy’, ‘Fz’, ‘Ex’, ‘Ex’, ‘Ey’, ‘Ez’] Return type numpy.ndarray Returns nodeInds SimPEG.Utils.meshutils.readUBCTensorMesh(fileName) Read UBC GIF 3DTensor mesh and generate 3D Tensor mesh in simpegTD Input: :param fileName, path to the UBC GIF mesh file Output: :param SimPEG TensorMesh object :return SimPEG.Utils.meshutils.readUBCTensorModel(fileName, mesh) Read UBC 3DTensor mesh model and generate 3D Tensor mesh model in simpeg Input: :param fileName, path to the UBC GIF mesh file to read :param mesh, TensorMesh object, mesh that coresponds to the model Output: :return numpy array, model with TensorMesh ordered SimPEG.Utils.meshutils.writeUBCTensorMesh(fileName, mesh) Writes a SimPEG TensorMesh to a UBC-GIF format mesh file. Parameters • fileName (str) – File to write to • mesh (simpeg.Mesh.TensorMesh) – The mesh SimPEG.Utils.meshutils.writeUBCTensorModel(fileName, mesh, model) Writes a model associated with a SimPEG TensorMesh to a UBC-GIF format model file. Parameters • fileName (str) – File to write to • mesh (simpeg.Mesh.TensorMesh) – The mesh • model (numpy.ndarray) – The model SimPEG.Utils.meshutils.readVTRFile(fileName) Read VTK Rectilinear (vtr xml file) and return SimPEG Tensor mesh and model Input: :param vtrFileName, path to the vtr model file to write to Output: :return SimPEG TensorMesh object :return SimPEG model dictionary SimPEG.Utils.meshutils.writeVTRFile(fileName, mesh, model=None) Makes and saves a VTK rectilinear file (vtr) for a simpeg Tensor mesh and model. Input: :param str, path to the output vtk file :param mesh, SimPEG TensorMesh object - mesh to be transfer to VTK :param model, dictionary of numpy.array - Name(‘s) and array(‘s). Match number of cells SimPEG.Utils.meshutils.ExtractCoreMesh(xyzlim, mesh, meshType=’tensor’) Extracts Core Mesh from Global mesh xyzlim: 2D array [ndim x 2] mesh: SimPEG mesh This function ouputs: •actind: corresponding boolean index from global to core •meshcore: core SimPEG mesh Warning: 1D and 2D has not been tested 6.3. Utilities 75 SimPEG Documentation, Release 0.1.9 6.3.5 Model Builder Utilities SimPEG.Utils.ModelBuilder.addBlock(gridCC, modelCC, p0, p1, blockProp) Add a block to an exsisting cell centered model, modelCC Parameters • gridCC (numpy.array,) – mesh.gridCC is the cell centered grid • modelCC (numpy.array,) – cell centered model • p0 (numpy.array,) – bottom, southwest corner of block • p1 (numpy.array,) – top, northeast corner of block BlockProp float, blockProp property to assign to the model Return numpy.array, modelBlock model with block SimPEG.Utils.ModelBuilder.getIndicesBlock(p0, p1, ccMesh) Creates a vector containing the block indices in the cell centers mesh. Returns a tuple The block is defined by the points p0, describe the position of the left upper front corner, and p1, describe the position of the right bottom back corner. ccMesh represents the cell-centered mesh The points p0 and p1 must live in the the same dimensional space as the mesh. SimPEG.Utils.ModelBuilder.defineBlock(ccMesh, p0, p1, vals=[0, 1]) Build a block with the conductivity specified by condVal. Returns an array. vals[0] conductivity of the block vals[1] conductivity of the ground SimPEG.Utils.ModelBuilder.defineElipse(ccMesh, center=[0, 0, 0], anisotropy=[1, 1, 1], slope=10.0, theta=0.0) SimPEG.Utils.ModelBuilder.defineTwoLayers(ccMesh, depth, vals=[0, 1]) Define a two layered model. Depth of the first layer must be specified. CondVals vector with the conductivity values of the layers. Eg: Convention to number the layers: <----------------------------|------------------------------------> 0 depth zf 1st layer 2nd layer SimPEG.Utils.ModelBuilder.scalarConductivity(ccMesh, pFunction) Define the distribution conductivity in the mesh according to the analytical expression given in pFunction SimPEG.Utils.ModelBuilder.layeredModel(ccMesh, layerTops, layerValues) Define a layered model from layerTops (z-positive up) Parameters • ccMesh (numpy.array) – cell-centered mesh • layerTops (numpy.array) – z-locations of the tops of each layer • layerValue (numpy.array) – values of the property to assign for each layer (starting at the top) Return type numpy.array Returns M, layered model on the mesh 76 Chapter 6. Utility Codes SimPEG Documentation, Release 0.1.9 SimPEG.Utils.ModelBuilder.randomModel(shape, seed=None, anisotropy=None, bounds=[0, 1]) Create a random model by convolving a kernel with a uniformly distributed model. its=100, Parameters • shape (int,tuple) – shape of the model. • seed (int) – pick which model to produce, prints the seed if you don’t choose. • anisotropy (numpy.ndarray,list) – this is the (3 x n) blurring kernel that is used. • its (int) – number of smoothing iterations • bounds (list) – bounds on the model, len(list) == 2 Return type numpy.ndarray Returns M, the model A very cool, yet completely random model. 0 0.0 0.4 0.8 10 1.2 1.6 20 2.0 2.4 30 2.8 3.2 40 3.6 0 10 20 30 40 4.0 6.3.6 Interpolation Utilities SimPEG.Utils.interputils.interpmat(locs, x, y=None, z=None) Local interpolation computed for each receiver point in turn Parameters • loc (numpy.ndarray) – Location of points to interpolate to • x (numpy.ndarray) – Tensor vector of 1st dimension of grid. 6.3. Utilities 77 SimPEG Documentation, Release 0.1.9 • y (numpy.ndarray) – Tensor vector of 2nd dimension of grid. None by default. • z (numpy.ndarray) – Tensor vector of 3rd dimension of grid. None by default. Return type scipy.sparse.csr.csr_matrix Returns Interpolation matrix 1.0 0.5 0.0 0.5 1.0 0.0 0.2 0.4 0.6 0.8 1.0 6.3.7 Counter Utilities :: class MyClass(object): def __init__(self, url): self.counter = Counter() @count def MyMethod(self): pass @timeIt def MySecondMethod(self): pass c = MyClass(‘blah’) for i in range(100): c.counter.summary() Counters: MyClass.MyMethod 78 c.MyMethod() for i in range(300): : c.MySecondMethod() 100 Chapter 6. Utility Codes SimPEG Documentation, Release 0.1.9 Times: MyClass.MySecondMethod mean sum : 1.70e-06, 5.10e-04, 300x The API class SimPEG.Utils.CounterUtils.Counter Counter allows anything that calls it to record iterations and timings in a simple way. Also has plotting functions that allow quick recalls of data. If you want to use this, import count or timeIt and use them as decorators on class methods. class MyClass(object): def __init__(self, url): self.counter = Counter() @count def MyMethod(self): pass @timeIt def MySecondMethod(self): pass c = MyClass('blah') for i in range(100): c.MyMethod() for i in range(300): c.MySecondMethod() c.counter.summary() count(prop) Increases the count of the property. countTic(prop) Times a property call, this is the init call. countToc(prop) Times a property call, this is the end call. summary() Provides a text summary of the current counters and timers. SimPEG.Utils.CounterUtils.count(f ) SimPEG.Utils.CounterUtils.timeIt(f ) 6.4 Testing SimPEG class SimPEG.Tests.OrderTest(methodName=’runTest’) OrderTest is a base class for testing convergence orders with respect to mesh sizes of integral/differential operators. Mathematical Problem: Given are an operator A and its discretization A[h]. For a given test function f and h –> 0 we compare: 𝑒𝑟𝑟𝑜𝑟(ℎ) = ‖𝐴[ℎ](𝑓 ) − 𝐴(𝑓 )‖∞ Note that you can provide any norm. 6.4. Testing SimPEG 79 SimPEG Documentation, Release 0.1.9 Test is passed when estimated rate order of convergence is at least within the specified tolerance of the estimated rate supplied by the user. Minimal example for a curl operator: class TestCURL(OrderTest): name = "Curl" def getError(self): # For given Mesh, generate A[h], f and A(f) and return norm of error. fun = lambda x: np.cos(x) # i (cos(y)) + j (cos(z)) + k (cos(x)) sol = lambda x: np.sin(x) # i (sin(z)) + j (sin(x)) + k (sin(y)) Ex = fun(self.M.gridEx[:, 1]) Ey = fun(self.M.gridEy[:, 2]) Ez = fun(self.M.gridEz[:, 0]) f = np.concatenate((Ex, Ey, Ez)) Fx Fy Fz Af = = = = sol(self.M.gridFx[:, 2]) sol(self.M.gridFy[:, 0]) sol(self.M.gridFz[:, 1]) np.concatenate((Fx, Fy, Fz)) # Generate DIV matrix Ah = self.M.edgeCurl curlE = Ah*E err = np.linalg.norm((Ah*f -Af), np.inf) return err def test_order(self): # runs the test self.orderTest() See also: test_operatorOrder.py name = ‘Order Test’ expectedOrders = 2.0 tolerance = 0.85 meshSizes = [4, 8, 16, 32] meshTypes = [’uniformTensorMesh’] meshDimension = 3 setupMesh(nc) For a given number of cells nc, generate a TensorMesh with uniform cells with edge length h=1/nc. getError() For given h, generate A[h], f and A(f) and return norm of error. orderTest() For number of cells specified in meshSizes setup mesh, call getError and prints mesh size, error, ratio between current and previous error, and estimated order of convergence. SimPEG.Tests.Rosenbrock(x, return_g=True, return_H=True) Rosenbrock function for testing GaussNewton scheme 80 Chapter 6. Utility Codes SimPEG Documentation, Release 0.1.9 SimPEG.Tests.checkDerivative(fctn, x0, num=7, plotIt=True, dx=None, expectedOrder=2, tolerance=0.85, eps=1e-10, ax=None) Basic derivative check Compares error decay of 0th and 1st order Taylor approximation at point x0 for a randomized search direction. Parameters • fctn (lambda) – function handle • x0 (numpy.array) – point at which to check derivative • num (int) – number of times to reduce step length, h • plotIt (bool) – if you would like to plot • dx (numpy.array) – step direction • expectedOrder (int) – The order that you expect the derivative to yield. • tolerance (float) – The tolerance on the expected order. • eps (float) – What is zero? Return type bool Returns did you pass the test?! Error from SimPEG import Tests, Utils, np def simplePass(x): return np.sin(x), Utils.sdiag(np.cos(x)) Tests.checkDerivative(simplePass, np.random.randn(5)) 100 10-1 10-2 10-3 10-4 10-5 10-6 10-7 10-8 10-9 10-10 10-11 10-12 10-13 10-14 10-15 -7 10 6.4. Testing SimPEG Check Derivative - PASSED :) 10-6 10-5 f(x + h∆x)−f(x)−hg(x)∆x−O(h2 ) =0 O(h) O(h2 ) 10-4 h 10-3 10-2 10-1 81 SimPEG Documentation, Release 0.1.9 SimPEG.Tests.getQuadratic(A, b, c=0) Given A, b and c, this returns a quadratic, Q Q(x) = 0.5xAx + bx + 𝑐 82 Chapter 6. Utility Codes CHAPTER 7 Packages 7.1 Electromagnetics SimPEG.EM uses SimPEG as the framework for the forward and inverse electromagnetics geophysical problems. 7.1.1 Time Domian Electromagnetics 7.1.2 Code for Time Domian Electromagnetics 7.1.3 Frequency Domian Electromagnetics Frequency Domain Electromagnetics Electromagnetic (EM) geophysical methods are used in a variety of applications from resource exploration, including for hydrocarbons and minerals, to environmental applications, such as groundwater monitoring. The primary physical property of interest in EM is electrical conductivity, which describes the ease with which electric current flows through a material. Background Electromagnetic phenomena are governed by Maxwell’s equations. They describe the behavior of EM fields and fluxes. Electromagnetic theory for geophysical applications by Ward and Hohmann (1988) is a highly recommended resource on this topic. Fourier Transform Convention In order to examine Maxwell’s equations in the frequency domain, we must first define our choice of harmonic time-dependence by choosing a Fourier transform convention. We use the \(e^{i \omega t} \) convention, so we define our Fourier Transform pair as ∫︁ ∞ 𝐹 (𝜔) = 𝑓 (𝑡)𝑒−𝑖𝜔𝑡 𝑑𝑡 −∞ ∫︁ ∞ 1 𝐹 (𝜔)𝑒𝑖𝜔𝑡 𝑑𝜔 𝑓 (𝑡) = 2𝜋 −∞ 83 SimPEG Documentation, Release 0.1.9 where \(\omega\) is angular frequency, \(t\) is time, \(F(\omega)\) is the function defined in the frequency domain and \(f(t)\) is the function defined in the time domain. Maxwell’s Equations In the frequency domain, Maxwell’s equations are given by ⃗ = −𝑖𝜔 𝐵 ⃗ 𝐸 ⃗ = 𝐽⃗ + 𝑖𝜔 𝐷 ⃗ +𝑆 ⃗ 𝐻 ⃗ =0 ÷𝐵 ⃗ = 𝜌𝑓 ÷𝐷 where: • \(\vec{E}\) : electric field (\(V/m\)) • \(\vec{H}\) : magnetic field (\(A/m\)) • \(\vec{B}\) : magnetic flux density (\(Wb/m^2\)) • \(\vec{D}\) : electric displacement / electric flux density (\(C/m^2\)) • \(\vec{J}\) : electric current density (\(A/m^2\)) • \(\rho_f\) : free charge density The source term is \(\vec{S}\) Constitutive Relations The fields and fluxes are related through the constitutive relations. At each frequency, they are given by ⃗ 𝐽⃗ = 𝜎 𝐸 ⃗ = 𝜇𝐻 ⃗ 𝐵 ⃗ = 𝜀𝐸 ⃗ 𝐷 where: • \(\sigma\) : electrical conductivity \(S/m\) • \(\mu\) : magnetic permeability \(H/m\) • \(\varepsilon\) : dielectric permittivity \(F/m\) \(\sigma\), \(\mu\), \(\varepsilon\) are physical properties which depend on the material. \(\sigma\) describes how easily electric current passes through a material, \(\mu\) describes how easily a material is magnetized, and \(\varepsilon\) describes how easily a material is electrically polarized. In most geophysical applications of EM, \(\sigma\) is the the primary physical property of interest, and \(\mu\), \(\varepsilon\) are assumed to have their free-space values \(\mu_0 = 4\pi \times 10^{-7} H/m \), \(\varepsilon_0 = 8.85 \times 10^{-12} F/m\) Quasi-static Approximation For the frequency range typical of most geophysical surveys, the contribution of the electric displacement is negligible compared to the electric current density. In this case, we use the Quasi-static approximation and assume that this term can be neglected, giving ⃗ = −𝑖𝜔 𝐵 ⃗ ∇×𝐸 ⃗ = 𝐽⃗ + 𝑆 ⃗ ∇×𝐻 84 Chapter 7. Packages SimPEG Documentation, Release 0.1.9 Implementation in SimPEG.EM We consider two formulations in SimPEG.EM, both first-order and both in terms of one field and one flux. We allow for the definition of magnetic and electric sources (see for example: Ward and Hohmann, starting on page 144). The E-B formulation is in terms of the electric field and the magnetic flux: ⃗ + 𝑖𝜔 𝐵 ⃗ =𝑆 ⃗𝑚 ∇×𝐸 ⃗ − 𝜎𝐸 ⃗ =𝑆 ⃗𝑒 ∇ × 𝜇−1 𝐵 The H-J formulation is in terms of the current density and the magnetic field: ⃗ =𝑆 ⃗𝑚 ∇ × 𝜎 −1 𝐽⃗ + 𝑖𝜔𝜇𝐻 ⃗ − 𝐽⃗ = 𝑆 ⃗𝑒 ∇×𝐻 Discretizing For both formulations, we use a finite volume discretization and discretize fields on cell edges, fluxes on cell faces and physical properties in cell centers. This is particularly important when using symmetry to reduce the dimensionality of a problem (for instance on a 2D CylMesh, there are \(r\), \(z\) faces and \(\theta\) edges) For the two formulations, the discretization of the physical properties, fields and fluxes are summarized below. Note that resistivity is the inverse of conductivity, \(\rho = \sigma^{-1}\). E-B Formulation: Ce + 𝑖𝜔b = sm C T Mf𝜇−1 b − Me𝜎 e = Me se H-J Formulation: CT Mf𝜌 j + 𝑖𝜔Me𝜇 h = Me sm Ch − j = se 7.1. Electromagnetics 85 SimPEG Documentation, Release 0.1.9 API class SimPEG.EM.FDEM.FDEM.BaseFDEMProblem(mesh, **kwargs) Bases: SimPEG.EM.Base.BaseEMProblem We start by looking at Maxwell’s equations in the electric field \(\mathbf{e}\) and the magnetic flux density \(\mathbf{b}\) Ce + 𝑖𝜔b = sm 𝑇 C Mf𝜇−1 b − Me𝜎 e = Me se if using the E-B formulation (Problem_e or Problem_b) or the magnetic field \(\mathbf{h}\) and current density \(\mathbf{j}\) C𝑇 Mf𝜌 j + 𝑖𝜔Me𝜇 h = Me sm Ch − j = se if using the H-J formulation (Problem_j or Problem_h). The problem performs the elimination so that we are solving the system for \(\mathbf{e},\mathbf{b},\mathbf{j} \) or \(\mathbf{h}\) surveyPair alias of Survey fieldsPair alias of Fields fields(m=None) Solve the forward problem for the fields. Jvec(m, v, f=None) Sensitivity times a vector Jtvec(m, v, f=None) Sensitivity transpose times a vector getSourceTerm(freq) Evaluates the sources for a given frequency and puts them in matrix form 86 Chapter 7. Packages SimPEG Documentation, Release 0.1.9 Parameters freq (float) – Frequency Return type numpy.ndarray (nE or nF, nSrc) Returns S_m, S_e class SimPEG.EM.FDEM.FDEM.Problem_e(mesh, **kwargs) Bases: SimPEG.EM.FDEM.FDEM.BaseFDEMProblem By eliminating the magnetic flux density using b= 1 (−Ce + sm ) 𝑖𝜔 we can write Maxwell’s equations as a second order system in \(\mathbf{e}\) only: (︁ )︁ C𝑇 Mf𝜇−1 C + 𝑖𝜔Me𝜎 e = C𝑇 Mf𝜇−1 sm − 𝑖𝜔Me se which we solve for \(\mathbf{e}\). fieldsPair alias of Fields_e getA(freq) A = C𝑇 Mf𝜇−1 C + 𝑖𝜔Me𝜎 Parameters freq (float) – Frequency Return type scipy.sparse.csr_matrix Returns A getADeriv_m(freq, u, v, adjoint=False) getRHS(freq) RHS = C𝑇 Mf𝜇−1 sm − 𝑖𝜔Me se Parameters freq (float) – Frequency Return type numpy.ndarray (nE, nSrc) Returns RHS getRHSDeriv_m(freq, src, v, adjoint=False) class SimPEG.EM.FDEM.FDEM.Problem_b(mesh, **kwargs) Bases: SimPEG.EM.FDEM.FDEM.BaseFDEMProblem We eliminate \(\mathbf{e}\) using (︁ )︁ e = Me𝜎 −1 C𝑇 Mf𝜇−1 b − se and solve for \(\mathbf{b}\) using: (︁ )︁ CMe𝜎 −1 C𝑇 Mf𝜇−1 + 𝑖𝜔 b = sm + Me𝜎 −1 Me se Note: The inverse problem will not work with full anisotropy 7.1. Electromagnetics 87 SimPEG Documentation, Release 0.1.9 fieldsPair alias of Fields_b getA(freq) A = CMe𝜎 −1 C𝑇 Mf𝜇−1 + 𝑖𝜔 Parameters freq (float) – Frequency Return type scipy.sparse.csr_matrix Returns A getADeriv_m(freq, u, v, adjoint=False) getRHS(freq) RHS = sm + Me𝜎 −1 se Parameters freq (float) – Frequency Return type numpy.ndarray (nE, nSrc) Returns RHS getRHSDeriv_m(freq, src, v, adjoint=False) class SimPEG.EM.FDEM.FDEM.Problem_j(mesh, **kwargs) Bases: SimPEG.EM.FDEM.FDEM.BaseFDEMProblem We eliminate \(\mathbf{h}\) using h= )︀ 1 e −1 (︀ M𝜇 −C𝑇 Mf𝜌 j + Me sm 𝑖𝜔 and solve for \(\mathbf{j}\) using (︁ )︁ CMe𝜇 −1 C𝑇 Mf𝜌 + 𝑖𝜔 j = CMe𝜇 −1 Me sm − 𝑖𝜔se Note: This implementation does not yet work with full anisotropy!! fieldsPair alias of Fields_j getA(freq) A = CMemu−1 C𝑇 Mf𝜎−1 + 𝑖𝜔 Parameters freq (float) – Frequency Return type scipy.sparse.csr_matrix Returns A getADeriv_m(freq, u, v, adjoint=False) In this case, we assume that electrical conductivity, \(\sigma\) is the physical property of interest (i.e. \(\sigma\) = model.transform). Then we want = CMemu −1 CT 88 𝑑Mf𝜎−1 𝑑𝜎 −1 𝑑Mf𝜎−1 A(𝜎)v = CMemu−1 CT 𝑑m 𝑑m 𝑑𝜎 −1 𝑑𝜎 𝑑𝜎 𝑑m Chapter 7. Packages SimPEG Documentation, Release 0.1.9 getRHS(freq) RHS = CMe𝜇 −1 sm − 𝑖𝜔se Parameters freq (float) – Frequency Return type numpy.ndarray (nE, nSrc) Returns RHS getRHSDeriv_m(freq, src, v, adjoint=False) class SimPEG.EM.FDEM.FDEM.Problem_h(mesh, **kwargs) Bases: SimPEG.EM.FDEM.FDEM.BaseFDEMProblem We eliminate \(\mathbf{j}\) using j = Ch − se and solve for \(\mathbf{h}\) using (︀ 𝑇 f )︀ C M𝜌 C + 𝑖𝜔Me𝜇 h = Me sm + C𝑇 Mf𝜌 se fieldsPair alias of Fields_h getA(freq) A = C𝑇 Mf𝜌 C + 𝑖𝜔Me𝜇 Parameters freq (float) – Frequency Return type scipy.sparse.csr_matrix Returns A getADeriv_m(freq, u, v, adjoint=False) getRHS(freq) RHS = Me sm + C𝑇 Mf𝜌 se Parameters freq (float) – Frequency Return type numpy.ndarray (nE, nSrc) Returns RHS getRHSDeriv_m(freq, src, v, adjoint=False) FDEM Survey class SimPEG.EM.FDEM.SurveyFDEM.Rx(locs, rxType) Bases: SimPEG.Survey.BaseRx knownRxTypes = {‘hzi’: [’h’, ‘Ez’, ‘imag’], ‘ezr’: [’e’, ‘Ez’, ‘real’], ‘ezi’: [’e’, ‘Ez’, ‘imag’], ‘jxr’: [’j’, ‘Fx’, ‘real’], ‘jzi’: radius = None projField Field Type projection (e.g. e b ...) projGLoc Grid Location projection (e.g. Ex Fy ...) 7.1. Electromagnetics 89 SimPEG Documentation, Release 0.1.9 projComp Component projection (real/imag) projectFields(src, mesh, u) projectFieldsDeriv(src, mesh, u, v, adjoint=False) class SimPEG.EM.FDEM.SurveyFDEM.Survey(srcList, **kwargs) Bases: SimPEG.Survey.BaseSurvey docstring for SurveyFDEM srcPair alias of BaseSrc freqs Frequencies nFreq Number of frequencies nSrcByFreq getSrcByFreq(freq) Returns the sources associated with a specific frequency. projectFields(u) projectFieldsDeriv(u) 7.1.4 Utility Codes simpegEM Utilities SimPEG for EM provides a few EM specific utility codes, sources, and analytic functions. Analytic Functions - Time Analytic Functions - Frequency Sources 7.2 Richards Equation There are two different forms of Richards equation that differ on how they deal with the non-linearity in the timestepping term. The most fundamental form, referred to as the ‘mixed’-form of Richards Equation [Celia et al., 1990] 𝜕𝑘(𝜓) 𝜕𝜃(𝜓) − ∇ · 𝑘(𝜓)∇𝜓 − =0 𝜓∈Ω 𝜕𝑡 𝜕𝑧 where theta is water content, and psi is pressure head. This formulation of Richards equation is called the ‘mixed’-form because the equation is parameterized in psi but the time-stepping is in terms of theta. As noted in [Celia et al., 1990] the ‘head’-based form of Richards equation can be written in the continuous form as: 𝜕𝜃 𝜕𝜓 𝜕𝑘(𝜓) − ∇ · 𝑘(𝜓)∇𝜓 − =0 𝜓∈Ω 𝜕𝜓 𝜕𝑡 𝜕𝑧 90 Chapter 7. Packages SimPEG Documentation, Release 0.1.9 However, it can be shown that this does not conserve mass in the discrete formulation. Here we reproduce the results from Celia et al. (1990): 7.2.1 Richards 7.2. Richards Equation 91 SimPEG Documentation, Release 0.1.9 92 Chapter 7. Packages CHAPTER 8 Developer’s Documentation • Travis-CI Testing • Coveralls Testing 93 SimPEG Documentation, Release 0.1.9 94 Chapter 8. Developer’s Documentation CHAPTER 9 Project Index & Search • genindex • modindex • search 95 SimPEG Documentation, Release 0.1.9 96 Chapter 9. Project Index & Search CHAPTER 10 Examples 10.1 Examples 10.1.1 EM: FDEM: 1D: Inversion Here we will create and run a FDEM 1D inversion. 97 SimPEG Documentation, Release 0.1.9 0 100 Depth (m) 200 300 400 500 600 -4 10 98 10-3 Conductivity (S/m) 10-2 Chapter 10. Examples SimPEG Documentation, Release 0.1.9 10-14 Noisefree dobs Bz (T) 10-15 10-16 10-17 -5 10 10.1. Examples 10-4 Time (s) 10-3 99 SimPEG Documentation, Release 0.1.9 0 σtrue σpred 100 Depth (m) 200 300 400 500 600 -4 10 1 2 3 10-3 Conductivity (S/m) 10-2 from SimPEG import * import SimPEG.EM as EM from scipy.constants import mu_0 4 5 6 7 8 9 def run(plotIt=True): """ EM: FDEM: 1D: Inversion ======================= 10 Here we will create and run a FDEM 1D inversion. 11 12 """ 13 14 cs, ncx, ncz, npad = 5., 25, 15, 15 hx = [(cs,ncx), (cs,npad,1.3)] hz = [(cs,npad,-1.3), (cs,ncz), (cs,npad,1.3)] mesh = Mesh.CylMesh([hx,1,hz], '00C') 15 16 17 18 100 Chapter 10. Examples SimPEG Documentation, Release 0.1.9 19 20 21 22 23 24 25 26 27 28 29 30 active = mesh.vectorCCz<0. layer = (mesh.vectorCCz<0.) & (mesh.vectorCCz>=-100.) actMap = Maps.ActiveCells(mesh, active, np.log(1e-8), nC=mesh.nCz) mapping = Maps.ExpMap(mesh) * Maps.Vertical1DMap(mesh) * actMap sig_half = 2e-3 sig_air = 1e-8 sig_layer = 1e-3 sigma = np.ones(mesh.nCz)*sig_air sigma[active] = sig_half sigma[layer] = sig_layer mtrue = np.log(sigma[active]) 31 32 33 34 35 36 37 38 39 40 41 if plotIt: import matplotlib.pyplot as plt fig, ax = plt.subplots(1,1, figsize = (3, 6)) plt.semilogx(sigma[active], mesh.vectorCCz[active]) ax.set_ylim(-600, 0) ax.set_xlim(1e-4, 1e-2) ax.set_xlabel('Conductivity (S/m)', fontsize = 14) ax.set_ylabel('Depth (m)', fontsize = 14) ax.grid(color='k', alpha=0.5, linestyle='dashed', linewidth=0.5) 42 43 44 45 46 47 48 rxOffset=1e-3 rx = EM.TDEM.RxTDEM(np.array([[rxOffset, 0., 30]]), np.logspace(-5,-3, 31), 'bz') src = EM.TDEM.SrcTDEM_VMD_MVP([rx], np.array([0., 0., 80])) survey = EM.TDEM.SurveyTDEM([src]) prb = EM.TDEM.ProblemTDEM_b(mesh, mapping=mapping) 49 50 51 52 53 prb.Solver = SolverLU prb.timeSteps = [(1e-06, 20),(1e-05, 20), (0.0001, 20)] prb.pair(survey) dtrue = survey.dpred(mtrue) 54 55 56 57 58 59 60 61 survey.dtrue = dtrue std = 0.05 noise = std*abs(survey.dtrue)*np.random.randn(*survey.dtrue.shape) survey.dobs = survey.dtrue+noise survey.std = survey.dobs*0 + std survey.Wd = 1/(abs(survey.dobs)*std) 62 63 64 65 66 67 68 69 70 71 72 if plotIt: import matplotlib.pyplot as plt fig, ax = plt.subplots(1,1, figsize = (10, 6)) ax.loglog(rx.times, dtrue, 'b.-') ax.loglog(rx.times, survey.dobs, 'r.-') ax.legend(('Noisefree', '$d^{obs}$'), fontsize = 16) ax.set_xlabel('Time (s)', fontsize = 14) ax.set_ylabel('$B_z$ (T)', fontsize = 16) ax.set_xlabel('Time (s)', fontsize = 14) ax.grid(color='k', alpha=0.5, linestyle='dashed', linewidth=0.5) 73 74 75 76 dmisfit = DataMisfit.l2_DataMisfit(survey) regMesh = Mesh.TensorMesh([mesh.hz[mapping.maps[-1].indActive]]) reg = Regularization.Tikhonov(regMesh) 10.1. Examples 101 SimPEG Documentation, Release 0.1.9 opt = Optimization.InexactGaussNewton(maxIter = 5) invProb = InvProblem.BaseInvProblem(dmisfit, reg, opt) # Create an inversion object beta = Directives.BetaSchedule(coolingFactor=5, coolingRate=2) betaest = Directives.BetaEstimate_ByEig(beta0_ratio=1e0) inv = Inversion.BaseInversion(invProb, directiveList=[beta,betaest]) m0 = np.log(np.ones(mtrue.size)*sig_half) reg.alpha_s = 1e-2 reg.alpha_x = 1. prb.counter = opt.counter = Utils.Counter() opt.LSshorten = 0.5 opt.remember('xc') 77 78 79 80 81 82 83 84 85 86 87 88 89 mopt = inv.run(m0) 90 91 if plotIt: import matplotlib.pyplot as plt fig, ax = plt.subplots(1,1, figsize = (3, 6)) plt.semilogx(sigma[active], mesh.vectorCCz[active]) plt.semilogx(np.exp(mopt), mesh.vectorCCz[active]) ax.set_ylim(-600, 0) ax.set_xlim(1e-4, 1e-2) ax.set_xlabel('Conductivity (S/m)', fontsize = 14) ax.set_ylabel('Depth (m)', fontsize = 14) ax.grid(color='k', alpha=0.5, linestyle='dashed', linewidth=0.5) plt.legend(['$\sigma_{true}$', '$\sigma_{pred}$']) plt.show() 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 if __name__ == '__main__': run() 10.1.2 FLOW: Richards: 1D: Celia1990 There are two different forms of Richards equation that differ on how they deal with the non-linearity in the timestepping term. The most fundamental form, referred to as the ‘mixed’-form of Richards Equation Celia1990 𝜕𝜃(𝜓) 𝜕𝑘(𝜓) − ∇ · 𝑘(𝜓)∇𝜓 − =0 𝜓∈Ω 𝜕𝑡 𝜕𝑧 where \(\theta\) is water content, and \(\psi\) is pressure head. This formulation of Richards equation is called the ‘mixed’-form because the equation is parameterized in \(\psi\) but the time-stepping is in terms of \(\theta\). As noted in Celia1990 the ‘head’-based form of Richards equation can be written in the continuous form as: 𝜕𝜃 𝜕𝜓 𝜕𝑘(𝜓) − ∇ · 𝑘(𝜓)∇𝜓 − =0 𝜓∈Ω 𝜕𝜓 𝜕𝑡 𝜕𝑧 However, it can be shown that this does not conserve mass in the discrete formulation. Here we reproduce the results from Celia1990 demonstrating the head-based formulation and the mixed-formulation. 102 Chapter 10. Examples SimPEG Documentation, Release 0.1.9 Mixed Method 10 ∆t = 10 sec ∆t = 30 sec ∆t = 120 sec 30 40 50 60 2 30 40 50 60 70 0 1 ∆t = 10 sec ∆t = 30 sec ∆t = 120 sec 20 Pressure Head, cm Pressure Head, cm 20 Head-Based Method 10 5 10 15 20 25 Depth, cm 30 35 40 70 0 5 10 15 20 25 Depth, cm 30 35 40 from SimPEG import * from SimPEG.FLOW import Richards 3 4 5 6 7 def run(plotIt=True): """ FLOW: Richards: 1D: Celia1990 ============================= 8 9 10 There are two different forms of Richards equation that differ on how they deal with the non-linearity in the time-stepping term. 11 12 13 The most fundamental form, referred to as the 'mixed'-form of Richards Equation Celia1990_ 14 15 .. math:: 16 17 18 \\frac{\partial \\theta(\psi)}{\partial t} - \\nabla \cdot k(\psi) \\nabla \psi - \\frac{ \quad \psi \in \Omega 19 20 21 22 23 where \\\\(\\\\theta\\\\) is water content, and \\\\(\\\\psi\\\\) is pressure head. This formulation of Richards equation is called the 'mixed'-form because the equation is parameterized in \\\\(\\\\psi\\\\) but the time-stepping is in terms of \\\\(\\\\theta\\\\). 24 25 26 As noted in Celia1990_ the 'head'-based form of Richards equation can be written in the continuous form as: 27 28 .. math:: 29 30 \\frac{\partial \\theta}{\partial \psi}\\frac{\partial \psi}{\partial t} - \\nabla \cdot 31 32 However, it can be shown that this does not conserve mass in the discrete formulation. 33 34 Here we reproduce the results from Celia1990_ demonstrating the head-based formulation and th 35 36 37 38 39 40 41 .. _Celia1990: http://www.webpages.uidaho.edu/ch/papers/Celia.pdf """ M = Mesh.TensorMesh([np.ones(40)]) M.setCellGradBC('dirichlet') params = Richards.Empirical.HaverkampParams().celia1990 params['Ks'] = np.log(params['Ks']) 10.1. Examples 103 SimPEG Documentation, Release 0.1.9 E = Richards.Empirical.Haverkamp(M, **params) 42 43 bc = np.array([-61.5,-20.7]) h = np.zeros(M.nC) + bc[0] 44 45 46 47 def getFields(timeStep,method): timeSteps = np.ones(360/timeStep)*timeStep prob = Richards.RichardsProblem(M, mapping=E, timeSteps=timeSteps, boundaryConditions=bc, initialConditions=h, doNewton=False, method=method) return prob.fields(params['Ks']) 48 49 50 51 52 53 54 Hs_M10 = Hs_M30 = Hs_M120= Hs_H10 = Hs_H30 = Hs_H120= 55 56 57 58 59 60 getFields(10., 'mixed') getFields(30., 'mixed') getFields(120.,'mixed') getFields(10., 'head') getFields(30., 'head') getFields(120.,'head') 61 if not plotIt:return import matplotlib.pyplot as plt plt.figure(figsize=(13,5)) plt.subplot(121) plt.plot(40-M.gridCC, Hs_M10[-1],'b-') plt.plot(40-M.gridCC, Hs_M30[-1],'r-') plt.plot(40-M.gridCC, Hs_M120[-1],'k-') plt.ylim([-70,-10]) plt.title('Mixed Method') plt.xlabel('Depth, cm') plt.ylabel('Pressure Head, cm') plt.legend(('$\Delta t$ = 10 sec','$\Delta t$ = 30 sec','$\Delta t$ = 120 sec')) plt.subplot(122) plt.plot(40-M.gridCC, Hs_H10[-1],'b-') plt.plot(40-M.gridCC, Hs_H30[-1],'r-') plt.plot(40-M.gridCC, Hs_H120[-1],'k-') plt.ylim([-70,-10]) plt.title('Head-Based Method') plt.xlabel('Depth, cm') plt.ylabel('Pressure Head, cm') plt.legend(('$\Delta t$ = 10 sec','$\Delta t$ = 30 sec','$\Delta t$ = 120 sec')) plt.show() 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 if __name__ == '__main__': run() 104 Chapter 10. Examples SimPEG Documentation, Release 0.1.9 10.1.3 Forward BasicDirectCurrent TensorMesh (b) 0.000024 0.000018 0.8 CurvilinearMesh 0.000024 0.000018 0.8 0.000006 y 0.000000 0.4 0.000012 Voltage (V) 0.000012 0.6 0.000006 0.000006 0.6 0.000000 0.4 0.000006 0.000012 0.2 0.000018 0.2 1 0.4 x 0.6 0.8 0.000024 Voltage (V) (a) 0.000012 0.2 0.000018 0.2 0.4 x 0.6 0.8 0.000024 from SimPEG import Mesh, Utils, np, SolverLU 2 3 ## 2D DC forward modeling example with Tensor and Curvilinear Meshes 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 def run(plotIt=True): # Step1: Generate Tensor and Curvilinear Mesh sz = [40,40] # Tensor Mesh tM = Mesh.TensorMesh(sz) # Curvilinear Mesh rM = Mesh.CurvilinearMesh(Utils.meshutils.exampleLrmGrid(sz,'rotate')) # Step2: Direct Current (DC) operator def DCfun(mesh, pts): D = mesh.faceDiv G = D.T sigma = 1e-2*np.ones(mesh.nC) Msigi = mesh.getFaceInnerProduct(1./sigma) MsigI = Utils.sdInv(Msigi) A = D*MsigI*G A[-1,-1] /= mesh.vol[-1] # Remove null space rhs = np.zeros(mesh.nC) txind = Utils.meshutils.closestPoints(mesh, pts) rhs[txind] = np.r_[1,-1] return A, rhs 25 26 pts = np.vstack((np.r_[0.25, 0.5], np.r_[0.75, 0.5])) 27 28 29 30 31 #Step3: Solve DC problem (LU solver) AtM, rhstM = DCfun(tM, pts) AinvtM = SolverLU(AtM) phitM = AinvtM*rhstM 32 33 34 35 ArM, rhsrM = DCfun(rM, pts) AinvrM = SolverLU(ArM) phirM = AinvrM*rhsrM 36 37 if not plotIt: return 38 39 40 41 import matplotlib.pyplot as plt import matplotlib from matplotlib.mlab import griddata 42 10.1. Examples 105 SimPEG Documentation, Release 0.1.9 #Step4: Making Figure fig, axes = plt.subplots(1,2,figsize=(12*1.2,4*1.2)) label = ["(a)", "(b)"] opts = {} vmin, vmax = phitM.min(), phitM.max() dat = tM.plotImage(phitM, ax=axes[0], clim=(vmin, vmax), grid=True) 43 44 45 46 47 48 49 #TODO: At the moment Curvilinear Mesh do not have plotimage 50 51 Xi = tM.gridCC[:,0].reshape(sz[0], sz[1], order='F') Yi = tM.gridCC[:,1].reshape(sz[0], sz[1], order='F') PHIrM = griddata(rM.gridCC[:,0], rM.gridCC[:,1], phirM, Xi, Yi, interp='linear') axes[1].contourf(Xi, Yi, PHIrM, 100, vmin=vmin, vmax=vmax) 52 53 54 55 56 cb = plt.colorbar(dat[0], ax=axes[0]); cb.set_label("Voltage (V)") cb = plt.colorbar(dat[0], ax=axes[1]); cb.set_label("Voltage (V)") 57 58 59 tM.plotGrid(ax=axes[0], **opts) axes[0].set_title('TensorMesh') rM.plotGrid(ax=axes[1], **opts) axes[1].set_title('CurvilinearMesh') for i in range(2): axes[i].set_xlim(0.025, 0.975) axes[i].set_ylim(0.025, 0.975) axes[i].text(0., 1.0, label[i], fontsize=20) if i==0: axes[i].set_ylabel("y") else: axes[i].set_ylabel(" ") axes[i].set_xlabel("x") plt.show() 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 if __name__ == '__main__': run() 10.1.4 Inversion: Linear Problem Here we go over the basics of creating a linear problem and inversion. Columns of matrix G 1.0 1.5 True Model Recovered Model 0.8 1.0 0.6 0.4 0.5 0.2 0.0 0.0 0.2 0.4 0.5 0.6 0.8 0 1 20 40 60 80 100 1.0 0.0 0.2 0.4 0.6 0.8 1.0 from SimPEG import * 2 106 Chapter 10. Examples SimPEG Documentation, Release 0.1.9 3 4 5 6 7 def run(N=100, plotIt=True): """ Inversion: Linear Problem ========================= 8 Here we go over the basics of creating a linear problem and inversion. 9 10 11 """ 12 13 14 15 class LinearSurvey(Survey.BaseSurvey): def projectFields(self, u): return u 16 17 class LinearProblem(Problem.BaseProblem): 18 19 surveyPair = LinearSurvey 20 21 22 23 def __init__(self, mesh, G, **kwargs): Problem.BaseProblem.__init__(self, mesh, **kwargs) self.G = G 24 25 26 def fields(self, m, u=None): return self.G.dot(m) 27 28 29 def Jvec(self, m, v, u=None): return self.G.dot(v) 30 31 32 def Jtvec(self, m, v, u=None): return self.G.T.dot(v) 33 34 35 np.random.seed(1) 36 37 mesh = Mesh.TensorMesh([N]) 38 39 40 41 42 nk = 20 jk = np.linspace(1.,20.,nk) p = -0.25 q = 0.25 43 44 g = lambda k: np.exp(p*jk[k]*mesh.vectorCCx)*np.cos(2*np.pi*q*jk[k]*mesh.vectorCCx) 45 46 G = np.empty((nk, mesh.nC)) 47 48 49 for i in range(nk): G[i,:] = g(i) 50 51 52 53 54 mtrue = np.zeros(mesh.nC) mtrue[mesh.vectorCCx > 0.3] = 1. mtrue[mesh.vectorCCx > 0.45] = -0.5 mtrue[mesh.vectorCCx > 0.6] = 0 55 56 57 58 59 prob = LinearProblem(mesh, G) survey = LinearSurvey() survey.pair(prob) survey.makeSyntheticData(mtrue, std=0.01) 60 10.1. Examples 107 SimPEG Documentation, Release 0.1.9 M = prob.mesh 61 62 reg = Regularization.Tikhonov(mesh) dmis = DataMisfit.l2_DataMisfit(survey) opt = Optimization.InexactGaussNewton(maxIter=35) invProb = InvProblem.BaseInvProblem(dmis, reg, opt) beta = Directives.BetaSchedule() betaest = Directives.BetaEstimate_ByEig() inv = Inversion.BaseInversion(invProb, directiveList=[beta, betaest]) m0 = np.zeros_like(survey.mtrue) 63 64 65 66 67 68 69 70 71 mrec = inv.run(m0) 72 73 if plotIt: import matplotlib.pyplot as plt 74 75 76 fig, axes = plt.subplots(1,2,figsize=(12*1.2,4*1.2)) for i in range(prob.G.shape[0]): axes[0].plot(prob.G[i,:]) axes[0].set_title('Columns of matrix G') 77 78 79 80 81 axes[1].plot(M.vectorCCx, survey.mtrue, 'b-') axes[1].plot(M.vectorCCx, mrec, 'r-') axes[1].legend(('True Model', 'Recovered Model')) plt.show() 82 83 84 85 86 return prob, survey, mesh, mrec 87 88 if __name__ == '__main__': run() 10.1.5 Mesh: Basic: PlotImage You can use M.PlotImage to plot images on all of the Meshes. 0.8 0.6 0.4 0.2 0.0 0.0 108 1.0 0.9 0.8 0.7 0.6 0.5 0.4 0.3 0.2 0.1 0.0 0.2 0.4 x 0.6 0.8 1.0 TreeMesh 1.0 0.8 0.6 0.4 0.2 0.0 0.0 1.0 0.9 0.8 0.7 0.6 0.5 0.4 0.3 0.2 0.1 0.0 Random Field TensorMesh 1.0 Random y Field 90 y 89 0.2 0.4 x 0.6 0.8 1.0 Chapter 10. Examples SimPEG Documentation, Release 0.1.9 1 from SimPEG import * 2 3 4 5 6 def run(plotIt=True): """ Mesh: Basic: PlotImage ====================== 7 8 You can use M.PlotImage to plot images on all of the Meshes. 9 10 11 12 13 14 """ M = Mesh.TensorMesh([32,32]) v = Utils.ModelBuilder.randomModel(M.vnC, seed=789) v = Utils.mkvc(v) 15 16 17 18 19 20 21 22 23 24 O = Mesh.TreeMesh([32,32]) O.refine(1) def function(cell): if (cell.center[0] < 0.75 and cell.center[0] > 0.25 and cell.center[1] < 0.75 and cell.center[1] > 0.25):return 5 if (cell.center[0] < 0.9 and cell.center[0] > 0.1 and cell.center[1] < 0.9 and cell.center[1] > 0.1):return 4 return 3 O.refine(function) 25 26 P = M.getInterpolationMat(O.gridCC, 'CC') 27 28 ov = P * v 29 30 31 if plotIt: import matplotlib.pyplot as plt 32 33 fig, axes = plt.subplots(1,2,figsize=(10,5)) 34 35 36 37 out = M.plotImage(v, grid=True, ax=axes[0]) cb = plt.colorbar(out[0], ax=axes[0]); cb.set_label("Random Field") axes[0].set_title('TensorMesh') 38 39 40 41 out = O.plotImage(ov, grid=True, ax=axes[1], clim=[0,1]) cb = plt.colorbar(out[0], ax=axes[1]); cb.set_label("Random Field") axes[1].set_title('TreeMesh') 42 43 plt.show() 44 45 46 if __name__ == '__main__': run() 10.1.6 Mesh: Basic: Types Here we show SimPEG used to create three different types of meshes. 10.1. Examples 109 SimPEG Documentation, Release 0.1.9 TensorMesh 1.0 0.6 0.6 x2 0.6 x2 0.8 x2 0.8 0.4 0.4 0.4 0.2 0.2 0.2 0.2 0.4 x1 0.6 0.8 1.0 CurvilinearMesh 1.0 0.8 0.0 0.0 1 TreeMesh 1.0 0.0 0.0 0.2 0.4 x1 0.6 0.8 1.0 0.0 0.0 0.2 0.4 x1 0.6 0.8 1.0 from SimPEG import * 2 3 4 5 6 def run(plotIt=True): """ Mesh: Basic: Types ================== 7 Here we show SimPEG used to create three different types of meshes. 8 9 """ sz = [16,16] tM = Mesh.TensorMesh(sz) qM = Mesh.TreeMesh(sz) qM.refine(lambda cell: 4 if np.sqrt(((np.r_[cell.center]-0.5)**2).sum()) < 0.4 else 3) rM = Mesh.CurvilinearMesh(Utils.meshutils.exampleLrmGrid(sz,'rotate')) 10 11 12 13 14 15 16 if plotIt: import matplotlib.pyplot as plt fig, axes = plt.subplots(1,3,figsize=(14,5)) opts = {} tM.plotGrid(ax=axes[0], **opts) axes[0].set_title('TensorMesh') qM.plotGrid(ax=axes[1], **opts) axes[1].set_title('TreeMesh') rM.plotGrid(ax=axes[2], **opts) axes[2].set_title('CurvilinearMesh') plt.show() 17 18 19 20 21 22 23 24 25 26 27 28 29 30 if __name__ == '__main__': run() 10.1.7 Mesh: Operators: Cahn Hilliard This example is based on the example in the FiPy library. Please see their documentation for more information about the Cahn-Hilliard equation. The “Cahn-Hilliard” equation separates a field \( \phi \) into 0 and 1 with smooth transitions. (︂ )︂ 𝜕𝜑 𝜕𝑓 = ∇ · 𝐷∇ − 𝜖2 ∇2 𝜑 𝜕𝑡 𝜕𝜑 110 Chapter 10. Examples SimPEG Documentation, Release 0.1.9 Where \( f \) is the energy function \( f = ( a^2 / 2 )\phi^2(1 - \phi)^2 \) which drives \( \phi \) towards either 0 or 1, this competes with the term \(\epsilon^2 \nabla^2 \phi \) which is a diffusion term that creates smooth changes in \( \phi \). The equation can be factored: 𝜕𝜑 = ∇ · 𝐷∇𝜓 𝜕𝑡 2 𝜕 𝑓 𝜕𝑓 𝜓= (𝜑 − 𝜑old ) + − 𝜖2 ∇2 𝜑 2 𝜕𝜑 𝜕𝜑 Here we will need the derivatives of \( f \): 𝜕2𝑓 𝜕𝑓 = (𝑎2 /2)2𝜑(1 − 𝜑)(1 − 2𝜑) 2 = (𝑎2 /2)2[1 − 6𝜑(1 − 𝜑)] 𝜕𝜑 𝜕𝜑 The implementation below uses backwards Euler in time with an exponentially increasing time step. The initial \( \phi \) is a normally distributed field with a standard deviation of 0.1 and mean of 0.5. The grid is 60x60 and takes a few seconds to solve ~130 times. The results are seen below, and you can see the field separating as the time increases. 1 Elapsed Time: 0.1 Elapsed Time: 0.3 Elapsed Time: 0.7 Elapsed Time: 1.7 Elapsed Time: 4.4 Elapsed Time: 11.7 Elapsed Time: 30.5 Elapsed Time: 75.1 from SimPEG import * 2 3 4 5 6 def run(plotIt=True, n=60): """ Mesh: Operators: Cahn Hilliard ============================== 7 8 9 This example is based on the example in the FiPy_ library. Please see their documentation for more information about the Cahn-Hilliard equation. 10 11 The "Cahn-Hilliard" equation separates a field \\\\( \\\\phi \\\\) into 0 and 1 with smooth t 12 13 .. math:: 14 15 \\frac{\partial \phi}{\partial t} = \\nabla \cdot D \\nabla \left( \\frac{\partial f}{\pa 16 17 18 19 20 Where \\\\( f \\\\) is the energy function \\\\( f = ( a^2 / 2 )\\\\phi^2(1 - \\\\phi)^2 \\\\ which drives \\\\( \\\\phi \\\\) towards either 0 or 1, this competes with the term \\\\(\\\\epsilon^2 \\\\nabla^2 \\\\phi \\\\) which is a diffusion term that creates smooth ch The equation can be factored: 21 22 .. math:: 10.1. Examples 111 SimPEG Documentation, Release 0.1.9 23 \\frac{\partial \phi}{\partial t} = \\nabla \cdot D \\nabla \psi \\\\ \psi = \\frac{\partial^2 f}{\partial \phi^2} (\phi - \phi^{\\text{old}}) + \\frac{\partia 24 25 26 Here we will need the derivatives of \\\\( f \\\\): 27 28 .. math:: 29 30 \\frac{\partial f}{\partial \phi} = (a^2/2)2\phi(1-\phi)(1-2\phi) \\frac{\partial^2 f}{\partial \phi^2} = (a^2/2)2[1-6\phi(1-\phi)] 31 32 33 The implementation below uses backwards Euler in time with an exponentially increasing time s The initial \\\\( \\\\phi \\\\) is a normally distributed field with a standard deviation of The grid is 60x60 and takes a few seconds to solve ~130 times. The results are seen below, an field separating as the time increases. 34 35 36 37 38 .. _FiPy: http://www.ctcms.nist.gov/fipy/examples/cahnHilliard/generated/examples.cahnHilliar 39 40 """ 41 42 np.random.seed(5) 43 44 # Here we are going to rearrange the equations: 45 46 # # # # # # # # # 47 48 49 50 51 52 53 54 55 (phi_ - phi)/dt = A*(d2fdphi2*(phi_ - phi) + dfdphi - L*phi_) (phi_ - phi)/dt = A*(d2fdphi2*phi_ - d2fdphi2*phi + dfdphi - L*phi_) (phi_ - phi)/dt = A*d2fdphi2*phi_ + A*( - d2fdphi2*phi + dfdphi - L*phi_) phi_ - phi = dt*A*d2fdphi2*phi_ + dt*A*(- d2fdphi2*phi + dfdphi - L*phi_) phi_ - dt*A*d2fdphi2 * phi_ = dt*A*(- d2fdphi2*phi + dfdphi - L*phi_) + phi (I - dt*A*d2fdphi2) * phi_ = dt*A*(- d2fdphi2*phi + dfdphi - L*phi_) + phi (I - dt*A*d2fdphi2) * phi_ = dt*A*dfdphi - dt*A*d2fdphi2*phi - dt*A*L*phi_ + phi (dt*A*d2fdphi2 - I) * phi_ = dt*A*d2fdphi2*phi + dt*A*L*phi_ - phi - dt*A*dfdphi (dt*A*d2fdphi2 - I - dt*A*L) * phi_ = (dt*A*d2fdphi2 - I)*phi - dt*A*dfdphi 56 h = [(0.25,n)] M = Mesh.TensorMesh([h,h]) 57 58 59 # Constants D = a = epsilon = 1. I = Utils.speye(M.nC) 60 61 62 63 # Operators A = D * M.faceDiv * M.cellGrad L = epsilon**2 * M.faceDiv * M.cellGrad 64 65 66 67 duration = 75 elapsed = 0. dexp = -5 phi = np.random.normal(loc=0.5,scale=0.01,size=M.nC) ii, jj = 0, 0 PHIS = [] capture = np.logspace(-1,np.log10(duration),8) while elapsed < duration: dt = min(100, np.exp(dexp)) elapsed += dt dexp += 0.05 68 69 70 71 72 73 74 75 76 77 78 79 dfdphi 80 112 = a**2 * 2 * phi * (1 - phi) * (1 - 2 * phi) Chapter 10. Examples SimPEG Documentation, Release 0.1.9 81 d2fdphi2 = Utils.sdiag(a**2 * 2 * (1 - 6 * phi * (1 - phi))) 82 83 84 85 MAT = (dt*A*d2fdphi2 - I - dt*A*L) rhs = (dt*A*d2fdphi2 - I)*phi - dt*A*dfdphi phi = Solver(MAT)*rhs 86 87 88 89 90 91 if elapsed > capture[jj]: PHIS += [(elapsed, phi.copy())] jj += 1 if ii % 10 == 0: print ii, elapsed ii += 1 92 93 94 95 96 97 98 99 100 101 102 if plotIt: import matplotlib.pyplot as plt fig, axes = plt.subplots(2,4,figsize=(14,6)) axes = np.array(axes).flatten().tolist() for ii, ax in zip(np.linspace(0,len(PHIS)-1,len(axes)),axes): ii = int(ii) out = M.plotImage(PHIS[ii][1],ax=ax) ax.axis('off') ax.set_title('Elapsed Time: %4.1f'%PHIS[ii][0]) plt.show() 103 104 105 if __name__ == '__main__': run() 10.1.8 Mesh: QuadTree: Creation You can give the refine method a function, which is evaluated on every cell of the TreeMesh. Occasionally it is useful to initially refine to a constant level (e.g. 3 in this 32x32 mesh). This means the function is first evaluated on an 8x8 mesh (2^3). 10.1. Examples 113 SimPEG Documentation, Release 0.1.9 1.0 0.8 x2 0.6 0.4 0.2 0.0 0.0 1 0.2 0.4 x1 0.6 0.8 1.0 from SimPEG import * 2 3 4 5 6 def run(plotIt=True): """ Mesh: QuadTree: Creation ======================== 7 You can give the refine method a function, which is evaluated on every cell of the TreeMesh. 8 9 10 Occasionally it is useful to initially refine to a constant level (e.g. 3 in this 32x32 mesh). This means the function is first evaluated on an 8x8 mesh (2^3). 11 12 13 14 """ M = Mesh.TreeMesh([32,32]) M.refine(3) def function(cell): xyz = cell.center for i in range(3): if np.abs(np.sin(xyz[0]*np.pi*2)*0.5 + 0.5 - xyz[1]) < 0.2*i: return 6-i return 0 M.refine(function); if plotIt: M.plotGrid(showIt=True) 15 16 17 18 19 20 21 22 23 24 25 26 114 Chapter 10. Examples SimPEG Documentation, Release 0.1.9 27 28 if __name__ == '__main__': run() 10.1.9 Mesh: QuadTree: FaceDiv Simple QuadTree Mesh 33 12 13 30 13 11 28 11 2 2 20 3 0 0 18 1 10 0 34 0 5 10 14 31 14 12 29 5 5 6 22 23 8 3 4 4 21 1 19 35 6 Face Divergence 15 20 15 17 32 9 26 9 10 27 16 7 24 7 8 25 15 25 30 35 2 Cell Number 4 6 8 10 12 14 Face Number 1 from SimPEG import * 2 3 4 5 6 def run(plotIt=True, n=60): """ Mesh: QuadTree: FaceDiv ======================= 7 8 10.1. Examples 115 SimPEG Documentation, Release 0.1.9 9 """ 10 11 12 M = Mesh.TreeMesh([[(1,16)],[(1,16)]], levels=4) M._refineCell([0,0,0]) M._refineCell([0,0,1]) M._refineCell([4,4,2]) M.__dirty__ = True M.number() 13 14 15 16 17 18 19 20 if plotIt: import matplotlib.pyplot as plt fig, axes = plt.subplots(2,1,figsize=(10,10)) 21 22 23 24 M.plotGrid(cells=True, nodes=False, ax=axes[0]) axes[0].axis('off') axes[0].set_title('Simple QuadTree Mesh') axes[0].set_xlim([-1,17]) axes[0].set_ylim([-1,17]) 25 26 27 28 29 30 for ii, loc in zip(range(M.nC),M.gridCC): axes[0].text(loc[0]+0.2,loc[1],'%d'%ii, color='r') 31 32 33 axes[0].plot(M.gridFx[:,0],M.gridFx[:,1], 'g>') for ii, loc in zip(range(M.nFx),M.gridFx): axes[0].text(loc[0]+0.2,loc[1],'%d'%ii, color='g') 34 35 36 37 axes[0].plot(M.gridFy[:,0],M.gridFy[:,1], 'm^') for ii, loc in zip(range(M.nFy),M.gridFy): axes[0].text(loc[0]+0.2,loc[1]+0.2,'%d'%(ii+M.nFx), color='m') 38 39 40 41 axes[1].spy(M.faceDiv) axes[1].set_title('Face Divergence') axes[1].set_ylabel('Cell Number') axes[1].set_xlabel('Face Number') plt.show() 42 43 44 45 46 47 48 49 if __name__ == '__main__': run() 10.1.10 Mesh: QuadTree: Hanging Nodes You can give the refine method a function, which is evaluated on every cell of the TreeMesh. Occasionally it is useful to initially refine to a constant level (e.g. 3 in this 32x32 mesh). This means the function is first evaluated on an 8x8 mesh (2^3). 116 Chapter 10. Examples SimPEG Documentation, Release 0.1.9 1.0 Grid Cell Centers Nodes Hanging Nodes X faces Hanging X faces 0.8 x2 0.6 0.4 0.2 0.0 0.0 1 0.2 0.4 x1 0.6 0.8 1.0 from SimPEG import * 2 3 4 5 6 def run(plotIt=True): """ Mesh: QuadTree: Hanging Nodes ============================= 7 8 9 You can give the refine method a function, which is evaluated on every cell of the TreeMesh. 10 11 12 13 Occasionally it is useful to initially refine to a constant level (e.g. 3 in this 32x32 mesh). This means the function is first evaluated on an 8x8 mesh (2^3). 14 15 16 17 18 19 20 21 22 23 24 25 26 """ M = Mesh.TreeMesh([8,8]) def function(cell): xyz = cell.center dist = ((xyz - [0.25,0.25])**2).sum()**0.5 if dist < 0.25: return 3 return 2 M.refine(function); M.number() if plotIt: import matplotlib.pyplot as plt 10.1. Examples 117 SimPEG Documentation, Release 0.1.9 M.plotGrid(nodes=True, cells=True, facesX=True) plt.legend(('Grid', 'Cell Centers', 'Nodes', 'Hanging Nodes', 'X faces', 'Hanging X faces')) plt.show() 27 28 29 30 32 if __name__ == '__main__': run() 10.1.11 Mesh: Tensor: Creation For tensor meshes, there are some functions that can come in handy. For example, creating mesh tensors can be a bit time consuming, these can be created speedily by just giving numbers and sizes of padding. See the example below, that follows this notation: h1 = ( (cellSize, numPad, [, increaseFactor]), (cellSize, numCore), (cellSize, numPad, [, increaseFactor]) ) Note: You can center your mesh by passing a ‘C’ for the x0[i] position. A ‘N’ will make the entire mesh negative, and a ‘0’ (or a 0) will make the mesh start at zero. 0 50 100 x2 31 150 200 250 300 150 118 100 50 0 x1 50 100 150 Chapter 10. Examples SimPEG Documentation, Release 0.1.9 1 from SimPEG import * 2 3 4 def run(plotIt=True): """ 5 6 7 Mesh: Tensor: Creation ====================== 8 9 10 11 12 13 For tensor meshes, there are some functions that can come in handy. For example, creating mesh tensors can be a bit time consuming, these can be created speedily by just giving numbers and sizes of padding. See the example below, that follows this notation:: 14 15 h1 = ( (cellSize, numPad, [, increaseFactor]), (cellSize, numCore), (cellSize, numPad, [, increaseFactor]) 16 17 18 ) 19 20 21 .. note:: 22 23 24 25 You can center your mesh by passing a 'C' for the x0[i] position. A 'N' will make the entire mesh negative, and a '0' (or a 0) will make the mesh start at zero. 26 27 28 29 30 31 """ h1 = [(10, 5, -1.3), (5, 20), (10, 3, 1.3)] M = Mesh.TensorMesh([h1, h1], x0='CN') if plotIt: M.plotGrid(showIt=True) 32 33 34 if __name__ == '__main__': run() 10.1.12 External Notebooks • Example 1: Direct Current • Example 2: Seismic-Acoustic 10.1. Examples 119 SimPEG Documentation, Release 0.1.9 120 Chapter 10. Examples Python Module Index s SimPEG.Directives, 60 SimPEG.EM.FDEM.FDEM, 86 SimPEG.EM.FDEM.SurveyFDEM, 89 SimPEG.Inversion, 61 SimPEG.Mesh.BaseMesh, 22 SimPEG.Mesh.CylMesh, 15 SimPEG.Mesh.DiffOperators, 29 SimPEG.Mesh.InnerProducts, 35 SimPEG.Mesh.TensorMesh, 9 SimPEG.Optimization, 52 SimPEG.Problem, 40 SimPEG.Regularization, 49 SimPEG.Survey, 42 SimPEG.Tests, 79 SimPEG.Utils, 70 SimPEG.Utils.CounterUtils, 79 SimPEG.Utils.curvutils, 72 SimPEG.Utils.interputils, 77 SimPEG.Utils.matutils, 70 SimPEG.Utils.meshutils, 74 SimPEG.Utils.ModelBuilder, 76 SimPEG.Utils.SolverUtils, 72 121 SimPEG Documentation, Release 0.1.9 122 Python Module Index Index Symbols _doEndIterationRemember() (SimPEG.Optimization.Remember method), 58 _doEndIteration_BFGS() (SimPEG.Optimization.BFGS method), 58 _doEndIteration_ProjectedGradient() (SimPEG.Optimization.ProjectedGradient method), 58 _rememberThese (SimPEG.Optimization.Remember attribute), 57 _startup() (SimPEG.Optimization.ProjectedGradient method), 58 _startupRemember() (SimPEG.Optimization.Remember method), 58 _startup_BFGS() (SimPEG.Optimization.BFGS method), 58 A activeSet() (SimPEG.Optimization.ProjectedGradient method), 58 addBlock() (in module SimPEG.Utils.ModelBuilder), 76 alpha_s (SimPEG.Regularization.Tikhonov attribute), 51 alpha_x (SimPEG.Regularization.Tikhonov attribute), 51 alpha_xx (SimPEG.Regularization.Tikhonov attribute), 51 alpha_y (SimPEG.Regularization.Tikhonov attribute), 51 alpha_yy (SimPEG.Regularization.Tikhonov attribute), 51 alpha_z (SimPEG.Regularization.Tikhonov attribute), 51 alpha_zz (SimPEG.Regularization.Tikhonov attribute), 51 approxHinv (SimPEG.Optimization.InexactGaussNewton attribute), 59 area (SimPEG.Mesh.CylMesh.CylMesh attribute), 16 area (SimPEG.Mesh.TensorMesh.TensorMesh attribute), 12 area (SimPEG.Mesh.TreeMesh.TreeMesh attribute), 14 armijoGoldstein (SimPEG.Optimization.StoppingCriteria attribute), 52 aSet (SimPEG.Optimization.IterationPrinters attribute), 52 av() (in module SimPEG.Utils.matutils), 70 aveCC2F (SimPEG.Mesh.DiffOperators.DiffOperators attribute), 31 aveE2CC (SimPEG.Mesh.CylMesh.CylMesh attribute), 17 aveE2CC (SimPEG.Mesh.DiffOperators.DiffOperators attribute), 31 aveE2CC (SimPEG.Mesh.TreeMesh.TreeMesh attribute), 14 aveE2CCV (SimPEG.Mesh.CylMesh.CylMesh attribute), 17 aveE2CCV (SimPEG.Mesh.DiffOperators.DiffOperators attribute), 32 aveE2CCV (SimPEG.Mesh.TreeMesh.TreeMesh attribute), 14 aveEx2CC (SimPEG.Mesh.DiffOperators.DiffOperators attribute), 32 aveEx2CC (SimPEG.Mesh.TreeMesh.TreeMesh attribute), 14 aveEy2CC (SimPEG.Mesh.DiffOperators.DiffOperators attribute), 32 aveEy2CC (SimPEG.Mesh.TreeMesh.TreeMesh attribute), 14 aveEz2CC (SimPEG.Mesh.DiffOperators.DiffOperators attribute), 32 aveEz2CC (SimPEG.Mesh.TreeMesh.TreeMesh attribute), 14 aveF2CC (SimPEG.Mesh.CylMesh.CylMesh attribute), 17 aveF2CC (SimPEG.Mesh.DiffOperators.DiffOperators attribute), 31 aveF2CC (SimPEG.Mesh.TreeMesh.TreeMesh attribute), 14 aveF2CCV (SimPEG.Mesh.CylMesh.CylMesh attribute), 17 aveF2CCV (SimPEG.Mesh.DiffOperators.DiffOperators attribute), 31 aveF2CCV (SimPEG.Mesh.TreeMesh.TreeMesh attribute), 14 123 SimPEG Documentation, Release 0.1.9 aveFx2CC (SimPEG.Mesh.DiffOperators.DiffOperators attribute), 31 aveFx2CC (SimPEG.Mesh.TreeMesh.TreeMesh attribute), 14 aveFy2CC (SimPEG.Mesh.DiffOperators.DiffOperators attribute), 31 aveFy2CC (SimPEG.Mesh.TreeMesh.TreeMesh attribute), 14 aveFz2CC (SimPEG.Mesh.DiffOperators.DiffOperators attribute), 31 aveFz2CC (SimPEG.Mesh.TreeMesh.TreeMesh attribute), 14 aveN2CC (SimPEG.Mesh.DiffOperators.DiffOperators attribute), 32 aveN2CC (SimPEG.Mesh.TreeMesh.TreeMesh attribute), 14 aveN2E (SimPEG.Mesh.DiffOperators.DiffOperators attribute), 32 aveN2F (SimPEG.Mesh.DiffOperators.DiffOperators attribute), 32 avExtrap() (in module SimPEG.Utils.matutils), 70 B balance() (SimPEG.Mesh.TreeMesh.TreeMesh method), 14 BaseDataMisfit (class in SimPEG.DataMisfit), 47 BaseFDEMProblem (class in SimPEG.EM.FDEM.FDEM), 86 BaseInversion (class in SimPEG.Inversion), 61 BaseMesh (class in SimPEG.Mesh.BaseMesh), 22 BaseProblem (class in SimPEG.Problem), 40 BaseRectangularMesh (class in SimPEG.Mesh.BaseMesh), 27 BaseRegularization (class in SimPEG.Regularization), 49 BaseRx (class in SimPEG.Survey), 42 BaseSrc (class in SimPEG.Survey), 43 BaseSurvey (class in SimPEG.Survey), 43 BaseTensorMesh (class in SimPEG.Mesh.TensorMesh), 9 BaseTimeProblem (class in SimPEG.Problem), 41 BaseTimeRx (class in SimPEG.Survey), 42 beta (SimPEG.Optimization.IterationPrinters attribute), 53 beta0 (SimPEG.Directives.BetaEstimate_ByEig attribute), 60 beta0_ratio (SimPEG.Directives.BetaEstimate_ByEig attribute), 60 BetaEstimate_ByEig (class in SimPEG.Directives), 60 BetaSchedule (class in SimPEG.Directives), 61 BFGS (class in SimPEG.Optimization), 58 bfgs() (SimPEG.Optimization.BFGS method), 58 bfgsH0 (SimPEG.Optimization.BFGS attribute), 58 bfgsrec() (SimPEG.Optimization.BFGS method), 58 bindingSet (SimPEG.Optimization.StoppingCriteria attribute), 52 124 bindingSet() (SimPEG.Optimization.ProjectedGradient method), 58 bindingSet_LS (SimPEG.Optimization.StoppingCriteria attribute), 52 bSet (SimPEG.Optimization.IterationPrinters attribute), 53 C call() (SimPEG.Directives.DirectiveList method), 60 callback (SimPEG.Optimization.Minimize attribute), 53 cellBoundaryInd (SimPEG.Mesh.TensorMesh.TensorMesh attribute), 12 cellGrad (SimPEG.Mesh.CylMesh.CylMesh attribute), 16 cellGrad (SimPEG.Mesh.DiffOperators.DiffOperators attribute), 31 cellGradBC (SimPEG.Mesh.DiffOperators.DiffOperators attribute), 31 cellGradx (SimPEG.Mesh.DiffOperators.DiffOperators attribute), 31 cellGrady (SimPEG.Mesh.DiffOperators.DiffOperators attribute), 31 cellGradz (SimPEG.Mesh.DiffOperators.DiffOperators attribute), 31 checkBC() (in module SimPEG.Mesh.DiffOperators), 29 checkDerivative() (in module SimPEG.Tests), 81 clean() (SimPEG.Utils.SolverUtils.SolverDiag method), 72 closestPoints() (in module SimPEG.Utils.meshutils), 74 ComboMap (class in SimPEG.Maps), 69 comment (SimPEG.Optimization.IterationPrinters attribute), 53 comment (SimPEG.Optimization.Minimize attribute), 53 comments (SimPEG.Optimization.NewtonRoot attribute), 59 coolingFactor (SimPEG.Directives.BetaSchedule attribute), 61 coolingRate (SimPEG.Directives.BetaSchedule attribute), 61 corsen() (SimPEG.Mesh.TreeMesh.TreeMesh method), 14 count() (in module SimPEG.Utils.CounterUtils), 79 count() (SimPEG.Utils.CounterUtils.Counter method), 79 Counter (class in SimPEG.Utils.CounterUtils), 79 counter (SimPEG.DataMisfit.BaseDataMisfit attribute), 47 counter (SimPEG.Inversion.BaseInversion attribute), 62 counter (SimPEG.Optimization.Minimize attribute), 53 counter (SimPEG.Problem.BaseProblem attribute), 40 counter (SimPEG.Regularization.BaseRegularization attribute), 49 counter (SimPEG.Survey.BaseSurvey attribute), 43 countTic() (SimPEG.Utils.CounterUtils.Counter method), 79 Index SimPEG Documentation, Release 0.1.9 countToc() (SimPEG.Utils.CounterUtils.Counter edge (SimPEG.Mesh.TensorMesh.TensorMesh attribute), method), 79 12 curModel (SimPEG.Problem.BaseProblem attribute), 40 edge (SimPEG.Mesh.TreeMesh.TreeMesh attribute), 14 CylMesh (class in SimPEG.Mesh.CylMesh), 15 edgeCurl (SimPEG.Mesh.CylMesh.CylMesh attribute), 17 D edgeCurl (SimPEG.Mesh.DiffOperators.DiffOperators attribute), 31 Data (class in SimPEG.Survey), 43 edgeCurl (SimPEG.Mesh.TreeMesh.TreeMesh attribute), ddx() (in module SimPEG.Utils.matutils), 70 14 ddxCellGrad() (in module SimPEG.Mesh.DiffOperators), endIter() (SimPEG.Directives.BetaSchedule method), 61 29 (SimPEG.Directives.InversionDirective ddxCellGradBC() (in module Sim- endIter() method), 60 PEG.Mesh.DiffOperators), 30 debug (SimPEG.DataMisfit.BaseDataMisfit attribute), 47 endIter() (SimPEG.Directives.SaveModelEveryIteration method), 61 debug (SimPEG.Directives.DirectiveList attribute), 60 debug (SimPEG.Directives.InversionDirective attribute), endIter() (SimPEG.Directives.SaveOutputEveryIteration method), 61 60 endIter() (SimPEG.Directives.TargetMisfit method), 61 debug (SimPEG.Inversion.BaseInversion attribute), 61 eps (SimPEG.Optimization.Minimize attribute), 53 debug (SimPEG.Optimization.Minimize attribute), 53 debugLS (SimPEG.Optimization.Minimize attribute), 53 eval() (SimPEG.DataMisfit.BaseDataMisfit method), 47 defineBlock() (in module SimPEG.Utils.ModelBuilder), eval() (SimPEG.DataMisfit.l2_DataMisfit method), 48 eval() (SimPEG.Regularization.BaseRegularization 76 method), 49 defineElipse() (in module SimPEG.Utils.ModelBuilder), eval() (SimPEG.Regularization.Tikhonov method), 52 76 (SimPEG.DataMisfit.BaseDataMisfit defineTwoLayers() (in module Sim- eval2Deriv() method), 48 PEG.Utils.ModelBuilder), 76 (SimPEG.DataMisfit.l2_DataMisfit deleteTheseOnModelUpdate (Sim- eval2Deriv() method), 48 PEG.Problem.BaseProblem attribute), 40 eval2Deriv() (SimPEG.Regularization.BaseRegularization deriv() (SimPEG.Maps.ComboMap method), 70 method), 49 deriv() (SimPEG.Maps.ExpMap method), 68 evalDeriv() (SimPEG.DataMisfit.BaseDataMisfit deriv() (SimPEG.Maps.IdentityMap method), 67 method), 48 deriv() (SimPEG.Maps.Map2Dto3D method), 68 evalDeriv() (SimPEG.DataMisfit.l2_DataMisfit method), deriv() (SimPEG.Maps.Mesh2Mesh method), 69 48 deriv() (SimPEG.Maps.Vertical1DMap method), 68 evalDeriv() (SimPEG.Regularization.BaseRegularization diagEst() (in module SimPEG.Utils.matutils), 71 method), 49 DiffOperators (class in SimPEG.Mesh.DiffOperators), 30 evalDeriv() (SimPEG.Regularization.Tikhonov method), dim (SimPEG.Mesh.BaseMesh.BaseMesh attribute), 23 52 DirectiveList (class in SimPEG.Directives), 60 directiveList (SimPEG.Inversion.BaseInversion at- exampleLrmGrid() (in module SimPEG.Utils.meshutils), 74 tribute), 62 expectedOrders (SimPEG.Tests.OrderTest attribute), 80 dList (SimPEG.Directives.DirectiveList attribute), 60 dmisfit (SimPEG.Directives.InversionDirective attribute), ExpMap (class in SimPEG.Maps), 67 ExtractCoreMesh() (in module SimPEG.Utils.meshutils), 60 75 dobs (SimPEG.Survey.BaseSurvey attribute), 43 doEndIteration() (SimPEG.Optimization.Minimize F method), 57 doLS (SimPEG.Optimization.NewtonRoot attribute), 59 f (SimPEG.Optimization.IterationPrinters attribute), 52 (SimdoStartIteration() (SimPEG.Optimization.Minimize faceBoundaryInd PEG.Mesh.TensorMesh.TensorMesh attribute), method), 55 12 dpred() (SimPEG.Survey.BaseSurvey method), 44 faceDiv (SimPEG.Mesh.CylMesh.CylMesh attribute), 16 dtrue (SimPEG.Survey.BaseSurvey attribute), 43 faceDiv (SimPEG.Mesh.DiffOperators.DiffOperators attribute), 30 E faceDiv (SimPEG.Mesh.TreeMesh.TreeMesh attribute), edge (SimPEG.Mesh.CylMesh.CylMesh attribute), 16 14 Index 125 SimPEG Documentation, Release 0.1.9 faceDivx (SimPEG.Mesh.CylMesh.CylMesh attribute), getA() (SimPEG.EM.FDEM.FDEM.Problem_e method), 16 87 faceDivx (SimPEG.Mesh.DiffOperators.DiffOperators getA() (SimPEG.EM.FDEM.FDEM.Problem_h method), attribute), 30 89 faceDivy (SimPEG.Mesh.CylMesh.CylMesh attribute), getA() (SimPEG.EM.FDEM.FDEM.Problem_j method), 16 88 faceDivy (SimPEG.Mesh.DiffOperators.DiffOperators getADeriv_m() (SimPEG.EM.FDEM.FDEM.Problem_b attribute), 30 method), 88 faceDivz (SimPEG.Mesh.CylMesh.CylMesh attribute), getADeriv_m() (SimPEG.EM.FDEM.FDEM.Problem_e 16 method), 87 faceDivz (SimPEG.Mesh.DiffOperators.DiffOperators at- getADeriv_m() (SimPEG.EM.FDEM.FDEM.Problem_h tribute), 30 method), 89 faceInfo() (in module SimPEG.Utils.curvutils), 73 getADeriv_m() (SimPEG.EM.FDEM.FDEM.Problem_j fields() (SimPEG.EM.FDEM.FDEM.BaseFDEMProblem method), 88 method), 86 getBCProjWF() (SimPEG.Mesh.DiffOperators.DiffOperators fields() (SimPEG.Problem.BaseProblem method), 41 method), 31 fieldsPair (SimPEG.EM.FDEM.FDEM.BaseFDEMProblem getEdgeInnerProduct() (Simattribute), 86 PEG.Mesh.InnerProducts.InnerProducts fieldsPair (SimPEG.EM.FDEM.FDEM.Problem_b method), 36 attribute), 87 getEdgeInnerProductDeriv() (SimfieldsPair (SimPEG.EM.FDEM.FDEM.Problem_e PEG.Mesh.InnerProducts.InnerProducts attribute), 87 method), 36 fieldsPair (SimPEG.EM.FDEM.FDEM.Problem_h getError() (SimPEG.Tests.OrderTest method), 80 attribute), 89 getFaceInnerProduct() (SimfieldsPair (SimPEG.EM.FDEM.FDEM.Problem_j PEG.Mesh.InnerProducts.InnerProducts attribute), 88 method), 35 fill (SimPEG.Mesh.TreeMesh.TreeMesh attribute), 12 getFaceInnerProductDeriv() (SimfindSearchDirection() (SimPEG.Optimization.BFGS PEG.Mesh.InnerProducts.InnerProducts method), 58 method), 36 findSearchDirection() (Sim- getIndicesBlock() (in module SimPEG.Optimization.GaussNewton method), PEG.Utils.ModelBuilder), 76 59 getInterpolationMat() (SimfindSearchDirection() (SimPEG.Mesh.TensorMesh.BaseTensorMesh PEG.Optimization.InexactGaussNewton method), 10 method), 59 getInterpolationMat() (SimfindSearchDirection() (SimPEG.Optimization.Minimize PEG.Mesh.TreeMesh.TreeMesh method), method), 56 14 findSearchDirection() (Sim- getInterpolationMatCartMesh() (SimPEG.Optimization.ProjectedGradient method), PEG.Mesh.CylMesh.CylMesh method), 58 17 findSearchDirection() (Sim- getP() (SimPEG.Survey.BaseRx method), 42 PEG.Optimization.SteepestDescent method), getP() (SimPEG.Survey.BaseTimeRx method), 42 59 getQuadratic() (in module SimPEG.Tests), 81 finish() (SimPEG.Directives.InversionDirective method), getRHS() (SimPEG.EM.FDEM.FDEM.Problem_b 60 method), 88 finish() (SimPEG.Optimization.Minimize method), 55 getRHS() (SimPEG.EM.FDEM.FDEM.Problem_e freqs (SimPEG.EM.FDEM.SurveyFDEM.Survey atmethod), 87 tribute), 90 getRHS() (SimPEG.EM.FDEM.FDEM.Problem_h method), 89 G getRHS() (SimPEG.EM.FDEM.FDEM.Problem_j method), 89 GaussNewton (class in SimPEG.Optimization), 58 getRHSDeriv_m() (SimgetA() (SimPEG.EM.FDEM.FDEM.Problem_b method), PEG.EM.FDEM.FDEM.Problem_b method), 88 88 126 Index SimPEG Documentation, Release 0.1.9 getRHSDeriv_m() (Sim- hy (SimPEG.Mesh.TensorMesh.BaseTensorMesh atPEG.EM.FDEM.FDEM.Problem_e method), tribute), 9 87 hz (SimPEG.Mesh.TensorMesh.BaseTensorMesh atgetRHSDeriv_m() (Simtribute), 9 PEG.EM.FDEM.FDEM.Problem_h method), I 89 getRHSDeriv_m() (Sim- Identity (class in SimPEG.Utils.matutils), 72 PEG.EM.FDEM.FDEM.Problem_j method), IdentityMap (class in SimPEG.Maps), 66 89 inactiveSet() (SimPEG.Optimization.ProjectedGradient getSourceTerm() (SimPEG.EM.FDEM.FDEM.BaseFDEMProblem method), 58 method), 86 ind2sub() (in module SimPEG.Utils.matutils), 71 getSpatialP() (SimPEG.Survey.BaseTimeRx method), 42 indexCube() (in module SimPEG.Utils.curvutils), 73 getSrcByFreq() (SimPEG.EM.FDEM.SurveyFDEM.Survey InexactGaussNewton (class in SimPEG.Optimization), 59 method), 90 initialize() (SimPEG.Directives.BetaEstimate_ByEig getSubArray() (in module SimPEG.Utils.matutils), 71 method), 60 getTensor() (SimPEG.Mesh.TensorMesh.BaseTensorMesh initialize() (SimPEG.Directives.InversionDirective method), 10 method), 60 getTimeP() (SimPEG.Survey.BaseTimeRx method), 42 initialize() (SimPEG.Directives.SaveModelEveryIteration gridCC (SimPEG.Mesh.TensorMesh.BaseTensorMesh atmethod), 61 tribute), 10 initialize() (SimPEG.Directives.SaveOutputEveryIteration gridCC (SimPEG.Mesh.TreeMesh.TreeMesh attribute), method), 61 14 InnerProducts (class in SimPEG.Mesh.InnerProducts), 35 gridEx (SimPEG.Mesh.TensorMesh.BaseTensorMesh at- interpmat() (in module SimPEG.Utils.interputils), 77 tribute), 10 inv (SimPEG.Regularization.BaseRegularization atgridEx (SimPEG.Mesh.TreeMesh.TreeMesh attribute), tribute), 49 14 inv2X2BlockDiagonal() (in module SimgridEy (SimPEG.Mesh.TensorMesh.BaseTensorMesh atPEG.Utils.matutils), 71 tribute), 10 inv3X3BlockDiagonal() (in module SimgridEy (SimPEG.Mesh.TreeMesh.TreeMesh attribute), PEG.Utils.matutils), 71 14 inverse() (SimPEG.Maps.ExpMap method), 67 gridEz (SimPEG.Mesh.TensorMesh.BaseTensorMesh at- inverse() (SimPEG.Maps.IdentityMap method), 66 tribute), 10 inversion (SimPEG.Directives.DirectiveList attribute), 60 gridEz (SimPEG.Mesh.TreeMesh.TreeMesh attribute), inversion (SimPEG.Directives.InversionDirective at14 tribute), 60 gridFx (SimPEG.Mesh.TensorMesh.BaseTensorMesh at- InversionDirective (class in SimPEG.Directives), 60 tribute), 10 invProb (SimPEG.Directives.InversionDirective atgridFx (SimPEG.Mesh.TreeMesh.TreeMesh attribute), tribute), 60 14 invProb (SimPEG.Regularization.BaseRegularization atgridFy (SimPEG.Mesh.TensorMesh.BaseTensorMesh attribute), 49 tribute), 10 invPropertyTensor() (in module SimPEG.Utils.matutils), gridFy (SimPEG.Mesh.TreeMesh.TreeMesh attribute), 71 14 isInside() (SimPEG.Mesh.TensorMesh.BaseTensorMesh gridFz (SimPEG.Mesh.TensorMesh.BaseTensorMesh atmethod), 10 tribute), 10 ispaired (SimPEG.Problem.BaseProblem attribute), 40 gridFz (SimPEG.Mesh.TreeMesh.TreeMesh attribute), 14 isSymmetric (SimPEG.Mesh.CylMesh.CylMesh atgridN (SimPEG.Mesh.TensorMesh.BaseTensorMesh attribute), 15 tribute), 10 isSynthetic (SimPEG.Survey.BaseSurvey attribute), 44 gridN (SimPEG.Mesh.TreeMesh.TreeMesh attribute), 14 iteration (SimPEG.Optimization.IterationPrinters attribute), 52 H iteration (SimPEG.Optimization.StoppingCriteria attribute), 52 h (SimPEG.Mesh.TensorMesh.BaseTensorMesh atiterationLS (SimPEG.Optimization.IterationPrinters attribute), 9 tribute), 52 hx (SimPEG.Mesh.TensorMesh.BaseTensorMesh attribute), 9 Index 127 SimPEG Documentation, Release 0.1.9 iterationLS (SimPEG.Optimization.StoppingCriteria attribute), 52 IterationPrinters (class in SimPEG.Optimization), 52 itType (SimPEG.Optimization.IterationPrinters attribute), 52 J Jtvec() (SimPEG.EM.FDEM.FDEM.BaseFDEMProblem method), 86 Jtvec() (SimPEG.Problem.BaseProblem method), 41 Jtvec_approx() (SimPEG.Problem.BaseProblem method), 41 Jvec() (SimPEG.EM.FDEM.FDEM.BaseFDEMProblem method), 86 Jvec() (SimPEG.Problem.BaseProblem method), 40 Jvec_approx() (SimPEG.Problem.BaseProblem method), 41 K knownRxTypes (SimPEG.EM.FDEM.SurveyFDEM.Rx attribute), 89 knownRxTypes (SimPEG.Survey.BaseRx attribute), 42 kron3() (in module SimPEG.Utils.matutils), 70 L mapping (SimPEG.Problem.BaseProblem attribute), 40 mapping (SimPEG.Regularization.BaseRegularization attribute), 49 maxIter (SimPEG.Optimization.Minimize attribute), 53 maxIter (SimPEG.Optimization.NewtonRoot attribute), 59 maxIterCG (SimPEG.Optimization.InexactGaussNewton attribute), 59 maxIterCG (SimPEG.Optimization.ProjectedGradient attribute), 58 maxIterLS (SimPEG.Optimization.Minimize attribute), 53 maxLevel (SimPEG.Mesh.TreeMesh.TreeMesh attribute), 13 maxLS (SimPEG.Optimization.NewtonRoot attribute), 59 maxStep (SimPEG.Optimization.Minimize attribute), 53 mesh (SimPEG.Maps.IdentityMap attribute), 66 mesh (SimPEG.Problem.BaseProblem attribute), 40 mesh (SimPEG.Regularization.BaseRegularization attribute), 49 mesh (SimPEG.Survey.BaseSurvey attribute), 43 Mesh2Mesh (class in SimPEG.Maps), 69 meshDimension (SimPEG.Tests.OrderTest attribute), 80 meshSizes (SimPEG.Tests.OrderTest attribute), 80 meshTensor() (in module SimPEG.Utils.meshutils), 74 meshTypes (SimPEG.Tests.OrderTest attribute), 80 Minimize (class in SimPEG.Optimization), 53 minimize() (SimPEG.Optimization.Minimize method), 53 mkvc() (in module SimPEG.Utils.matutils), 70 modifySearchDirection() (SimPEG.Optimization.Minimize method), 56 modifySearchDirectionBreak() (SimPEG.Optimization.Minimize method), 57 moving_x (SimPEG.Optimization.StoppingCriteria attribute), 52 mref (SimPEG.Regularization.BaseRegularization attribute), 49 mtrue (SimPEG.Survey.BaseSurvey attribute), 43 l2_DataMisfit (class in SimPEG.DataMisfit), 48 layeredModel() (in module SimPEG.Utils.ModelBuilder), 76 levels (SimPEG.Mesh.TreeMesh.TreeMesh attribute), 12 loc (SimPEG.Survey.BaseSrc attribute), 43 locs (SimPEG.Survey.BaseRx attribute), 42 lower (SimPEG.Optimization.ProjectedGradient attribute), 58 LS_armijoGoldstein (SimPEG.Optimization.IterationPrinters attribute), 52 LS_ft (SimPEG.Optimization.IterationPrinters attribute), 52 LS_t (SimPEG.Optimization.IterationPrinters attribute), 52 LSreduction (SimPEG.Optimization.Minimize attribute), N 53 LSshorten (SimPEG.Optimization.Minimize attribute), name (SimPEG.Inversion.BaseInversion attribute), 61 name (SimPEG.Optimization.BFGS attribute), 58 53 name (SimPEG.Optimization.GaussNewton attribute), 58 M name (SimPEG.Optimization.InexactGaussNewton attribute), 59 makePropertyTensor() (in module Simname (SimPEG.Optimization.Minimize attribute), 53 PEG.Utils.matutils), 71 name (SimPEG.Optimization.ProjectedGradient atmakeSyntheticData() (SimPEG.Survey.BaseSurvey tribute), 58 method), 44 name (SimPEG.Optimization.SteepestDescent attribute), Map2Dto3D (class in SimPEG.Maps), 68 59 mapPair (SimPEG.Problem.BaseProblem attribute), 40 name (SimPEG.Tests.OrderTest attribute), 80 mapPair (SimPEG.Regularization.BaseRegularization atnameLS (SimPEG.Optimization.Minimize attribute), 56 tribute), 49 128 Index SimPEG Documentation, Release 0.1.9 nbfgs (SimPEG.Optimization.BFGS attribute), 58 nC (SimPEG.Mesh.BaseMesh.BaseMesh attribute), 23 nC (SimPEG.Mesh.BaseMesh.BaseRectangularMesh attribute), 28 nC (SimPEG.Mesh.TreeMesh.TreeMesh attribute), 13 nCx (SimPEG.Mesh.BaseMesh.BaseRectangularMesh attribute), 27 nCy (SimPEG.Mesh.BaseMesh.BaseRectangularMesh attribute), 27 nCz (SimPEG.Mesh.BaseMesh.BaseRectangularMesh attribute), 27 nD (SimPEG.Survey.BaseRx attribute), 42 nD (SimPEG.Survey.BaseSrc attribute), 43 nD (SimPEG.Survey.BaseSurvey attribute), 44 nD (SimPEG.Survey.BaseTimeRx attribute), 42 ndgrid() (in module SimPEG.Utils.matutils), 70 nE (SimPEG.Mesh.BaseMesh.BaseMesh attribute), 25 nE (SimPEG.Mesh.TreeMesh.TreeMesh attribute), 13 NewtonRoot (class in SimPEG.Optimization), 59 nEx (SimPEG.Mesh.BaseMesh.BaseMesh attribute), 24 nEx (SimPEG.Mesh.BaseMesh.BaseRectangularMesh attribute), 28 nEx (SimPEG.Mesh.TreeMesh.TreeMesh attribute), 13 nEy (SimPEG.Mesh.BaseMesh.BaseMesh attribute), 24 nEy (SimPEG.Mesh.BaseMesh.BaseRectangularMesh attribute), 28 nEy (SimPEG.Mesh.TreeMesh.TreeMesh attribute), 13 nEz (SimPEG.Mesh.BaseMesh.BaseMesh attribute), 24 nEz (SimPEG.Mesh.BaseMesh.BaseRectangularMesh attribute), 29 nEz (SimPEG.Mesh.CylMesh.CylMesh attribute), 16 nEz (SimPEG.Mesh.TreeMesh.TreeMesh attribute), 13 nF (SimPEG.Mesh.BaseMesh.BaseMesh attribute), 26 nF (SimPEG.Mesh.TreeMesh.TreeMesh attribute), 13 nFreq (SimPEG.EM.FDEM.SurveyFDEM.Survey attribute), 90 nFx (SimPEG.Mesh.BaseMesh.BaseMesh attribute), 25 nFx (SimPEG.Mesh.BaseMesh.BaseRectangularMesh attribute), 29 nFx (SimPEG.Mesh.TreeMesh.TreeMesh attribute), 13 nFy (SimPEG.Mesh.BaseMesh.BaseMesh attribute), 25 nFy (SimPEG.Mesh.BaseMesh.BaseRectangularMesh attribute), 29 nFy (SimPEG.Mesh.TreeMesh.TreeMesh attribute), 13 nFz (SimPEG.Mesh.BaseMesh.BaseMesh attribute), 25 nFz (SimPEG.Mesh.BaseMesh.BaseRectangularMesh attribute), 29 nFz (SimPEG.Mesh.TreeMesh.TreeMesh attribute), 13 nhE (SimPEG.Mesh.TreeMesh.TreeMesh attribute), 13 nhEx (SimPEG.Mesh.TreeMesh.TreeMesh attribute), 13 nhEy (SimPEG.Mesh.TreeMesh.TreeMesh attribute), 13 nhEz (SimPEG.Mesh.TreeMesh.TreeMesh attribute), 13 nhF (SimPEG.Mesh.TreeMesh.TreeMesh attribute), 13 nhFx (SimPEG.Mesh.TreeMesh.TreeMesh attribute), 13 Index nhFy (SimPEG.Mesh.TreeMesh.TreeMesh attribute), 13 nhFz (SimPEG.Mesh.TreeMesh.TreeMesh attribute), 13 nhN (SimPEG.Mesh.TreeMesh.TreeMesh attribute), 13 nN (SimPEG.Mesh.BaseMesh.BaseMesh attribute), 23 nN (SimPEG.Mesh.BaseMesh.BaseRectangularMesh attribute), 28 nN (SimPEG.Mesh.TreeMesh.TreeMesh attribute), 13 nNx (SimPEG.Mesh.BaseMesh.BaseRectangularMesh attribute), 27 nNx (SimPEG.Mesh.CylMesh.CylMesh attribute), 15 nNy (SimPEG.Mesh.BaseMesh.BaseRectangularMesh attribute), 27 nNy (SimPEG.Mesh.CylMesh.CylMesh attribute), 15 nNz (SimPEG.Mesh.BaseMesh.BaseRectangularMesh attribute), 27 nodalGrad (SimPEG.Mesh.CylMesh.CylMesh attribute), 17 nodalGrad (SimPEG.Mesh.DiffOperators.DiffOperators attribute), 31 nodalGrad (SimPEG.Mesh.TreeMesh.TreeMesh attribute), 14 nodalLaplacian (SimPEG.Mesh.CylMesh.CylMesh attribute), 17 nodalLaplacian (SimPEG.Mesh.DiffOperators.DiffOperators attribute), 31 norm_g (SimPEG.Optimization.IterationPrinters attribute), 52 norm_g (SimPEG.Optimization.StoppingCriteria attribute), 52 normal (SimPEG.Maps.Map2Dto3D attribute), 68 normals (SimPEG.Mesh.BaseMesh.BaseMesh attribute), 26 nP (SimPEG.Maps.ComboMap attribute), 69 nP (SimPEG.Maps.IdentityMap attribute), 66 nP (SimPEG.Maps.Map2Dto3D attribute), 68 nP (SimPEG.Maps.Mesh2Mesh attribute), 69 nP (SimPEG.Maps.Vertical1DMap attribute), 68 nSrc (SimPEG.Survey.BaseSurvey attribute), 44 nSrcByFreq (SimPEG.EM.FDEM.SurveyFDEM.Survey attribute), 90 nT (SimPEG.Problem.BaseTimeProblem attribute), 42 ntE (SimPEG.Mesh.TreeMesh.TreeMesh attribute), 13 ntEx (SimPEG.Mesh.TreeMesh.TreeMesh attribute), 13 ntEy (SimPEG.Mesh.TreeMesh.TreeMesh attribute), 13 ntEz (SimPEG.Mesh.TreeMesh.TreeMesh attribute), 13 ntF (SimPEG.Mesh.TreeMesh.TreeMesh attribute), 13 ntFx (SimPEG.Mesh.TreeMesh.TreeMesh attribute), 13 ntFy (SimPEG.Mesh.TreeMesh.TreeMesh attribute), 13 ntFz (SimPEG.Mesh.TreeMesh.TreeMesh attribute), 13 ntN (SimPEG.Mesh.TreeMesh.TreeMesh attribute), 13 number() (SimPEG.Mesh.TreeMesh.TreeMesh method), 14 129 SimPEG Documentation, Release 0.1.9 O opt (SimPEG.Directives.InversionDirective attribute), 60 opt (SimPEG.Regularization.BaseRegularization attribute), 49 OrderTest (class in SimPEG.Tests), 79 orderTest() (SimPEG.Tests.OrderTest method), 80 P pair() (SimPEG.Problem.BaseProblem method), 40 pair() (SimPEG.Survey.BaseSurvey method), 43 parent (SimPEG.Optimization.Minimize attribute), 53 parent (SimPEG.Regularization.BaseRegularization attribute), 49 permuteCC (SimPEG.Mesh.TreeMesh.TreeMesh attribute), 13 permuteE (SimPEG.Mesh.TreeMesh.TreeMesh attribute), 13 permuteF (SimPEG.Mesh.TreeMesh.TreeMesh attribute), 13 phi_d (SimPEG.Optimization.IterationPrinters attribute), 53 phi_d_target_Inversion (SimPEG.Optimization.StoppingCriteria attribute), 52 phi_d_target_Minimize (SimPEG.Optimization.StoppingCriteria attribute), 52 phi_m (SimPEG.Optimization.IterationPrinters attribute), 53 plotGrid() (SimPEG.Mesh.TreeMesh.TreeMesh method), 15 plotImage() (SimPEG.Mesh.TreeMesh.TreeMesh method), 15 plotSlice() (SimPEG.Mesh.TreeMesh.TreeMesh method), 15 point2index() (SimPEG.Mesh.TreeMesh.TreeMesh method), 14 printDone() (SimPEG.Optimization.Minimize method), 55 printInit() (SimPEG.Optimization.Minimize method), 55 printIter() (SimPEG.Optimization.Minimize method), 55 prob (SimPEG.Directives.InversionDirective attribute), 60 prob (SimPEG.Regularization.BaseRegularization attribute), 49 prob (SimPEG.Survey.BaseSurvey attribute), 43 Problem_b (class in SimPEG.EM.FDEM.FDEM), 87 Problem_e (class in SimPEG.EM.FDEM.FDEM), 87 Problem_h (class in SimPEG.EM.FDEM.FDEM), 89 Problem_j (class in SimPEG.EM.FDEM.FDEM), 88 projComp (SimPEG.EM.FDEM.SurveyFDEM.Rx attribute), 90 projectEdgeVector() (SimPEG.Mesh.BaseMesh.BaseMesh method), 130 26 ProjectedGradient (class in SimPEG.Optimization), 58 projectFaceVector() (SimPEG.Mesh.BaseMesh.BaseMesh method), 26 projectFields() (SimPEG.EM.FDEM.SurveyFDEM.Rx method), 90 projectFields() (SimPEG.EM.FDEM.SurveyFDEM.Survey method), 90 projectFields() (SimPEG.Survey.BaseSurvey method), 44 projectFieldsDeriv() (SimPEG.EM.FDEM.SurveyFDEM.Rx method), 90 projectFieldsDeriv() (SimPEG.EM.FDEM.SurveyFDEM.Survey method), 90 projectFieldsDeriv() (SimPEG.Survey.BaseSurvey method), 44 projection() (SimPEG.Optimization.Minimize method), 55 projection() (SimPEG.Optimization.ProjectedGradient method), 58 projField (SimPEG.EM.FDEM.SurveyFDEM.Rx attribute), 89 projGLoc (SimPEG.EM.FDEM.SurveyFDEM.Rx attribute), 89 projGLoc (SimPEG.Survey.BaseRx attribute), 42 PropMap (SimPEG.Problem.BaseProblem attribute), 40 R r() (SimPEG.Mesh.BaseMesh.BaseRectangularMesh method), 29 radius (SimPEG.EM.FDEM.SurveyFDEM.Rx attribute), 89 randomModel() (in module SimPEG.Utils.ModelBuilder), 76 readUBCTensorMesh() (in module SimPEG.Utils.meshutils), 75 readUBCTensorModel() (in module SimPEG.Utils.meshutils), 75 readVTRFile() (in module SimPEG.Utils.meshutils), 75 recall() (SimPEG.Optimization.Remember method), 58 refine() (SimPEG.Mesh.TreeMesh.TreeMesh method), 13 reg (SimPEG.Directives.InversionDirective attribute), 60 reg (SimPEG.Regularization.BaseRegularization attribute), 49 Remember (class in SimPEG.Optimization), 57 remember() (SimPEG.Optimization.Remember method), 57 residual() (SimPEG.Survey.BaseSurvey method), 44 root() (SimPEG.Optimization.NewtonRoot method), 59 Rosenbrock() (in module SimPEG.Tests), 80 run() (SimPEG.Inversion.BaseInversion method), 62 Rx (class in SimPEG.EM.FDEM.SurveyFDEM), 89 Index SimPEG Documentation, Release 0.1.9 rxList (SimPEG.Survey.BaseSrc attribute), 43 rxPair (SimPEG.Survey.BaseSrc attribute), 43 rxType (SimPEG.Survey.BaseRx attribute), 42 S save() (SimPEG.Optimization.Minimize method), 57 SaveModelEveryIteration (class in SimPEG.Directives), 61 SaveOutputEveryIteration (class in SimPEG.Directives), 61 scalarConductivity() (in module SimPEG.Utils.ModelBuilder), 76 scaleSearchDirection() (SimPEG.Optimization.Minimize method), 56 sdiag() (in module SimPEG.Utils.matutils), 70 sdInv() (in module SimPEG.Utils.matutils), 70 setCellGradBC() (SimPEG.Mesh.DiffOperators.DiffOperators method), 31 setupMesh() (SimPEG.Tests.OrderTest method), 80 shape (SimPEG.Maps.ComboMap attribute), 69 shape (SimPEG.Maps.IdentityMap attribute), 66 shape (SimPEG.Maps.Mesh2Mesh attribute), 69 SimPEG.Directives (module), 60 SimPEG.EM.FDEM.FDEM (module), 86 SimPEG.EM.FDEM.SurveyFDEM (module), 89 SimPEG.Inversion (module), 61 SimPEG.Mesh.BaseMesh (module), 22 SimPEG.Mesh.CylMesh (module), 15 SimPEG.Mesh.DiffOperators (module), 29 SimPEG.Mesh.InnerProducts (module), 35 SimPEG.Mesh.TensorMesh (module), 9 SimPEG.Optimization (module), 52 SimPEG.Problem (module), 40 SimPEG.Regularization (module), 49 SimPEG.Survey (module), 42 SimPEG.Tests (module), 79 SimPEG.Utils (module), 70 SimPEG.Utils.CounterUtils (module), 79 SimPEG.Utils.curvutils (module), 72 SimPEG.Utils.interputils (module), 77 SimPEG.Utils.matutils (module), 70 SimPEG.Utils.meshutils (module), 74 SimPEG.Utils.ModelBuilder (module), 76 SimPEG.Utils.SolverUtils (module), 72 smoothModel (SimPEG.Regularization.Tikhonov attribute), 51 Solver (in module SimPEG.Utils.SolverUtils), 72 Solver (SimPEG.Optimization.NewtonRoot attribute), 59 Solver (SimPEG.Problem.BaseProblem attribute), 40 SolverCG (in module SimPEG.Utils.SolverUtils), 72 SolverDiag (class in SimPEG.Utils.SolverUtils), 72 SolverLU (in module SimPEG.Utils.SolverUtils), 72 Index solverOpts (SimPEG.Optimization.NewtonRoot attribute), 59 solverOpts (SimPEG.Problem.BaseProblem attribute), 40 SolverWrapD() (in module SimPEG.Utils.SolverUtils), 63, 72 SolverWrapI() (in module SimPEG.Utils.SolverUtils), 64, 72 speye() (in module SimPEG.Utils.matutils), 70 spzeros() (in module SimPEG.Utils.matutils), 70 srcList (SimPEG.Survey.BaseSurvey attribute), 43 srcPair (SimPEG.EM.FDEM.SurveyFDEM.Survey attribute), 90 srcPair (SimPEG.Survey.BaseSurvey attribute), 43 startup() (SimPEG.Optimization.Minimize method), 54 std (SimPEG.Survey.BaseSurvey attribute), 43 SteepestDescent (class in SimPEG.Optimization), 59 stepDcr (SimPEG.Optimization.NewtonRoot attribute), 59 stopNextIteration (SimPEG.Optimization.Minimize attribute), 53 StoppingCriteria (class in SimPEG.Optimization), 52 stoppingCriteria() (SimPEG.Optimization.Minimize method), 55 storeProjections (SimPEG.Survey.BaseRx attribute), 42 sub2ind() (in module SimPEG.Utils.matutils), 71 summary() (SimPEG.Utils.CounterUtils.Counter method), 79 Survey (class in SimPEG.EM.FDEM.SurveyFDEM), 90 survey (SimPEG.Directives.InversionDirective attribute), 60 survey (SimPEG.Problem.BaseProblem attribute), 40 survey (SimPEG.Regularization.BaseRegularization attribute), 49 surveyPair (SimPEG.EM.FDEM.FDEM.BaseFDEMProblem attribute), 86 surveyPair (SimPEG.Problem.BaseProblem attribute), 40 T t0 (SimPEG.Problem.BaseTimeProblem attribute), 42 tangents (SimPEG.Mesh.BaseMesh.BaseMesh attribute), 26 target (SimPEG.Directives.TargetMisfit attribute), 61 TargetMisfit (class in SimPEG.Directives), 61 TensorMesh (class in SimPEG.Mesh.TensorMesh), 11 TensorType (class in SimPEG.Utils.matutils), 71 test() (SimPEG.Maps.IdentityMap method), 67 Tikhonov (class in SimPEG.Regularization), 50 timeIt() (in module SimPEG.Utils.CounterUtils), 79 timeMesh (SimPEG.Problem.BaseTimeProblem attribute), 42 times (SimPEG.Problem.BaseTimeProblem attribute), 42 times (SimPEG.Survey.BaseTimeRx attribute), 42 timeSteps (SimPEG.Problem.BaseTimeProblem attribute), 41 131 SimPEG Documentation, Release 0.1.9 tol (SimPEG.Optimization.NewtonRoot attribute), 59 tolCG (SimPEG.Optimization.InexactGaussNewton tribute), 59 tolCG (SimPEG.Optimization.ProjectedGradient tribute), 58 tolerance (SimPEG.Tests.OrderTest attribute), 80 tolerance_f (SimPEG.Optimization.StoppingCriteria tribute), 52 tolerance_g (SimPEG.Optimization.StoppingCriteria tribute), 52 tolF (SimPEG.Optimization.Minimize attribute), 53 tolG (SimPEG.Optimization.Minimize attribute), 53 tolX (SimPEG.Optimization.Minimize attribute), 53 totalLS (SimPEG.Optimization.IterationPrinters tribute), 52 TreeMesh (class in SimPEG.Mesh.TreeMesh), 12 vnEy (SimPEG.Mesh.CylMesh.CylMesh attribute), 16 at- vnEz (SimPEG.Mesh.BaseMesh.BaseRectangularMesh attribute), 28 at- vnEz (SimPEG.Mesh.CylMesh.CylMesh attribute), 16 vnF (SimPEG.Mesh.BaseMesh.BaseMesh attribute), 25 vnFx (SimPEG.Mesh.BaseMesh.BaseRectangularMesh atattribute), 28 vnFx (SimPEG.Mesh.CylMesh.CylMesh attribute), 16 at- vnFy (SimPEG.Mesh.BaseMesh.BaseRectangularMesh attribute), 28 vnFz (SimPEG.Mesh.BaseMesh.BaseRectangularMesh attribute), 28 vnN (SimPEG.Mesh.BaseMesh.BaseRectangularMesh atattribute), 27 vntE (SimPEG.Mesh.TreeMesh.TreeMesh attribute), 13 vntF (SimPEG.Mesh.TreeMesh.TreeMesh attribute), 13 vol (SimPEG.Mesh.CylMesh.CylMesh attribute), 16 U vol (SimPEG.Mesh.TensorMesh.TensorMesh attribute), 12 unpair() (SimPEG.Problem.BaseProblem method), 40 vol (SimPEG.Mesh.TreeMesh.TreeMesh attribute), 14 unpair() (SimPEG.Survey.BaseSurvey method), 43 upper (SimPEG.Optimization.ProjectedGradient at- volTetra() (in module SimPEG.Utils.curvutils), 72 tribute), 58 W V W (SimPEG.Regularization.BaseRegularization attribute), 49 W (SimPEG.Regularization.Tikhonov attribute), 52 Wd (SimPEG.DataMisfit.l2_DataMisfit attribute), 48 writeUBCTensorMesh() (in module SimPEG.Utils.meshutils), 75 writeUBCTensorModel() (in module SimPEG.Utils.meshutils), 75 writeVTRFile() (in module SimPEG.Utils.meshutils), 75 Ws (SimPEG.Regularization.Tikhonov attribute), 51 Wsmooth (SimPEG.Regularization.Tikhonov attribute), 51 Wx (SimPEG.Regularization.Tikhonov attribute), 51 Wxx (SimPEG.Regularization.Tikhonov attribute), 51 Wy (SimPEG.Regularization.Tikhonov attribute), 51 Wyy (SimPEG.Regularization.Tikhonov attribute), 51 Wz (SimPEG.Regularization.Tikhonov attribute), 51 Wzz (SimPEG.Regularization.Tikhonov attribute), 51 vectorCCx (SimPEG.Mesh.CylMesh.CylMesh attribute), 16 vectorCCx (SimPEG.Mesh.TensorMesh.BaseTensorMesh attribute), 9 vectorCCy (SimPEG.Mesh.CylMesh.CylMesh attribute), 16 vectorCCy (SimPEG.Mesh.TensorMesh.BaseTensorMesh attribute), 9 vectorCCz (SimPEG.Mesh.TensorMesh.BaseTensorMesh attribute), 9 vectorNx (SimPEG.Mesh.CylMesh.CylMesh attribute), 16 vectorNx (SimPEG.Mesh.TensorMesh.BaseTensorMesh attribute), 9 vectorNy (SimPEG.Mesh.CylMesh.CylMesh attribute), 16 vectorNy (SimPEG.Mesh.TensorMesh.BaseTensorMesh attribute), 9 vectorNz (SimPEG.Mesh.TensorMesh.BaseTensorMesh X attribute), 9 x0 (SimPEG.Mesh.BaseMesh.BaseMesh attribute), 23 Vertical1DMap (class in SimPEG.Maps), 68 vnC (SimPEG.Mesh.BaseMesh.BaseRectangularMesh Z attribute), 27 Zero (class in SimPEG.Utils.matutils), 72 vnD (SimPEG.Survey.BaseSrc attribute), 43 vnD (SimPEG.Survey.BaseSurvey attribute), 44 vnE (SimPEG.Mesh.BaseMesh.BaseMesh attribute), 24 vnEx (SimPEG.Mesh.BaseMesh.BaseRectangularMesh attribute), 27 vnEy (SimPEG.Mesh.BaseMesh.BaseRectangularMesh attribute), 28 132 Index