Page MenuHomec4science

PadeTaylor.py
No OneTemporary

File Metadata

Created
Mon, Nov 4, 12:05

PadeTaylor.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.taylor import ApproximantTaylorPade as Pade
testNo = 4
if testNo == 1:
params = {'N':4, 'M':3, 'E':4, 'sampleType':'Arnoldi', 'POD':True}
z0 = 12
ztar = 10.5
solver = HSBPE(kappa = 12 ** .5, theta = np.pi / 3, n = 40)
solver.omega = np.real(z0 ** .5)
plotter = HS(solver.V)
approx = Pade(solver, plotter, mu0 = z0, approxParameters = params)
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:
params = {'N':7, 'M':6, 'E':7, 'sampleType':'Arnoldi', 'POD':True}
z0 = 16
ztar = 14
solver = HSTPE(nT = 2, nB = 1, theta = np.pi * 45/180, kappa = 4., n = 50)
solver.omega = np.real(z0 ** .5)
plotter = HS(solver.V)
approx = Pade(solver, plotter, mu0 = z0, approxParameters = params,
plotDer = '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 in [3, 4]:
if testNo == 3:
params = {'N':8, 'M':7, 'E':8, 'sampleType':'Krylov', 'POD':True}
else:
params = {'N':8, 'M':7, 'E':8, 'sampleType':'Arnoldi', 'POD':True}
k0 = 3
ktar = 4.25+.5j
solver = HBSPE(R = 5, kappa = 3, theta = - np.pi * 75 / 180, n = 30)
solver.omega = np.real(k0)
plotter = HS(solver.V)
approx = Pade(solver, plotter, mu0 = k0, approxParameters = params, plotDer = '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