diff --git a/SimPEG/forward/DCProblem.py b/SimPEG/forward/DCProblem.py index 34046a52..074cdb8b 100644 --- a/SimPEG/forward/DCProblem.py +++ b/SimPEG/forward/DCProblem.py @@ -1,5 +1,5 @@ from SimPEG.mesh import TensorMesh -from SimPEG.forward import Problem, SyntheticProblem, ModelTransforms +from SimPEG.forward import Problem, ModelTransforms from SimPEG.tests import checkDerivative from SimPEG.utils import ModelBuilder, sdiag, mkvc from SimPEG import Solver @@ -201,23 +201,17 @@ if __name__ == '__main__': P = Q.T # Create some data - class syntheticDCProblem(DCProblem, SyntheticProblem): - pass + problem = DCProblem(mesh) + problem.P = P + problem.RHS = q + dobs, Wd = problem.createSyntheticData(mSynth, std=0.05) - synthetic = syntheticDCProblem(mesh); - synthetic.P = P - synthetic.RHS = q - dobs, Wd = synthetic.createData(mSynth, std=0.05) - - u = synthetic.field(mSynth) - u = synthetic.reshapeFields(u) + u = problem.field(mSynth) + u = problem.reshapeFields(u) mesh.plotImage(u[:,10]) # plt.show() # Now set up the problem to do some minimization - problem = DCProblem(mesh) - problem.P = P - problem.RHS = q problem.dobs = dobs problem.std = dobs*0 + 0.05 m0 = mesh.gridCC[:,0]*0+sig2 diff --git a/SimPEG/forward/Problem.py b/SimPEG/forward/Problem.py index cf22baae..35d41cb8 100644 --- a/SimPEG/forward/Problem.py +++ b/SimPEG/forward/Problem.py @@ -218,27 +218,15 @@ class Problem(object): """ return sp.eye(m.size) - - - -class SyntheticProblem(object): - """ - Has helpful functions when dealing with synthetic problems - - To use this class, inherit to your problem:: - - class mySyntheticExample(Problem, SyntheticProblem): - pass - """ - def createData(self, m, std=0.05): + def createSyntheticData(self, m, std=0.05): """ + Create synthetic data given a model, and a standard deviation. + :param numpy.array m: geophysical model :param numpy.array std: standard deviation :rtype: numpy.array, numpy.array :return: dobs, Wd - Create synthetic data given a model, and a standard deviation. - Returns the observed data with random Gaussian noise and Wd which is the same size as data, and can be used to weight the inversion. """ diff --git a/SimPEG/forward/Richards.py b/SimPEG/forward/Richards.py index e472ca6a..d6d268be 100644 --- a/SimPEG/forward/Richards.py +++ b/SimPEG/forward/Richards.py @@ -78,7 +78,6 @@ class RichardsProblem(Problem): self._dataType = value - def __init__(self, mesh, empirical, **kwargs): Problem.__init__(self, mesh) self.empirical = empirical @@ -92,12 +91,9 @@ class RichardsProblem(Problem): Hs = range(self.numIts+1) Hs[0] = self.initialConditions for ii in range(self.numIts): - hn = Hs[ii] - hn1 = self.rootFinder.root(lambda hn1: self.getResidual(hn,hn1), hn) - Hs[ii+1] = hn1 + Hs[ii+1] = self.rootFinder.root(lambda hn1: self.getResidual(Hs[ii],hn1), Hs[ii]) return Hs - def diagsJacobian(self, hn, hn1): DIV = self.mesh.faceDiv diff --git a/SimPEG/tests/test_Richards.py b/SimPEG/tests/test_Richards.py index e64d2759..86f1a7e7 100644 --- a/SimPEG/tests/test_Richards.py +++ b/SimPEG/tests/test_Richards.py @@ -85,7 +85,7 @@ class RichardsTests(unittest.TestCase): self.assertTrue(passed,True) def test_Adjoint_PressureHead(self): - # self.prob.dataType = 'pressureHead' + self.prob.dataType = 'pressureHead' Ks = self.Ks v = np.random.rand(self.prob.P.shape[0]) z = np.random.rand(self.M.nC) diff --git a/SimPEG/tests/test_forward_DCproblem.py b/SimPEG/tests/test_forward_DCproblem.py index c6e6f9c2..847d1055 100644 --- a/SimPEG/tests/test_forward_DCproblem.py +++ b/SimPEG/tests/test_forward_DCproblem.py @@ -2,7 +2,7 @@ import numpy as np import unittest from SimPEG.mesh import TensorMesh from SimPEG.utils import ModelBuilder, sdiag -from SimPEG.forward import Problem, SyntheticProblem +from SimPEG.forward import Problem from SimPEG.forward.DCProblem import * from TestUtils import checkDerivative from scipy.sparse.linalg import dsolve @@ -40,18 +40,13 @@ class DCProblemTests(unittest.TestCase): P = Q.T # Create some data - class syntheticDCProblem(DCProblem, SyntheticProblem): - pass - synthetic = syntheticDCProblem(mesh); - synthetic.P = P - synthetic.RHS = q - dobs, Wd = synthetic.createData(mSynth, std=0.05) - - # Now set up the problem to do some minimization problem = DCProblem(mesh) problem.P = P problem.RHS = q + dobs, Wd = problem.createSyntheticData(mSynth, std=0.05) + + # Now set up the problem to do some minimization problem.W = Wd problem.dobs = dobs problem.std = dobs*0 + 0.05