.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_example/plot_example2.py" .. LINE NUMBERS ARE GIVEN BELOW. .. 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_example_plot_example2.py: Example 2: Use of AK - IS on Non linear oscillator -------------------------------------------------- .. GENERATED FROM PYTHON SOURCE LINES 7-16 .. code-block:: default import openturns as ot from openturns.viewer import View import numpy as np import otak ot.RandomGenerator.SetSeed(1) .. GENERATED FROM PYTHON SOURCE LINES 17-18 | Definition of Input distribution .. GENERATED FROM PYTHON SOURCE LINES 18-31 .. code-block:: default dist_c1=ot.Normal(1, 0.1) dist_c2=ot.Normal(0.1, 0.01) dist_m=ot.Normal(1.,0.05 ) dist_r =ot.Normal(0.5, 0.05) dist_t1 =ot.Normal(1., 0.2) dist_F1=ot.Normal(1., 0.2) std_dev = [dist_c1.getStandardDeviation()[0],dist_c2.getStandardDeviation()[0],dist_m.getStandardDeviation()[0], dist_r.getStandardDeviation()[0],dist_t1.getStandardDeviation()[0],dist_F1.getStandardDeviation()[0]] dim_inputs=6 marginals = [dist_c1,dist_c2,dist_m,dist_r,dist_t1,dist_F1] dist_x = ot.ComposedDistribution(marginals) .. GENERATED FROM PYTHON SOURCE LINES 32-33 | Definition of limit state function .. GENERATED FROM PYTHON SOURCE LINES 33-50 .. code-block:: default def non_lin_osc(x): c1 = x[0] c2 = x[1] m = x[2] r = x[3] t1 = x[4] F1= x[5] omega = np.sqrt((c1+c2)/m) G = 3*r - np.abs(2*F1/(m*omega**2)*np.sin(omega*t1/2)) return [G] # Definition of pythonfunction non_lin_osc = ot.PythonFunction(6, 1, non_lin_osc) .. GENERATED FROM PYTHON SOURCE LINES 51-52 | Definition of event .. GENERATED FROM PYTHON SOURCE LINES 52-58 .. code-block:: default vect = ot.RandomVector(dist_x) G = ot.CompositeRandomVector(non_lin_osc, vect) event_osc = ot.ThresholdEvent(G, ot.Less(), 0.0) .. GENERATED FROM PYTHON SOURCE LINES 59-60 | Run of AK IS .. GENERATED FROM PYTHON SOURCE LINES 60-85 .. code-block:: default dim_osc = 6 basis = ot.ConstantBasisFactory(dim_inputs).build() covarianceModel = ot.SquaredExponential([0.1]*dim_osc, [1.0]) n_IS_osc = 1000 n_DoE_osc = 40 sim_budget_osc = 200 verbose = False my_AK_non_lin_osc = otak.AK_ISAlgorithm(event_osc, n_IS_osc, n_DoE_osc, sim_budget_osc, basis, covarianceModel, ot.Cobyla(), 2, verbose) #computation of probability with AK-IS my_AK_non_lin_osc.compute_proba() print('Probability of failure:',my_AK_non_lin_osc.getFailureProbability()) print('Simulation budget:',my_AK_non_lin_osc.getSimBudget()) .. rst-class:: sphx-glr-script-out Out: .. code-block:: none Probability of failure: 0.02867081530928803 Simulation budget: 49 .. rst-class:: sphx-glr-timing **Total running time of the script:** ( 0 minutes 0.394 seconds) .. _sphx_glr_download_auto_example_plot_example2.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_example2.py ` .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_example2.ipynb ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_