diff --git a/README.md b/README.md index e107fea3..c2eafa26 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ ![SimPEG](https://raw.github.com/simpeg/simpeg/master/docs/simpeg-logo.png) -Simulation and Parameter Estimation in Geophysics - A python package for simulation and gradient based parameter estimation in the context of geophysical applications. +Simulation and Parameter Estimation in Geoscience - A python package for simulation and gradient based parameter estimation in the context of geophysical applications. The vision is to create a package for finite volume simulation with applications to geophysical imaging and subsurface flow. To enable the understanding of the many different components, this package has the following features: diff --git a/SimPEG/__init__.py b/SimPEG/__init__.py index f455e866..f421bc82 100644 --- a/SimPEG/__init__.py +++ b/SimPEG/__init__.py @@ -5,7 +5,6 @@ from utils import Solver import mesh import data import forward -import regularization import inverse import visualize import examples diff --git a/SimPEG/examples/DC.py b/SimPEG/examples/DC.py index 074cdb8b..ad98d6c2 100644 --- a/SimPEG/examples/DC.py +++ b/SimPEG/examples/DC.py @@ -168,7 +168,6 @@ def genTxRxmat(nelec, spacelec, surfloc, elecini, mesh): if __name__ == '__main__': - from SimPEG.regularization import Regularization from SimPEG import inverse import matplotlib.pyplot as plt @@ -217,7 +216,7 @@ if __name__ == '__main__': m0 = mesh.gridCC[:,0]*0+sig2 opt = inverse.InexactGaussNewton(maxIterLS=20, maxIter=10, tolF=1e-6, tolX=1e-6, tolG=1e-6, maxIterCG=6) - reg = Regularization(mesh) + reg = inverse.Regularization(mesh) inv = inverse.Inversion(problem, reg, opt, beta0=1e4) # Check Derivative diff --git a/SimPEG/examples/Linear.py b/SimPEG/examples/Linear.py index 79bec85c..dbee7dff 100644 --- a/SimPEG/examples/Linear.py +++ b/SimPEG/examples/Linear.py @@ -1,4 +1,4 @@ -from SimPEG import mesh, forward, inverse, regularization, np +from SimPEG import mesh, forward, inverse, np import matplotlib.pyplot as plt @@ -51,7 +51,7 @@ if __name__ == '__main__': prob, data = example(100) M = prob.mesh - reg = regularization.Regularization(M) + reg = inverse.Regularization(M) opt = inverse.InexactGaussNewton(maxIter=20) inv = inverse.Inversion(prob,reg,opt,data) m0 = np.zeros_like(data.mtrue) diff --git a/SimPEG/regularization/Regularization.py b/SimPEG/inverse/Regularization.py similarity index 92% rename from SimPEG/regularization/Regularization.py rename to SimPEG/inverse/Regularization.py index a8406d9b..30c4b86d 100644 --- a/SimPEG/regularization/Regularization.py +++ b/SimPEG/inverse/Regularization.py @@ -111,46 +111,46 @@ class Regularization(object): @property def Ws(self): if getattr(self,'_Ws', None) is None: - self._Ws = utils.sdiag(self.mesh.vol) + self._Ws = utils.sdiag(self.mesh.vol**0.5) return self._Ws @property def Wx(self): if getattr(self, '_Wx', None) is None: - Ave_x_vol = self.mesh.aveCC2F[:self.mesh.nFv[0],:]*self.mesh.vol + Ave_x_vol = self.mesh.aveF2CC[:,:self.mesh.nFv[0]].T*self.mesh.vol self._Wx = utils.sdiag(Ave_x_vol**0.5)*self.mesh.cellGradx return self._Wx @property def Wy(self): if getattr(self, '_Wy', None) is None: - Ave_y_vol = self.mesh.aveCC2F[self.mesh.nFv[0]:np.sum(self.mesh.nFv[:2]),:]*self.mesh.vol + Ave_y_vol = self.mesh.aveF2CC[:,self.mesh.nFv[0]:np.sum(self.mesh.nFv[:2])].T*self.mesh.vol self._Wy = utils.sdiag(Ave_y_vol**0.5)*self.mesh.cellGrady return self._Wy @property def Wz(self): if getattr(self, '_Wz', None) is None: - Ave_z_vol = self.mesh.aveCC2F[np.sum(self.mesh.nFv[:2]):,:]*self.mesh.vol + Ave_z_vol = self.mesh.aveF2CC[:,np.sum(self.mesh.nFv[:2]):].T*self.mesh.vol self._Wz = utils.sdiag(Ave_z_vol**0.5)*self.mesh.cellGradz return self._Wz @property def Wxx(self): if getattr(self, '_Wxx', None) is None: - self._Wxx = self.mesh.faceDivx*self.mesh.cellGradx*utils.sdiag(self.mesh.vol) + self._Wxx = utils.sdiag(self.mesh.vol**0.5)*self.mesh.faceDivx*self.mesh.cellGradx return self._Wxx @property def Wyy(self): if getattr(self, '_Wyy', None) is None: - self._Wyy = self.mesh.faceDivy*self.mesh.cellGrady*utils.sdiag(self.mesh.vol) + self._Wyy = utils.sdiag(self.mesh.vol**0.5)*self.mesh.faceDivy*self.mesh.cellGrady return self._Wyy @property def Wzz(self): if getattr(self, '_Wzz', None) is None: - self._Wzz = self.mesh.faceDivz*self.mesh.cellGradz*utils.sdiag(self.mesh.vol) + self._Wzz = utils.sdiag(self.mesh.vol**0.5)*self.mesh.faceDivz*self.mesh.cellGradz return self._Wzz diff --git a/SimPEG/inverse/__init__.py b/SimPEG/inverse/__init__.py index 14bddce7..d83a8269 100644 --- a/SimPEG/inverse/__init__.py +++ b/SimPEG/inverse/__init__.py @@ -1,3 +1,4 @@ from Optimize import * from Inversion import * +from Regularization import Regularization import BetaSchedule diff --git a/SimPEG/mesh/InnerProducts.py b/SimPEG/mesh/InnerProducts.py index 5c2e7b5f..45853071 100644 --- a/SimPEG/mesh/InnerProducts.py +++ b/SimPEG/mesh/InnerProducts.py @@ -81,9 +81,9 @@ class InnerProducts(object): def getFaceInnerProduct(self, mu=None, returnP=False): """Wrapper function, - :py:func:`SimPEG.mesh.InnerProducts.InnerProducts.getEdgeInnerProduct` + :py:func:`SimPEG.mesh.InnerProducts.InnerProducts.getFaceInnerProduct` - :py:func:`SimPEG.mesh.InnerProducts.InnerProducts.getEdgeInnerProduct2D` + :py:func:`SimPEG.mesh.InnerProducts.InnerProducts.getFaceInnerProduct2D` """ if self.dim == 2: return getFaceInnerProduct2D(self, mu, returnP) @@ -93,9 +93,9 @@ class InnerProducts(object): def getEdgeInnerProduct(self, sigma=None, returnP=False): """Wrapper function, - :py:func:`SimPEG.mesh.InnerProducts.InnerProducts.getFaceInnerProduct` + :py:func:`SimPEG.mesh.InnerProducts.InnerProducts.getEdgeInnerProduct` - :py:func:`SimPEG.mesh.InnerProducts.InnerProducts.getFaceInnerProduct2D` + :py:func:`SimPEG.mesh.InnerProducts.InnerProducts.getEdgeInnerProduct2D` """ if self.dim == 2: return getEdgeInnerProduct2D(self, sigma, returnP) diff --git a/SimPEG/regularization/__init__.py b/SimPEG/regularization/__init__.py deleted file mode 100644 index 0230f8c3..00000000 --- a/SimPEG/regularization/__init__.py +++ /dev/null @@ -1 +0,0 @@ -from Regularization import Regularization diff --git a/SimPEG/tests/test_forward_DCproblem.py b/SimPEG/tests/test_forward_DCproblem.py index 36216bf7..90312fdf 100644 --- a/SimPEG/tests/test_forward_DCproblem.py +++ b/SimPEG/tests/test_forward_DCproblem.py @@ -6,7 +6,6 @@ from SimPEG.forward import Problem from SimPEG.examples.DC import * from TestUtils import checkDerivative from scipy.sparse.linalg import dsolve -from SimPEG.regularization import Regularization from SimPEG import inverse @@ -48,7 +47,7 @@ class DCProblemTests(unittest.TestCase): # Now set up the problem to do some minimization opt = inverse.InexactGaussNewton(maxIterLS=20, maxIter=10, tolF=1e-6, tolX=1e-6, tolG=1e-6, maxIterCG=6) - reg = Regularization(mesh) + reg = inverse.Regularization(mesh) inv = inverse.Inversion(problem, reg, opt, data, beta0=1e4) self.inv = inv diff --git a/SimPEG/tests/test_forward_problem.py b/SimPEG/tests/test_forward_problem.py index ba49efd8..1d4de045 100644 --- a/SimPEG/tests/test_forward_problem.py +++ b/SimPEG/tests/test_forward_problem.py @@ -1,8 +1,6 @@ import numpy as np import unittest -from SimPEG.mesh import TensorMesh -from SimPEG.forward import Problem -from SimPEG.regularization import Regularization +from SimPEG import mesh, forward, inverse from TestUtils import checkDerivative from scipy.sparse.linalg import dsolve @@ -14,9 +12,9 @@ class ProblemTests(unittest.TestCase): a = np.array([1, 1, 1]) b = np.array([1, 2]) c = np.array([1, 4]) - self.mesh2 = TensorMesh([a, b], np.array([3, 5])) - self.p2 = Problem(self.mesh2) - self.reg = Regularization(self.mesh2) + self.mesh2 = mesh.TensorMesh([a, b], np.array([3, 5])) + self.p2 = forward.Problem(self.mesh2) + self.reg = inverse.Regularization(self.mesh2) def test_modelTransform(self): print 'SimPEG.forward.Problem: Testing Model Transform' diff --git a/docs/api_Optimize.rst b/docs/api_Optimize.rst index 15c31e6d..a30e55f7 100644 --- a/docs/api_Optimize.rst +++ b/docs/api_Optimize.rst @@ -29,7 +29,7 @@ Beta Schedule Regularization ************** -.. automodule:: SimPEG.regularization.Regularization +.. automodule:: SimPEG.inverse.Regularization :show-inheritance: :members: :undoc-members: