import openturns as ot import persalys myStudy = persalys.Study('myStudy') # 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.) print(limitState) myStudy.add(limitState) limitState.setThreshold(10.) limitState.setOperator(ot.Less()) print(limitState) # limit state ## limitState2 = persalys.LimitState('aLimitState2', model) print(limitState2) myStudy.add(limitState2) limitState2.setThreshold(15.) print(limitState2)
ot.Normal(30.0, 7.5), 0, ot.TruncatedDistribution.LOWER) dist_Zv = ot.Uniform(49.0, 51.0) dist_Zm = ot.Uniform(54.0, 56.0) 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 ##
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) 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)