mirror of
https://github.com/wassname/simpeg.git
synced 2026-08-14 12:50:10 +08:00
129 lines
3.6 KiB
Python
129 lines
3.6 KiB
Python
from SimPEG import Utils, np
|
|
from SimPEG.Survey import BaseSurvey
|
|
|
|
class SurveyTDEM1D(BaseSurvey):
|
|
"""
|
|
docstring for SurveyTDEM1D
|
|
"""
|
|
|
|
txLoc = None #: txLoc
|
|
txType = None #: txType
|
|
rxLoc = None #: rxLoc
|
|
rxType = None #: rxType
|
|
timeCh = None #: timeCh
|
|
nTx = 1 #: Number of transmitters
|
|
|
|
@property
|
|
def nTimeCh(self):
|
|
"""Number of time channels"""
|
|
return self.timeCh.size
|
|
|
|
def __init__(self, **kwargs):
|
|
BaseSurvey.__init__(self, **kwargs)
|
|
Utils.setKwargs(self, **kwargs)
|
|
|
|
def projectFields(self, u):
|
|
#TODO: this is hardcoded to 1Tx
|
|
return self.Qrx.dot(u.b[:,:,0].T).T
|
|
|
|
def projectFieldsAdjoint(self, d):
|
|
# TODO: make the following self.nTimeCh
|
|
d = d.reshape((self.prob.nT, self.nTx), order='F')
|
|
#TODO: *Qtime.T need to multiply by a time projection. (outside for loop??)
|
|
ii = 0
|
|
F = FieldsTDEM(self.prob.mesh, self.nTx, self.prob.nT, 'b')
|
|
for ii in range(self.prob.nT):
|
|
b = self.Qrx.T*d[ii,:]
|
|
F.set_b(b, ii)
|
|
F.set_e(np.zeros((self.prob.mesh.nE,self.nTx)), ii)
|
|
return F
|
|
|
|
####################################################
|
|
# Interpolation Matrices
|
|
####################################################
|
|
|
|
@property
|
|
def Qrx(self):
|
|
if self._Qrx is None:
|
|
if self.rxType == 'bz':
|
|
locType = 'Fz'
|
|
self._Qrx = self.prob.mesh.getInterpolationMat(self.rxLoc, locType=locType)
|
|
return self._Qrx
|
|
_Qrx = None
|
|
|
|
|
|
class FieldsTDEM(object):
|
|
"""docstring for FieldsTDEM"""
|
|
|
|
phi0 = None #: Initial electric potential
|
|
A0 = None #: Initial magnetic vector potential
|
|
e0 = None #: Initial electric field
|
|
b0 = None #: Initial magnetic flux density
|
|
j0 = None #: Initial current density
|
|
h0 = None #: Initial magnetic field
|
|
|
|
phi = None #: Electric potential
|
|
A = None #: Magnetic vector potential
|
|
e = None #: Electric field
|
|
b = None #: Magnetic flux density
|
|
j = None #: Current density
|
|
h = None #: Magnetic field
|
|
|
|
def __init__(self, mesh, nTx, nT, store='b'):
|
|
|
|
self.nT = nT #: Number of times
|
|
self.nTx = nTx #: Number of transmitters
|
|
self.mesh = mesh
|
|
|
|
def update(self, newFields, tInd):
|
|
self.set_b(newFields['b'], tInd)
|
|
self.set_e(newFields['e'], tInd)
|
|
|
|
def fieldVec(self):
|
|
u = np.ndarray((0, self.nTx))
|
|
for i in range(self.nT):
|
|
u = np.r_[u, self.get_b(i), self.get_e(i)]
|
|
if self.nTx == 1:
|
|
u = u.flatten()
|
|
return u
|
|
|
|
####################################################
|
|
# Get Methods
|
|
####################################################
|
|
|
|
def get_b(self, ind):
|
|
if ind == -1:
|
|
return self.b0
|
|
else:
|
|
return self.b[ind,:,:]
|
|
|
|
def get_e(self, ind):
|
|
if ind == -1:
|
|
return self.e0
|
|
else:
|
|
return self.e[ind,:,:]
|
|
|
|
####################################################
|
|
# Set Methods
|
|
####################################################
|
|
|
|
def set_b(self, b, ind):
|
|
if self.b is None:
|
|
self.b = np.zeros((self.nT, np.sum(self.mesh.nF), self.nTx))
|
|
self.b[:] = np.nan
|
|
if len(b.shape) == 1:
|
|
b = b[:, np.newaxis]
|
|
self.b[ind,:,:] = b
|
|
|
|
def set_e(self, e, ind):
|
|
if self.e is None:
|
|
self.e = np.zeros((self.nT, np.sum(self.mesh.nE), self.nTx))
|
|
self.e[:] = np.nan
|
|
if len(e.shape) == 1:
|
|
e = e[:, np.newaxis]
|
|
self.e[ind,:,:] = e
|
|
|
|
|
|
def __contains__(self, key):
|
|
return key in self.children
|