Пример #1
0
    def evaluate_potential(self,wave_number,density):
        
        
        if self._evaluation_options is None:
            raise Exception("Error. 'evaluation_options' must be defined")
        
        if self._evaluation_quadrature_strategy is None:
            raise Exception("Error. 'evaluation_quadrature_options' must be defined")
        
        
        op_found_in_cache = False
        if self._operator_cache:
            try:
                potential = self._potential_operator_cache.get(wave_number)
                op_found_in_cache = True
            except:
                pass
        
        if not op_found_in_cache:
 
        
            potential = _bempplib.createMaxwell3dSingleLayerPotentialOperator(self._context,1.0j*wave_number).assemble(self._space,
                                                                                                                       self._evaluation_points,
                                                                                                                       self._evaluation_quadrature_strategy,
                                                                                                                       self._evaluation_options)
            if self._operator_cache: self._potential_operator_cache.insert(wave_number,potential)
            
        n = len(density[0])
        
        gridFun = _bempplib.createGridFunction(self._context,self._space,coefficients=density[0])
        return potential.apply(gridFun)
Пример #2
0
    def evaluate_potential(self,wave_number,density):
        
        
        if self._evaluation_options is None:
            raise Exception("Error. 'evaluation_options' must be defined")
        
        if self._evaluation_quadrature_strategy is None:
            raise Exception("Error. 'evaluation_quadrature_options' must be defined")
        
        
        op_found_in_cache = False
        if self._operator_cache:
            try:
                pot_ext_single,pot_ext_double,pot_int_single,pot_int_double = self._potential_operator_cache.get(wave_number)
                op_found_in_cache = True
            except:
                pass
        
        if not op_found_in_cache:
 

            k_ext = 1.0j*wave_number * _np.sqrt(self._eps_ext * self._mu_ext)
            k_int = 1.0j*wave_number * _np.sqrt(self._eps_int * self._mu_int)
            rho = (k_int * self._mu_ext) / (k_ext * self._mu_int)
            


        
            pot_ext_single = _bempplib.createMaxwell3dSingleLayerPotentialOperator(self._context,k_ext).assemble(self._space,
                                                                                                                 self._evaluation_points[:,self._outside],
                                                                                                                 self._evaluation_quadrature_strategy,
                                                                                                                 self._evaluation_options)
            
            pot_ext_double = _bempplib.createMaxwell3dDoubleLayerPotentialOperator(self._context,k_ext).assemble(self._space,
                                                                                                                 self._evaluation_points[:,self._outside],
                                                                                                                 self._evaluation_quadrature_strategy,
                                                                                                                 self._evaluation_options)
            

            pot_int_single = _bempplib.createMaxwell3dSingleLayerPotentialOperator(self._context,k_int).assemble(self._space,
                                                                                                                 self._evaluation_points[:,self._inside],
                                                                                                                 self._evaluation_quadrature_strategy,
                                                                                                                 self._evaluation_options)
            
            pot_int_double = _bempplib.createMaxwell3dDoubleLayerPotentialOperator(self._context,k_int).assemble(self._space,
                                                                                                                 self._evaluation_points[:,self._inside],
                                                                                                                 self._evaluation_quadrature_strategy,
                                                                                                                 self._evaluation_options)
            
            
            
            
            if self._operator_cache: self._potential_operator_cache.insert(wave_number,pot_int_single,pot_int_double,
                                                                           pot_ext_single,pot_ext_double)
            


        dirichlet_ext = density[0]
        dirichlet_int = dirichlet_ext
        neumann_ext = density[1]
        neumann_int = density[1]/rho
            
        dirichlet_ext_fun = _bempplib.createGridFunction(self._context,self._space,self._space,coefficients=dirichlet_ext)
        dirichlet_int_fun = _bempplib.createGridFunction(self._context,self._space,self._space,coefficients=dirichlet_int)
        neumann_ext_fun = _bempplib.createGridFunction(self._context,self._space,self._space,coefficients=neumann_ext)
        neumann_int_fun = _bempplib.createGridFunction(self._context,self._space,self._space,coefficients=neumann_int)
        
        scatt_dirichlet_ext_fun = dirichlet_ext_fun - self._inc_dirichlet_traces[wave_number]
        print "Eval Dirichlet Error "+str(scatt_dirichlet_ext_fun.L2Norm()/dirichlet_ext_fun.L2Norm())
        scatt_neumann_ext_fun = neumann_ext_fun - self._inc_neumann_traces[wave_number]
        print "Eval Neumann Error "+str(scatt_neumann_ext_fun.L2Norm()/dirichlet_ext_fun.L2Norm())                
        
        valsExt = pot_ext_single.apply(scatt_neumann_ext_fun) + pot_ext_double.apply(scatt_dirichlet_ext_fun)
        valsInt = pot_int_single.apply(neumann_int_fun) + pot_int_double.apply(dirichlet_int_fun)
        
        vals = _np.zeros((3,self._evaluation_points.shape[1]), dtype='complex128')
        vals[:,self._inside] = valsInt
        vals[:,self._outside] = valsExt

        return vals