taylor2.setInterestVariables(['fake_var']) myStudy.add(taylor2) # 3- reliability ## # limit state ## limitState = persalys.LimitState('aLimitState', model1, 'y1', ot.Greater(), 0.5) myStudy.add(limitState) optimAlgo = ot.AbdoRackwitz() optimAlgo.setMaximumIterationNumber(150) optimAlgo.setMaximumAbsoluteError(1e-3) # 3-a Monte Carlo ## monteCarloReliability = persalys.MonteCarloReliabilityAnalysis( 'MonteCarloReliability', limitState) monteCarloReliability.setMaximumCoefficientOfVariation(-1.) monteCarloReliability.setMaximumElapsedTime(1000) monteCarloReliability.setMaximumCalls(20) monteCarloReliability.setSeed(2) myStudy.add(monteCarloReliability) # 3-b FORM IS ## form_is = persalys.FORMImportanceSamplingAnalysis('FORM_IS', limitState) form_is.setOptimizationAlgorithm(optimAlgo) form_is.setMaximumCoefficientOfVariation(-1.) form_is.setMaximumElapsedTime(1000) form_is.setMaximumCalls(20) form_is.setSeed(2) myStudy.add(form_is)
Q = persalys.Input('Q', 1000., dist_Q, 'Débit maximal annuel (m3/s)') Ks = persalys.Input('Ks', 30., dist_Ks, 'Strickler (m^(1/3)/s)') Zv = persalys.Input('Zv', 50., dist_Zv, 'Côte de la rivière en aval (m)') Zm = persalys.Input('Zm', 55., dist_Zm, 'Côte de la rivière en amont (m)') S = persalys.Output('S', 'Surverse (m)') model = persalys.SymbolicPhysicalModel('myPhysicalModel', [Q, Ks, Zv, Zm], [ S], ['(Q/(Ks*300.*sqrt((Zm-Zv)/5000)))^(3.0/5.0)+Zv-55.5-3.']) myStudy.add(model) # limit state ## limitState = persalys.LimitState('limitState1', model, 'S', ot.Greater(), 0.) myStudy.add(limitState) # Monte Carlo ## montecarlo = persalys.MonteCarloReliabilityAnalysis( 'myMonteCarlo', limitState) montecarlo.setMaximumCalls(10000) myStudy.add(montecarlo) montecarlo.run() montecarloResult = montecarlo.getResult() # Comparaison openturns.testing.assert_almost_equal(montecarloResult.getSimulationResult().getProbabilityEstimate(), 0.0, 1e-6) # FORM-IS ## formIS = persalys.FORMImportanceSamplingAnalysis('myformIS', limitState) formIS.setMaximumCoefficientOfVariation(0.01) formIS.setMaximumCalls(10000) formIS.setBlockSize(1000) myStudy.add(formIS)
# Model X0 = persalys.Input('X0', ot.Normal(1, 1)) X1 = persalys.Input('X1', ot.Normal(1, 1)) Y0 = persalys.Output('Y0') model = persalys.SymbolicPhysicalModel('aModelPhys', [X0, X1], [Y0], ['sin(X0) + 8*X1']) myStudy.add(model) # limit state ## limitState = persalys.LimitState('aLimitState', model, 'Y0', ot.Greater(), 20.) myStudy.add(limitState) # Monte Carlo ## analysis = persalys.MonteCarloReliabilityAnalysis('myMonteCarlo', limitState) analysis.setMaximumCalls(1000) analysis.setSeed(2) myStudy.add(analysis) print(analysis) analysis.run() print("result=", analysis.getResult()) # Monte Carlo ## analysis2 = persalys.MonteCarloReliabilityAnalysis('myMonteCarlo2', limitState) analysis2.setMaximumCoefficientOfVariation(0.02) analysis2.setMaximumElapsedTime(100000) analysis2.setBlockSize(100) myStudy.add(analysis2)