Ejemplo n.º 1
0
formula_y1 = "cos(0.5*xi1) + sin(xi2) + xi3"
model = persalys.SymbolicPhysicalModel('model', [xi1, xi2, xi3], [y00, y0, y1], [
                                        formula_y00, formula_y0, formula_y1])
myStudy.add(model)

# Design of Experiment ##
aDesign = persalys.FixedDesignOfExperiment('design', model)
inputSample = ot.LHSExperiment(model.getDistribution(), 50).generate()
inputSample.stack(ot.Sample(50, [0.5]))
aDesign.setOriginalInputSample(inputSample)
myStudy.add(aDesign)

aDesign.run()

# Chaos 1 ##
analysis = persalys.FunctionalChaosAnalysis('chaos_0', aDesign)
analysis.setChaosDegree(4)
analysis.setSparseChaos(True)
myStudy.add(analysis)
print(analysis)

analysis.run()

chaosResult = analysis.getResult()
sobolResult = chaosResult.getSobolResult()
print("result=", chaosResult)
print("functionalChaosResult", chaosResult.getFunctionalChaosResult())

# Comparaison
mean = [0, 0.4885327735406139]
variance = [0.8727523923767868, 0.8729938152031875]
Ejemplo n.º 2
0
    10327.9, 10364.5
],
          [
              2975.33, 2980.81, 2986.29, 2991.78, 2997.26, 3002.74, 3008.22,
              3013.71, 3019.19, 3024.67
          ],
          [
              3901.31, 3923.24, 3945.17, 3967.1, 3989.03, 4010.97, 4032.9,
              4054.83, 4076.76, 4098.69
          ]]

design_1 = persalys.GridDesignOfExperiment('aDesign_1', model, values)
design_1.run()
myStudy.add(design_1)

chaos = persalys.FunctionalChaosAnalysis('chaos_0', design_1)
chaos.setChaosDegree(2)
chaos.setSparseChaos(False)
myStudy.add(chaos)
chaos.run()
chaosResult = chaos.getResult()

# Comparaison
openturns.testing.assert_almost_equal(
    0.6356916720224053,
    chaosResult.getSobolResult().getFirstOrderIndices()[0][0], 1e-16)
openturns.testing.assert_almost_equal(
    0.04806204987068495,
    chaosResult.getSobolResult().getFirstOrderIndices()[0][1], 1e-17)
openturns.testing.assert_almost_equal(
    0.31620207904361813,
design_3.run()
myStudy.add(design_3)

# 1- meta model1 ##

# 1-a Kriging ##
kriging = persalys.KrigingAnalysis('kriging', probaDesign)
kriging.setBasis(ot.LinearBasisFactory(2).build())
kriging.setCovarianceModel(ot.MaternModel(2))
kriging.setTestSampleValidation(True)
kriging.setKFoldValidation(True)
kriging.setInterestVariables(['y0', 'y1'])
myStudy.add(kriging)

# 1-b Chaos ##
chaos1 = persalys.FunctionalChaosAnalysis('chaos_1', probaDesign)
chaos1.setChaosDegree(7)
chaos1.setSparseChaos(True)
chaos1.setTestSampleValidation(True)
chaos1.setKFoldValidation(True)
chaos1.setInterestVariables(['y1'])
myStudy.add(chaos1)

# 1-c Chaos ##
chaos2 = persalys.FunctionalChaosAnalysis('chaos_2', design_2)
chaos2.setChaosDegree(2)
chaos2.setSparseChaos(True)
myStudy.add(chaos2)

# 2- central tendancy ##
Ejemplo n.º 4
0
probaDesign.run()
myStudy.add(probaDesign)

# 1- meta model1 ##

# 1-a Kriging ##
kriging = persalys.KrigingAnalysis('kriging', probaDesign)
kriging.setBasis(ot.LinearBasisFactory(2).build())
kriging.setCovarianceModel(ot.MaternModel(2))
kriging.setTestSampleValidation(True)
kriging.setKFoldValidation(True)
kriging.setInterestVariables(['y0', 'y1'])
myStudy.add(kriging)

# 1-b Chaos ##
chaos1 = persalys.FunctionalChaosAnalysis('chaos_1', probaDesign)
chaos1.setChaosDegree(7)
chaos1.setSparseChaos(True)
chaos1.setTestSampleValidation(True)
chaos1.setKFoldValidation(True)
chaos1.setInterestVariables(['y1'])
myStudy.add(chaos1)

# 2- central tendancy ##

# 2-a Monte Carlo ##
monteCarlo = persalys.MonteCarloAnalysis('MonteCarlo', model1)
monteCarlo.setIsConfidenceIntervalRequired(False)
monteCarlo.setMaximumCoefficientOfVariation(-1.)
monteCarlo.setMaximumElapsedTime(1000)
monteCarlo.setMaximumCalls(20)
Ejemplo n.º 5
0
X3 = persalys.Input('X3', 0, '')
Y0 = persalys.Output('Y0', '')
inputs = [X0, X1, X2, X3]
outputs = [Y0]
formulas = ['X0+X1+X2+X3']
SymbolicModel_0 = persalys.SymbolicPhysicalModel('SymbolicModel_0', inputs, outputs, formulas)
values = [[0],
[0],
[-0.1, 0.1],
[-0.1, 0.1]]
design_0 = persalys.GridDesignOfExperiment('design_0', SymbolicModel_0, values)
design_0.setBlockSize(1)
interestVariables = ['Y0']
design_0.setInterestVariables(interestVariables)
design_0.run()
metaModel_0 = persalys.FunctionalChaosAnalysis('metaModel_0', design_0)
metaModel_0.setChaosDegree(1)
metaModel_0.setSparseChaos(False)
metaModel_0.setAnalyticalValidation(True)
metaModel_0.setTestSampleValidation(False)
metaModel_0.setKFoldValidation(False)
metaModel_0.run()
print(metaModel_0.getResult())

# deterministic/chaos
X0 = persalys.Input('X0', 0, '')
X1 = persalys.Input('X1', 0, '')
X2 = persalys.Input('X2', 0, '')
X3 = persalys.Input('X3', 0, '')
Y0 = persalys.Output('Y0', '')
inputs = [X0, X1, X2, X3]