Beispiel #1
0
 def getInverse(self, s):
     """
     returns the value of the inverse of the mapping for s
     """
     # self.logger.info("m0:"+str(log(s[0]**2+s[1]**2)/2))
     return (log(s[0]**2 + s[1]**2) / 2 -
             self.Mr) * [1., 0] + (atan2(s[1], s[0]) - self.Mi) * [0, 1.]
Beispiel #2
0
def createAbsorptionLayerFunction(x,
                                  absorption_zone=300 * U.m,
                                  absorption_cut=1.e-2,
                                  top_absorption=False):
    """
    Creates a distribution which is one in the interior of the domain of `x`
    and is falling down to the value 'absorption_cut' over a margin of thickness 'absorption_zone'
    toward each boundary except the top of the domain.

    :param x: location of points in the domain
    :type x: `escript.Data`
    :param absorption_zone: thickness of the absorption zone
    :param absorption_cut: value of decay function on domain boundary
    :return: function on 'x' which is one in the iterior and decays to almost zero over a margin
             toward the boundary.
    """

    if absorption_zone is None or absorption_zone == 0:
        return 1

    dom = x.getDomain()
    bb = escript.boundingBox(dom)
    DIM = dom.getDim()
    decay = -escript.log(absorption_cut) / absorption_zone**2
    f = 1
    for i in range(DIM):
        x_i = x[i]
        x_l = x_i - (bb[i][0] + absorption_zone)
        m_l = escript.whereNegative(x_l)
        f = f * ((escript.exp(-decay * (x_l * m_l)**2) - 1) * m_l + 1)
        if top_absorption or not DIM - 1 == i:
            x_r = (bb[i][1] - absorption_zone) - x_i
            m_r = escript.whereNegative(x_r)
            f = f * ((escript.exp(-decay * (x_r * m_r)**2) - 1) * m_r + 1)
    return f
Beispiel #3
0
    def getInverse(self, s):
        """
        returns the value of the inverse of the mapping for s
        """
        if not (inf(s) > self.s_min and sup(s) < self.s_max):
            raise ValueError("s is out of range [%f,%f]" % (inf(s), sup(s)))

        return 1.0 / 2.0 * log((s - self.s_min) / (self.s_max - s))
Beispiel #4
0
 def getInverse(self, s):
     """
     returns the value of the inverse of the mapping for s
     """
     ms = whereZero(s)
     ms0 = whereZero(self.__sigma0)
     m = 1 / self.__a * log(((1 - ms) * s + ms * 1) / ((1 - ms0) * self.__sigma0 + ms0 * 1)) * (1 - ms) * (1 - ms0)
     return m
Beispiel #5
0
    def getInverse(self, s):
        """
        returns the value of the inverse of the mapping for s
        """
        if not (inf(s) > self.s_min and sup(s) < self.s_max):
            raise ValueError("s is out of range [%f,%f]" % (inf(s), sup(s)))

        return 1. / 2. * log((s - self.s_min) / (self.s_max - s))
Beispiel #6
0
 def getInverse(self, s):
     """
     returns the value of the inverse of the mapping for s
     """
     # return (s-self.__sigma0) / (self.__sigma0 * self.__k)
     if inf(((self.__sigma0 * self.a) / s)) <= 1.0:
         raise ValueError("sigma 0*a/s < 1 this is not valid as log cannot be 0 or negative")
     m = -1.0 / self.__k * log(((self.__sigma0 * self.a) / (s - self.minVal)) - 1)
     print("inv(s)=", m)
     return m
Beispiel #7
0
 def getInverse(self, s):
     """
     returns the value of the inverse of the mapping for s
     """
     ms = whereZero(s)
     ms0 = whereZero(self.__sigma0)
     m = 1 / self.__a * log(
         ((1 - ms) * s + ms * 1) /
         ((1 - ms0) * self.__sigma0 + ms0 * 1)) * (1 - ms) * (1 - ms0)
     return m
Beispiel #8
0
    def __init__(self, V_prior, Q_prior):
        """
        initializes the mapping

        :param V_prior: a-priori p-wave velocity
        :param Q_prior: a-priori Q-index (must be positive)
        """
        over2Q = 1.0 / (2 * Q_prior)
        # sigma_prior=1/(V_prior*(1-I*over2Q))**2 = 1/( V_prior * (1+over2Q**2)) **2 * ( (1-over2Q**2) + I * 2* over2Q )
        self.Mr = log(sqrt((1 - over2Q ** 2) ** 2 + (2 * over2Q) ** 2) / (V_prior * (1 + over2Q ** 2)) ** 2)
        self.Mi = atan2(2 * over2Q, 1 - over2Q ** 2)
Beispiel #9
0
 def getInverse(self, s):
     """
     returns the value of the inverse of the mapping for s
     """
     # return (s-self.__sigma0) / (self.__sigma0 * self.__k)
     if inf(((self.__sigma0 * self.a) / s)) <= 1.:
         raise ValueError(
             "sigma 0*a/s < 1 this is not valid as log cannot be 0 or negative"
         )
     m = -1. / self.__k * log(((self.__sigma0 * self.a) /
                               (s - self.minVal)) - 1)
     print("inv(s)=", m)
     return m
Beispiel #10
0
    def __init__(self, V_prior, Q_prior):
        """
        initializes the mapping

        :param V_prior: a-priori p-wave velocity
        :param Q_prior: a-priori Q-index (must be positive)
        """
        over2Q = 1. / (2 * Q_prior)
        # sigma_prior=1/(V_prior*(1-I*over2Q))**2 = 1/( V_prior * (1+over2Q**2)) **2 * ( (1-over2Q**2) + I * 2* over2Q )
        self.Mr = log(
            sqrt((1 - over2Q**2)**2 + (2 * over2Q)**2) / (V_prior *
                                                          (1 + over2Q**2))**2)
        self.Mi = atan2(2 * over2Q, 1 - over2Q**2)
Beispiel #11
0
 def getInverse(self, s):
     """
     returns the value of the inverse of the mapping for s
     """
     # self.logger.info("m0:"+str(log(s[0]**2+s[1]**2)/2))
     return (log(s[0] ** 2 + s[1] ** 2) / 2 - self.Mr) * [1.0, 0] + (atan2(s[1], s[0]) - self.Mi) * [0, 1.0]