def __init__(self):
        self.dim = 2
        self.D = 0.02
        # Random variable : R
        self.muR = 3.0e6
        self.sigmaR = 3.0e5
        # Random variable : F
        self.muF = 750.
        self.sigmaF = 50.
        # create the limit state function model
        self.model = ot.SymbolicFunction(['R', 'F'], ['R-F/(pi_/10000.0)'])

        # Yield strength
        self.distribution_R = ot.LogNormalMuSigma(self.muR, self.sigmaR,
                                                  0.0).getDistribution()
        self.distribution_R.setName('Yield strength')
        self.distribution_R.setDescription('R')
        # Traction load
        self.distribution_F = ot.Normal(self.muF, self.sigmaF)
        self.distribution_F.setName('Traction_load')
        self.distribution_F.setDescription('F')

        # Joint distribution of the input parameters
        self.distribution = ot.ComposedDistribution(
            [self.distribution_R, self.distribution_F])
def define_distribution():
    """
    Define the distribution of the training example (beam).
    Return a ComposedDistribution object from openTURNS
    """
    sample_E = ot.Sample.ImportFromCSVFile("sample_E.csv")
    kernel_smoothing = ot.KernelSmoothing(ot.Normal())
    bandwidth = kernel_smoothing.computeSilvermanBandwidth(sample_E)
    E = kernel_smoothing.build(sample_E, bandwidth)
    E.setDescription(['Young modulus'])

    F = ot.LogNormal()
    F.setParameter(ot.LogNormalMuSigma()([30000, 9000, 15000]))
    F.setDescription(['Load'])

    L = ot.Uniform(250, 260)
    L.setDescription(['Length'])

    I = ot.Beta(2.5, 4, 310, 450)
    I.setDescription(['Inertia'])

    marginal_distributions = [F, E, L, I]
    SR_cor = ot.CorrelationMatrix(len(marginal_distributions))
    SR_cor[2, 3] = -0.2
    copula = ot.NormalCopula(ot.NormalCopula.GetCorrelationFromSpearmanCorrelation(SR_cor))

    return(ot.ComposedDistribution(marginal_distributions, copula))
    def __init__(self, threshold=0.0):
        """
        Create a axial stressed beam reliability problem.

        The inputs are R, the Yield strength, and F, the traction load.
        The event is {g(X) < threshold} where

        g(R, F) = R - F/(pi_ * 100.0)

        We have R ~ LogNormalMuSigma() and F ~ Normal().

        Parameters
        ----------
        threshold : float
            The threshold.

        Example
        -------
        problem  = AxialStressedBeamReliability()
        """
        limitStateFunction = ot.SymbolicFunction(["R", "F"], ["R - F/(pi_ * 100.0)"])

        R_dist = ot.LogNormalMuSigma(300.0, 30.0, 0.0).getDistribution()
        R_dist.setName("Yield strength")
        R_dist.setDescription("R")

        F_dist = ot.Normal(75000.0, 5000.0)
        F_dist.setName("Traction load")
        F_dist.setDescription("F")

        myDistribution = ot.ComposedDistribution([R_dist, F_dist])

        inputRandomVector = ot.RandomVector(myDistribution)
        outputRandomVector = ot.CompositeRandomVector(
            limitStateFunction, inputRandomVector
        )
        thresholdEvent = ot.ThresholdEvent(outputRandomVector, ot.Less(), 0.0)

        name = "Axial stressed beam"
        diff = R_dist - F_dist / (np.pi * 100.0)
        probability = diff.computeCDF(threshold)
        super(AxialStressedBeamReliability, self).__init__(
            name, thresholdEvent, probability
        )

        return None
    def __init__(self):
        self.dim = 4  # number of inputs
        # Young's modulus E
        self.E = ot.Beta(0.9, 3.5, 65.0e9, 75.0e9)  # in N/m^2
        self.E.setDescription("E")
        self.E.setName("Young modulus")

        # Load F
        self.F = ot.LogNormal()  # in N
        self.F.setParameter(ot.LogNormalMuSigma()([300.0, 30.0, 0.0]))
        self.F.setDescription("F")
        self.F.setName("Load")

        # Length L
        self.L = ot.Uniform(2.5, 2.6)  # in m
        self.L.setDescription("L")
        self.L.setName("Length")

        # Moment of inertia I
        self.I = ot.Beta(2.5, 4.0, 1.3e-7, 1.7e-7)  # in m^4
        self.I.setDescription("I")
        self.I.setName("Inertia")

        # physical model
        self.model = ot.SymbolicFunction(['E', 'F', 'L', 'I'],
                                         ['F*L^3/(3*E*I)'])

        # correlation matrix
        self.R = ot.CorrelationMatrix(self.dim)
        self.R[2, 3] = -0.2
        self.copula = ot.NormalCopula(
            ot.NormalCopula.GetCorrelationFromSpearmanCorrelation(self.R))
        self.distribution = ot.ComposedDistribution(
            [self.E, self.F, self.L, self.I], self.copula)

        # special case of an independent copula
        self.independentDistribution = ot.ComposedDistribution(
            [self.E, self.F, self.L, self.I])
