Пример #1
0
    def test_aliasFunction(self):
        nT = self.F.simulation.nT + 1
        count = [0]

        def alias(e, srcInd, timeInd):
            count[0] += 1
            self.assertTrue(srcInd[0] is self.Src0)
            return self.F.mesh.edgeCurl * e

        F = fields.TimeFields(
            self.simulation,
            knownFields={"e": "E"},
            aliasFields={"b": ["e", "F", alias]},
        )
        e = np.random.rand(F.mesh.nE, 1, nT)
        F[self.Src0, "e", :] = e
        F[self.Src0, "b", :]
        # ensure that this is called for every time separately.
        self.assertTrue(count[0] == nT)
        e = np.random.rand(F.mesh.nE, 1, 1)
        F[self.Src0, "e", 1] = e
        count[0] = 0
        F[self.Src0, "b", 1]
        self.assertTrue(count[0] == 1)  # ensure that this is called only once.

        def alias(e, srcInd, timeInd):
            count[0] += 1
            self.assertTrue(type(srcInd) is list)
            self.assertTrue(srcInd[0] is self.Src0)
            self.assertTrue(srcInd[1] is self.Src1)
            return self.F.mesh.edgeCurl * e

        F = fields.TimeFields(
            self.simulation,
            knownFields={"e": "E"},
            aliasFields={"b": ["e", "F", alias]},
        )
        e = np.random.rand(F.mesh.nE, 2, nT)
        F[[self.Src0, self.Src1], "e", :] = e
        count[0] = 0
        F[[self.Src0, self.Src1], "b", :]

        # ensure that this is called for every time separately.
        self.assertTrue(count[0] == nT)
        e = np.random.rand(F.mesh.nE, 2, 1)
        F[[self.Src0, self.Src1], "e", 1] = e
        count[0] = 0
        F[[self.Src0, self.Src1], "b", 1]
        self.assertTrue(count[0] == 1)  # ensure that this is called only once.
Пример #2
0
    def setUp(self):
        mesh = discretize.TensorMesh([np.ones(n) * 5 for n in [10, 11, 12]],
                                     [0, 0, -30])
        x = np.linspace(5, 10, 3)
        XYZ = utils.ndgrid(x, x, np.r_[0.0])
        srcLoc = np.r_[0, 0, 0.0]
        rxList0 = survey.BaseRx(XYZ)
        Src0 = survey.BaseSrc(receiver_list=[rxList0], location=srcLoc)
        rxList1 = survey.BaseRx(XYZ)
        Src1 = survey.BaseSrc(receiver_list=[rxList1], location=srcLoc)
        rxList2 = survey.BaseRx(XYZ)
        Src2 = survey.BaseSrc(receiver_list=[rxList2], location=srcLoc)
        rxList3 = survey.BaseRx(XYZ)
        Src3 = survey.BaseSrc(receiver_list=[rxList3], location=srcLoc)
        Src4 = survey.BaseSrc(
            receiver_list=[rxList0, rxList1, rxList2, rxList3],
            location=srcLoc)
        source_list = [Src0, Src1, Src2, Src3, Src4]
        mysurvey = survey.BaseSurvey(source_list=source_list)
        sim = simulation.BaseTimeSimulation(mesh,
                                            time_steps=[(10.0, 3), (20.0, 2)],
                                            survey=mysurvey)

        def alias(b, srcInd, timeInd):
            return self.F.mesh.edgeCurl.T * b + timeInd

        self.F = fields.TimeFields(sim,
                                   knownFields={"b": "F"},
                                   aliasFields={"e": ["b", "E", alias]})
        self.Src0 = Src0
        self.Src1 = Src1
        self.mesh = mesh
        self.XYZ = XYZ
        self.simulation = sim
Пример #3
0
 def setUp(self):
     mesh = discretize.TensorMesh([np.ones(n) * 5 for n in [10, 11, 12]],
                                  [0, 0, -30])
     x = np.linspace(5, 10, 3)
     XYZ = utils.ndgrid(x, x, np.r_[0.0])
     srcLoc = np.r_[0, 0, 0.0]
     rxList0 = survey.BaseRx(XYZ)
     Src0 = survey.BaseSrc([rxList0], location=srcLoc)
     rxList1 = survey.BaseRx(XYZ)
     Src1 = survey.BaseSrc([rxList1], location=srcLoc)
     rxList2 = survey.BaseRx(XYZ)
     Src2 = survey.BaseSrc([rxList2], location=srcLoc)
     rxList3 = survey.BaseRx(XYZ)
     Src3 = survey.BaseSrc([rxList3], location=srcLoc)
     Src4 = survey.BaseSrc([rxList0, rxList1, rxList2, rxList3],
                           location=srcLoc)
     source_list = [Src0, Src1, Src2, Src3, Src4]
     mysurvey = survey.BaseSurvey(source_list=source_list)
     sim = simulation.BaseTimeSimulation(mesh,
                                         time_steps=[(10.0, 3), (20.0, 2)],
                                         survey=mysurvey)
     self.F = fields.TimeFields(simulation=sim,
                                knownFields={
                                    "phi": "CC",
                                    "e": "E",
                                    "b": "F"
                                })
     self.Src0 = Src0
     self.Src1 = Src1
     self.mesh = mesh
     self.XYZ = XYZ