Ejemplo n.º 1
0
def test():

    Study_0 = persalys.Study('Study_0')
    persalys.Study.Add(Study_0)
    X0 = persalys.Input('X0', 0, '')
    Y0 = persalys.Output('Y0', '')
    Y0.setValue(0)
    inputCollection = []
    inputCollection.append(X0)
    outputCollection = []
    outputCollection.append(Y0)
    code = 'def _exec(X0):\n    Y0 = X0\n    return Y0'
    PhysicalModel_0 = persalys.PythonPhysicalModel('PhysicalModel_0',
                                                   inputCollection,
                                                   outputCollection, code)
    Study_0.add(PhysicalModel_0)
    print(Study_0.getPythonScript())
Ejemplo n.º 2
0
#! /usr/bin/env python

from __future__ import print_function
import openturns as ot
import persalys
from math import pi

myStudy = persalys.Study('myStudy')

# Model
x0 = persalys.Input('x0', ot.Normal())
x1 = persalys.Input('x1', ot.Normal())
y00 = persalys.Output('fake_y0')
y00.setIsSelected(False)
y0 = persalys.Output('y0')

formula_y00 = 'x0'
formula_y0 = '10+3*x0+x1'
model = persalys.SymbolicPhysicalModel('aModel', [x0, x1], [y00, y0],
                                       [formula_y00, formula_y0])
myStudy.add(model)

# Sobol ##
analysis = persalys.SobolAnalysis('aSobol', model)
analysis.setMaximumCalls(1000)
analysis.setMaximumConfidenceIntervalLength(-1)
analysis.setMaximumElapsedTime(30)
analysis.setSeed(2)
analysis.setReplicationSize(250)
analysis.setBlockSize(4)
myStudy.add(analysis)
#!/usr/bin/env python

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

ot.RandomGenerator.SetSeed(0)
ot.TBB_Disable()

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

# Models
x1 = persalys.Input('x1', 0.2)
x2 = persalys.Input('x2', 1.2)
x3 = persalys.Input('x3', 1.0)
fake_var = persalys.Output('fake_var')
fake_var.setIsSelected(False)
y0 = persalys.Output('y0')
fake_y0 = persalys.Output('fake_y0')
y1 = persalys.Output('y1')

# symboilc model ##
formula_fake_var = 'x1'
formula_y0 = 'cos(0.5*x1) + sin(x2)'
formula_y1 = 'cos(0.5*x1) + sin(x2) + x3'
symbolicModel = persalys.SymbolicPhysicalModel('symbolicModel', [x1, x2, x3], [fake_var, y0, fake_y0, y1], [
                                         formula_fake_var, formula_y0, formula_y0, formula_y1])

myStudy.add(symbolicModel)
#!/usr/bin/env python

import openturns as ot
import openturns.testing
import persalys

ot.RandomGenerator.SetSeed(0)

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

# Models
x1 = persalys.Input('x1', 0.2)
x2 = persalys.Input('x2', 1.2)
x3 = persalys.Input('x3', 1.0)
fake_var = persalys.Output('fake_var')
fake_var.setIsSelected(False)
y0 = persalys.Output('y0')
fake_y0 = persalys.Output('fake_y0')
y1 = persalys.Output('y1')

# symboilc model ##
formula_fake_var = 'x1'
formula_y0 = 'cos(0.5*x1) + sin(x2)'
formula_y1 = 'cos(0.5*x1) + sin(x2) + x3'
symbolicModel = persalys.SymbolicPhysicalModel(
    'symbolicModel', [x1, x2, x3], [fake_var, y0, fake_y0, y1],
    [formula_fake_var, formula_y0, formula_y0, formula_y1])

myStudy.add(symbolicModel)
Ejemplo n.º 5
0
#!/usr/bin/env python

import openturns as ot
import persalys

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

# variables
dist_z0 = ot.Uniform(100, 150)
z0 = persalys.Input('z0', 100, dist_z0, '')
dist_v0 = ot.Normal(55, 10)
v0 = persalys.Input('v0', 55, dist_v0, '')
dist_m = ot.Normal(80, 8)
m = persalys.Input('m', 80, dist_m, '')
dist_c = ot.Uniform(0, 30)
c = persalys.Input('c', 16, dist_c, '')
z1 = persalys.Output('z1', '')
z2 = persalys.Output('z2', 'fake output')
inputs = [z0, v0, m, c]
outputs = [z1, z2]

