def halfSpaceProblemAnaVMDDiff(showIt=False, waveformType="STEPOFF"):
    cs, ncx, ncz, npad = 20., 25, 25, 15
    hx = [(cs, ncx), (cs, npad, 1.3)]
    hz = [(cs, npad, -1.3), (cs, ncz), (cs, npad, 1.3)]
    mesh = Mesh.CylMesh([hx, 1, hz], '00C')
    sighalf = 1e-2
    siginf = np.ones(mesh.nC) * 1e-8
    siginf[mesh.gridCC[:, -1] < 0.] = sighalf
    eta = np.ones(mesh.nC) * 0.2
    tau = np.ones(mesh.nC) * 0.005
    c = np.ones(mesh.nC) * 0.7
    m = np.r_[siginf, eta, tau, c]
    iMap = Maps.IdentityMap(nP=int(mesh.nC))
    maps = [('sigmaInf', iMap), ('eta', iMap), ('tau', iMap), ('c', iMap)]
    prb = ProblemATEMIP_b(mesh, mapping=maps)

    if waveformType == "GENERAL":
        # timeon = np.cumsum(np.r_[np.ones(10)*1e-3, np.ones(10)*5e-4, np.ones(10)*1e-4])
        timeon = np.cumsum(np.r_[np.ones(10) * 1e-3,
                                 np.ones(10) * 5e-4,
                                 np.ones(10) * 1e-4])
        timeon -= timeon.max()
        timeoff = np.cumsum(np.r_[np.ones(20) * 1e-5,
                                  np.ones(20) * 1e-4,
                                  np.ones(20) * 1e-3])
        time = np.r_[timeon, timeoff]
        current_on = np.ones_like(timeon)
        current_on[[0, -1]] = 0.
        current = np.r_[current_on, np.zeros_like(timeoff)]
        wave = np.c_[time, current]
        prb.waveformType = "GENERAL"
        prb.currentwaveform(wave)
        prb.t0 = time.min()
    elif waveformType == "STEPOFF":
        prb.timeSteps = [(1e-5, 20), (1e-4, 20), (1e-3, 10)]
    offset = 20.
    tobs = np.logspace(-4, -2, 21)
    rx = EM.TDEM.RxTDEM(np.array([[offset, 0., 0.]]), tobs, "bz")
    src = EM.TDEM.SrcTDEM_VMD_MVP([rx],
                                  np.array([[0., 0., 0.]]),
                                  waveformType=waveformType)
    survey = EM.TDEM.SurveyTDEM([src])
    prb.Solver = MumpsSolver
    prb.pair(survey)
    out = survey.dpred(m)
    bz_ana = mu_0 * hzAnalyticDipoleT_CC(
        offset, rx.times, sigmaInf=sighalf, eta=eta[0], tau=tau[0], c=c[0])
    err = np.linalg.norm(bz_ana - out) / np.linalg.norm(bz_ana)
    print '>> Relative error = ', err

    if showIt:
        plt.loglog(rx.times, abs(bz_ana), 'k')
        plt.loglog(rx.times, abs(out), 'b.')
        plt.show()
    return err
Exemple #2
0
def halfSpaceProblemAnaVMDDiff(showIt=False, waveformType="STEPOFF"):
    cs, ncx, ncz, npad = 20., 25, 25, 15
    hx = [(cs, ncx), (cs, npad, 1.3)]
    hz = [(cs, npad, -1.3), (cs, ncz), (cs, npad, 1.3)]
    mesh = Mesh.CylMesh([hx, 1, hz], '00C')
    prb = ProblemATEM_b(mesh)
    if waveformType == "GENERAL":
        timeon = np.cumsum(np.r_[np.ones(10) * 1e-3,
                                 np.ones(10) * 5e-4,
                                 np.ones(10) * 1e-4])
        timeon -= timeon.max()
        timeoff = np.cumsum(np.r_[np.ones(10) * 5e-5,
                                  np.ones(10) * 1e-4,
                                  np.ones(10) * 5e-4,
                                  np.ones(10) * 1e-3,
                                  np.ones(10) * 5e-3])
        time = np.r_[timeon, timeoff]
        current_on = np.ones_like(timeon)
        current_on[[0, -1]] = 0.
        current = np.r_[current_on, np.zeros_like(timeoff)]
        wave = np.c_[time, current]
        prb.waveformType = "GENERAL"
        prb.currentwaveform(wave)
        prb.t0 = time.min()
    elif waveformType == "STEPOFF":
        prb.timeSteps = [(1e-5, 10), (5e-5, 10), (1e-4, 10), (5e-4, 10),
                         (1e-3, 10), (5e-3, 10)]
    offset = 20.
    tobs = np.logspace(-4, -2, 21)
    rx = EM.TDEM.RxTDEM(np.array([[offset, 0., 0.]]), tobs, "bz")
    src = EM.TDEM.SrcTDEM_VMD_MVP([rx],
                                  np.array([[0., 0., 0.]]),
                                  waveformType=waveformType)
    survey = EM.TDEM.SurveyTDEM([src])
    prb.Solver = MumpsSolver
    sigma = np.ones(mesh.nC) * 1e-8
    active = mesh.gridCC[:, 2] < 0.
    sig_half = 1e-2
    sigma[active] = sig_half
    prb.pair(survey)

    out = survey.dpred(sigma)
    bz_ana = mu_0 * hzAnalyticDipoleT(offset, rx.times, sig_half)
    err = np.linalg.norm(bz_ana - out) / np.linalg.norm(bz_ana)
    print '>> Relative error = ', err

    if showIt:
        plt.loglog(rx.times, bz_ana, 'k')
        plt.loglog(rx.times, out, 'b.')
        plt.show()
    return err
