예제 #1
0
 def test_defaults(self):
     edws = fdem.ElectricDipoleWholeSpace()
     assert (edws.sigma == 1)
     assert (edws.mu == mu_0)
     assert (edws.epsilon == epsilon_0)
     assert (np.all(edws.orientation == np.r_[1., 0., 0.]))
     assert (edws.length == 1.)
     assert (np.all(edws.location == np.r_[0., 0., 0.]))
     assert (edws.frequency == 1.)
예제 #2
0
    def test_electric_dipole_tilted_e(self):

        orientation = np.random.rand(3)
        orientation = orientation / np.linalg.norm(orientation)

        edws = fdem.ElectricDipoleWholeSpace(orientation=orientation)
        x = np.linspace(-20., 20., 50)
        y = np.linspace(-30., 30., 50)
        z = np.linspace(-40., 40., 50)

        xyz = discretize.utils.ndgrid([x, y, z])

        extest0, eytest0, eztest0 = E_from_EDWS(xyz,
                                                edws.location,
                                                edws.sigma,
                                                edws.frequency,
                                                orientation='X')
        extest1, eytest1, eztest1 = E_from_EDWS(xyz,
                                                edws.location,
                                                edws.sigma,
                                                edws.frequency,
                                                orientation='Y')
        extest2, eytest2, eztest2 = E_from_EDWS(xyz,
                                                edws.location,
                                                edws.sigma,
                                                edws.frequency,
                                                orientation='Z')

        extest = (orientation[0] * extest0 + orientation[1] * extest1 +
                  orientation[2] * extest2)
        eytest = (orientation[0] * eytest0 + orientation[1] * eytest1 +
                  orientation[2] * eytest2)
        eztest = (orientation[0] * eztest0 + orientation[1] * eztest1 +
                  orientation[2] * eztest2)

        e = edws.electric_field(xyz)
        print(
            "\n\nTesting Electric Dipole {} orientation\n".format("45 degree"))

        self.compare_fields(e, np.vstack([extest, eytest, eztest]).T)
예제 #3
0
    def electric_dipole_e(self, orientation):
        sigma = np.random.random_integers(1)
        frequency = np.random.random_integers(1)
        edws = fdem.ElectricDipoleWholeSpace(orientation=orientation,
                                             sigma=sigma,
                                             frequency=frequency)
        x = np.linspace(-20., 20., 50)
        y = np.linspace(-30., 30., 50)
        z = np.linspace(-40., 40., 50)
        xyz = discretize.utils.ndgrid([x, y, z])

        extest, eytest, eztest = E_from_EDWS(xyz,
                                             edws.location,
                                             edws.sigma,
                                             edws.frequency,
                                             orientation=orientation.upper())

        e = edws.electric_field(xyz)
        print(
            "\n\nTesting Electric Dipole {} orientation\n".format(orientation))

        passed = self.compare_fields(e, np.vstack([extest, eytest, eztest]).T)
        self.assertTrue(passed)
