Example 2: Use of AK - IS on Non linear oscillatorΒΆ

import openturns as ot
from openturns.viewer import View
import numpy as np
import otak

ot.RandomGenerator.SetSeed(1)
Definition of Input distribution
Definition of limit state function
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)
Definition of event
Run of AK IS
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())

Out:

Probability of failure: 0.02867081530928803
Simulation budget: 49

Total running time of the script: ( 0 minutes 0.394 seconds)

Gallery generated by Sphinx-Gallery