.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_functional_modeling/vectorial_functions/plot_parametric_function.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code. .. rst-class:: sphx-glr-example-title .. _sphx_glr_auto_functional_modeling_vectorial_functions_plot_parametric_function.py: Create a parametric function ============================ .. GENERATED FROM PYTHON SOURCE LINES 7-11 In this example, we show how to use the :class:`~openturns.ParametricFunction` class. This is a tool which is very convenient when we perform calibration, e.g. with :class:`~openturns.NonLinearLeastSquaresCalibration` or :class:`~openturns.RandomWalkMetropolisHastings`. .. GENERATED FROM PYTHON SOURCE LINES 13-23 In this example we create a parametric function: .. math:: d_{L,I}(E, F): \Rset^2 \rightarrow \Rset function from an existing "full" function: .. math:: d(E, F, L, I): \Rset^4 \rightarrow \Rset. .. GENERATED FROM PYTHON SOURCE LINES 25-30 .. code-block:: Python import openturns as ot ot.Log.Show(ot.Log.NONE) .. GENERATED FROM PYTHON SOURCE LINES 31-33 Define the function ~~~~~~~~~~~~~~~~~~~ .. GENERATED FROM PYTHON SOURCE LINES 36-37 Create the function with all parameters d(E, F, L, I) .. GENERATED FROM PYTHON SOURCE LINES 37-46 .. code-block:: Python def d_func(X): E, F, L, II = X d = -F * L**3 / (3.0 * E * II) return [d] beam = ot.PythonFunction(4, 1, d_func) beam.setInputDescription(["E", "F", "L", "I"]) .. GENERATED FROM PYTHON SOURCE LINES 47-48 Evaluate d .. GENERATED FROM PYTHON SOURCE LINES 48-51 .. code-block:: Python x = [50.0, 1.0, 10.0, 5.0] beam(x) .. raw:: html
class=Point name=Unnamed dimension=1 values=[-1.33333]


.. GENERATED FROM PYTHON SOURCE LINES 52-76 In the physical model, the inputs and parameters are ordered as presented in the next table. Notice that there are no parameters in the physical model. +-------+----------------+ | Index | Input variable | +=======+================+ | 0 | E | +-------+----------------+ | 1 | F | +-------+----------------+ | 2 | L | +-------+----------------+ | 3 | I | +-------+----------------+ +-------+-----------+ | Index | Parameter | +=======+===========+ | ∅ | ∅ | +-------+-----------+ **Table 1.** Indices and names of the inputs and parameters of the physical model. .. GENERATED FROM PYTHON SOURCE LINES 78-81 The next cell presents the description of the input variables and the description of the parameters of the physical model. We see that there is no parameter at this stage in this function. .. GENERATED FROM PYTHON SOURCE LINES 81-85 .. code-block:: Python print("Physical Model Inputs:", beam.getInputDescription()) print("Physical Model Parameters:", beam.getParameterDescription()) .. rst-class:: sphx-glr-script-out .. code-block:: none Physical Model Inputs: [E,F,L,I] Physical Model Parameters: [] .. GENERATED FROM PYTHON SOURCE LINES 86-88 Define the parametric function ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .. GENERATED FROM PYTHON SOURCE LINES 90-112 We create a :class:`~openturns.ParametricFunction` where the parameters are `L` and `I` which have the indices 2 and and 3 in the physical model. +-------+----------------+ | Index | Input variable | +=======+================+ | 0 | E | +-------+----------------+ | 1 | F | +-------+----------------+ +-------+-----------+ | Index | Parameter | +=======+===========+ | 0 | L | +-------+-----------+ | 1 | I | +-------+-----------+ **Table 2.** Indices and names of the inputs and parameters of the parametric model. .. GENERATED FROM PYTHON SOURCE LINES 114-115 Create the indices of the frozen parameters (L,I) from the full parameter list .. GENERATED FROM PYTHON SOURCE LINES 115-117 .. code-block:: Python indices = [2, 3] .. GENERATED FROM PYTHON SOURCE LINES 118-119 Create the values of the frozen parameters (L,I) .. GENERATED FROM PYTHON SOURCE LINES 119-121 .. code-block:: Python referencePoint = [10.0, 5.0] .. GENERATED FROM PYTHON SOURCE LINES 122-123 Create the parametric function .. GENERATED FROM PYTHON SOURCE LINES 123-125 .. code-block:: Python beam_LI = ot.ParametricFunction(beam, indices, referencePoint) .. GENERATED FROM PYTHON SOURCE LINES 126-129 The next cell presents the description of the input variables and the description of the parameters of the parametric function. We see that the parametric function has 2 parameters: L and I. .. GENERATED FROM PYTHON SOURCE LINES 129-132 .. code-block:: Python print("Physical Model Inputs:", beam_LI.getInputDescription()) print("Physical Model Parameters:", beam_LI.getParameterDescription()) .. rst-class:: sphx-glr-script-out .. code-block:: none Physical Model Inputs: [E,F] Physical Model Parameters: [L,I] .. GENERATED FROM PYTHON SOURCE LINES 133-134 Evaluate d on (E,F) with fixed parameters (L,I) .. GENERATED FROM PYTHON SOURCE LINES 134-135 .. code-block:: Python beam_LI([50.0, 1.0]) .. raw:: html
class=Point name=Unnamed dimension=1 values=[-1.33333]


.. _sphx_glr_download_auto_functional_modeling_vectorial_functions_plot_parametric_function.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_parametric_function.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_parametric_function.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_parametric_function.zip `