.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_functional_modeling/field_functions/plot_viscous_fall_field_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_field_functions_plot_viscous_fall_field_function.py: Define a function with a field output: the viscous free fall example ==================================================================== .. GENERATED FROM PYTHON SOURCE LINES 7-11 In this example, we define a function which has a vector input and a field output. This is why we use the :class:`~openturns.PythonPointToFieldFunction` class to create the associated function and propagate the uncertainties through it. We consider a viscous free fall as explained :ref:`here `. .. GENERATED FROM PYTHON SOURCE LINES 13-15 Define the model ---------------- .. GENERATED FROM PYTHON SOURCE LINES 17-24 .. code-block:: Python import openturns as ot import openturns.viewer as viewer from matplotlib import pylab as plt from openturns.usecases import viscous_free_fall ot.Log.Show(ot.Log.NONE) .. GENERATED FROM PYTHON SOURCE LINES 25-26 Load the viscous free fall example. .. GENERATED FROM PYTHON SOURCE LINES 26-30 .. code-block:: Python vff = viscous_free_fall.ViscousFreeFall() distribution = vff.distribution model = vff.model .. GENERATED FROM PYTHON SOURCE LINES 31-33 Sample trajectories ------------------- .. GENERATED FROM PYTHON SOURCE LINES 35-36 In order to sample trajectories, we use the `getSample` method of the input distribution and apply the field function. .. GENERATED FROM PYTHON SOURCE LINES 38-42 .. code-block:: Python size = 10 inputSample = distribution.getSample(size) outputSample = model(inputSample) .. GENERATED FROM PYTHON SOURCE LINES 43-45 .. code-block:: Python ot.ResourceMap.SetAsUnsignedInteger("Drawable-DefaultPalettePhase", size) .. GENERATED FROM PYTHON SOURCE LINES 46-47 Draw some curves. .. GENERATED FROM PYTHON SOURCE LINES 49-56 .. code-block:: Python graph = outputSample.drawMarginal(0) graph.setTitle("Viscous free fall: %d trajectories" % (size)) graph.setXTitle(r"$t$") graph.setYTitle(r"$z$") view = viewer.View(graph) plt.show() .. image-sg:: /auto_functional_modeling/field_functions/images/sphx_glr_plot_viscous_fall_field_function_001.png :alt: Viscous free fall: 10 trajectories :srcset: /auto_functional_modeling/field_functions/images/sphx_glr_plot_viscous_fall_field_function_001.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 57-61 We see that the object first moves up and then falls down. Not all objects, however, achieve the same maximum altitude. We see that some trajectories reach a higher maximum altitude than others. Moreover, at the final time :math:`t_{max}`, one trajectory hits the ground: :math:`z(t_{max})=0` for this trajectory. .. GENERATED FROM PYTHON SOURCE LINES 63-64 Reset default settings .. GENERATED FROM PYTHON SOURCE LINES 64-65 .. code-block:: Python ot.ResourceMap.Reload() .. _sphx_glr_download_auto_functional_modeling_field_functions_plot_viscous_fall_field_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_viscous_fall_field_function.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_viscous_fall_field_function.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_viscous_fall_field_function.zip `