Beispiel #1
0
def model_fields(A, B, h0, h1, rho0, rho1, rho2):
    # Create halfspace model
    # halfspaceMod = sig2 * np.ones([mesh.nC])
    # mhalf = np.log(halfspaceMod)
    # Create layered model with background resistivities

    resistivity_model = ModelBuilder.layeredModel(mesh.gridCC,
                                                  np.r_[0., -h0, -(h0 + h1)],
                                                  np.r_[rho0, rho1, rho2])

    Mx = mesh.gridCC
    # Nx = np.empty(shape=(mesh.nC, 2))
    rx = DC.Rx.Pole_ky(Mx)
    # rx = DC.Rx.Dipole(Mx,Nx)
    if B == []:
        src = DC.Src.Pole([rx], np.r_[A, 0.0])
    else:
        src = DC.Src.Dipole([rx], np.r_[A, 0.0], np.r_[B, 0.0])
    survey = DC.Survey_ky([src])
    problem = DC.Problem2D_CC(mesh,
                              rhoMap=mapping,
                              Solver=Pardiso,
                              survey=survey)

    mesh.setCellGradBC("neumann")
    cellGrad = mesh.cellGrad
    faceDiv = mesh.faceDiv

    phi_total = problem.dpred(resistivity_model)
    e_total = -cellGrad * phi_total
    j_total = problem.MfRhoI * problem.Grad * phi_total
    q_total = epsilon_0 * problem.Vol * (faceDiv * e_total)
    total_field = {"phi": phi_total, "e": e_total, "j": j_total, "q": q_total}

    return src, total_field
Beispiel #2
0
def getSensitivity(survey, A, B, M, N, model):

    if survey == "Dipole-Dipole":
        rx = DC.receivers.Dipole_ky(np.r_[M, 0.0], np.r_[N, 0.0])
        src = DC.sources.Dipole([rx], np.r_[A, 0.0], np.r_[B, 0.0])
    elif survey == "Pole-Dipole":
        rx = DC.receivers.Dipole_ky(np.r_[M, 0.0], np.r_[N, 0.0])
        src = DC.sources.Pole([rx], np.r_[A, 0.0])
    elif survey == "Dipole-Pole":
        rx = DC.receivers.Pole_ky(np.r_[M, 0.0])
        src = DC.sources.Dipole([rx], np.r_[A, 0.0], np.r_[B, 0.0])
    elif survey == "Pole-Pole":
        rx = DC.receivers.Pole_ky(np.r_[M, 0.0])
        src = DC.sources.Pole([rx], np.r_[A, 0.0])

    Srv = DC.Survey_ky([src])
    problem = DC.simulation_2d.Problem2D_CC(mesh,
                                            survey=Srv,
                                            sigmaMap=sigmaMap)
    problem.Solver = Pardiso
    fieldObj = problem.fields(model)

    J = problem.Jtvec(model, np.array([1.0]), f=fieldObj)

    return J
Beispiel #3
0
def getSensitivity(survey, A, B, M, N, model):

    if survey == "Dipole-Dipole":
        rx = DC.receivers.Dipole_ky(np.r_[M, 0.0], np.r_[N, 0.0])
        src = DC.sources.Dipole([rx], np.r_[A, 0.0], np.r_[B, 0.0])
    elif survey == "Pole-Dipole":
        rx = DC.receivers.Dipole_ky(np.r_[M, 0.0], np.r_[N, 0.0])
        src = DC.sources.Pole([rx], np.r_[A, 0.0])
    elif survey == "Dipole-Pole":
        rx = DC.receivers.Pole_ky(np.r_[M, 0.0])
        src = DC.sources.Dipole([rx], np.r_[A, 0.0], np.r_[B, 0.0])
    elif survey == "Pole-Pole":
        rx = DC.receivers.Pole_ky(np.r_[M, 0.0])
        src = DC.sources.Pole([rx], np.r_[A, 0.0])

    survey = DC.Survey_ky([src])
    problem = DC.simulation_2d.Simulation2DCellCentered(mesh,
                                                        survey=survey,
                                                        sigmaMap=mapping)
    problem.Solver = SolverLU
    fieldObj = problem.fields(model)

    J = problem.Jtvec(model, np.array([1.0]), f=fieldObj)

    return J
