Skip to content

Commit 5f82f9b

Browse files
committed
doc: Fix metamodel example
1 parent 9281731 commit 5f82f9b

1 file changed

Lines changed: 10 additions & 9 deletions

File tree

doc/examples/application/plot_metamodel.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
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
#
@@ -53,10 +53,13 @@
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.
5555
inputLaw = ot.Uniform(1.5, 2.5)
56-
inputSample = inputLaw.getSample(10)
56+
inputSample = inputLaw.getSample(100)
5757
outputFMUSample = 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)
6063
graph.setTitle("FMU simulations")
6164
graph.setXTitle("Time")
6265
graph.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
100103
algoKL = ot.KarhunenLoeveSVDAlgorithm(outputFMUSample, threshold)
101104
algoKL.run()
102105
resultKL = 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.
122125
dim = inputSample.getDimension() # only 1 input dimension
123126
univb = ot.ConstantBasisFactory(dim).build() # univariate basis
124127
coll = [ot.AggregatedFunction(
@@ -127,9 +130,7 @@ def drawKL(scaledKL, KLev, mesh, title="Scaled KL modes"):
127130
basis = ot.Basis(coll) # multivariate basis
128131
covarianceModel = ot.SquaredExponential(dim)
129132
covarianceModel = ot.TensorizedCovarianceModel([covarianceModel] * n_mode)
130-
131-
132-
algo = ot.KrigingAlgorithm(inputSample, projectionSample, covarianceModel, basis)
133+
algo = ot.FunctionalChaosAlgorithm(inputSample, projectionSample, inputLaw)
133134
algo.run()
134135
result = algo.getResult()
135136
metamodel = result.getMetaModel()
@@ -187,7 +188,7 @@ def globalMetamodel(sample):
187188
view = 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):
192193
projectFunction = ot.KarhunenLoeveProjection(resultKL)
193194
coefficientSample = projectFunction(outputFMUTestSample)

0 commit comments

Comments
 (0)