Ejemplo n.º 1
0
    def translate_from(self, src_expansion, src_coeff_exprs, dvec):
        from sumpy.symbolic import sympy_real_norm_2

        k = sp.Symbol(self.kernel.get_base_kernel().helmholtz_k_name)

        if isinstance(src_expansion, H2DLocalExpansion):
            dvec_len = sympy_real_norm_2(dvec)
            bessel_j = sp.Function("bessel_j")
            new_center_angle_rel_old_center = sp.atan2(dvec[1], dvec[0])
            translated_coeffs = []
            for l in self.get_coefficient_identifiers():
                translated_coeffs.append(
                    sum(
                        src_coeff_exprs[src_expansion.get_storage_index(m)]
                        * bessel_j(m - l, k * dvec_len)
                        * sp.exp(sp.I * (m - l) * -new_center_angle_rel_old_center)
                        for m in src_expansion.get_coefficient_identifiers()
                    )
                )
            return translated_coeffs

        from sumpy.expansion.multipole import H2DMultipoleExpansion

        if isinstance(src_expansion, H2DMultipoleExpansion):
            dvec_len = sympy_real_norm_2(dvec)
            hankel_1 = sp.Function("hankel_1")
            new_center_angle_rel_old_center = sp.atan2(dvec[1], dvec[0])
            translated_coeffs = []
            for l in self.get_coefficient_identifiers():
                translated_coeffs.append(
                    sum(
                        (-1) ** l
                        * hankel_1(m + l, k * dvec_len)
                        * sp.exp(sp.I * (m + l) * new_center_angle_rel_old_center)
                        * src_coeff_exprs[src_expansion.get_storage_index(m)]
                        for m in src_expansion.get_coefficient_identifiers()
                    )
                )
            return translated_coeffs

        raise RuntimeError(
            "do not know how to translate %s to " "local 2D Helmholtz Bessel expansion" % type(src_expansion).__name__
        )
Ejemplo n.º 2
0
    def evaluate(self, coeffs, bvec):
        from sumpy.symbolic import sympy_real_norm_2
        hankel_1 = sp.Function("hankel_1")
        bvec_len = sympy_real_norm_2(bvec)
        target_angle_rel_center = sp.atan2(bvec[1], bvec[0])

        k = sp.Symbol(self.kernel.get_base_kernel().helmholtz_k_name)

        return sum(coeffs[self.get_storage_index(l)]
                   * self.kernel.postprocess_at_target(
                       hankel_1(l, k * bvec_len)
                       * sp.exp(sp.I * l * target_angle_rel_center), bvec)
                for l in self.get_coefficient_identifiers())
Ejemplo n.º 3
0
    def coefficients_from_source(self, avec, bvec):
        from sumpy.symbolic import sympy_real_norm_2
        bessel_j = sp.Function("bessel_j")
        avec_len = sympy_real_norm_2(avec)

        k = sp.Symbol(self.kernel.get_base_kernel().helmholtz_k_name)

        # The coordinates are negated since avec points from source to center.
        source_angle_rel_center = sp.atan2(-avec[1], -avec[0])
        return [self.kernel.postprocess_at_source(
                    bessel_j(l, k * avec_len) *
                    sp.exp(sp.I * l * -source_angle_rel_center), avec)
                for l in self.get_coefficient_identifiers()]
Ejemplo n.º 4
0
    def translate_from(self, src_expansion, src_coeff_exprs, dvec):
        if not isinstance(src_expansion, type(self)):
            raise RuntimeError("do not know how to translate %s to "
                               "multipole 2D Helmholtz Bessel expansion"
                               % type(src_expansion).__name__)
        from sumpy.symbolic import sympy_real_norm_2
        dvec_len = sympy_real_norm_2(dvec)
        bessel_j = sp.Function("bessel_j")
        new_center_angle_rel_old_center = sp.atan2(dvec[1], dvec[0])

        k = sp.Symbol(self.kernel.get_base_kernel().helmholtz_k_name)

        translated_coeffs = []
        for l in self.get_coefficient_identifiers():
            translated_coeffs.append(
                sum(src_coeff_exprs[src_expansion.get_storage_index(m)]
                    * bessel_j(m - l, k * dvec_len)
                    * sp.exp(sp.I * (m - l) * new_center_angle_rel_old_center)
                for m in src_expansion.get_coefficient_identifiers()))
        return translated_coeffs