def getSensitivity(survey, A, B, M, N, model):

    if survey == "Dipole-Dipole":
        rx = DC.Rx.Dipole_ky(np.r_[M, 0.0], np.r_[N, 0.0])
        src = DC.Src.Dipole([rx], np.r_[A, 0.0], np.r_[B, 0.0])
    elif survey == "Pole-Dipole":
        rx = DC.Rx.Dipole_ky(np.r_[M, 0.0], np.r_[N, 0.0])
        src = DC.Src.Pole([rx], np.r_[A, 0.0])
    elif survey == "Dipole-Pole":
        rx = DC.Rx.Pole_ky(np.r_[M, 0.0])
        src = DC.Src.Dipole([rx], np.r_[A, 0.0], np.r_[B, 0.0])
    elif survey == "Pole-Pole":
        rx = DC.Rx.Pole_ky(np.r_[M, 0.0])
        src = DC.Src.Pole([rx], np.r_[A, 0.0])

    survey = DC.Survey_ky([src])
    problem = DC.Problem2D_CC(mesh,
                              sigmaMap=mapping,
                              Solver=Pardiso,
                              survey=survey)
    fieldObj = problem.fields(model)

    J = problem.Jtvec(model, np.array([1.0]), f=fieldObj)

    return J
def model_fields(A, B, zcLayer, dzLayer, xc, zc, r, sigLayer, sigTarget,
                 sigHalf):
    # Create halfspace model
    halfspaceMod = sigHalf * np.ones([mesh.nC])
    mhalf = np.log(halfspaceMod)
    # Add layer to model
    LayerMod = addLayer2Mod(zcLayer, dzLayer, halfspaceMod, sigLayer)

    # Add plate or cylinder
    # fullMod = addPlate2Mod(xc,zc,dx,dz,rotAng,LayerMod,sigTarget)
    fullMod = addCylinder2Mod(xc, zc, r, LayerMod, sigTarget)
    mtrue = np.log(fullMod)

    Mx = mesh.gridCC
    # Nx = np.empty(shape=(mesh.nC, 2))
    rx = DC.Rx.Pole_ky(Mx)
    # rx = DC.Rx.Dipole(Mx,Nx)
    if B == []:
        src = DC.Src.Pole([rx], np.r_[A, 0.0])
    else:
        src = DC.Src.Dipole([rx], np.r_[A, 0.0], np.r_[B, 0.0])
    # src = DC.Src.Dipole_ky([rx], np.r_[A,0.], np.r_[B,0.])
    survey = DC.Survey_ky([src])
    # survey = DC.Survey([src])
    # survey_prim = DC.Survey([src])
    # problem = DC.Problem3D_CC(mesh, sigmaMap = mapping)
    problem = DC.Problem2D_CC(mesh,
                              sigmaMap=mapping,
                              Solver=Pardiso,
                              survey=survey)
    # problem_prim = DC.Problem3D_CC(mesh, sigmaMap = mapping)
    problem_prim = DC.Problem2D_CC(mesh,
                                   sigmaMap=mapping,
                                   Solver=Pardiso,
                                   survey=survey)

    mesh.setCellGradBC("neumann")
    cellGrad = mesh.cellGrad
    faceDiv = mesh.faceDiv

    phi_primary = problem_prim.dpred(mhalf)
    e_primary = -cellGrad * phi_primary
    j_primary = problem_prim.MfRhoI * problem_prim.Grad * phi_primary
    q_primary = epsilon_0 * problem_prim.Vol * (faceDiv * e_primary)
    primary_field = {
        "phi": phi_primary,
        "e": e_primary,
        "j": j_primary,
        "q": q_primary
    }

    phi_total = problem.dpred(mtrue)
    e_total = -cellGrad * phi_total
    j_total = problem.MfRhoI * problem.Grad * phi_total
    q_total = epsilon_0 * problem.Vol * (faceDiv * e_total)
    total_field = {"phi": phi_total, "e": e_total, "j": j_total, "q": q_total}

    return mtrue, mhalf, src, primary_field, total_field
