.. only:: html .. note:: :class: sphx-glr-download-link-note Click :ref:`here ` to download the full example code .. rst-class:: sphx-glr-example-title .. _sphx_glr_auto_reliability_sensitivity_reliability_plot_flood_model.py: Estimate a flooding probability =============================== In this example, we estimate the probability that the ouput of a function exceeds a given threshold with the FORM method. We consider the :ref:`flooding model `. Define the model ---------------- .. code-block:: default from __future__ import print_function import openturns as ot import openturns.viewer as viewer from matplotlib import pylab as plt ot.Log.Show(ot.Log.NONE) We load the flooding model from the usecases module : .. code-block:: default from openturns.usecases import flood_model as flood_model fm = flood_model.FloodModel() We load the joint probability distribution of the input parameters. .. code-block:: default distribution = fm.distribution We create the model. .. code-block:: default model = fm.model Define the event ---------------- Then we create the event whose probability we want to estimate. .. code-block:: default vect = ot.RandomVector(distribution) G = ot.CompositeRandomVector(model, vect) event = ot.ThresholdEvent(G, ot.Greater(), 0.0) event.setName('overflow') Estimate the probability with FORM ---------------------------------- Define a solver. .. code-block:: default optimAlgo = ot.Cobyla() optimAlgo.setMaximumEvaluationNumber(1000) optimAlgo.setMaximumAbsoluteError(1.0e-10) optimAlgo.setMaximumRelativeError(1.0e-10) optimAlgo.setMaximumResidualError(1.0e-10) optimAlgo.setMaximumConstraintError(1.0e-10) Run FORM. .. code-block:: default startingPoint = distribution.getMean() algo = ot.FORM(optimAlgo, event, startingPoint) algo.run() result = algo.getResult() standardSpaceDesignPoint = result.getStandardSpaceDesignPoint() Retrieve results. .. code-block:: default result = algo.getResult() probability = result.getEventProbability() print('Pf=', probability) .. rst-class:: sphx-glr-script-out Out: .. code-block:: none Pf= 0.0005340887806479528 Importance factors. .. code-block:: default graph = result.drawImportanceFactors() view = viewer.View(graph) plt.show() .. image:: /auto_reliability_sensitivity/reliability/images/sphx_glr_plot_flood_model_001.png :alt: Importance Factors from Design Point - overflow :class: sphx-glr-single-img .. rst-class:: sphx-glr-timing **Total running time of the script:** ( 0 minutes 0.051 seconds) .. _sphx_glr_download_auto_reliability_sensitivity_reliability_plot_flood_model.py: .. only :: html .. container:: sphx-glr-footer :class: sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_flood_model.py ` .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_flood_model.ipynb ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_