mirror of
https://github.com/wassname/simpeg.git
synced 2026-07-04 05:02:11 +08:00
Linear Problem Working
This commit is contained in:
@@ -45,7 +45,7 @@ class Parameter(object):
|
||||
@property
|
||||
def prob(self): return self.parent.prob
|
||||
@property
|
||||
def model(self): return self.parent.model
|
||||
def mapping(self): return self.parent.mapping
|
||||
@property
|
||||
def mesh(self): return self.parent.mesh
|
||||
|
||||
|
||||
+1
-1
@@ -20,7 +20,7 @@ class BaseProblem(object):
|
||||
Utils.setKwargs(self, **kwargs)
|
||||
self.mesh = mesh
|
||||
self.mapping = mapping or Maps.IdentityMap(mesh)
|
||||
self.mapping._assertMatchesPair(mapPair)
|
||||
self.mapping._assertMatchesPair(self.mapPair)
|
||||
|
||||
@property
|
||||
def survey(self):
|
||||
|
||||
+11
-12
@@ -24,42 +24,41 @@ class LinearProblem(Problem.BaseProblem):
|
||||
|
||||
|
||||
def example(N):
|
||||
M = Mesh.TensorMesh([N])
|
||||
mesh = Mesh.TensorMesh([N])
|
||||
|
||||
nk = 20
|
||||
jk = np.linspace(1.,20.,nk)
|
||||
p = -0.25
|
||||
q = 0.25
|
||||
|
||||
g = lambda k: np.exp(p*jk[k]*M.vectorCCx)*np.cos(2*np.pi*q*jk[k]*M.vectorCCx)
|
||||
g = lambda k: np.exp(p*jk[k]*mesh.vectorCCx)*np.cos(2*np.pi*q*jk[k]*mesh.vectorCCx)
|
||||
|
||||
G = np.empty((nk, M.nC))
|
||||
G = np.empty((nk, mesh.nC))
|
||||
|
||||
for i in range(nk):
|
||||
G[i,:] = g(i)
|
||||
|
||||
mtrue = np.zeros(M.nC)
|
||||
mtrue[M.vectorCCx > 0.3] = 1.
|
||||
mtrue[M.vectorCCx > 0.45] = -0.5
|
||||
mtrue[M.vectorCCx > 0.6] = 0
|
||||
mtrue = np.zeros(mesh.nC)
|
||||
mtrue[mesh.vectorCCx > 0.3] = 1.
|
||||
mtrue[mesh.vectorCCx > 0.45] = -0.5
|
||||
mtrue[mesh.vectorCCx > 0.6] = 0
|
||||
|
||||
|
||||
|
||||
model = Model.BaseModel(M)
|
||||
prob = LinearProblem(model, G)
|
||||
prob = LinearProblem(mesh, G)
|
||||
survey = prob.createSyntheticSurvey(mtrue, std=0.01)
|
||||
|
||||
return prob, survey, model
|
||||
return prob, survey, mesh
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
import matplotlib.pyplot as plt
|
||||
|
||||
prob, survey, model = example(100)
|
||||
prob, survey, mesh = example(100)
|
||||
M = prob.mesh
|
||||
|
||||
reg = Regularization.Tikhonov(model)
|
||||
reg = Regularization.Tikhonov(mesh)
|
||||
beta = Parameters.BetaSchedule()
|
||||
objFunc = ObjFunction.BaseObjFunction(survey, reg, beta=beta)
|
||||
opt = Optimization.InexactGaussNewton(maxIter=20)
|
||||
|
||||
Reference in New Issue
Block a user