Пример #1
0
    def _initialize_bcs(self, bcs="damp"):
        # Create dampening field as symbol `damp`
        if self.nbl == 0:
            self.damp = 1 if bcs == "mask" else 0
            return

        # First initialization
        init = self.damp is None
        # Get current Function if alread yinitialized
        self.damp = self.damp or Function(name="damp", grid=self.grid)
        if callable(bcs):
            bcs(self.damp, self.nbl)
        else:
            re_init = ((bcs == "mask" and mmin(self.damp) == 0)
                       or (bcs == "damp" and mmax(self.damp) == 1))
            if init or re_init:
                if re_init and not init:
                    bcs_o = "damp" if bcs == "mask" else "mask"
                    warning("Re-initializing damp profile from %s to %s" %
                            (bcs_o, bcs))
                    warning("Model has to be created with `bcs=\"%s\"`"
                            "for this WaveSolver" % bcs)
                initialize_damp(self.damp,
                                self.padsizes,
                                self.spacing,
                                abc_type=bcs,
                                fs=self.fs)
        self._physical_parameters.update(['damp'])
Пример #2
0
    def test_min_max_sparse(self):
        """
        Test that mmin/mmax work on SparseFunction
        """
        grid = Grid((101, 101), extent=(1000., 1000.))

        nrec = 101
        rec0 = SparseTimeFunction(name='rec0', grid=grid, nt=1001, npoint=nrec)

        rec0.data[:, :] = 1 + np.random.randn(*rec0.shape).astype(grid.dtype)
        term1 = np.min(rec0.data)
        term2 = mmin(rec0)
        assert np.isclose(term1 / term2 - 1, 0.0, rtol=0.0, atol=1e-5)

        term1 = np.max(rec0.data)
        term2 = mmax(rec0)
        assert np.isclose(term1 / term2 - 1, 0.0, rtol=0.0, atol=1e-5)
Пример #3
0
 def _max_vp(self):
     if 'vp' in self._physical_parameters:
         return mmax(self.vp)
     else:
         return np.sqrt(mmin(self.b) * (mmax(self.lam) + 2 * mmax(self.mu)))