Beispiel #6
0
def cylinder_fields(A, B, r, sigcyl, sighalf, xc=0.0, zc=-20.0):

    circhalf = np.r_[np.log(sighalf), np.log(sighalf), xc, zc, r]
    circtrue = np.r_[np.log(sigcyl), np.log(sighalf), xc, zc, r]

    mhalf = circmap * circhalf
    mtrue = circmap * circtrue

    Mx = np.empty(shape=(0, 2))
    Nx = np.empty(shape=(0, 2))
    # rx = DC.receivers.Dipole_ky_ky(Mx,Nx)
    rx = DC.receivers.Dipole_ky(Mx, Nx)
    if B == []:
        src = DC.sources.Pole([rx], np.r_[A, 0.0])
    else:
        src = DC.sources.Dipole([rx], np.r_[A, 0.0], np.r_[B, 0.0])
    # survey = DC.Survey_ky_ky([src])
    survey = DC.Survey_ky([src])
    survey_prim = DC.Survey_ky([src])
    # problem = DC.Problem2D_CC(mesh, sigmaMap = sigmaMap)
    problem = DC.simulation_2d.Problem2D_CC(mesh,
                                            survey=survey,
                                            sigmaMap=sigmaMap)
    problem_prim = DC.simulation_2d.Problem2D_CC(mesh,
                                                 survey=survey_prim,
                                                 sigmaMap=sigmaMap)
    problem.Solver = Pardiso
    problem_prim.Solver = Pardiso

    f = problem_prim.fields(mhalf)
    primary_field = problem_prim.fields_to_space(f)
    # phihalf = f[src, 'phi', 15]
    # ehalf = f[src, 'e']
    # jhalf = f[src, 'j']
    # charge = f[src, 'charge']

    f = problem.fields(mtrue)
    total_field = problem.fields_to_space(f)
    # phi = f[src, 'phi', 15]
    # e = f[src, 'e']
    # j = f[src, 'j']
    # charge = f[src, 'charge']

    return mtrue, mhalf, src, total_field, primary_field
def model_fields(survey_type, a_spacing, array_center, xc, zc, r, rhoHalf,
                 rhoTarget):
    # Create halfspace model
    mhalf = rhoHalf * np.ones(mesh.nC)

    grid_r = np.sqrt((xc - mesh.gridCC[:, 0])**2 + (zc - mesh.gridCC[:, 1])**2)

    # Add plate or cylinder
    mtrue = mhalf.copy()
    mtrue[grid_r < r] = rhoTarget

    Mx = mesh.gridCC
    # Nx = np.empty(shape=(mesh.nC, 2))
    rx = DC.Rx.Pole_ky(Mx)
    # rx = DC.Rx.Dipole(Mx,Nx)

    if survey_type == 'Wenner':
        A = array_center - 1.5 * a_spacing
        M = array_center - 0.5 * a_spacing
        N = array_center + 0.5 * a_spacing
        B = array_center + 1.5 * a_spacing
    elif survey_type == 'Dipole-Dipole':
        A = array_center - 1.5 * a_spacing
        B = array_center - 0.5 * a_spacing
        M = array_center + 0.5 * a_spacing
        N = array_center + 1.5 * a_spacing

    src = DC.Src.Dipole([rx], np.r_[A, 0.0], np.r_[B, 0.0])
    survey = DC.Survey_ky([src])
    problem = DC.Problem2D_CC(mesh,
                              rhoMap=mapping,
                              Solver=Pardiso,
                              survey=survey)

    mesh.setCellGradBC("neumann")
    cellGrad = mesh.cellGrad
    faceDiv = mesh.faceDiv

    phi_total = problem.dpred(mtrue)
    e_total = -cellGrad * phi_total
    j_total = problem.MfRhoI * problem.Grad * phi_total
    q_total = epsilon_0 * problem.Vol * (faceDiv * e_total)
    total_field = {"phi": phi_total, "e": e_total, "j": j_total, "q": q_total}

    return src, total_field, [A, B, M, N]
