# a- observations
nbObs = 100
inObs = ot.Uniform(0., 10.).getSample(nbObs)
inObs.setDescription(['x1'])

y0Noise = ot.Normal(0, 0.1).getSample(nbObs)
y0Sample = ot.ParametricFunction(symbolicModel.getFunction('y0'), [1, 2], [1.2, 1.])(inObs)

y0Obs = y0Sample + y0Noise
y0Obs.setDescription(['y0'])
obs = persalys.Observations("observations", symbolicModel, inObs, y0Obs)
myStudy.add(obs)

# b- calibrationAnalysis
calibration = persalys.CalibrationAnalysis('calibration', obs)
calibration.setCalibratedInputs(['x2'], ot.Dirac([1.2]), ['x3'], [1.1])
calibration.setMethodName('GaussianNonlinear')
sigma = 0.15
errorCovariance = ot.CovarianceMatrix(1)
errorCovariance[0, 0] = sigma**2
calibration.setErrorCovariance(errorCovariance)
calibration.setBootStrapSize(25)
calibration.setConfidenceIntervalLength(0.99)

optimAlgo = calibration.getOptimizationAlgorithm()
optimAlgo.setMaximumEvaluationNumber(50)
optimAlgo.setMaximumAbsoluteError(1e-6)
optimAlgo.setMaximumRelativeError(1e-6)
optimAlgo.setMaximumResidualError(1e-6)
optimAlgo.setMaximumConstraintError(1e-6)
Ejemplo n.º 2
0
nbObs = 100
strainObs = dist_strain.getSample(nbObs)
strainObs.setDescription(['strain'])

stressSampleNoise = ot.Normal(0., 40.e6).getSample(nbObs)
stressSample = ot.ParametricFunction(model.getFunction('sigma'), [0, 1, 2],
                                     [750e6, 2750e6, 10.])(strainObs)

stressObs = stressSample + stressSampleNoise
stressObs.setDescription(['sigma'])
observations = persalys.Observations('obs1', model, strainObs, stressObs)

myStudy.add(observations)

# Least Squares linear
analysis = persalys.CalibrationAnalysis('myAnalysis', observations)
analysis.run()
myStudy.add(analysis)
print("analysis=", analysis)
print("result=", analysis.getResult())

# Least Squares Non linear
analysis2 = persalys.CalibrationAnalysis('myAnalysis2', observations)
analysis2.setMethodName('LeastSquaresNonlinear')
analysis2.setCalibratedInputs(['R', 'C'], ot.Dirac([700e6, 2400e6]), ['gam'],
                              [7.])
analysis2.run()
myStudy.add(analysis2)
print("analysis=", analysis2)

# Gaussian linear calibration