Page MenuHomec4science

sampling_engine_standard_pod.py
No OneTemporary

File Metadata

Created
Thu, May 2, 17:26

sampling_engine_standard_pod.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/>.
#
from copy import deepcopy as copy
from rrompy.sampling.base.pod_engine import PODEngine
from .sampling_engine_standard import SamplingEngineStandard
from rrompy.utilities.base.types import Np1D, paramVal, sampList
from rrompy.utilities.base import verbosityManager as vbMng
from rrompy.sampling import sampleList
__all__ = ['SamplingEngineStandardPOD']
class SamplingEngineStandardPOD(SamplingEngineStandard):
"""HERE"""
def resetHistory(self):
super().resetHistory()
self.samples_full = None
self.RPOD = None
def popSample(self):
if hasattr(self, "nsamples") and self.nsamples > 1:
self.RPOD = self.RPOD[: -1, : -1]
self.samples_full.pop()
super().popSample()
@property
def HFEngine(self):
"""Value of HFEngine. Its assignment resets history."""
return self._HFEngine
@HFEngine.setter
def HFEngine(self, HFEngine):
self._HFEngine = HFEngine
self.resetHistory()
self.PODEngine = PODEngine(self._HFEngine)
def preprocesssamples(self, idxs:Np1D) -> sampList:
if self.samples_full is None or len(self.samples_full) == 0: return
return self.samples_full(idxs)
def postprocessu(self, u:sampList, overwrite : bool = False) -> Np1D:
ns = self.nsamples
if overwrite:
self.samples_full[ns] = copy(u)
else:
if ns == 0:
self.samples_full = sampleList(u)
else:
self.samples_full.append(u)
return u
def postprocessuBulk(self, u:sampList) -> sampList:
self.samples_full = copy(u)
vbMng(self, "INIT", "Starting orthogonalization.", 10)
u, self.RPOD = self.PODEngine.generalizedQR(self.samples_full)
vbMng(self, "DEL", "Done orthogonalizing.", 10)
return u
def lastSampleManagement(self):
self.samples = self.postprocessuBulk(self.samples_full)
def preallocateSamples(self, u:Np1D, mu:paramVal, n:int):
super().preallocateSamples(u, mu, n)
self.samples_full.reset((u.shape[0], n), u.dtype)
self.samples_full[0] = u

Event Timeline