Example #1
0
def run(plotIt=False):
    cs = 25.
    hx = [(cs,7, -1.3),(cs,21),(cs,7, 1.3)]
    hy = [(cs,7, -1.3),(cs,21),(cs,7, 1.3)]
    hz = [(cs,7, -1.3),(cs,20)]
    mesh = Mesh.TensorMesh([hx, hy, hz], 'CCN')
    sighalf = 1e-2
    sigma = np.ones(mesh.nC)*sighalf
    xtemp = np.linspace(-150, 150, 21)
    ytemp = np.linspace(-150, 150, 21)
    xyz_rxP = Utils.ndgrid(xtemp-10., ytemp, np.r_[0.])
    xyz_rxN = Utils.ndgrid(xtemp+10., ytemp, np.r_[0.])
    xyz_rxM = Utils.ndgrid(xtemp, ytemp, np.r_[0.])

    # if plotIt:
    #     fig, ax = plt.subplots(1,1, figsize = (5,5))
    #     mesh.plotSlice(sigma, grid=True, ax = ax)
    #     ax.plot(xyz_rxP[:,0],xyz_rxP[:,1], 'w.')
    #     ax.plot(xyz_rxN[:,0],xyz_rxN[:,1], 'r.', ms = 3)

    rx = DC.RxDipole(xyz_rxP, xyz_rxN)
    src = DC.SrcDipole([rx], [-200, 0, -12.5], [+200, 0, -12.5])
    survey = DC.SurveyDC([src])
    problem = DC.ProblemDC_CC(mesh)
    problem.pair(survey)
    try:
        from pymatsolver import MumpsSolver
        problem.Solver = MumpsSolver
    except Exception, e:
        pass
Example #2
0
    def test_IPforward(self):

        cs = 12.5
        nc = 200 / cs + 1
        hx = [(cs, 7, -1.3), (cs, nc), (cs, 7, 1.3)]
        hy = [(cs, 7, -1.3), (cs, int(nc / 2 + 1)), (cs, 7, 1.3)]
        hz = [(cs, 7, -1.3), (cs, int(nc / 2 + 1))]
        mesh = Mesh.TensorMesh([hx, hy, hz], 'CCN')
        sighalf = 1e-2
        sigma = np.ones(mesh.nC) * sighalf
        p0 = np.r_[-50., 50., -50.]
        p1 = np.r_[50., -50., -150.]
        blk_ind = Utils.ModelBuilder.getIndicesBlock(p0, p1, mesh.gridCC)
        sigma[blk_ind] = 1e-3
        eta = np.zeros_like(sigma)
        eta[blk_ind] = 0.1
        sigmaInf = sigma.copy()
        sigma0 = sigma * (1 - eta)

        nElecs = 11
        x_temp = np.linspace(-100, 100, nElecs)
        aSpacing = x_temp[1] - x_temp[0]
        y_temp = 0.
        xyz = Utils.ndgrid(x_temp, np.r_[y_temp], np.r_[0.])
        srcList = DC.Utils.WennerSrcList(nElecs, aSpacing)
        survey = DC.SurveyDC(srcList)

        imap = Maps.IdentityMap(mesh)
        problem = DC.ProblemDC_CC(mesh, mapping=imap)

        try:
            from pymatsolver import MumpsSolver
            solver = MumpsSolver
        except ImportError, e:
            solver = SolverLU
    def setUp(self):

        aSpacing = 2.5
        nElecs = 10

        surveySize = nElecs * aSpacing - aSpacing
        cs = surveySize / nElecs / 4

        mesh = Mesh.TensorMesh(
            [
                [(cs, 10, -1.3), (cs, surveySize / cs), (cs, 10, 1.3)],
                [(cs, 3, -1.3), (cs, 3, 1.3)],
                #         [(cs,5, -1.3),(cs,10)]
            ],
            'CN')

        srcList = DC.Utils.WennerSrcList(nElecs, aSpacing, in2D=True)
        survey = DC.SurveyDC(srcList)
        problem = DC.ProblemDC_CC(mesh)
        problem.pair(survey)

        mSynth = np.ones(mesh.nC)
        survey.makeSyntheticData(mSynth)

        # Now set up the problem to do some minimization
        dmis = DataMisfit.l2_DataMisfit(survey)
        reg = Regularization.Tikhonov(mesh)
        opt = Optimization.InexactGaussNewton(maxIterLS=20,
                                              maxIter=10,
                                              tolF=1e-6,
                                              tolX=1e-6,
                                              tolG=1e-6,
                                              maxIterCG=6)
        invProb = InvProblem.BaseInvProblem(dmis, reg, opt, beta=1e4)
        inv = Inversion.BaseInversion(invProb)

        self.inv = inv
        self.reg = reg
        self.p = problem
        self.mesh = mesh
        self.m0 = mSynth
        self.survey = survey
        self.dmis = dmis
Example #4
0
                     alpha=0.75,
                     vmin=-1e-2,
                     vmax=1e-2)
cbar = plt.colorbar(im2,
                    format="$10^{%.1f}$",
                    fraction=0.04,
                    orientation="horizontal")
im3 = axs.streamplot(xx,
                     zz,
                     np.zeros((mesh2d.nCy, mesh2d.nCx)),
                     np.zeros((mesh2d.nCy, mesh2d.nCx)),
                     color='k')
im4 = axs.scatter([], [], c='r', s=200)
im5 = axs.scatter([], [], c='r', s=200)

problem = DC.ProblemDC_CC(mesh)
tinf = np.squeeze(Rx[-1][-1, :3]) + np.array([dl_x, dl_y, 0]) * 10 * a


def animate(ii):

    removeStream()

    if not re.match(stype, 'pdp'):

        inds = Utils.closestPoints(mesh, np.asarray(Tx[ii]).T)
        RHS = mesh.getInterpolationMat(np.asarray(Tx[ii]).T,
                                       'CC').T * ([-1, 1] / mesh.vol[inds])

    else: