Exemplo n.º 1
0
 def _gmres(self, super_operator, super_rhs, tol):
     """
     Wrapper around BEMPP's built-in GMRES implementation.
     """
     sol, solve_info, residuals = linalg.gmres(super_operator,
                                               super_rhs,
                                               tol=tol,
                                               use_strong_form=True,
                                               return_residuals=True,
                                               **SOLVER_OPTIONS)
     return sol, solve_info, residuals
Exemplo n.º 2
0
# solve

from bempp.api.linalg import gmres

it_count = 0


def iteration_counter(x):
    global it_count
    it_count += 1


w_fun, info, resid, it_count = gmres(lhs,
                                     dirichlet_fun,
                                     tol=epsilon,
                                     return_residuals=True,
                                     return_iteration_count=True)

time3 = time.time()

print("Solved in {0} iterations, {1} s".format(it_count, time3 - time2))

# post-processing

print("--------------")

exec(open("subscript/postProcess.py").read())
exec(open("subscript/analit.py").read())

# microphones
Exemplo n.º 3
0
# In[7]:


@bempp.api.complex_callable
def combined_data(x, n, domain_index, result):
    result[0] = 1j * k * np.exp(1j * k * x[0]) * (n[0] - 1)


grid_fun = bempp.api.GridFunction(piecewise_const_space, fun=combined_data)

# We can now use GMRES to solve the problem.

# In[8]:

from bempp.api.linalg import gmres
neumann_fun, info = gmres(lhs, grid_fun, tol=1E-5)

# `gmres` returns a grid function `neumann_fun` and an integer `info`. When everything works fine info is equal to 0.
#
# At this stage, we have the surface solution of the integral equation. Now we will evaluate the solution in the domain of interest. We define the evaluation points as follows.

# In[9]:

Nx = 200
Ny = 200
xmin, xmax, ymin, ymax = [-3, 3, -3, 3]
plot_grid = np.mgrid[xmin:xmax:Nx * 1j, ymin:ymax:Ny * 1j]
points = np.vstack(
    (plot_grid[0].ravel(), plot_grid[1].ravel(), np.zeros(plot_grid[0].size)))
u_evaluated = np.zeros(points.shape[1], dtype=np.complex128)
u_evaluated[:] = np.nan
Exemplo n.º 4
0
lhs = (.5*identity + dlp) - 1j * muD * slp

time2 = time.time()

print ("prepared to ", time2 - time1, " s")


# solve
from bempp.api.linalg import gmres

it_count = 0
def iteration_counter(x):
    global it_count
    it_count += 1
    
w_fun,info,resid, it_count = gmres(lhs, dirichlet_fun, tol=epsilon, return_residuals = True, return_iteration_count = True)
print("The linear system was solved in {0} iterations".format(it_count))

time3 = time.time()

print ("solved to ", time3 - time2, " s")



# compute and output result


def result (points):
    from bempp.api.operators.potential import helmholtz as helmholtz_potential

    slp_pot=helmholtz_potential.single_layer(piecewise_lin_space, points, k)
Exemplo n.º 5
0
lhs = .5*identity + adlp - 1j * k * slp


# We now discretize the right-hand side. Here, this means converting the Python callable `data_fun` into a GridFunction defined on the elements of the grid.

# In[8]:

grid_fun = bempp.api.GridFunction(piecewise_const_space, fun=combined_data)


# We can now use GMRES to solve the problem.

# In[9]:

from bempp.api.linalg import gmres
neumann_fun,info = gmres(lhs, grid_fun, tol=1E-5)


# `gmres` returns a grid function `neumann_fun` and an integer `info`. When everything works fine info is equal to 0.

# At this stage, we have the surface solution of the integral equation. Now we will evaluate the solution in the domain of interest. We define the evaluation points as follows.

# In[10]:

Nx = 200
Ny = 200
xmin, xmax, ymin, ymax = [-3, 3, -3, 3]
plot_grid = np.mgrid[xmin:xmax:Nx * 1j, ymin:ymax:Ny * 1j]
points = np.vstack((plot_grid[0].ravel(), plot_grid[1].ravel(), np.zeros(plot_grid[0].size)))
u_evaluated = np.zeros(points.shape[1], dtype=np.complex128)
u_evaluated[:] = np.nan