Example #1
0
# Design of Experiment - Parametric analysis ##
bounds = persalys.GridDesignOfExperiment.GetDefaultBounds(model)
values = [[bounds.getLowerBound()[i],
           bounds.getUpperBound()[i]] for i in range(3)]
aDesign = persalys.GridDesignOfExperiment('aDesign_0', model, values)
myStudy.add(aDesign)
aDesign.run()

# Comparaison
openturns.testing.assert_almost_equal(
    outputSample,
    aDesign.getResult().getDesignOfExperiment().getOutputSample(), 1e-16)

# Taylor Expansions ##
taylorExpansionsMoments = persalys.TaylorExpansionMomentsAnalysis(
    'myTaylorExpansionMoments', model)
myStudy.add(taylorExpansionsMoments)
taylorExpansionsMoments.run()
taylorExpansionsMomentsResult = taylorExpansionsMoments.getResult()

# Comparaison
openturns.testing.assert_almost_equal(
    0.059730458221,
    taylorExpansionsMomentsResult.getMeanFirstOrder()[0], 1e-13)

# Monte Carlo ##
montecarlo = persalys.MonteCarloAnalysis('myMonteCarlo', model)
montecarlo.setMaximumCalls(1000)
montecarlo.setMaximumCoefficientOfVariation(-1)
myStudy.add(montecarlo)
montecarlo.run()
myStudy = persalys.Study('myStudy')

X0 = persalys.Input('X0', ot.Normal(1, 1))
X1 = persalys.Input('X1', ot.Normal(1, 1))
Y00 = persalys.Output('fake_Y0')
Y00.setIsSelected(False)
Y0 = persalys.Output('Y0')

formula_Y00 = 'X0'
formula_Y0 = 'sin(X0) + 8*X1'
model = persalys.SymbolicPhysicalModel('aModelPhys', [X0, X1], [Y00, Y0], [
                                        formula_Y00, formula_Y0])
myStudy.add(model)

# Taylor Expansion ##
analysis = persalys.TaylorExpansionMomentsAnalysis('aTaylor', model)
myStudy.add(analysis)
print(analysis)

analysis.run()

print("result=", analysis.getResult())
print("\n")

# Taylor Expansion ##
# test with a deterministic variable
X2 = persalys.Input('X2', 10)
model.addInput(X2)
model.addOutput(persalys.Output('Y1'))
model.setFormula('Y1', 'sin(X0) + 8*X1 + X2')
Example #3
0
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)
monteCarlo.setSeed(2)
monteCarlo.setInterestVariables(['y0', 'y1'])
myStudy.add(monteCarlo)

# 2-b Taylor Expansion ##
taylor = persalys.TaylorExpansionMomentsAnalysis('Taylor', model1)
taylor.setInterestVariables(['y0', 'y1'])
myStudy.add(taylor)

# 2-c Taylor Expansion which generate an error
taylor2 = persalys.TaylorExpansionMomentsAnalysis('Taylor2', model1)
taylor2.setInterestVariables(['fake_var'])
myStudy.add(taylor2)

# 3- reliability ##

# limit state ##
limitState = persalys.LimitState('aLimitState', model1, 'y1', ot.Greater(),
                                 0.5)
myStudy.add(limitState)