1010#
1111# Metamodeling a model with time-dependent output is a difficult problem. We
1212# will combine two methods: Karhunen-Loeve dimension reduction should precede
13- # the Kriging metamodeling.
13+ # the chaos metamodeling.
1414#
1515# We will proceed the following way:
1616#
5353# We create a Monte-Carlo design of experiment, on which we simulate the FMU.
5454# The simulation inputs and outputs will be used to train the metamodel.
5555inputLaw = ot .Uniform (1.5 , 2.5 )
56- inputSample = inputLaw .getSample (10 )
56+ inputSample = inputLaw .getSample (100 )
5757outputFMUSample = function (inputSample )
5858
59- graph = outputFMUSample .draw ().getGraph (0 , 0 )
59+ outputFMUSample10 = ot .ProcessSample (outputFMUSample .getMesh (), 10 , 1 )
60+ for i in range (10 ):
61+ outputFMUSample10 .setField (outputFMUSample .getField (i ), i )
62+ graph = outputFMUSample10 .draw ().getGraph (0 , 0 )
6063graph .setTitle ("FMU simulations" )
6164graph .setXTitle ("Time" )
6265graph .setYTitle ("Number of infected" )
@@ -96,7 +99,7 @@ def drawKL(scaledKL, KLev, mesh, title="Scaled KL modes"):
9699# We compute the Karhunen-Loeve decomposition of the model outputs.
97100# The underlying assumption is that these outputs are realizations of a
98101# stochastic process.
99- threshold = 1e-4
102+ threshold = 0.0
100103algoKL = ot .KarhunenLoeveSVDAlgorithm (outputFMUSample , threshold )
101104algoKL .run ()
102105resultKL = algoKL .getResult ()
@@ -118,7 +121,7 @@ def drawKL(scaledKL, KLev, mesh, title="Scaled KL modes"):
118121# %%
119122# We keep on following our road map, by metamodeling the projection
120123# of the curves on the smaller-dimension space.
121- # We metamodel the Karhunen-Loeve coefficients using ordinary Kriging .
124+ # We metamodel the Karhunen-Loeve coefficients using ordinary chaos .
122125dim = inputSample .getDimension () # only 1 input dimension
123126univb = ot .ConstantBasisFactory (dim ).build () # univariate basis
124127coll = [ot .AggregatedFunction (
@@ -127,9 +130,7 @@ def drawKL(scaledKL, KLev, mesh, title="Scaled KL modes"):
127130basis = ot .Basis (coll ) # multivariate basis
128131covarianceModel = ot .SquaredExponential (dim )
129132covarianceModel = ot .TensorizedCovarianceModel ([covarianceModel ] * n_mode )
130-
131-
132- algo = ot .KrigingAlgorithm (inputSample , projectionSample , covarianceModel , basis )
133+ algo = ot .FunctionalChaosAlgorithm (inputSample , projectionSample , inputLaw )
133134algo .run ()
134135result = algo .getResult ()
135136metamodel = result .getMetaModel ()
@@ -187,7 +188,7 @@ def globalMetamodel(sample):
187188view = otv .View (graph )
188189
189190# %%
190- # We validate the Kriging (using the Karhunen-Loeve coefficients of the test
191+ # We validate the chaos (using the Karhunen-Loeve coefficients of the test
191192# sample):
192193projectFunction = ot .KarhunenLoeveProjection (resultKL )
193194coefficientSample = projectFunction (outputFMUTestSample )
0 commit comments