# mesh model
meshModel = persalys.GridMeshModel(ot.Interval(0., 12.), [20])

# Python model
code = 'from math import exp\n\ndef _exec(z0,v0,m,c):\n    g = 9.81\n    zmin = 0.\n    tau = m / c\n    vinf = -m * g / c\n\n    # mesh nodes\n    t = getMesh().getVertices()\n\n    z = [max(z0 + vinf * t_i[0] + tau * (v0 - vinf) * (1 - exp(-t_i[0] / tau)), zmin) for t_i in t]\n    z2 = [2*max(z0 + vinf * t_i[0] + tau * (v0 - vinf) * (1 - exp(-t_i[0] / tau)), zmin) for t_i in t]\n\n    return z, z2'
PhysicalModel_1 = persalys.PythonFieldModel('PhysicalModel_1', meshModel, inputs, outputs, code)
Study_0.add(PhysicalModel_1)

# central tendency
Ejemplo n.º 6
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')

# Model
xi1 = persalys.Input('xi1', ot.Uniform(0., 10.))
xi2 = persalys.Input('xi2', ot.Uniform(0., 10.))
xi3 = persalys.Input('xi3', 0.5)
y00 = persalys.Output('fake_y0')
y00.setIsSelected(False)
y0 = persalys.Output('y0')
y1 = persalys.Output('y1')

formula_y00 = "xi1"
formula_y0 = "cos(0.5*xi1) + sin(xi2)"
formula_y1 = "cos(0.5*xi1) + sin(xi2) + xi3"
model = persalys.SymbolicPhysicalModel('model', [xi1, xi2, xi3], [y00, y0, y1], [
                                        formula_y00, formula_y0, formula_y1])
myStudy.add(model)

# Design of Experiment ##
aDesign = persalys.FixedDesignOfExperiment('design', model)
inputSample = ot.LHSExperiment(model.getDistribution(), 50).generate()
inputSample.stack(ot.Sample(50, [0.5]))
Ejemplo n.º 7
0
#!/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()
Ejemplo n.º 8
0
myStudy = persalys.Study('myStudy')

# data
filename = 'données.csv'
ot.RandomGenerator.SetSeed(0)
ot.Normal(3).getSample(10).exportToCSVFile(filename)
inColumns = [0, 2]

# Model 1
model = persalys.DataModel('myDataModel', filename, inColumns)
myStudy.add(model)
print(model)

# Model 2
model2 = persalys.SymbolicPhysicalModel('SM', [persalys.Input('A'), persalys.Input('B')], [persalys.Output('S')], ['A+B+2'])
myStudy.add(model2)
importedDOE = persalys.ImportedDesignOfExperiment('doeI', model2, filename, inColumns)
myStudy.add(importedDOE)

# script
script = myStudy.getPythonScript()
print(script)

# save
xmlFileName = 'file_with_données.xml'
myStudy.save(xmlFileName)

# open
s = persalys.Study.Open('file_with_données.xml')
print(s.getPythonScript())
Ejemplo n.º 9
0
                for l in range(k + 1, 20):
                    y += b4[i][j][k][l] * w[i] * w[j] * w[k] * w[l]

    y = y + b0
    y_fake = 0.

    return y