예제 #4
0
    def setUp(self):

        cs = 0.5
        npad = 11
        hx = [(cs, npad, -1.5), (cs, 15), (cs, npad, 1.5)]
        hy = [(cs, npad, -1.5), (cs, 15), (cs, npad, 1.5)]
        hz = [(cs, npad, -1.5), (cs, 15), (cs, npad, 1.5)]
        mesh = Mesh.TensorMesh([hx, hy, hz], x0="CCC")
        sigma = np.ones(mesh.nC)*1e-2

        # Set up survey parameters for numeric solution
        x = mesh.vectorNx[(mesh.vectorNx > -75.) & (mesh.vectorNx < 75.)]
        y = mesh.vectorNy[(mesh.vectorNy > -75.) & (mesh.vectorNy < 75.)]

        Aloc = np.r_[1.25, 0., 0.]
        Bloc = np.r_[-1.25, 0., 0.]
        M = Utils.ndgrid(x-25., y, np.r_[0.])
        N = Utils.ndgrid(x+25., y, np.r_[0.])

        rx = DC.Rx.Dipole(M, N)
        src = DC.Src.Dipole([rx], Aloc, Bloc)
        survey = DC.Survey([src])

        # Create Dipole Obj for Analytic Solution
        edipole = fdem.ElectricDipoleWholeSpace(
            sigma=1e-2,  # conductivity of 1 S/m
            mu=mu_0,  # permeability of free space (this is the default)
            epsilon=epsilon_0,  # permittivity of free space (this is the default)
            location=np.r_[0., 0., 0.],  # location of the dipole
            orientation='X',  # horizontal dipole (can also be a unit-vector)
            quasistatic=True,  # don't use the quasistatic assumption
            frequency=0.0,  # DC
            length=2.5  # length of dipole
        )

        # evaluate the electric field and current density
        Ex_analytic = np.zeros_like([mesh.nEx,1])
        Ey_analytic = np.zeros_like([mesh.nEy,1])
        Ez_analytic = np.zeros_like([mesh.nEz,1])
        Ex_analytic = np.real(edipole.electric_field(mesh.gridEx))[:,0]
        Ey_analytic = np.real(edipole.electric_field(mesh.gridEy))[:,1]
        Ez_analytic = np.real(edipole.electric_field(mesh.gridEz))[:,2]
        E_analytic = np.hstack([Ex_analytic,Ey_analytic,Ez_analytic])

        Jx_analytic = np.zeros_like([mesh.nEx,1])
        Jy_analytic = np.zeros_like([mesh.nEy,1])
        Jz_analytic = np.zeros_like([mesh.nEz,1])
        Jx_analytic = np.real(edipole.current_density(mesh.gridEx))[:,0]
        Jy_analytic = np.real(edipole.current_density(mesh.gridEy))[:,1]
        Jz_analytic = np.real(edipole.current_density(mesh.gridEz))[:,2]
        J_analytic = np.hstack([Jx_analytic,Jy_analytic,Jz_analytic])

        # Find edges at which to compare solutions
        edgeGrid = np.vstack([mesh.gridEx,mesh.gridEy,mesh.gridEz])
        # print(faceGrid.shape)

        ROI_large_BNW = np.array([-75,75,-75])
        ROI_large_TSE = np.array([75,-75,75])
        ROI_largeInds = Utils.ModelBuilder.getIndicesBlock(ROI_large_BNW,ROI_large_TSE,edgeGrid)[0]
        # print(ROI_largeInds.shape)

        ROI_small_BNW = np.array([-4,4,-4])
        ROI_small_TSE = np.array([4,-4,4])
        ROI_smallInds = Utils.ModelBuilder.getIndicesBlock(ROI_small_BNW,ROI_small_TSE,edgeGrid)[0]
        # print(ROI_smallInds.shape)

        ROIedgeInds = np.setdiff1d(ROI_largeInds,ROI_smallInds)
        # print(ROIedgeInds.shape)
        # print(len(ROI_largeInds) - len(ROI_smallInds))

        self.survey = survey
        self.mesh = mesh
        self.sigma = sigma
        self.E_analytic = E_analytic
        self.J_analytic = J_analytic
        self.ROIedgeInds = ROIedgeInds
예제 #5
0
location=np.r_[0., 0., 0.]  # location of the dipole
orientation='Z'  # vertical dipole (can also be a unit-vector)
quasistatic=False  # don't use the quasistatic assumption

###############################################################################
# Electric Dipole
# ---------------
#
# Here, we build the geoana electric dipole in a wholespace using the
# parameters defined above. For a full list of the properties you can set on an
# electric dipole, see the :class:`geoana.em.fdem.ElectricDipoleWholeSpace`
# docs

edipole = fdem.ElectricDipoleWholeSpace(
    sigma=sigma, mu=mu, epsilon=epsilon,
    location=location, orientation=orientation,
    quasistatic=False
)

###############################################################################
# Evaluate fields and fluxes
# --------------------------
#
# Next, we construct a grid where we want to plot electric fields

x = np.linspace(-50, 50, 100)
z = np.linspace(-50, 50, 100)
xyz = utils.ndgrid([x, np.r_[0], z])

###############################################################################
#