Page MenuHomec4science

HelmholtzPadeLagrangeApproximant.py
No OneTemporary

File Metadata

Created
Tue, Nov 26, 03:42

HelmholtzPadeLagrangeApproximant.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 ApproximantLagrangePade as Pade
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 = {'N':4, 'M':3, 'S':5, 'POD':True, 'sampler':QS(z0s, "CHEBYSHEV")}
solver = HSBPE(kappa = 12 ** .5, theta = np.pi / 3, n = 40)
plotter = HS(solver.V)
approx = Pade(solver, plotter, mu0 = z0, approxParameters = params)#,
# plotSnap = 'ALL')
approx.plotApp(ztar, name = 'u_Pade''')
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 Pade'':')
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 = {'N':9, 'M':8, 'S':10, '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 = Pade(solver, plotter, mu0 = z0, approxParameters = params,
plotSnap = 'ALL')
approx.plotApp(ztar, name = 'u_Pade''')
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 Pade'':')
print(approx.getPoles())
############
elif testNo == 3:
k0s = [2, 5]
k0 = np.mean(k0s)
ktar = 4.5 - .2j
params = {'N':10, 'M':9, 'S':15, 'POD':True, 'sampler':QS(k0s, "CHEBYSHEV")}
solver = HBSPE(R = 7, kappa = 3, theta = - np.pi * 75 / 180, n = 40)
plotter = HS(solver.V)
approx = Pade(solver, plotter, mu0 = k0, approxParameters = params)#,
# plotSnap = 'ALL')
approx.plotApp(ktar, name = 'u_Pade''')
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 Pade'':')
print(approx.getPoles())

Event Timeline