Page MenuHomec4science

helmholtz_external.py
No OneTemporary

File Metadata

Created
Tue, May 7, 16:43

helmholtz_external.py

# Copyright (C) 2018 by the RROMPy authors
#
# This file is part of RROMPy.
#
# RROMPy is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# RROMPy is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with RROMPy. If not, see <http://www.gnu.org/licenses/>.
#
import numpy as np
from rrompy.hfengines.linear_problem import (
HelmholtzCavityScatteringProblemEngine, HelmholtzBoxScatteringProblemEngine)
def test_helmholtz_square_scattering():
solver = HelmholtzCavityScatteringProblemEngine(kappa = 4, gamma = 2.,
n = 20, verbosity = 0)
mu = 5
uh = solver.solve(mu)
assert np.isclose(solver.norm(uh), 20.719752682674923, rtol = 1e-5)
assert np.isclose(solver.norm(solver.residual(uh, mu)), 4.25056407e-13,
rtol = 1e-1)
def test_helmholtz_box_scattering():
solver = HelmholtzBoxScatteringProblemEngine(R = 2, kappa = 10.,
theta = np.pi * 30 / 180, n = 20, verbosity = 0)
mu = 15
uh = solver.solve(mu)
solver.plotmesh(show = False, figsize = (7, 7))
assert np.isclose(solver.norm(uh), 63.98946657389119, rtol = 1e-5)
assert np.isclose(solver.norm(solver.residual(uh, mu)), 9.62989935e-13,
rtol = 1e-1)
from matplotlib import pyplot as plt
plt.close('all')

Event Timeline