Page MenuHomec4science

trained_model_pivoted_reduced_basis.py
No OneTemporary

File Metadata

Created
Tue, May 7, 13:17

trained_model_pivoted_reduced_basis.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 .trained_model_pivoted_general import TrainedModelPivotedGeneral
from .trained_model_reduced_basis import TrainedModelReducedBasis
from rrompy.utilities.base.types import HFEng
from rrompy.utilities.poly_fitting.heaviside import affine2heaviside
from rrompy.utilities.exception_manager import RROMPyAssert
__all__ = ['TrainedModelPivotedReducedBasis']
class TrainedModelPivotedReducedBasis(TrainedModelPivotedGeneral,
TrainedModelReducedBasis):
"""
ROM approximant evaluation for pivoted RB approximant (with pole matching).
Attributes:
Data: dictionary with all that can be pickled.
"""
def initializeFromAffine(self, HFEngine:HFEng, matchingWeight : float = 1.,
POD : bool = True, jSupp : int = 1):
"""Initialize Heaviside representation."""
RROMPyAssert(self.data.nparPivot, 1, "Number of pivot parameters")
poles, coeffs = [], []
nbadpls = 0
for As, bs in zip(self.data.ARBsList, self.data.bRBsList):
cfs, pls, basis = affine2heaviside(As, bs, jSupp)
poles += [pls]
coeffs += [cfs]
nbadpls = max(nbadpls, np.sum(np.isinf(pls)))
if nbadpls > 0:
for j in range(len(poles)):
plsgood = np.argsort(np.abs(pls))[: - nbadpls]
poles[j] = poles[j][plsgood]
coeffs[j] = coeffs[j][plsgood, :]
self.initializeFromLists(poles, coeffs, basis, HFEngine,
matchingWeight, POD)

Event Timeline