Exemple #5
0
#!/usr/bin/env python

# -*- coding: utf8 -*-
import openturns as ot

from analytical_functions import gfun_8
from simulation_methods import run_MonteCarlo

# Distributions d'entrée
# ~ dist_X1 = ot.Normal(0., 1.)
# ~ dist_X2 = ot.Normal(0., 1.)
# ~ myDistribution = ot.ComposedDistribution([dist_X1, dist_X2])
parameters1 = ot.LogNormalMuSigma(120, 12, 0.0)
dist_X1 = ot.ParametrizedDistribution(parameters1)

parameters2 = ot.LogNormalMuSigma(120, 12, 0.0)
dist_X2 = ot.ParametrizedDistribution(parameters2)

parameters3 = ot.LogNormalMuSigma(120, 12, 0.0)
dist_X3 = ot.ParametrizedDistribution(parameters3)

parameters4 = ot.LogNormalMuSigma(120, 12, 0.0)
dist_X4 = ot.ParametrizedDistribution(parameters4)

parameters5 = ot.LogNormalMuSigma(50, 10, 0.0)
dist_X5 = ot.ParametrizedDistribution(parameters5)

parameters6 = ot.LogNormalMuSigma(40, 8, 0.0)
dist_X6 = ot.ParametrizedDistribution(parameters6)

