.. 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 6-10 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 12-22 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 24-29 .. code-block:: Python import openturns as ot ot.Log.Show(ot.Log.NONE) .. GENERATED FROM PYTHON SOURCE LINES 30-32 Define the function ~~~~~~~~~~~~~~~~~~~ .. GENERATED FROM PYTHON SOURCE LINES 35-36 Create the function with all parameters d(E, F, L, I) .. GENERATED FROM PYTHON SOURCE LINES 36-45 .. 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 46-47 Evaluate d .. GENERATED FROM PYTHON SOURCE LINES 47-50 .. 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 51-75 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 77-80 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 80-84 .. 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 85-87 Define the parametric function ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .. GENERATED FROM PYTHON SOURCE LINES 89-111 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 113-114 Create the indices of the frozen parameters (L,I) from the full parameter list .. GENERATED FROM PYTHON SOURCE LINES 114-116 .. code-block:: Python indices = [2, 3] .. GENERATED FROM PYTHON SOURCE LINES 117-118 Create the values of the frozen parameters (L,I) .. GENERATED FROM PYTHON SOURCE LINES 118-120 .. code-block:: Python referencePoint = [10.0, 5.0] .. GENERATED FROM PYTHON SOURCE LINES 121-122 Create the parametric function .. GENERATED FROM PYTHON SOURCE LINES 122-124 .. code-block:: Python beam_LI = ot.ParametricFunction(beam, indices, referencePoint) .. GENERATED FROM PYTHON SOURCE LINES 125-128 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 128-131 .. 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 132-133 Evaluate d on (E,F) with fixed parameters (L,I) .. GENERATED FROM PYTHON SOURCE LINES 133-134 .. 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 `