"""


myStudy = persalys.Study('myStudy')

inputs = []
for i in range(20):
    inputs.append(persalys.Input('x' + str(i + 1), ot.Uniform(0, 1)))
y = persalys.Output('y')
y_fake = persalys.Output('y_fake')
print(inputs)
model = persalys.PythonPhysicalModel('MorrisModel', inputs, [y, y_fake], code)

myStudy.add(model)

# Morris ##
analysis = persalys.MorrisAnalysis('aMorris', model)
analysis.setInterestVariables(['y'])
analysis.setLevel(4)
analysis.setTrajectoriesNumber(4)
analysis.setSeed(2)
myStudy.add(analysis)
print(analysis)
Ejemplo n.º 10
0
#!/usr/bin/env python

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

myStudy = persalys.Study('myStudy')

# Model
dist_Q = ot.Normal(10200, 100)
dist_E = ot.Normal(3000, 15)
dist_C = ot.Normal(4000, 60)

Q = persalys.Input('Q', 10200, dist_Q, 'Primary energy (W.h)')
E = persalys.Input('E', 3000, dist_E, 'Produced electric energy (W.h)')
C = persalys.Input('C', 4000, dist_C, 'Valued thermal energy (W.h)')
Ep = persalys.Output('Ep', 'Primary energy savings (W.h)')

model = persalys.SymbolicPhysicalModel('myPhysicalModel', [Q, E, C], [Ep],
                                       ['1-(Q/((E/((1-0.05)*0.54))+(C/0.8)))'])
myStudy.add(model)

outputSample = [[0.060036508072], [0.0812679132055], [0.0684295269203],
                [0.0892876773294], [0.0292238907867], [0.0511512752497],
                [0.0378920382755], [0.0594339324804]]

# Design of Experiment - Parametric analysis ##
bounds = persalys.GridDesignOfExperiment.GetDefaultBounds(model)
values = [[bounds.getLowerBound()[i],
           bounds.getUpperBound()[i]] for i in range(3)]
Ejemplo n.º 11
0
#!/usr/bin/env python

import openturns as ot
import openturns.testing
import persalys

ot.RandomGenerator.SetSeed(0)

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

# Models
x1 = persalys.Input('x1', 0.2, ot.Uniform(0., 10.))
x2 = persalys.Input('x2', 1.2, ot.Uniform(0., 10.))
x3 = persalys.Input('x3', 1.0)
fake_var = persalys.Output('fake_var')
fake_var.setIsSelected(False)
y0 = persalys.Output('y0')
fake_y0 = persalys.Output('fake_y0')
y1 = persalys.Output('y1')

# model 1 ##
formula_fake_var = 'x1+'
formula_y0 = 'cos(0.5*x1) + sin(x2)'
formula_y1 = 'cos(0.5*x1) + sin(x2) + x3'
model1 = persalys.SymbolicPhysicalModel(
    'model1', [x1, x2, x3], [fake_var, y0, fake_y0, y1],
    [formula_fake_var, formula_y0, formula_y0, formula_y1])

myStudy.add(model1)
Ejemplo n.º 12
0
#!/usr/bin/env python

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

myStudy = persalys.Study('myStudy')

# Model
dist_R = ot.LogNormalMuSigma(300., 30.).getDistribution()
dist_F = ot.Normal(75000., 5000.)

R = persalys.Input('R', 300., dist_R, 'Yield stress (Pa)')
F = persalys.Input('F', 75000., dist_F, 'Traction force (N)')
G = persalys.Output('G', 'Stress difference (Pa)')

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.]))

# Design of Experiment - Parametric analysis ##
bounds = persalys.GridDesignOfExperiment.GetDefaultBounds(model)
values = [[bounds.getLowerBound()[i],
           bounds.getUpperBound()[i]] for i in range(2)]
aDesign = persalys.GridDesignOfExperiment('design', model, values)
myStudy.add(aDesign)
aDesign.run()
Ejemplo n.º 13
0
#!/usr/bin/env python

import openturns as ot
import openturns.testing
import persalys

myStudy = persalys.Study('myStudy')

# Model
dist_E = ot.Beta(0.93, 3.2, 2.8e7, 4.8e7)
dist_F = ot.LogNormalMuSigma(30000., 9000., 15000).getDistribution()
dist_L = ot.Uniform(250, 260)
dist_I = ot.Beta(2.5, 4., 3.1e2, 4.5e2)

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

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

f = model.getFunction()
print(f([3e7, 3e4, 250, 400]))

# Sobol ##
sobol = persalys.SobolAnalysis('mySobol', model)
sobol.setMaximumConfidenceIntervalLength(-1)
sobol.setMaximumCalls(1000)
Ejemplo n.º 14
0
#!/usr/bin/env python

import openturns as ot
import persalys

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

# variables
z0 = persalys.Input('z0', 100, '')
v0 = persalys.Input('v0', 55, '')
m = persalys.Input('m', 80, '')
c = persalys.Input('c', 15, '')
z = persalys.Output('z', '')
z2 = persalys.Output('z2', '')
inputs = [z0, v0, m, c]
outputs = [z]

# mesh model
meshModel = persalys.GridMeshModel(ot.Interval(0., 12.), [20])

# Symbolic model
formula = [
    "max(0, z0 - (m * 9.81 / c) * t + (m / c) * (v0 + (m * 9.81 / c)) * (1 - exp(-t * c / m)))"
]
model1 = persalys.SymbolicFieldModel('model1', meshModel, inputs, outputs,
                                     formula)
Study_0.add(model1)

f = model1.getPointToFieldFunction()
print(f([100, 55, 81, 17]))
Ejemplo n.º 15
0
#! /usr/bin/env python

import openturns as ot
import persalys
import os

# Model with error
X0 = persalys.Input('X0', 1, ot.Normal())
X1 = persalys.Input('X1', 2)
Y0 = persalys.Output('Y0')
Y1 = persalys.Output('Y1')
model2 = persalys.PythonPhysicalModel('model2',  [X0, X1], [Y0], 'from math import pi\n\ndef _exec(X0, X1):\n    Y0 = 2*X1 - 1/X0\n    return Y0\n')
model2.setParallel(True)

design5 = persalys.FixedDesignOfExperiment('design5', model2)
design5.setOriginalInputSample([[0.9, 1.1], [1.8, 2.2], [0, 2.2]])
design5.setBlockSize(3)
design5.run()
assert design5.getResult().getDesignOfExperiment().getOutputSample().getSize() == 2, "whole block must no fail"


model3 = persalys.PythonPhysicalModel('model3',  [X0, X1], [Y0, Y1], 'from math import pi\n\ndef _exec(X0, X1):\n    Y0 = 2*X1 - 1/X0\n    Y1=5\n    return Y0, Y1\n')
model3.setParallel(True)

# same with multiple outputs
design6 = persalys.FixedDesignOfExperiment('design6', model3)
design6.setInterestVariables(['Y0'])
design6.setOriginalInputSample([[0.9, 1.1], [1.8, 2.2], [0, 2.2]])
design6.setBlockSize(3)
design6.run()
assert design6.getResult().getDesignOfExperiment().getOutputSample().getSize() == 2, "whole block must no fail"
Ejemplo n.º 16
0
from __future__ import print_function
import openturns as ot
import openturns.testing
import persalys

myStudy = persalys.Study('myStudy')

# Model
dist_Q = ot.TruncatedDistribution(
    ot.Gumbel(1. / 558., 1013.), 0, ot.TruncatedDistribution.LOWER)
dist_Ks = ot.TruncatedDistribution(
    ot.Normal(30.0, 7.5), 0, ot.TruncatedDistribution.LOWER)
dist_Zv = ot.Uniform(49.0, 51.0)
dist_Zm = ot.Uniform(54.0, 56.0)

Q = persalys.Input('Q', 1000., dist_Q, 'Débit maximal annuel (m3/s)')
Ks = persalys.Input('Ks', 30., dist_Ks, 'Strickler (m^(1/3)/s)')
Zv = persalys.Input('Zv', 50., dist_Zv, 'Côte de la rivière en aval (m)')
Zm = persalys.Input('Zm', 55., dist_Zm, 'Côte de la rivière en amont (m)')
S = persalys.Output('S', 'Surverse (m)')

model = persalys.SymbolicPhysicalModel('myPhysicalModel', [Q, Ks, Zv, Zm], [
                                        S], ['(Q/(Ks*300.*sqrt((Zm-Zv)/5000)))^(3.0/5.0)+Zv-55.5-3.'])
myStudy.add(model)

# limit state ##
limitState = persalys.LimitState('limitState1', model, 'S', ot.Greater(), 0.)
myStudy.add(limitState)

# Monte Carlo ##
montecarlo = persalys.MonteCarloReliabilityAnalysis(
Ejemplo n.º 17
0
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', '32bit'): 'win32'}

path_here = os.path.dirname(os.path.abspath(__file__))
try:
    directory_platform = dict_platform[key_platform]
except KeyError:
    raise RuntimeError('Not available')

path_fmu = os.path.join(path_here, 'fmu', directory_platform, 'deviation.fmu')

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()
Ejemplo n.º 18
0
#! /usr/bin/env python

import openturns as ot
import openturns.testing
import persalys
import os

ot.RandomGenerator.SetSeed(0)

anOTStudy = persalys.Study('anOTStudy')

# Model
X0 = persalys.Input('X0', 1, ot.Normal())
X1 = persalys.Input('X1', 2)
X2 = persalys.Input('X2', 2)
X3 = persalys.Input('X3', 2)
Y0 = persalys.Output('Y0')
Y1 = persalys.Output('Y1')
Y2 = persalys.Output('Y2')

model = persalys.SymbolicPhysicalModel('aModelPhys', [X0, X1, X2, X3],
                                       [Y0, Y1, Y2], ['sin(X0)+8*X1'] * 3)
anOTStudy.add(model)

# Observations ##
filename = 'normal2.csv'
sample = ot.Normal(8).getSample(10)
sample.exportToCSVFile(filename)

obs = persalys.Observations("obs", model, filename, [7, 3], [6, 2],
                            ["X3", "X1"], ["Y2", "Y1"])
Ejemplo n.º 19
0
#!/usr/bin/env python

import openturns as ot
import persalys

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

# variables
z0 = persalys.Input('z0', 100)
v0 = persalys.Input('v0', 55)
m = persalys.Input('m', 80)
c = persalys.Input('c', 16)
z1 = persalys.Output('z1', '')
z2 = persalys.Output('z2', 'fake output')
inputs = [z0, v0, m, c]
outputs = [z1, z2]

# mesh model
meshModel = persalys.GridMeshModel(ot.Interval(0., 12.), [20])

# Python model
code = 'from math import exp\n\ndef _exec(z0,v0,m,c):\n    g = 9.81\n    zmin = 0.\n    tau = m / c\n    vinf = -m * g / c\n\n    # mesh nodes\n    t = getMesh().getVertices()\n\n    z = [max(z0 + vinf * t_i[0] + tau * (v0 - vinf) * (1 - exp(-t_i[0] / tau)), zmin) for t_i in t]\n    z2 = [2*max(z0 + vinf * t_i[0] + tau * (v0 - vinf) * (1 - exp(-t_i[0] / tau)), zmin) for t_i in t]\n\n    return z, z2'
PhysicalModel_1 = persalys.PythonFieldModel('PhysicalModel_1', meshModel,
                                            inputs, outputs, code)
Study_0.add(PhysicalModel_1)

# evaluation
analysis1 = persalys.FieldModelEvaluation("analysis1", PhysicalModel_1)
Study_0.add(analysis1)
print(analysis1)
Ejemplo n.º 20
0
myStudy = persalys.Study('myStudy')

# data
filename = 'données.csv'
ot.RandomGenerator_SetSeed(0)
ot.Normal(3).getSample(10).exportToCSVFile(filename)
inColumns = [0, 2]

# Model 1
model = persalys.DataModel('myDataModel', filename, inColumns)
myStudy.add(model)
print(model)

# Model 2
model2 = persalys.SymbolicPhysicalModel(
    'SM', [persalys.Input('A'), persalys.Input('B')], [persalys.Output('S')],
    ['A+B+2'])
myStudy.add(model2)
importedDOE = persalys.ImportedDesignOfExperiment('doeI', model2, filename,
                                                  inColumns)
myStudy.add(importedDOE)

# script
script = myStudy.getPythonScript()
print(script)

# save
xmlFileName = 'file_with_données.xml'
myStudy.save(xmlFileName)

# open
#! /usr/bin/env python

import openturns as ot
import persalys

myStudy = persalys.Study('myStudy')

# Model
X0 = persalys.Input('X0', 1, ot.Normal(), 'aDescription')
X1 = persalys.Input('X1', 2)
Y0 = persalys.Output('Y0', 'output_1')
inputs = [X0, X1]
outputs = [Y0]
formulas = ['sin(X0)+8*X1']
model = persalys.SymbolicPhysicalModel('aModelPhys', inputs, outputs, formulas)
myStudy.add(model)
print(model)

# get attributs values
print('function=', model.getFunction())
print('formulas=', model.getFormulas())
print('formula_Y0=', model.getFormula('Y0'))
print('stochastic var=', model.getStochasticInputNames())
print('distribution=', model.getDistribution())
print('copula=', model.getCopula())
print('output_YO=', model.getOutputByName('Y0'))
print('input_XO=', model.getInputByName('X0'))
print('inputs names=', model.getInputNames())
print('outputs names=', model.getOutputNames())
print('hasY0', model.hasOutputNamed('Y0'))
print('hasX0', model.hasInputNamed('X0'))
Ejemplo n.º 22
0
#! /usr/bin/env python

import openturns as ot
import persalys

myStudy = persalys.Study('myStudy')

# Model
X0 = persalys.Input('X0', ot.Normal(1, 1))
X1 = persalys.Input('X1', ot.Normal(1, 1))
Y00 = persalys.Output('fake_Y0')
Y00.setIsSelected(False)
Y0 = persalys.Output('Y0')

formula_Y00 = 'X0'
formula_Y0 = 'sin(X0) + 8*X1'
model = persalys.SymbolicPhysicalModel('aModelPhys', [X0, X1], [Y00, Y0],
                                       [formula_Y00, formula_Y0])
myStudy.add(model)

# Monte Carlo ##
analysis = persalys.MonteCarloAnalysis('myMonteCarlo', model)
analysis.setLevelConfidenceInterval(0.93)
analysis.setMaximumCalls(1000)
analysis.setMaximumCoefficientOfVariation(-1)
analysis.setMaximumElapsedTime(30)
analysis.setSeed(2)
myStudy.add(analysis)
print(analysis)

analysis.run()
Ejemplo n.º 23
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
Ejemplo n.º 24
0
#! /usr/bin/env python

import openturns as ot
import persalys
import os

anOTStudy = persalys.Study('anOTStudy')

# Model
X0 = persalys.Input('X0', 1, ot.Normal())
X1 = persalys.Input('X1', 2, ot.Normal())
Y0 = persalys.Output('Y0')

model = persalys.SymbolicPhysicalModel('aModelPhys', [X0, X1], [Y0],
                                       ['sin(X0)+8*X1'])
anOTStudy.add(model)

# Design of Experiment ##
aDesign = persalys.GridDesignOfExperiment('aDesign_1', model,
                                          [[0.9, 1.1], [1.8, 2.2]])
anOTStudy.add(aDesign)

aDesign.run()
print('outs=', aDesign.getResult().getDesignOfExperiment().getOutputSample())

# Design of Experiment ##
filename = 'normal.csv'
ot.Normal(3).getSample(10).exportToCSVFile(filename)
aDesign2 = persalys.ImportedDesignOfExperiment('aDesign_2', model, filename,
                                               [0, 2])
anOTStudy.add(aDesign2)
Ejemplo n.º 25
0
#!/usr/bin/env python

import openturns as ot
import persalys

# proba
dist_X0 = ot.Normal(0, 1)
X0 = persalys.Input('X0', 0, dist_X0, '')
dist_X1 = ot.Normal(0, 1)
X1 = persalys.Input('X1', 0, dist_X1, '')
X2 = persalys.Input('X2', 0, '')
X3 = persalys.Input('X3', 0, '')
Y0 = persalys.Output('Y0', '')
inputs = [X0, X1, X2, X3]
outputs = [Y0]
formulas = ['X0+X1+X2+X3']
SymbolicModel_0 = persalys.SymbolicPhysicalModel('SymbolicModel_0', inputs, outputs, formulas)
values = [[0],
[0],
[-0.1, 0.1],
[-0.1, 0.1]]
design_0 = persalys.GridDesignOfExperiment('design_0', SymbolicModel_0, values)
design_0.setBlockSize(1)
interestVariables = ['Y0']
design_0.setInterestVariables(interestVariables)
design_0.run()
metaModel_0 = persalys.FunctionalChaosAnalysis('metaModel_0', design_0)
metaModel_0.setChaosDegree(1)
metaModel_0.setSparseChaos(False)
metaModel_0.setAnalyticalValidation(True)
metaModel_0.setTestSampleValidation(False)