mirror of
https://github.com/wassname/simpeg.git
synced 2026-07-15 11:26:09 +08:00
Changed Data --> Survey
This commit is contained in:
@@ -19,7 +19,6 @@ import sys, os
|
||||
#sys.path.insert(0, os.path.abspath('.'))
|
||||
|
||||
sys.path.append('../')
|
||||
sys.path.append('../../')
|
||||
|
||||
# -- General configuration -----------------------------------------------------
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import sys
|
||||
sys.path.append('../')
|
||||
sys.path.append('../../')
|
||||
|
||||
from SimPEG import *
|
||||
@@ -17,7 +16,7 @@ h = np.zeros(M.nC) + bc[0]
|
||||
|
||||
|
||||
def getFields(timeStep,method):
|
||||
prob = Richards.RichardsProblem(M,model, timeStep=timeStep, timeEnd=360,
|
||||
prob = Richards.RichardsProblem(model, timeStep=timeStep, timeEnd=360,
|
||||
boundaryConditions=bc, initialConditions=h,
|
||||
doNewton=False, method=method)
|
||||
return prob.fields(params['Ks'])
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
from SimPEG import *
|
||||
from Empirical import RichardsModel
|
||||
|
||||
class RichardsData(Data.BaseData):
|
||||
"""docstring for RichardsData"""
|
||||
class RichardsSurvey(Survey.BaseSurvey):
|
||||
"""docstring for RichardsSurvey"""
|
||||
|
||||
P = None
|
||||
|
||||
def __init__(self, **kwargs):
|
||||
Data.BaseData.__init__(self, **kwargs)
|
||||
Survey.BaseSurvey.__init__(self, **kwargs)
|
||||
|
||||
@property
|
||||
def dataType(self):
|
||||
@@ -66,11 +66,11 @@ class RichardsProblem(Problem.BaseProblem):
|
||||
boundaryConditions = None
|
||||
initialConditions = None
|
||||
|
||||
dataPair = RichardsData
|
||||
surveyPair = RichardsSurvey
|
||||
modelPair = RichardsModel
|
||||
|
||||
def __init__(self, mesh, model, **kwargs):
|
||||
Problem.BaseProblem.__init__(self, mesh, model, **kwargs)
|
||||
def __init__(self, model, **kwargs):
|
||||
Problem.BaseProblem.__init__(self, model, **kwargs)
|
||||
|
||||
@property
|
||||
def timeStep(self):
|
||||
@@ -221,7 +221,7 @@ class RichardsProblem(Problem.BaseProblem):
|
||||
B = np.array(sp.vstack(Bs).todense())
|
||||
|
||||
Ainv = Solver(A)
|
||||
P = self.data.projectFieldsDeriv(u, m)
|
||||
P = self.survey.projectFieldsDeriv(u, m)
|
||||
J = P * Ainv.solve(B)
|
||||
return J
|
||||
|
||||
@@ -244,14 +244,14 @@ class RichardsProblem(Problem.BaseProblem):
|
||||
Adiaginv = Solver(Adiag)
|
||||
JvC[ii] = Adiaginv.solve(B*v - Asub*JvC[ii-1])
|
||||
|
||||
P = self.data.projectFieldsDeriv(u, m)
|
||||
P = self.survey.projectFieldsDeriv(u, m)
|
||||
return P * np.concatenate(JvC)
|
||||
|
||||
def Jtvec(self, m, v, u=None):
|
||||
if u is None:
|
||||
u = self.field(m)
|
||||
|
||||
P = self.data.projectFieldsDeriv(u, m)
|
||||
P = self.survey.projectFieldsDeriv(u, m)
|
||||
PTv = P.T*v
|
||||
|
||||
# This is done via backward substitution.
|
||||
|
||||
@@ -114,21 +114,21 @@ class RichardsTests1D(unittest.TestCase):
|
||||
bc = np.array([-61.5,-20.7])
|
||||
h = np.zeros(M.nC) + bc[0]
|
||||
|
||||
prob = Richards.RichardsProblem(M,model, timeStep=60, timeEnd=180,
|
||||
prob = Richards.RichardsProblem(model, timeStep=60, timeEnd=180,
|
||||
boundaryConditions=bc, initialConditions=h,
|
||||
doNewton=False, method='mixed')
|
||||
|
||||
q = sp.csr_matrix((np.ones(3),(np.arange(3),np.array([5,10,15]))),shape=(3,M.nC))
|
||||
P = sp.kron(sp.identity(prob.numIts),q)
|
||||
data = Richards.RichardsData(P=P)
|
||||
survey = Richards.RichardsSurvey(P=P)
|
||||
|
||||
prob.pair(data)
|
||||
prob.pair(survey)
|
||||
|
||||
self.h0 = h
|
||||
self.M = M
|
||||
self.Ks = params['Ks']
|
||||
self.prob = prob
|
||||
self.data = data
|
||||
self.survey = survey
|
||||
|
||||
def test_Richards_getResidual_Newton(self):
|
||||
self.prob.doNewton = True
|
||||
@@ -144,7 +144,7 @@ class RichardsTests1D(unittest.TestCase):
|
||||
|
||||
def test_Adjoint_PressureHead(self):
|
||||
self.prob.dataType = 'pressureHead'
|
||||
v = np.random.rand(self.data.P.shape[0])
|
||||
v = np.random.rand(self.survey.P.shape[0])
|
||||
z = np.random.rand(self.M.nC)
|
||||
Hs = self.prob.fields(self.Ks)
|
||||
vJz = v.dot(self.prob.Jvec(self.Ks,z,u=Hs))
|
||||
@@ -157,7 +157,7 @@ class RichardsTests1D(unittest.TestCase):
|
||||
|
||||
def test_Adjoint_Saturation(self):
|
||||
self.prob.dataType = 'saturation'
|
||||
v = np.random.rand(self.data.P.shape[0])
|
||||
v = np.random.rand(self.survey.P.shape[0])
|
||||
z = np.random.rand(self.M.nC)
|
||||
Hs = self.prob.fields(self.Ks)
|
||||
vJz = v.dot(self.prob.Jvec(self.Ks,z,u=Hs))
|
||||
@@ -173,10 +173,10 @@ class RichardsTests1D(unittest.TestCase):
|
||||
self.prob.unpair()
|
||||
mTrue = np.ones(self.M.nC)*self.Ks
|
||||
stdev = 0.01 # The standard deviation for the noise
|
||||
data = self.prob.createSyntheticData(mTrue, std=stdev, P=self.data.P)
|
||||
survey = self.prob.createSyntheticSurvey(mTrue, std=stdev, P=self.survey.P)
|
||||
opt = Optimization.InexactGaussNewton(maxIterLS=20, maxIter=10, tolF=1e-6, tolX=1e-6, tolG=1e-6, maxIterCG=6)
|
||||
reg = Regularization.Tikhonov(Model.BaseModel(self.M))
|
||||
obj = ObjFunction.BaseObjFunction(data, reg)
|
||||
obj = ObjFunction.BaseObjFunction(survey, reg)
|
||||
derChk = lambda m: [obj.dataObj(m), obj.dataObjDeriv(m)]
|
||||
print 'Testing Richards Derivative - Pressure Head'
|
||||
passed = checkDerivative(derChk, mTrue, num=5, plotIt=False)
|
||||
@@ -187,10 +187,10 @@ class RichardsTests1D(unittest.TestCase):
|
||||
self.prob.dataType = 'saturation'
|
||||
mTrue = np.ones(self.M.nC)*self.Ks
|
||||
stdev = 0.01 # The standard deviation for the noise
|
||||
data = self.prob.createSyntheticData(mTrue, std=stdev, P=self.data.P)
|
||||
survey = self.prob.createSyntheticSurvey(mTrue, std=stdev, P=self.survey.P)
|
||||
opt = Optimization.InexactGaussNewton(maxIterLS=20, maxIter=10, tolF=1e-6, tolX=1e-6, tolG=1e-6, maxIterCG=6)
|
||||
reg = Regularization.Tikhonov(Model.BaseModel(self.M))
|
||||
obj = ObjFunction.BaseObjFunction(data, reg)
|
||||
obj = ObjFunction.BaseObjFunction(survey, reg)
|
||||
derChk = lambda m: [obj.dataObj(m), obj.dataObjDeriv(m)]
|
||||
print 'Testing Richards Derivative - Saturation'
|
||||
passed = checkDerivative(derChk, mTrue, num=5, plotIt=False)
|
||||
@@ -264,7 +264,7 @@ class RichardsTests1D(unittest.TestCase):
|
||||
# self.prob.dataType = 'pressureHead'
|
||||
# mTrue = np.ones(self.M.nC)*self.Ks
|
||||
# stdev = 0.01 # The standard deviation for the noise
|
||||
# dobs = self.prob.createSyntheticData(mTrue,std=stdev)[0]
|
||||
# dobs = self.prob.createSyntheticSurvey(mTrue,std=stdev)[0]
|
||||
# self.prob.dobs = dobs
|
||||
# self.prob.std = dobs*0 + stdev
|
||||
# Hs = self.prob.field(mTrue)
|
||||
|
||||
Reference in New Issue
Block a user