Page MenuHomec4science

HelmholtzRBLagrangeApproximant.py
No OneTemporary

File Metadata

Created
Wed, Dec 18, 06:15

HelmholtzRBLagrangeApproximant.py

import numpy as np
from rrompy.hfengines.fenics import HelmholtzSquareBubbleProblemEngine as HSBPE
from rrompy.hfengines.fenics import HelmholtzSquareTransmissionProblemEngine as HSTPE
from rrompy.hfengines.fenics import HelmholtzBoxScatteringProblemEngine as HBSPE
from rrompy.hsengines.fenics import HSEngine as HS
from rrompy.reduction_methods.lagrange import ApproximantLagrangeRB as RB
from rrompy.sampling import QuadratureSampler as QS
testNo = 3
if testNo == 1:
z0s = [10 + 0.j, 14 + 0.j]
z0 = np.mean(z0s)
ztar = 11 + .5j
params = {'S':5, 'R':4, 'POD':True, 'sampler':QS(z0s, "CHEBYSHEV")}
solver = HSBPE(kappa = 12 ** .5, theta = np.pi / 3, n = 40)
plotter = HS(solver.V)
approx = RB(solver, plotter, mu0 = z0, approxParameters = params)#,
# plotSnap = 'ALL')
approx.plotApp(ztar, name = 'u_RB')
approx.plotHF(ztar, name = 'u_HF')
approx.plotErr(ztar, name = 'err')
appErr, solNorm = approx.approxError(ztar), approx.HFNorm(ztar)
print(('SolNorm:\t{}\nErr:\t{}\nErrRel:\t{}').format(solNorm, appErr,
np.divide(appErr, solNorm)))
print('\nPoles RB:')
print(approx.getPoles())
############
elif testNo == 2:
z0s = np.power([3.85 + 0.j, 4.15 + 0.j], 2.)
z0 = np.mean(z0s)
ztar = (4 + .15j) ** 2.
params = {'S':10, 'R':9, 'POD':True, 'sampler':QS(z0s, "CHEBYSHEV")}
solver = HSTPE(nT = 2, nB = 1, theta = np.pi * 45/180, kappa = 4., n = 50)
plotter = HS(solver.V)
approx = RB(solver, plotter, mu0 = z0, approxParameters = params,
plotSnap = 'ALL')
approx.plotApp(ztar, name = 'u_RB')
approx.plotHF(ztar, name = 'u_HF')
approx.plotErr(ztar, name = 'err')
appErr, solNorm = approx.approxError(ztar), approx.HFNorm(ztar)
print(('SolNorm:\t{}\nErr:\t{}\nErrRel:\t{}').format(solNorm, appErr,
np.divide(appErr, solNorm)))
print('\nPoles RB:')
print(approx.getPoles())
############
elif testNo == 3:
k0s = [2, 5]
k0 = np.mean(k0s)
ktar = 4.5 - .2j
params = {'S':15, 'R':10, 'POD':True, 'sampler':QS(k0s, "CHEBYSHEV")}
solver = HBSPE(R = 7, kappa = 3, theta = - np.pi * 75 / 180, n = 40)
plotter = HS(solver.V)
approx = RB(solver, plotter, mu0 = k0, approxParameters = params)
approx.plotApp(ktar, name = 'u_RB')
approx.plotHF(ktar, name = 'u_HF')
approx.plotErr(ktar, name = 'err')
appErr, solNorm = approx.approxError(ktar), approx.HFNorm(ktar)
print(('SolNorm:\t{}\nErr:\t{}\nErrRel:\t{}').format(solNorm, appErr,
np.divide(appErr, solNorm)))
print('\nPoles RB:')
print(approx.getPoles())

Event Timeline