Tx -> Src

This commit is contained in:
Lindsey Heagy
2015-04-30 15:33:21 -07:00
parent 932deb21ee
commit f5900aaeab
+45 -45
View File
@@ -3,7 +3,7 @@ from SimPEG.Utils import sdiag, mkvc, sdInv
import matplotlib.pyplot as plt import matplotlib.pyplot as plt
from time import clock from time import clock
class AcousticTx(Survey.BaseTx): class AcousticSrc(Survey.BaseSrc):
def __init__(self, loc, time, rxList, **kwargs): def __init__(self, loc, time, rxList, **kwargs):
@@ -45,9 +45,9 @@ class AcousticTx(Survey.BaseTx):
def getq(self, mesh): def getq(self, mesh):
txind = Utils.closestPoints(mesh, self.loc, gridLoc='CC') srcind = Utils.closestPoints(mesh, self.loc, gridLoc='CC')
q = sdiag(1/mesh.vol)*np.zeros(mesh.nC) q = sdiag(1/mesh.vol)*np.zeros(mesh.nC)
q[txind] = 1. q[srcind] = 1.
return q return q
@@ -80,15 +80,15 @@ class SurveyAcoustic(Survey.BaseSurvey):
""" """
def __init__(self, txList,**kwargs): def __init__(self, srcList,**kwargs):
self.txList = txList self.srcList = srcList
Survey.BaseSurvey.__init__(self, **kwargs) Survey.BaseSurvey.__init__(self, **kwargs)
def projectFields(self, u): def projectFields(self, u):
data = [] data = []
for i, tx in enumerate(self.txList): for i, src in enumerate(self.srcList):
Proj = tx.rxList[0].getP(self.prob.mesh) Proj = src.rxList[0].getP(self.prob.mesh)
data.append(Proj*u[i]) data.append(Proj*u[i])
return data return data
@@ -202,20 +202,20 @@ class AcousticProblemSponge(Problem.BaseProblem):
if self.storefield==True: if self.storefield==True:
P = [] P = []
#TODO: parallize in terms of sources #TODO: parallize in terms of sources
ntx = len(self.survey.txList) nsrc = len(self.survey.srcList)
for itx, tx in enumerate(self.survey.txList): for isrc, src in enumerate(self.survey.srcList):
print (" Tx at (%7.2f, %7.2f): %4i/%4i")%(tx.loc[0], tx.loc[0], itx+1, ntx) print (" Src at (%7.2f, %7.2f): %4i/%4i")%(src.loc[0], src.loc[0], isrc+1, nsrc)
pn = np.zeros(self.mesh.nC) pn = np.zeros(self.mesh.nC)
p0 = np.zeros_like(pn) p0 = np.zeros_like(pn)
un = np.zeros(self.mesh.nF) un = np.zeros(self.mesh.nF)
u0 = np.zeros_like(un) u0 = np.zeros_like(un)
time = tx.time time = src.time
dt = tx.dt dt = src.dt
p = np.zeros((self.mesh.nC, time.size)) p = np.zeros((self.mesh.nC, time.size))
q = tx.getq(self.mesh) q = src.getq(self.mesh)
for i in range(time.size-1): for i in range(time.size-1):
sn = tx.Wave(i+1) sn = src.Wave(i+1)
s0 = tx.Wave(i) s0 = src.Wave(i)
pn = p0-dt*DSig*p0+Drhoi*dt*(Div*un+(sn-s0)/dt*q) pn = p0-dt*DSig*p0+Drhoi*dt*(Div*un+(sn-s0)/dt*q)
p0 = pn.copy() p0 = pn.copy()
# un = u0 - dt*sdiag(AvF2CC.T*self.sig)*u0 + dt*MfmuiI*Grad*p0 # un = u0 - dt*sdiag(AvF2CC.T*self.sig)*u0 + dt*MfmuiI*Grad*p0
@@ -233,21 +233,21 @@ class AcousticProblemSponge(Problem.BaseProblem):
Data = [] Data = []
ntx = len(self.survey.txList) nsrc = len(self.survey.srcList)
for itx, tx in enumerate(self.survey.txList): for isrc, src in enumerate(self.survey.srcList):
print (" Tx at (%7.2f, %7.2f): %4i/%4i")%(tx.loc[0], tx.loc[0], itx+1, ntx) print (" Src at (%7.2f, %7.2f): %4i/%4i")%(src.loc[0], src.loc[0], isrc+1, nsrc)
pn = np.zeros(self.mesh.nC) pn = np.zeros(self.mesh.nC)
p0 = np.zeros_like(pn) p0 = np.zeros_like(pn)
un = np.zeros(self.mesh.nF) un = np.zeros(self.mesh.nF)
u0 = np.zeros_like(un) u0 = np.zeros_like(un)
time = tx.time time = src.time
dt = tx.dt dt = src.dt
data = np.zeros((time.size, tx.nD)) data = np.zeros((time.size, src.nD))
q = tx.getq(self.mesh) q = src.getq(self.mesh)
Proj = tx.rxList[0].getP(self.mesh) Proj = src.rxList[0].getP(self.mesh)
for i in range(time.size-1): for i in range(time.size-1):
sn = tx.Wave(i+1) sn = src.Wave(i+1)
s0 = tx.Wave(i) s0 = src.Wave(i)
pn = p0-dt*DSig*p0+Drhoi*dt*(Div*un+(sn-s0)/dt*q) pn = p0-dt*DSig*p0+Drhoi*dt*(Div*un+(sn-s0)/dt*q)
p0 = pn.copy() p0 = pn.copy()
# un = u0 - dt*sdiag(AvF2CC.T*self.sig)*u0 + dt*MfmuiI*Grad*p0 # un = u0 - dt*sdiag(AvF2CC.T*self.sig)*u0 + dt*MfmuiI*Grad*p0
@@ -372,22 +372,22 @@ class AcousticProblemPML(Problem.BaseProblem):
if self.storefield==True: if self.storefield==True:
Phi = [] Phi = []
#TODO: parallize in terms of sources #TODO: parallize in terms of sources
ntx = len(self.survey.txList) nsrc = len(self.survey.srcList)
for itx, tx in enumerate(self.survey.txList): for isrc, src in enumerate(self.survey.srcList):
print (" Tx at (%7.2f, %7.2f): %4i/%4i")%(tx.loc[0], tx.loc[0], itx+1, ntx) print (" Src at (%7.2f, %7.2f): %4i/%4i")%(src.loc[0], src.loc[0], isrc+1, nsrc)
phi = np.zeros((self.mesh.nC, tx.time.size)) phi = np.zeros((self.mesh.nC, src.time.size))
phin = np.zeros(self.mesh.nC*2) phin = np.zeros(self.mesh.nC*2)
phi0 = np.zeros_like(phin) phi0 = np.zeros_like(phin)
un = np.zeros(self.mesh.nF) un = np.zeros(self.mesh.nF)
u0 = np.zeros_like(un) u0 = np.zeros_like(un)
time = tx.time time = src.time
dt = tx.dt dt = src.dt
q = tx.getq(self.mesh) q = src.getq(self.mesh)
qvec = np.r_[q, q]*1/2 qvec = np.r_[q, q]*1/2
for i in range(time.size-1): for i in range(time.size-1):
sn = tx.Wave(i+1) sn = src.Wave(i+1)
s0 = tx.Wave(i) s0 = src.Wave(i)
phin = phi0-dt*(Msigcc*phi0)+dt*MrhoccI*(1/dt*(sn-s0)*qvec+Divvec*un) phin = phi0-dt*(Msigcc*phi0)+dt*MrhoccI*(1/dt*(sn-s0)*qvec+Divvec*un)
phi0 = phin.copy() phi0 = phin.copy()
un = u0 - dt*Msigf*u0 + dt*MmuifvecI*Grad*(Ivec*phi0) un = u0 - dt*Msigf*u0 + dt*MmuifvecI*Grad*(Ivec*phi0)
@@ -403,22 +403,22 @@ class AcousticProblemPML(Problem.BaseProblem):
Data = [] Data = []
ntx = len(self.survey.txList) nsrc = len(self.survey.srcList)
for itx, tx in enumerate(self.survey.txList): for isrc, src in enumerate(self.survey.srcList):
print (" Tx at (%7.2f, %7.2f): %4i/%4i")%(tx.loc[0], tx.loc[0], itx+1, ntx) print (" Src at (%7.2f, %7.2f): %4i/%4i")%(src.loc[0], src.loc[0], isrc+1, nsrc)
phi = np.zeros((mesh.nC, time.size)) phi = np.zeros((mesh.nC, time.size))
phin = np.zeros(mesh.nC*2) phin = np.zeros(mesh.nC*2)
phi0 = np.zeros_like(phin) phi0 = np.zeros_like(phin)
un = np.zeros(mesh.nF) un = np.zeros(mesh.nF)
u0 = np.zeros_like(un) u0 = np.zeros_like(un)
time = tx.time time = src.time
dt = tx.dt dt = src.dt
p = np.zeros((self.mesh.nC, time.size)) p = np.zeros((self.mesh.nC, time.size))
q = tx.getq(self.mesh) q = src.getq(self.mesh)
qvec = np.r_[q, q]*1/2 qvec = np.r_[q, q]*1/2
for i in range(time.size-1): for i in range(time.size-1):
sn = tx.Wave(i+1) sn = src.Wave(i+1)
s0 = tx.Wave(i) s0 = src.Wave(i)
phin = phi0-dt*(Msigcc*phi0)+dt*MrhoccI*(1/dt*(sn-s0)*qvec+Divvec*un) phin = phi0-dt*(Msigcc*phi0)+dt*MrhoccI*(1/dt*(sn-s0)*qvec+Divvec*un)
phi0 = phin.copy() phi0 = phin.copy()
un = u0 - dt*Msigf*u0 + dt*MmuifvecI*Grad*(Ivec*phi0) un = u0 - dt*Msigf*u0 + dt*MmuifvecI*Grad*(Ivec*phi0)
@@ -438,9 +438,9 @@ if __name__ == '__main__':
dt = time[1]-time[0] dt = time[1]-time[0]
options={'tlag':0.0025, 'fmain':400} options={'tlag':0.0025, 'fmain':400}
rx = AcousticRx(np.vstack((np.r_[0, 1], np.r_[0, 1]))) rx = AcousticRx(np.vstack((np.r_[0, 1], np.r_[0, 1])))
tx = AcousticTx(np.r_[0, 1], time, [rx], **options) src = AcousticSrc(np.r_[0, 1], time, [rx], **options)
survey = SurveyAcoustic([tx]) survey = SurveyAcoustic([src])
wave = tx.RickerWavelet() wave = src.RickerWavelet()
cs = 0.5 cs = 0.5
hx = np.ones(150)*cs hx = np.ones(150)*cs
hy = np.ones(150)*cs hy = np.ones(150)*cs