{
  "cells": [
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "%matplotlib inline"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "\n# Generating a Random 2D Vector Field\n\nAs a first example we are going to generate a 2d vector field with a Gaussian\ncovariance model on a structured grid:\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "import numpy as np\nimport gstools as gs\n\n# the grid\nx = np.arange(100)\ny = np.arange(100)\n\n# a smooth Gaussian covariance model\nmodel = gs.Gaussian(dim=2, var=1, len_scale=10)\nsrf = gs.SRF(model, generator=\"VectorField\", seed=19841203)\nsrf((x, y), mesh_type=\"structured\")\nsrf.plot()"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "Let us have a look at the influence of the covariance model. Choosing the\nexponential model and keeping all other parameters the same\n\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "# a rougher exponential covariance model\nmodel2 = gs.Exponential(dim=2, var=1, len_scale=10)\nsrf.model = model2\nsrf((x, y), mesh_type=\"structured\", seed=19841203)\nsrf.plot()"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "and we see, that the wiggles are much \"rougher\" than the smooth Gaussian ones.\n\n"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "## Applications\n\nOne great advantage of the Kraichnan method is, that after some initializations,\none can compute the velocity field at arbitrary points, online, with hardly any\noverhead.\nThis means, that for a Lagrangian transport simulation for example, the velocity\ncan be evaluated at each particle position very efficiently and without any\ninterpolation. These field interpolations are a common problem for Lagrangian\nmethods.\n\n"
      ]
    }
  ],
  "metadata": {
    "kernelspec": {
      "display_name": "Python 3",
      "language": "python",
      "name": "python3"
    },
    "language_info": {
      "codemirror_mode": {
        "name": "ipython",
        "version": 3
      },
      "file_extension": ".py",
      "mimetype": "text/x-python",
      "name": "python",
      "nbconvert_exporter": "python",
      "pygments_lexer": "ipython3",
      "version": "3.7.9"
    }
  },
  "nbformat": 4,
  "nbformat_minor": 0
}