1import openturns as ot
2from matplotlib import pyplot as plt
3from openturns.viewer import View
4ot.RandomGenerator.SetSeed(0)
5
6
7def flooding(X):
8    Hd = 3.0
9    Zb = 55.5
10    L = 5.0e3
11    B = 300.0
12    Zd = Zb + Hd
13    Q, Ks, Zv, Zm = X
14    alpha = (Zm - Zv) / L
15    H = (Q / (Ks * B * alpha**0.5))**0.6
16    Zc = H + Zv
17    S = Zc - Zd
18    return [S]
19
20
21myFunction = ot.PythonFunction(4, 1, flooding)
22Q = ot.Gumbel(558.0, 1013.0)
23Q = ot.TruncatedDistribution(Q, 0.0, ot.SpecFunc.MaxScalar)
24Ks = ot.Normal(30.0, 7.5)
25Ks = ot.TruncatedDistribution(Ks, 0.0, ot.SpecFunc.MaxScalar)
26Zv = ot.Uniform(49.0, 51.0)
27Zm = ot.Uniform(54.0, 56.0)
28inputX = ot.ComposedDistribution([Q, Ks, Zv, Zm])
29inputX.setDescription(["Q", "Ks", "Zv", "Zm"])
30
31size = 5000
32computeSO = True
33inputDesign = ot.SobolIndicesExperiment(inputX, size, computeSO).generate()
34outputDesign = myFunction(inputDesign)
35sensitivityAnalysis = ot.MartinezSensitivityAlgorithm(
36    inputDesign, outputDesign, size)
37
38graph = sensitivityAnalysis.draw()
39
40fig = plt.figure(figsize=(8, 4))
41axis = fig.add_subplot(111)
42axis.set_xlim(auto=True)
43View(graph, figure=fig, axes=[axis], add_legend=True)
44