Page MenuHomec4science

TaylorSweep.py
No OneTemporary

File Metadata

Created
Mon, Nov 4, 12:19

TaylorSweep.py

import numpy as np
from rrompy.hfengines.fenics import HelmholtzSquareBubbleProblemEngine as HSBPE
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
from rrompy.reduction_methods.taylor import ApproximantTaylorRB as RB
from rrompy.utilities.parameter_sweeper import ParameterSweeper as Sweeper
testNo = 1
z0 = 12 + .25j
npoints = 31
shift = 5
nsets = 3
stride = 2
Emax = stride * (nsets - 1) + shift + 2
if testNo == 1:
solver = HSBPE(kappa = 12 ** .5, theta = np.pi / 3, n = 10)
solver.omega = np.real(z0**.5)
params = {'Emax':Emax, 'sampleType':'ARNOLDI', 'POD':True}
ktars = np.linspace(7, 16, npoints)
filenamebase = '../data/output/HelmholtzBubbleTaylor'
elif testNo == 2:
solver = HBSPE(R = 5, kappa = 3, theta = - np.pi * 75 / 180, n = 10)
solver.omega = np.real(z0**.5)
params = {'Emax':Emax, 'sampleType':'KRYLOV', 'POD':True}
ktars = np.linspace(11, 13, npoints)
filenamebase = '../data/output/HelmholtzBoxTaylor'
plotter = HS(solver.V)
paramsSetsPade = [None] * nsets
paramsSetsRB = [None] * nsets
for i in range(nsets):
paramsSetsPade[i] = {'N':stride*i+shift+1, 'M':stride*i+shift,
'E':stride*i+shift+1}
paramsSetsRB[i] = {'E':stride*i+shift+1,'R':stride*i+shift+1}
appPade = Pade(solver, plotter, mu0 = z0, approxParameters = params)
appRB = RB(solver, plotter, mu0 = z0, approxParameters = params)
sweeper = Sweeper(mutars = ktars, mostExpensive = 'Approx')
sweeper.ROMEngine = appPade
sweeper.params = paramsSetsPade
filenamePade = sweeper.sweep(filenamebase + 'PadeFE.dat', outputs = 'ALL')
sweeper.ROMEngine = appRB
sweeper.params = paramsSetsRB
filenameRB = sweeper.sweep(filenamebase + 'RBFE.dat', outputs = 'ALL')
sweeper.plot(filenamePade, ['muRe'], ['HFNorm', 'AppNorm'], ['E'],
onePlot = True)
sweeper.plot(filenameRB, ['muRe'], ['HFNorm', 'AppNorm'], ['E'],
onePlot = True)
sweeper.plot(filenamePade, ['muRe'], ['ErrNorm'], ['E'])
sweeper.plot(filenameRB, ['muRe'], ['ErrNorm'], ['E'])

Event Timeline