myDistribution = ot.ComposedDistribution(
Exemple #6
0
#dimension
dim = 2

#Analytical model definition
limitState = ot.SymbolicFunction(['R', 'F'], ['R-F/(pi_*100)'])

#Test of the limit state function
x = [300, 75000]
print('x=', x)
print('G(x)=', limitState(x))

#Stochastic model definition

#Create a first marginal : LogNormal distribution 1D, parametrized by
#its mean and standard deviation
R_dist = ot.LogNormalMuSigma(300, 30, 0).getDistribution()
R_dist.setName('Yield strength')
R_dist.setDescription('R')

#Graphical output of the PDF
R_dist.drawPDF()

#Create a second marginal : Normal distribution 1D
F_dist = ot.Normal(75000, 5000)
F_dist.setName('Traction_load')
F_dist.setDescription('F')

#Graphical output of the PDF
F_dist.drawPDF()

#Create a copula : IndependentCopula (no correlation)
Exemple #7
0
    view = View(graph)
    # view.save('curve7.png')
    view.ShowAll(block=True)

    # Pie
    graph = ot.SobolIndicesAlgorithm.DrawImportanceFactors(
        [.4, .3, .2, .1], ['a0', 'a1', 'a2', 'a3'], 'Zou')
    # graph.draw('curve8.png')
    view = View(graph)
    # view.save('curve8.png')
    view.show()

    # Convergence graph curve
    aCollection = []
    aCollection.append(ot.LogNormalFactory().build(
        ot.LogNormalMuSigma()([300.0, 30.0, 0.0])))
    aCollection.append(ot.Normal(75e3, 5e3))
    myDistribution = ot.ComposedDistribution(aCollection)
    vect = ot.RandomVector(myDistribution)
    LimitState = ot.SymbolicFunction(('R', 'F'), ('R-F/(pi_*100.0)', ))
    G = ot.CompositeRandomVector(LimitState, vect)
    myEvent = ot.ThresholdEvent(G, ot.Less(), 0.0)
    experiment = ot.MonteCarloExperiment()
    myAlgo = ot.ProbabilitySimulationAlgorithm(myEvent, experiment)
    myAlgo.setMaximumCoefficientOfVariation(0.05)
    myAlgo.setMaximumOuterSampling(int(1e5))
    myAlgo.run()
    graph = myAlgo.drawProbabilityConvergence()
    # graph.draw('curve10.png')
    view = View(graph)
    # view.save('curve10.png')
#!/usr/bin/env python

import openturns as ot
import openturns.testing
import persalys

myStudy = persalys.Study('myStudy')

# Model
R = persalys.Input('R', 0., ot.LogNormalMuSigma(
    300., 30.).getDistribution(), 'Yield strength')
F = persalys.Input('F', 0., ot.Normal(75000., 5000.), 'Traction load')
G = persalys.Output('G', 'deviation')
code = 'from math import pi\n\ndef _exec(R, F):\n    G = R-F/(pi*100.0)\n    return G\n'

model = persalys.PythonPhysicalModel('myPhysicalModel', [R, F], [G], code)
myStudy.add(model)

f = model.getFunction()
print(f([300., 75000.]))

# several outputs
model.setCode(
    'from math import pi\n\ndef _exec(R, F):\n    G =  6*F\n    H = 42.0\n    return G, H\n')
f = model.getFunction()
print(f([300., 75000.]))

# test operator() (sample)
model.setCode(
    'from math import pi\n\ndef _exec(R, F):\n    G = 2*R-F/(pi*100.0)\n    return G\n')
f = model.getFunction()
Exemple #9
0
from __future__ import print_function
#§ Identifying the platform
import platform
key_platform = (platform.system(), platform.architecture()[0])
# Call to either 'platform.system' or 'platform.architecture' *after*
# importing pyfmi causes a segfault.
dict_platform = {("Linux", "64bit"):"linux64",
                 ("Windows", "64bit"):"win64"}

#§ Define the input distribution
import numpy as np
import openturns as ot

E = ot.Beta(0.93, 3.2, 2.8e7, 4.8e7)
F = ot.LogNormalMuSigma(3.0e4, 9000.0, 15000.0).getDistribution()
L = ot.Uniform(250.0, 260.0)
I = ot.Beta(2.5, 4.0, 310.0, 450.0)

# Create the Spearman correlation matrix of the input random vector
RS = ot.CorrelationMatrix(4)
RS[2,3] = -0.2

# Evaluate the correlation matrix of the Normal copula from RS
R = ot.NormalCopula.GetCorrelationFromSpearmanCorrelation(RS)

# Create the Normal copula parametrized by R
mycopula = ot.NormalCopula(R)

# Create the input probability distribution of dimension 4
inputDistribution = ot.ComposedDistribution([E, F, L, I], mycopula)
Exemple #10
0
# %%
# We define the symbolic function which evaluates the output Y depending on the inputs E, F, L and I.

# %%
model = ot.SymbolicFunction(["E", "F", "L", "I"], ["F*L^3/(3*E*I)"])

# %%
# Then we define the distribution of the input random vector.

# %%
# Young's modulus E
E = ot.Beta(0.9, 3.5, 2.5e7, 5.0e7)  # in N/m^2
E.setDescription("E")
# Load F
F = ot.LogNormal()  # in N
F.setParameter(ot.LogNormalMuSigma()([30.e3, 9e3, 15.e3]))
F.setDescription("F")
# Length L
L = ot.Uniform(250., 260.)  # in cm
L.setDescription("L")
# Moment of inertia I
I = ot.Beta(2.5, 4, 310, 450)  # in cm^4
I.setDescription("I")

# %%
# Finally, we define the dependency using a `NormalCopula`.

# %%
myDistribution = ot.ComposedDistribution([E, F, L, I])

# %%
#!/usr/bin/env python

from __future__ import print_function
import openturns as ot
import openturns.testing
import persalys

myStudy = persalys.Study('myStudy')

# Model
R = persalys.Input('R', 0.,
                   ot.LogNormalMuSigma(300., 30.).getDistribution(),
                   'Yield strength')
F = persalys.Input('F', 0., ot.Normal(75000., 5000.), 'Traction load')
G = persalys.Output('G', 'deviation')
code = 'from math import pi\n\ndef _exec(R, F):\n    G = R-F/(pi*100.0)\n    return G\n'

model = persalys.PythonPhysicalModel('myPhysicalModel', [R, F], [G], code)
myStudy.add(model)

f = model.getFunction()
print(f([300., 75000.]))

# several outputs
model.setCode(
    'from math import pi\n\ndef _exec(R, F):\n    G =  6*F\n    H = 42.0\n    return G, H\n'
)
f = model.getFunction()
print(f([300., 75000.]))

# test operator() (sample)
Exemple #12
0
#! /usr/bin/env python

import openturns as ot

distParams = []
distParams.append(ot.ArcsineMuSigma(8.4, 2.25))
distParams.append(ot.BetaMuSigma(0.2, 0.6, -1, 2))
distParams.append(ot.GammaMuSigma(1.5, 2.5, -0.5))
distParams.append(ot.GumbelLambdaGamma(0.6, 6.0))
distParams.append(ot.GumbelMuSigma(1.5, 1.3))
distParams.append(ot.LogNormalMuErrorFactor(0.63, 1.5, -0.5))
distParams.append(ot.LogNormalMuSigma(0.63, 3.3, -0.5))
distParams.append(ot.LogNormalMuSigmaOverMu(0.63, 5.24, -0.5))
distParams.append(ot.WeibullMaxMuSigma(1.3, 1.23, 3.1))
distParams.append(ot.WeibullMinMuSigma(1.3, 1.23, -0.5))

for distParam in distParams:

    print('Distribution Parameters ', repr(distParam))
    print('Distribution Parameters ', distParam)

    non_native = distParam.getValues()
    desc = distParam.getDescription()
    print('non-native=', non_native, desc)
    native = distParam.evaluate()
    print('native=', native)
    non_native = distParam.inverse(native)
    print('non-native=', non_native)
    print('built dist=', distParam.getDistribution())

    # derivative of the native parameters with regards the parameters of the
Exemple #13
0
#!/usr/bin/env python

from __future__ import print_function
import openturns as ot
import openturns.testing as ott
import persalys

ot.RandomGenerator.SetSeed(0)

myStudy = persalys.Study('myStudy')
persalys.Study.Add(myStudy)

R = persalys.Input('R', 700e6,
                   ot.LogNormalMuSigma(750e6, 11e6).getDistribution(),
                   'Parameter R')
C = persalys.Input('C', 2500e6, ot.Normal(2750e6, 250e6), 'Parameter C')
gamma = persalys.Input('gam', 8., ot.Normal(10, 2), 'Parameter gamma')
dist_strain = ot.Uniform(0, 0.07)
strain = persalys.Input('strain', 0., dist_strain, 'Strain')
sigma = persalys.Output('sigma', 'Stress (Pa)')
fakeSigma = persalys.Output('fakeSigma', 'Stress (Pa)')

formula = [
    'R + C * (1 - exp(-gam * strain))', '2*(R + C * (1 - exp(-gam * strain)))'
]
model = persalys.SymbolicPhysicalModel('model1', [R, C, gamma, strain],
                                       [sigma, fakeSigma], formula)
myStudy.add(model)

# generate observations
nbObs = 100
    def __init__(
        self,
        threshold=0.0,
        mu1=120.0,
        sigma1=12.0,
        mu2=120.0,
        sigma2=12.0,
        mu3=120.0,
        sigma3=12.0,
        mu4=120.0,
        sigma4=12.0,
        mu5=50.0,
        sigma5=10.0,
        mu6=40.0,
        sigma6=8.0,
    ):
        """
        Creates a reliability problem RP8.

        The event is {g(X) < threshold} where

        X = (x1, x2, x3, x4, x5, x6)

        g(X) = x1 + 2 * x2 + 2 * x3 + x4 - 5 * x5 - 5 * x6

        We have :
            x1 ~ LogNormalMuSigma(mu1, sigma1)

            x2 ~ LogNormalMuSigma(mu2, sigma2)

            x3 ~ LogNormalMuSigma(mu3, sigma3)

            x4 ~ LogNormalMuSigma(mu4, sigma4)

            x5 ~ LogNormalMuSigma(mu5, sigma5)

            x6 ~ LogNormalMuSigma(mu6, sigma6)

        Parameters
        ----------
        threshold : float
            The threshold.
        mu1 : float
            The mean of the LogNormal random variable X1.
        sigma1 : float
            The standard deviation of the LogNormal random variable X1.
        mu2 : float
            The mean of the LogNormal random variable X2.
        sigma2 : float
            The standard deviation of the LogNormal random variable X2.
        mu3 : float
            The mean of the LogNormal random variable X3.
        sigma3 : float
            The standard deviation of the LogNormal random variable X3.
        mu4 : float
            The mean of the LogNormal random variable X4.
        sigma4 : float
            The standard deviation of the LogNormal random variable X4.
        mu5 : float
            The mean of the LogNormal random variable X5.
        sigma5 : float
            The standard deviation of the LogNormal random variable X5.
        mu6 : float
            The mean of the LogNormal random variable X6.
        sigma6 : float
            The standard deviation of the LogNormal random variable X6.
        """

        formula = "x1 + 2 * x2 + 2 * x3 + x4 - 5 * x5 - 5 * x6"

        limitStateFunction = ot.SymbolicFunction(
            ["x1", "x2", "x3", "x4", "x5", "x6"], [formula]
        )
        parameters1 = ot.LogNormalMuSigma(mu1, sigma1, 0.0)
        X1 = ot.ParametrizedDistribution(parameters1)
        X1.setDescription(["X1"])
        parameters2 = ot.LogNormalMuSigma(mu2, sigma2, 0.0)
        X2 = ot.ParametrizedDistribution(parameters2)
        X2.setDescription(["X2"])
        parameters3 = ot.LogNormalMuSigma(mu3, sigma3, 0.0)
        X3 = ot.ParametrizedDistribution(parameters3)
        X3.setDescription(["X3"])
        parameters4 = ot.LogNormalMuSigma(mu4, sigma4, 0.0)
        X4 = ot.ParametrizedDistribution(parameters4)
        X4.setDescription(["X4"])
        parameters5 = ot.LogNormalMuSigma(mu5, sigma5, 0.0)
        X5 = ot.ParametrizedDistribution(parameters5)
        X5.setDescription(["X5"])
        parameters6 = ot.LogNormalMuSigma(mu6, sigma6, 0.0)
        X6 = ot.ParametrizedDistribution(parameters6)
        X6.setDescription(["X6"])

        myDistribution = ot.ComposedDistribution([X1, X2, X3, X4, X5, X6])
        inputRandomVector = ot.RandomVector(myDistribution)
        outputRandomVector = ot.CompositeRandomVector(
            limitStateFunction, inputRandomVector
        )
        thresholdEvent = ot.ThresholdEvent(outputRandomVector, ot.Less(), threshold)

        name = "RP8"
        Y = X1 + 2 * X2 + 2 * X3 + X4 - 5 * X5 - 5 * X6
        probability = Y.computeCDF(threshold)
        super(ReliabilityProblem8, self).__init__(name, thresholdEvent, probability)
        return None
E = persalys.Input('E', 1.0, ot.Normal(), 'E description')
F = persalys.Input('F', 1.0)
I = persalys.Input('I', 1.0)
L = persalys.Input('L', 1.0)
y = persalys.Output('y', 'deviation')

inputs = [E, F, I, L]
outputs = [y]
model = persalys.FMIPhysicalModel(
    'myPhysicalModel', inputs, outputs, path_fmu)
myStudy.add(model)

# print(model.getCode())

E_d = ot.Beta(0.93, 3.2-0.93, 28000000.0, 48000000.0)
F_d = ot.LogNormalMuSigma(30000.0, 9000.0, 15000.0).getDistribution()
L_d = ot.Uniform(250.0, 260.0)
I_d = ot.Beta(2.5, 4.0-2.5, 310.0, 450.0)
distribution = ot.ComposedDistribution([E_d, F_d, I_d, L_d])
x = distribution.getMean()


f = model.getFunction()
y = f(x)
ott.assert_almost_equal(y, [12.3369])

# script
script = myStudy.getPythonScript()
print('script=', script)
exec(script)
Exemple #16
0
    def __init__(
        self,
        threshold=0.0,
        mu1=2200,
        sigma1=220,
        mu2=2100,
        sigma2=210,
        mu3=2300,
        sigma3=230,
        mu4=2000,
        sigma4=200,
        mu5=1200,
        sigma5=480,
    ):
        """
        Creates a reliability problem RP60.

        The event is {g(X) < threshold} with:

            X = (x1, x2, x3, x4, x5)

            g1 = x1 - x5

            g2 = x2 - x5 / 2

            g3 = x3 - x5 / 2

            g4 = x4 - x5 / 2

            g5 = x2 - x5

            g6 = x3 - x5

            g7 = x4 - x5

            g8 = min(g5, g6)

            g9 = max(g7, g8)

            g10 = min(g2, g3, g4)

            g11 = max(g10, g9)

            g(X) = min(g1, g11)

        We have :
            x1 ~ LogNormalMuSigma(mu1, sigma1)

            x2 ~ LogNormalMuSigma(mu2, sigma2)

            x3 ~ LogNormalMuSigma(mu3, sigma3)

            x4 ~ LogNormalMuSigma(mu4, sigma4)

            x5 ~ LogNormalMuSigma(mu5, sigma5)

        Parameters
        ----------
        threshold : float
            The threshold.
        mu1 : float
            The mean of the LogNormal random variable X1.
        sigma1 : float
            The standard deviation of the LogNormal random variable X1.
        mu2 : float
            The mean of the LogNormal random variable X2.
        sigma2 : float
            The standard deviation of the LogNormal random variable X2.
        mu3 : float
            The mean of the LogNormal random variable X3.
        sigma3 : float
            The standard deviation of the LogNormal random variable X3.
        mu4 : float
            The mean of the LogNormal random variable X4.
        sigma4 : float
            The standard deviation of the LogNormal random variable X4.
        mu5 : float
            The mean of the LogNormal random variable X5.
        sigma5 : float
            The standard deviation of the LogNormal random variable X5.
        """
        equations = ["var g1 := x1 - x5"]
        equations.append("var g2 := x2 - x5 / 2")
        equations.append("var g3 := x3 - x5 / 2")
        equations.append("var g4 := x4 - x5 / 2")
        equations.append("var g5 := x2 - x5")
        equations.append("var g6 := x3 - x5")
        equations.append("var g7 := x4 - x5")
        equations.append("var g8 := min(g5, g6)")
        equations.append("var g9 := max(g7, g8)")
        equations.append("var g10 := min(g2, g3, g4)")
        equations.append("var g11 := max(g10, g9)")
        equations.append("gsys := min(g1, g11)")
        formula = ";".join(equations)
        limitStateFunction = ot.SymbolicFunction(
            ["x1", "x2", "x3", "x4", "x5"], ["gsys"], formula
        )

        parameters1 = ot.LogNormalMuSigma(mu1, sigma1, 0.0)
        X1 = ot.ParametrizedDistribution(parameters1)
        X1.setDescription(["X1"])
        parameters2 = ot.LogNormalMuSigma(mu2, sigma2, 0.0)
        X2 = ot.ParametrizedDistribution(parameters2)
        X2.setDescription(["X2"])
        parameters3 = ot.LogNormalMuSigma(mu3, sigma3, 0.0)
        X3 = ot.ParametrizedDistribution(parameters3)
        X3.setDescription(["X3"])
        parameters4 = ot.LogNormalMuSigma(mu4, sigma4, 0.0)
        X4 = ot.ParametrizedDistribution(parameters4)
        X4.setDescription(["X4"])
        parameters5 = ot.LogNormalMuSigma(mu5, sigma5, 0.0)
        X5 = ot.ParametrizedDistribution(parameters5)
        X5.setDescription(["X5"])

        myDistribution = ot.ComposedDistribution([X1, X2, X3, X4, X5])
        inputRandomVector = ot.RandomVector(myDistribution)
        outputRandomVector = ot.CompositeRandomVector(
            limitStateFunction, inputRandomVector
        )
        thresholdEvent = ot.ThresholdEvent(outputRandomVector, ot.Less(), threshold)

        name = "RP60"
        probability = 0.0456
        super(ReliabilityProblem60, self).__init__(name, thresholdEvent, probability)
        return None
#!/usr/bin/env python
# coding: utf-8

from __future__ import print_function
import openturns as ot
import otguibase

myStudy = otguibase.OTStudy('Study_CantileverBeam')

## Model
dist_E = ot.Beta(0.9, 3.5, 2.5e7, 5.0e7)
dist_F = ot.LogNormalMuSigma(30.e3, 9.e3, 15.e3).getDistribution()
dist_L = ot.Uniform(250., 260.)
dist_I = ot.Beta(2.5, 4., 310., 450.)

E = otguibase.Input('E', 3e7, dist_E, 'Young\'s modulus (Pa)')
F = otguibase.Input('F', 3e4, dist_F, 'Force applied (N)')
L = otguibase.Input('L', 250, dist_L, 'Length (m)')
I = otguibase.Input('I', 400, dist_I, 'Section modulus (m4)')
y = otguibase.Output('y', 'Vertical deviation (m)')

model = otguibase.SymbolicPhysicalModel('myPhysicalModel', [E, F, L, I], [y], ['F*L^3/(3*E*I)'])
myStudy.add(model)

# Create the Spearman correlation matrix of the input random vector
RS = ot.CorrelationMatrix(4)
RS[2,3] = -0.2
# Evaluate the correlation matrix of the Normal copula from RS
R = ot.NormalCopula.GetCorrelationFromSpearmanCorrelation(RS)
# Create the Normal copula parametrized by R
copula = ot.NormalCopula(R)
Exemple #18
0
#
# In this example we are going to evaluate the min and max values of the output variable of interest from a sample and to evaluate the gradient of the limit state function defining the output variable of interest at a particular point.

# %%
from __future__ import print_function
import openturns as ot
import openturns.viewer as viewer
from matplotlib import pylab as plt
import math as m

ot.Log.Show(ot.Log.NONE)

# %%
# Create the marginal distributions of the parameters
dist_E = ot.Beta(0.93, 2.27, 2.8e7, 4.8e7)
dist_F = ot.LogNormalMuSigma(30000, 9000, 15000).getDistribution()
dist_L = ot.Uniform(250, 260)
dist_I = ot.Beta(2.5, 1.5, 3.1e2, 4.5e2)
marginals = [dist_E, dist_F, dist_L, dist_I]
distribution = ot.ComposedDistribution(marginals)

# %%
# Sample inputs
sampleX = distribution.getSample(100)

# %%
# Create the model
model = ot.SymbolicFunction(['E', 'F', 'L', 'I'], ['F*L^3/(3*E*I)'])

# %%
# Evaluate outputs
# # Problem definition
#
# # Input probabilistic model

# In[2]:

sample_E = ot.Sample.ImportFromCSVFile("sample_E.csv")
kernel_smoothing = ot.KernelSmoothing(ot.Normal())
bandwidth = kernel_smoothing.computeSilvermanBandwidth(sample_E)
E = kernel_smoothing.build(sample_E, bandwidth)
E.setDescription(['Young modulus'])

# In[3]:

F = ot.LogNormal()
F.setParameter(ot.LogNormalMuSigma()([30000, 9000, 15000]))
F.setDescription(['Load'])

# In[4]:

L = ot.Uniform(250, 260)
L.setDescription(['Length'])

# In[5]:

I = ot.Beta(2.5, 4, 310, 450)
I.setDescription(['Inertia'])

# We now fix the order of the marginal distributions in the joint distribution. Order must match in the implementation of the physical model (to come).

# In[6]:
Exemple #20
0
    # Distribution parameters

    # ArcsineMuSigma parameter ave
    ams_parameters = ot.ArcsineMuSigma(8.4, 2.25)
    myStudy.add('ams_parameters', ams_parameters)
    # BetaMuSigma parameter save
    bms_parameters = ot.BetaMuSigma(0.2, 0.6, -1, 2)
    myStudy.add('bms_parameters', bms_parameters)
    # GammaMuSigma parameter save
    gmms_parameters = ot.GammaMuSigma(1.5, 2.5, -0.5)
    myStudy.add('gmms_parameters', gmms_parameters)
    # GumbelMuSigma parameter save
    gms_parameters = ot.GumbelMuSigma(1.5, 1.3)
    myStudy.add('gms_parameters', gms_parameters)
    # LogNormalMuSigma parameter save
    lnms_parameters = ot.LogNormalMuSigma(30000.0, 9000.0, 15000)
    myStudy.add('lnms_parameters', lnms_parameters)
    # LogNormalMuSigmaOverMu parameter save
    lnmsm_parameters = ot.LogNormalMuSigmaOverMu(0.63, 5.24, -0.5)
    myStudy.add('lnmsm_parameters', lnmsm_parameters)
    # WeibullMinMuSigma parameter save
    wms_parameters = ot.WeibullMinMuSigma(1.3, 1.23, -0.5)
    myStudy.add('wms_parameters', wms_parameters)

    # MemoizeFunction
    f = ot.SymbolicFunction(['x1', 'x2'], ['x1*x2'])
    memoize = ot.MemoizeFunction(f)
    memoize([5, 6])
    myStudy.add('memoize', memoize)

    # print ('Study = ' , myStudy)
# - the confidence interval
# - the convergence graph of the estimator
# - the stored input and output numerical samples
# - importance factors

# %%
import openturns as ot
import openturns.viewer as viewer
from matplotlib import pylab as plt
ot.Log.Show(ot.Log.NONE)

# %%
# Create the joint distribution of the parameters.

# %%
distribution_R = ot.LogNormalMuSigma(300.0, 30.0, 0.0).getDistribution()
distribution_F = ot.Normal(75e3, 5e3)
marginals = [distribution_R, distribution_F]
distribution = ot.ComposedDistribution(marginals)

# %%
# Create the model.

# %%
model = ot.SymbolicFunction(['R', 'F'], ['R-F/(pi_*100.0)'])

# %%
modelCallNumberBefore = model.getEvaluationCallsNumber()
modelGradientCallNumberBefore = model.getGradientCallsNumber()
modelHessianCallNumberBefore = model.getHessianCallsNumber()
# %%
maxDegree = 4

# %%
# For real tests, we suggest using the following parameter value:

# %%
# maxDegree = 7

# %%
# Let us define the parameters of the cantilever beam problem.

# %%
dist_E = ot.Beta(0.9, 2.2, 2.8e7, 4.8e7)
dist_E.setDescription(["E"])
F_para = ot.LogNormalMuSigma(3.0e4, 9.0e3, 15.0e3)  # in N
dist_F = ot.ParametrizedDistribution(F_para)
dist_F.setDescription(["F"])
dist_L = ot.Uniform(250.0, 260.0)  # in cm
dist_L.setDescription(["L"])
dist_I = ot.Beta(2.5, 1.5, 310.0, 450.0)  # in cm^4
dist_I.setDescription(["I"])

myDistribution = ot.ComposedDistribution([dist_E, dist_F, dist_L, dist_I])

dim_input = 4  # dimension of the input
dim_output = 1  # dimension of the output


def function_beam(X):
    E, F, L, I = X
Exemple #23
0
# Hard model
hard_model_hparams = {
    'model': var_dim,
    'dim': 50,
    'series': True  # if series or parallel
}
# Surrogate model
soft_model_hparams = {
    'name': 'GP',
    'kernel': None,
    'n_restarts_optimizer': 0,
    'normalize': False
}
# Distributions of random variables
n = hard_model_hparams['dim']
dist_params = ot.LogNormalMuSigma(1.0, 0.2, 0.0)
marginals = [ot.ParametrizedDistribution(dist_params)] * n
dist = ot.ComposedDistribution(marginals)

# Infill strategy
infill_params_1 = {
    'candidate': None,  # 'uniform'
    'num_pnt_re': 10000,
    'num_neighbors': 1000,
    'name': 'conv_comb',
    'n_top': 1,
    'decay_rate': None,
    'metric': 'cosine',
    'min_it': 40,
    'max_it': 10000
}