Create a parametric function¶
In this example we are going to create a parametric function:
function from an existing “full” function:
[1]:
from __future__ import print_function
import openturns as ot
import math as m
[2]:
# Create the function with all parameters d(E, F, L, I)
def d_func(X):
E, F, L, I = X
d = -F * L**3 / (3.0 * E * I)
return [d]
beam = ot.PythonFunction(4, 1, d_func)
[3]:
# Evaluate d
x = [50.0, 1.0, 10.0, 5.0]
beam(x)
[3]:
[-1.33333]
[4]:
# Create the indices of the frozen parameters (L,I) from the full parameter list
indices = [2, 3]
[5]:
# Create the values of the frozen parameters (L,I)
referencePoint = [10.0, 5.0]
[6]:
# Create the parametric function
beam_LI = ot.ParametricFunction(beam, indices, referencePoint)
[7]:
# Evaluate d on (E,F) with fixed parameters (L,I)
beam_LI([50.0, 1.0])
[7]:
[-1.33333]