def halfSpaceProblemAnaVMDDiff(showIt=False, waveformType="STEPOFF"):
	cs, ncx, ncz, npad = 20., 25, 25, 15
	hx = [(cs,ncx), (cs,npad,1.3)]
	hz = [(cs,npad,-1.3), (cs,ncz), (cs,npad,1.3)]
	mesh = Mesh.CylMesh([hx,1,hz], '00C')   
	sighalf = 1e-2
	siginf = np.ones(mesh.nC)*1e-8
	siginf[mesh.gridCC[:,-1]<0.] = sighalf
	eta = np.ones(mesh.nC)*0.2
	tau = np.ones(mesh.nC)*0.005
	c = np.ones(mesh.nC)*0.7
	m = np.r_[siginf, eta, tau, c]
	iMap = Maps.IdentityMap(nP=int(mesh.nC))
	maps = [('sigmaInf', iMap), ('eta', iMap), ('tau', iMap), ('c', iMap)]
	prb = ProblemATEMIP_b(mesh, mapping = maps)	

	if waveformType =="GENERAL":
		# timeon = np.cumsum(np.r_[np.ones(10)*1e-3, np.ones(10)*5e-4, np.ones(10)*1e-4])
		timeon = np.cumsum(np.r_[np.ones(10)*1e-3, np.ones(10)*5e-4, np.ones(10)*1e-4])
		timeon -= timeon.max()
		timeoff = np.cumsum(np.r_[np.ones(20)*1e-5, np.ones(20)*1e-4, np.ones(20)*1e-3])
		time = np.r_[timeon, timeoff]
		current_on = np.ones_like(timeon)
		current_on[[0,-1]] = 0.
		current = np.r_[current_on, np.zeros_like(timeoff)]
		wave = np.c_[time, current]		
		prb.waveformType = "GENERAL"
		prb.currentwaveform(wave)
		prb.t0 = time.min()
	elif waveformType =="STEPOFF":
		prb.timeSteps = [(1e-5, 20), (1e-4, 20), (1e-3, 10)]
	offset = 20.
	tobs = np.logspace(-4, -2, 21)
	rx = EM.TDEM.RxTDEM(np.array([[offset, 0., 0.]]), tobs, "bz")
	src = EM.TDEM.SrcTDEM_VMD_MVP([rx], np.array([[0., 0., 0.]]), waveformType=waveformType)
	survey = EM.TDEM.SurveyTDEM([src])
	prb.Solver = MumpsSolver
	prb.pair(survey)
	out = survey.dpred(m)
	bz_ana = mu_0*hzAnalyticDipoleT_CC(offset, rx.times, sigmaInf=sighalf, eta=eta[0], tau=tau[0], c=c[0])
	err = np.linalg.norm(bz_ana-out)/np.linalg.norm(bz_ana)
	print '>> Relative error = ', err

	if showIt:
		plt.loglog(rx.times, abs(bz_ana), 'k')
		plt.loglog(rx.times, abs(out), 'b.')
		plt.show()	
	return err
