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
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
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(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]