Beispiel #8
0
def DC2Dsurvey(flag="PolePole"):
    """
    Function that define a surface DC survey
    :param str flag: Survey Type 'PoleDipole', 'DipoleDipole', 'DipolePole', 'PolePole'
    """
    if flag == "PoleDipole":
        ntx, nmax = xr.size - 2, 8
    elif flag == "DipolePole":
        ntx, nmax = xr.size - 2, 8
    elif flag == "DipoleDipole":
        ntx, nmax = xr.size - 3, 8
    elif flag == "PolePole":
        ntx, nmax = xr.size - 2, 8
    else:
        raise Exception("Not Implemented")
    xzlocs = getPseudoLocs(xr, ntx, nmax, flag)

    txList = []
    zloc = -2.5
    for i in range(ntx):
        if flag == "PoleDipole":
            A = np.r_[xr[i], zloc]
            B = np.r_[mesh.vectorCCx.min(), zloc]
            if i < ntx - nmax + 1:
                M = np.c_[xr[i + 1:i + 1 + nmax], np.ones(nmax) * zloc]
                N = np.c_[xr[i + 2:i + 2 + nmax], np.ones(nmax) * zloc]
            else:
                M = np.c_[xr[i + 1:ntx + 1], np.ones(ntx - i) * zloc]
                N = np.c_[xr[i + 2:i + 2 + nmax], np.ones(ntx - i) * zloc]
        elif flag == "DipolePole":
            A = np.r_[xr[i], zloc]
            B = np.r_[xr[i + 1], zloc]
            if i < ntx - nmax + 1:
                M = np.c_[xr[i + 2:i + 2 + nmax], np.ones(nmax) * zloc]
                N = np.c_[np.ones(nmax) * mesh.vectorCCx.max(),
                          np.ones(nmax) * zloc]
            else:
                M = np.c_[xr[i + 2:ntx + 2], np.ones(ntx - i) * zloc]
                N = np.c_[np.ones(ntx - i) * mesh.vectorCCx.max(),
                          np.ones(ntx - i) * zloc]
        elif flag == "DipoleDipole":
            A = np.r_[xr[i], zloc]
            B = np.r_[xr[i + 1], zloc]
            if i < ntx - nmax:
                M = np.c_[xr[i + 2:i + 2 + nmax],
                          np.ones(len(xr[i + 2:i + 2 + nmax])) * zloc, ]
                N = np.c_[xr[i + 3:i + 3 + nmax],
                          np.ones(len(xr[i + 3:i + 3 + nmax])) * zloc, ]
            else:
                M = np.c_[xr[i + 2:len(xr) - 1],
                          np.ones(len(xr[i + 2:len(xr) - 1])) * zloc, ]
                N = np.c_[xr[i + 3:len(xr)],
                          np.ones(len(xr[i + 3:len(xr)])) * zloc]
        elif flag == "PolePole":
            A = np.r_[xr[i], zloc]
            B = np.r_[mesh.vectorCCx.min(), zloc]

            if i < ntx - nmax + 1:
                M = np.c_[xr[i + 2:i + 2 + nmax], np.ones(nmax) * zloc]
                N = np.c_[np.ones(nmax) * mesh.vectorCCx.max(),
                          np.ones(nmax) * zloc]
            else:
                M = np.c_[xr[i + 2:ntx + 2], np.ones(ntx - i) * zloc]
                N = np.c_[np.ones(ntx - i) * mesh.vectorCCx.max(),
                          np.ones(ntx - i) * zloc]

        rx = DC.receivers.Dipole_ky(M, N)
        src = DC.sources.Dipole([rx], A, B)
        txList.append(src)

    survey = DC.Survey_ky(txList)
    simulation = DC.simulation_2d.Problem2D_CC(mesh,
                                               survey=survey,
                                               sigmaMap=mapping)

    sigblk, sighalf, siglayer = 2e-2, 2e-3, 1e-3
    xc, yc, r, zh = -15, -8, 4, -5
    mtrue = np.r_[np.log(sighalf),
                  np.log(siglayer),
                  np.log(sigblk), xc, yc, r, zh]
    dtrue = simulation.dpred(mtrue)
    perc = 0.0001
    floor = np.linalg.norm(dtrue) * 1e-8
    np.random.seed([1])
    uncert = np.random.randn(survey.nD) * perc + floor
    dobs = dtrue + uncert

    return dobs, uncert, simulation, xzlocs