Exemple #4
0
def halfSpaceProblemAnaVMDDiff(showIt=False, waveformType="STEPOFF"):
	cs, ncx, ncz, npad = 20., 25, 25, 15
	hx = [(cs,ncx), (cs,npad,1.3)]
	hz = [(cs,npad,-1.3), (cs,ncz), (cs,npad,1.3)]
	mesh = Mesh.CylMesh([hx,1,hz], '00C')    
	prb = ProblemATEM_b(mesh)
	if waveformType =="GENERAL":
		timeon = np.cumsum(np.r_[np.ones(10)*1e-3, np.ones(10)*5e-4, np.ones(10)*1e-4])
		timeon -= timeon.max()
		timeoff = np.cumsum(np.r_[np.ones(10)*5e-5, np.ones(10)*1e-4, np.ones(10)*5e-4, np.ones(10)*1e-3, np.ones(10)*5e-3])
		time = np.r_[timeon, timeoff]
		current_on = np.ones_like(timeon)
		current_on[[0,-1]] = 0.
		current = np.r_[current_on, np.zeros_like(timeoff)]
		wave = np.c_[time, current]		
		prb.waveformType = "GENERAL"
		prb.currentwaveform(wave)
		prb.t0 = time.min()
	elif waveformType =="STEPOFF":
		prb.timeSteps = [(1e-5, 10), (5e-5, 10), (1e-4, 10), (5e-4, 10), (1e-3, 10),(5e-3, 10)]
	offset = 20.
	tobs = np.logspace(-4, -2, 21)
	rx = EM.TDEM.RxTDEM(np.array([[offset, 0., 0.]]), tobs, "bz")
	src = EM.TDEM.SrcTDEM_VMD_MVP([rx], np.array([[0., 0., 0.]]), waveformType=waveformType)
	survey = EM.TDEM.SurveyTDEM([src])
	prb.Solver = MumpsSolver
	sigma = np.ones(mesh.nC)*1e-8
	active = mesh.gridCC[:,2]<0.
	sig_half = 1e-2
	sigma[active] = sig_half
	prb.pair(survey)

	out = survey.dpred(sigma)
	bz_ana = mu_0*hzAnalyticDipoleT(offset, rx.times, sig_half)
	err = np.linalg.norm(bz_ana-out)/np.linalg.norm(bz_ana)
	print '>> Relative error = ', err

	if showIt:
		plt.loglog(rx.times, bz_ana, 'k')
		plt.loglog(rx.times, out, 'b.')
		plt.show()	
	return err
Exemple #5
0
nz = mesh.vectorNz
endp = np.c_[np.asarray(temp), np.ones(2).T * nz[-1]]

# Create dipole survey receivers and plot
nrx = 10
ab = 40
a = 20

# Evenly distribute transmitters for now and put on surface
dplen = np.sqrt(np.sum((endp[1, :] - endp[0, :])**2))
dp_x = (endp[1, 0] - endp[0, 0]) / dplen
dp_y = (endp[1, 1] - endp[0, 1]) / dplen

nstn = np.floor(dplen / ab)

stn_x = endp[0, 0] + np.cumsum(np.ones(nstn) * dp_x * ab)
stn_y = endp[0, 1] + np.cumsum(np.ones(nstn) * dp_y * ab)

plt.scatter(stn_x, stn_y, s=100, c='w')

M = np.c_[stn_x - a * dp_x, stn_y - a * dp_y, np.ones(nstn).T * nz[-1]]
N = np.c_[stn_x + a * dp_x, stn_y + a * dp_y, np.ones(nstn).T * nz[-1]]

plt.scatter(M[:, 0], M[:, 1], s=10, c='r')
plt.scatter(N[:, 0], N[:, 1], s=10, c='b')

#%% Create inversion parameter

Rx = DC.RxDipole(M, N)
Tx = DC.SrcDipole([Rx], tx[0, :], tx[1, :])
survey = DC.SurveyDC([Tx])
Exemple #6
0
                self._tangents = (np.r_[edge1, edge2, edge3] /
                                  np.c_[self._edge, self._edge, self._edge])
            return self._edge
        return self._edge

    @property
    def tangents(self):
        """
        Edge tangents
        """
        if getattr(self, '_tangents', None) is None:
            self.edge  # calling .edge will create the tangents
        return self._tangents


if __name__ == '__main__':
    nc = 5
    h1 = np.cumsum(np.r_[0, np.ones(nc) / (nc)])
    nc = 7
    h2 = np.cumsum(np.r_[0, np.ones(nc) / (nc)])
    h3 = np.cumsum(np.r_[0, np.ones(nc) / (nc)])
    dee3 = True
    if dee3:
        X, Y, Z = Utils.ndgrid(h1, h2, h3, vector=False)
        M = CurvilinearMesh([X, Y, Z])
    else:
        X, Y = Utils.ndgrid(h1, h2, vector=False)
        M = CurvilinearMesh([X, Y])

    print M.r(M.normals, 'F', 'Fx', 'V')
Exemple #7
0
                                  np.c_[self._edge, self._edge, self._edge])
            return self._edge
        return self._edge

    @property
    def tangents(self):
        """
        Edge tangents
        """
        if getattr(self, '_tangents', None) is None:
            self.edge  # calling .edge will create the tangents
        return self._tangents



if __name__ == '__main__':
    nc = 5
    h1 = np.cumsum(np.r_[0, np.ones(nc)/(nc)])
    nc = 7
    h2 = np.cumsum(np.r_[0, np.ones(nc)/(nc)])
    h3 = np.cumsum(np.r_[0, np.ones(nc)/(nc)])
    dee3 = True
    if dee3:
        X, Y, Z = Utils.ndgrid(h1, h2, h3, vector=False)
        M = CurvilinearMesh([X, Y, Z])
    else:
        X, Y = Utils.ndgrid(h1, h2, vector=False)
        M = CurvilinearMesh([X, Y])

    print(M.r(M.normals, 'F', 'Fx', 'V'))
Exemple #8
0
# Add intermediate tiles until the min_Olap is respected
# First in the x-direction
lx = np.floor((max_mcell / mesh.nCz)**0.5)
ntile = 2
Olap = -1

while Olap < min_Olap:

    ntile += 1

    # Set location of SW corners
    #x0 = np.c_[xmin,xmax-lx*dx]

    dx_t = np.round((endl[1, 0] - endl[0, 0]) / ((ntile - 1) * dx))

    x1 = np.r_[endl[0, 0], endl[0, 0] + np.cumsum(
        (np.ones(ntile - 2)) * dx_t * dx), endl[1, 0]]
    x2 = x1 + lx * dx

    y1 = np.ones(len(x1)) * ymin
    y2 = np.ones(len(x1)) * (ymax + lx * dx)

    Olap = x1[0] + lx * dx - x1[1]

#%% Run forward modeling
# Compute forward model using integral equation
#d = PF.Magnetics.Intgrl_Fwr_Data(mesh,B,M,rxLoc,model,actv,'tmi')

# Form data object with coordinates and write to file
#wd =  np.zeros((ndata,1))
#
# Save forward data to file
Exemple #9
0
     
 mshfile2d = 'Mesh_2D.msh'
 modfile2d = 'MtIsa_2D.con'
 obsfile2d = 'FWR_3D_2_2D.dat'
 inp_file = 'dcinv2d.inp'
 
 
 # Export 2D mesh
 fid = open(inv_dir + dsep + mshfile2d,'w')
 fid.write('%i\n'% mesh2d.nCx)
 fid.write('%f %f 1\n'% (mesh2d.vectorNx[0],mesh2d.vectorNx[1]))  
 np.savetxt(fid, np.c_[mesh2d.vectorNx[2:],np.ones(mesh2d.nCx-1)], fmt='\t %e %i',delimiter=' ',newline='\n')
 fid.write('\n')
 fid.write('%i\n'% mesh2d.nCy)
 fid.write('%f %f 1\n'%( 0,mesh2d.hy[-1]))   
 np.savetxt(fid, np.c_[np.cumsum(mesh2d.hy[-2::-1])+mesh2d.hy[-1],np.ones(mesh2d.nCy-1)], fmt='\t %e %i',delimiter=' ',newline='\n')
 fid.close()
 
 # Export 2D model
 fid = open(inv_dir + dsep + modfile2d,'w')
 fid.write('%i %i\n'% (mesh2d.nCx,mesh2d.nCy))
 np.savetxt(fid, mkvc(m2D[::-1,:].T), fmt='%e',delimiter=' ',newline='\n')
 fid.close()
 
 # Export data file
 DC.writeUBC_DCobs(inv_dir + dsep + obsfile2d,Tx2d,Rx2d,data,unct,'2D') 
 
 # Write input file
 fid = open(inv_dir + dsep + inp_file,'w')
 fid.write('OBS LOC_X %s \n'% obsfile2d)
 fid.write('MESH FILE %s \n'% mshfile2d)