Forward simulation and inversion for a block (fracture) on a whole space
In [15]:
from SimPEG import *
import simpegEM as EM
from pymatsolver import MumpsSolver
from scipy.constants import mu_0
In [2]:
cs = 5
ncore = 35
ncore_x = 15
pad = 8
padfactor = 1.4
hx = [(cs,pad,-padfactor),(cs,ncore_x),(cs,pad,padfactor)]
h = [(cs,pad,-padfactor),(cs,ncore),(cs,pad,padfactor)]
mesh = Mesh.TensorMesh([hx, h, h],'CCC')
In [3]:
sigwh = 1e-2 # conductivity of the wholespace background
sigma = 1e-2*np.ones(prod(mesh.nC)) # whole space
sigmaB = 1e-2*np.ones(prod(mesh.nC)) # with block
sigmaB[(np.abs(mesh.gridCC[:,0]) < 10.) & (np.abs(mesh.gridCC[:,1]) < 25.) & (np.abs(mesh.gridCC[:,2]) < 25.)] = 1
mesh.plotSlice(sigmaB,grid=True) # todo: fix axes
mesh.plotImage(sigmaB) #
Out[3]:
Start by comparing the solution for the whole-space model to what we expect for a dipole in a whole-space
In [4]:
x = np.linspace(-50,50,10)
XYZ = Utils.ndgrid(np.r_[0],np.r_[50],x)
Rx0 = EM.FDEM.RxFDEM(XYZ, 'bzr')
Rx1 = EM.FDEM.RxFDEM(XYZ, 'bzi')
txList = []
freq = 500.
Tx = EM.FDEM.TxFDEM(np.r_[0.,0.,0.], 'VMD',freq,[Rx0,Rx1])
txList.append(Tx)
survey = EM.FDEM.SurveyFDEM(txList)
mapping = Maps.ExpMap(mesh)
prb = EM.FDEM.ProblemFDEM_b(mesh, mapping=mapping)
prb.pair(survey)
prb.Solver = MumpsSolver
In [5]:
# SimPEG soln
fTest = prb.fields(np.log(sigma))
In [61]:
Bx, By, Bz = EM.Analytics.FDEM.AnalyticMagDipoleWholeSpace(Rx0.locs,Tx.loc,sigwh,freq, m = 1.0, orientation='Z')
Bx0, By0, Bz0 = EM.Analytics.FDEM.AnalyticMagDipoleWholeSpace(Rx0.locs,Tx.loc,sigwh,0.0, m = 1.0, orientation='Z')
BxA = Bx - Bx0
ByA = By - By0
BzA = Bz - Bz0
# XYZ2 = Utils.ndgrid(np.r_[0],np.r_[100],x)
# Bx, By, Bz = EM.Analytics.FDEM.AnalyticMagDipoleWholeSpace(np.r_[0,100,0],Tx.loc,sigwh,100., m = 1.0, orientation='Z')
In [66]:
plot(x, np.c_[BzA.real/data[Tx,Rx0]])
Out[66]:
In [53]:
plot(x, np.c_[np.arctan2(Bz.imag,Bz.real)*180./np.pi, np.arctan2(data[Tx,Rx1],data[Tx,Rx0])*180./np.pi])
legend(('ana','data'))
Out[53]:
In [9]:
data = survey.projectFields(fTest)
In [19]:
plot(x, np.c_[data[Tx,Rx0], Bz.real])
legend(('data','Ana'))
Out[19]:
In [48]:
fTest
Out[48]:
In [ ]:
In [16]:
x = np.linspace(-50,50,10)
XYZ = Utils.ndgrid(np.r_[0],np.r_[50],x)
Rx0 = EM.FDEM.RxFDEM(XYZ, 'bzr')
Rx1 = EM.FDEM.RxFDEM(XYZ, 'bzi')
txList = []
for z in np.linspace(-50,50,10):
for freq in [300.,600.,900.]:
Tx = EM.FDEM.TxFDEM(np.r_[0.,-50.,z], 'VMD', freq, [Rx0,Rx1])
txList.append(Tx)
survey = EM.FDEM.SurveyFDEM(txList)
mapping = Maps.ExpMap(mesh)
prb = EM.FDEM.ProblemFDEM_b(mesh, mapping=mapping)
prb.pair(survey)
prb.Solver = MumpsSolver
In [41]:
fB = prb.fields(np.log(sigmaB))
In [ ]:
dB = survey.projectFields(fB)
In [71]:
f300 = dB[survey.getTransmitters(300.)[-1],Rx0]
f600 = dB[survey.getTransmitters(600.)[-1],Rx0]
f900 = dB[survey.getTransmitters(900.)[-1],Rx0]
semilogy(x, np.abs(np.c_[f300,f600,f900]))
legend(('3','6','9'))
# plot(x, np.c_[dpred[Tx0,Rx0], dB[Tx0,Rx0]])
Out[71]:
In [80]:
survey.dobs = survey.dpred(None, u=fB)
survey.std = 0.01
In [81]:
reg = Regularization.Tikhonov(mesh)
dmis = DataMisfit.l2_DataMisfit(survey)
opt = Optimization.InexactGaussNewton(maxIter=3)
invProb = InvProblem.BaseInvProblem(dmis, reg, opt)
beta = Directives.BetaSchedule()
betaest = Directives.BetaEstimate_ByEig()
inv = Inversion.BaseInversion(invProb, directiveList=[beta, betaest])
m0 = np.ones_like(sigmaB)*1e-2
In [82]:
inv.run(np.log(m0))
Out[82]:
In [83]:
mopt = _
In [90]:
colorbar(mesh.plotSlice(mapping*mopt)[0])
Out[90]:
In [85]: