1 # -*- coding: utf-8 -*-
3 # Copyright (C) 2008-2024 EDF R&D
5 # This library is free software; you can redistribute it and/or
6 # modify it under the terms of the GNU Lesser General Public
7 # License as published by the Free Software Foundation; either
8 # version 2.1 of the License.
10 # This library is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 # Lesser General Public License for more details.
15 # You should have received a copy of the GNU Lesser General Public
16 # License along with this library; if not, write to the Free Software
17 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 # Author: Jean-Philippe Argaud, jean-philippe.argaud@edf.fr, EDF R&D
24 from daCore import BasicObjects
25 from daAlgorithms.Atoms import ecweim
27 # ==============================================================================
28 class ElementaryAlgorithm(BasicObjects.Algorithm):
30 BasicObjects.Algorithm.__init__(self, "INTERPOLATIONBYREDUCEDMODEL")
31 self.defineRequiredParameter(
32 name = "ReducedBasis",
34 typecast = numpy.array,
35 message = "Base réduite, 1 vecteur par colonne",
37 self.defineRequiredParameter(
38 name = "OptimalLocations",
41 message = "Liste des indices ou noms de positions optimales de mesure selon l'ordre interne d'un vecteur de base", # noqa: E501
43 self.defineRequiredParameter(
44 name = "ObservationsAlreadyRestrictedOnOptimalLocations",
47 message = "Stockage des mesures restreintes a priori aux positions optimales de mesure ou non",
49 self.defineRequiredParameter(
50 name = "StoreSupplementaryCalculations",
53 message = "Liste de calculs supplémentaires à stocker et/ou effectuer",
59 self.requireInputArguments(
73 def run(self, Xb=None, Y=None, U=None, HO=None, EM=None, CM=None, R=None, B=None, Q=None, Parameters=None):
74 self._pre_run(Parameters, Xb, Y, U, HO, EM, CM, R, B, Q)
76 # --------------------------
77 __rb = self._parameters["ReducedBasis"]
78 __ip = self._parameters["OptimalLocations"]
79 if len(__ip) != __rb.shape[1]:
80 raise ValueError("The number of optimal measurement locations (%i) and the dimension of the RB (%i) has to be the same."%(len(__ip), __rb.shape[1])) # noqa: E501
82 # Nombre de pas identique au nombre de pas d'observations
83 if hasattr(Y, "stepnumber"):
84 duration = Y.stepnumber()
88 for step in range(0, duration - 1):
90 # La boucle sur les mesures permet une interpolation par jeu de mesure,
91 # sans qu'il y ait de lien entre deux jeux successifs de mesures.
93 # Important : les observations sont données sur tous les points
94 # possibles ou déjà restreintes aux points optimaux de mesure, mais
95 # ne sont utilisés qu'aux points optimaux
96 if hasattr(Y, "store"):
97 _Ynpu = numpy.ravel( Y[step + 1] ).reshape((-1, 1))
99 _Ynpu = numpy.ravel( Y ).reshape((-1, 1))
100 if self._parameters["ObservationsAlreadyRestrictedOnOptimalLocations"]:
106 ecweim.EIM_online(self, __rb, __rm, __ip)
107 # --------------------------
109 self._post_run(HO, EM)
112 # ==============================================================================
113 if __name__ == "__main__":
114 print("\n AUTODIAGNOSTIC\n")