.. DO NOT EDIT.
.. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY.
.. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE:
.. "auto_tutorials/basics/g_app.py"
.. LINE NUMBERS ARE GIVEN BELOW.

.. only:: html

    .. note::
        :class: sphx-glr-download-link-note

        Click :ref:`here <sphx_glr_download_auto_tutorials_basics_g_app.py>`
        to download the full example code

.. rst-class:: sphx-glr-example-title

.. _sphx_glr_auto_tutorials_basics_g_app.py:


Using `fmas` as a black-box application
=======================================

This examples shows how to use `py-fmas` as a black-box application, that
only requires a minimal amount of scripting.

.. codeauthor:: Oliver Melchert <melchert@iqo.uni-hannover.de>

.. GENERATED FROM PYTHON SOURCE LINES 13-15

We start by simply importing the required `fmas` into the current namespace.


.. GENERATED FROM PYTHON SOURCE LINES 15-18

.. code-block:: default


    import fmas








.. GENERATED FROM PYTHON SOURCE LINES 19-23

If an adequate input file is located within the current working directory,
`fmas` can be used as shown below. It features a particular function called
`run`, which reads-in the propagation setting stored in the input file
`input_file.h5` and runs the simulaton

.. GENERATED FROM PYTHON SOURCE LINES 23-26

.. code-block:: default


    res = fmas.run('input_file.h5', model_type='FMAS_S_R', solver_type='IFM_RK4IP')








.. GENERATED FROM PYTHON SOURCE LINES 27-34

An example that shows how an adequate input file can be generated via python
is shown under the link below:

:ref:`sphx_glr_auto_tutorials_basics_ng_generate_infile.py`

After the proapgation algorithm (specified in `input_file.h5`) terminates,
a simple dictionary data structure with the following keys is available

.. GENERATED FROM PYTHON SOURCE LINES 34-37

.. code-block:: default


    print(res.keys())





.. rst-class:: sphx-glr-script-out

 Out:

 .. code-block:: none

    dict_keys(['t', 'z', 'w', 'u', 'Cp'])




.. GENERATED FROM PYTHON SOURCE LINES 38-40

A simple plot that shows the result of the simulation run can be produced
using function `plot_evolution` implemented in module `tools`

.. GENERATED FROM PYTHON SOURCE LINES 40-44

.. code-block:: default


    from fmas.tools import plot_evolution
    plot_evolution( res['z'], res['t'], res['u'], t_lim=(-500,2200), w_lim=(1.,4.))




.. image:: /auto_tutorials/basics/images/sphx_glr_g_app_001.png
    :alt: $|u|^2/{\rm{max}}\left(|u|^2\right)$, $|u_\omega|^2/{\rm{max}}\left(|u_\omega|^2\right)$
    :class: sphx-glr-single-img





.. GENERATED FROM PYTHON SOURCE LINES 45-48

The results can be stored for later postprocessing using the function
`save_h5` implemented in module `data_io`. It will generate a file
`out_file.h5` with HDF5 format in the current working directory

.. GENERATED FROM PYTHON SOURCE LINES 48-51

.. code-block:: default


    from fmas.data_io import save_h5
    save_h5('out_file.h5', **res)








.. rst-class:: sphx-glr-timing

   **Total running time of the script:** ( 0 minutes  34.211 seconds)


.. _sphx_glr_download_auto_tutorials_basics_g_app.py:


.. only :: html

 .. container:: sphx-glr-footer
    :class: sphx-glr-footer-example



  .. container:: sphx-glr-download sphx-glr-download-python

     :download:`Download Python source code: g_app.py <g_app.py>`



  .. container:: sphx-glr-download sphx-glr-download-jupyter

     :download:`Download Jupyter notebook: g_app.ipynb <g_app.ipynb>`


.. only:: html

 .. rst-class:: sphx-glr-signature

    `Gallery generated by Sphinx-Gallery <https://sphinx-gallery.github.io>`_