diff --git a/CHANGES.rst b/CHANGES.rst index e38fec89..5016d200 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -1,7 +1,6 @@ -0.0.8a +0.0.1a ------ -- The fluiddyn package now only contains base files for the FluidDyn - project. Other packages (fluidsim, fluidlab, ...) provide other - files. +- Split the package fluiddyn between one base package and specialized + packages. diff --git a/doc/HOWTO_build_the_doc b/doc/HOWTO_build_the_doc new file mode 100644 index 00000000..3725d5b4 --- /dev/null +++ b/doc/HOWTO_build_the_doc @@ -0,0 +1,8 @@ +Run in a terminal from this directory:: + + make html + +Also useful:: + + rm -rf generated + make clean diff --git a/doc/Makefile b/doc/Makefile new file mode 100644 index 00000000..8784715a --- /dev/null +++ b/doc/Makefile @@ -0,0 +1,169 @@ +# Makefile for Sphinx documentation +# + +# You can set these variables from the command line. +SPHINXOPTS = +SPHINXBUILD = python $(shell which sphinx-build) +PAPER = +BUILDDIR = _build + +# Internal variables. +PAPEROPT_a4 = -D latex_paper_size=a4 +PAPEROPT_letter = -D latex_paper_size=letter +ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) . +# the i18n builder cannot share the environment and doctrees with the others +I18NSPHINXOPTS = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) . + +IPYNB_DIR = $(abspath ipynb) +IPYTHON_NOTEBOOKS = $(wildcard ipynb/*.ipynb) +IPYTHON_NOTEBOOKS_RST = $(IPYTHON_NOTEBOOKS:.ipynb=.rst) +IPYTHON_NOTEBOOKS_DIR = $(IPYTHON_NOTEBOOKS:.ipynb=_files) + +.PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest gettext + +help: + @echo "Please use \`make ' where is one of" + @echo " html to make standalone HTML files" + @echo " dirhtml to make HTML files named index.html in directories" + @echo " singlehtml to make a single large HTML file" + @echo " pickle to make pickle files" + @echo " json to make JSON files" + @echo " htmlhelp to make HTML files and a HTML help project" + @echo " qthelp to make HTML files and a qthelp project" + @echo " devhelp to make HTML files and a Devhelp project" + @echo " epub to make an epub" + @echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter" + @echo " latexpdf to make LaTeX files and run them through pdflatex" + @echo " text to make text files" + @echo " man to make manual pages" + @echo " texinfo to make Texinfo files" + @echo " info to make Texinfo files and run them through makeinfo" + @echo " gettext to make PO message catalogs" + @echo " changes to make an overview of all changed/added/deprecated items" + @echo " linkcheck to check all external links for integrity" + @echo " doctest to run all doctests embedded in the documentation (if enabled)" + +clean: + rm -rf $(BUILDDIR)/* + rm -rf $(IPYTHON_NOTEBOOKS_DIR) + rm -f $(IPYTHON_NOTEBOOKS_RST) + +cleanall: clean + rm -rf generated html.zip + +html: $(IPYTHON_NOTEBOOKS_RST) + $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html + @echo + @echo "Build finished. The HTML pages are in $(BUILDDIR)/html." + +dirhtml: + $(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml + @echo + @echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml." + +singlehtml: + $(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml + @echo + @echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml." + +pickle: + $(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle + @echo + @echo "Build finished; now you can process the pickle files." + +json: + $(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json + @echo + @echo "Build finished; now you can process the JSON files." + +htmlhelp: + $(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp + @echo + @echo "Build finished; now you can run HTML Help Workshop with the" \ + ".hhp project file in $(BUILDDIR)/htmlhelp." + +qthelp: + $(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp + @echo + @echo "Build finished; now you can run "qcollectiongenerator" with the" \ + ".qhcp project file in $(BUILDDIR)/qthelp, like this:" + @echo "# qcollectiongenerator $(BUILDDIR)/qthelp/fluidlab.qhcp" + @echo "To view the help file:" + @echo "# assistant -collectionFile $(BUILDDIR)/qthelp/fluidlab.qhc" + +devhelp: + $(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp + @echo + @echo "Build finished." + @echo "To view the help file:" + @echo "# mkdir -p $$HOME/.local/share/devhelp/fluidlab" + @echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/fluidlab" + @echo "# devhelp" + +epub: + $(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub + @echo + @echo "Build finished. The epub file is in $(BUILDDIR)/epub." + +latex: + $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex + @echo + @echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex." + @echo "Run \`make' in that directory to run these through (pdf)latex" \ + "(use \`make latexpdf' here to do that automatically)." + +latexpdf: + $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex + @echo "Running LaTeX files through pdflatex..." + $(MAKE) -C $(BUILDDIR)/latex all-pdf + @echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex." + +text: + $(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text + @echo + @echo "Build finished. The text files are in $(BUILDDIR)/text." + +man: + $(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man + @echo + @echo "Build finished. The manual pages are in $(BUILDDIR)/man." + +texinfo: + $(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo + @echo + @echo "Build finished. The Texinfo files are in $(BUILDDIR)/texinfo." + @echo "Run \`make' in that directory to run these through makeinfo" \ + "(use \`make info' here to do that automatically)." + +info: + $(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo + @echo "Running Texinfo files through makeinfo..." + make -C $(BUILDDIR)/texinfo info + @echo "makeinfo finished; the Info files are in $(BUILDDIR)/texinfo." + +gettext: + $(SPHINXBUILD) -b gettext $(I18NSPHINXOPTS) $(BUILDDIR)/locale + @echo + @echo "Build finished. The message catalogs are in $(BUILDDIR)/locale." + +changes: + $(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes + @echo + @echo "The overview file is in $(BUILDDIR)/changes." + +linkcheck: + $(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck + @echo + @echo "Link check complete; look for any errors in the above output " \ + "or in $(BUILDDIR)/linkcheck/output.txt." + +doctest: + $(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest + @echo "Testing of doctests in the sources finished, look at the " \ + "results in $(BUILDDIR)/doctest/output.txt." + +zip: html + cd _build/html && zip -r html.zip * && mv html.zip ../../. + +%.rst: %.ipynb + cd $(IPYNB_DIR) && ipython nbconvert --to rst $(notdir $<) diff --git a/doc/changes.rst b/doc/changes.rst new file mode 100644 index 00000000..955deaf2 --- /dev/null +++ b/doc/changes.rst @@ -0,0 +1,4 @@ +Changes +======= + +.. include:: ../CHANGES.rst diff --git a/doc/conf.py b/doc/conf.py new file mode 100644 index 00000000..fd39d4e4 --- /dev/null +++ b/doc/conf.py @@ -0,0 +1,274 @@ +# -*- coding: utf-8 -*- +# +# fluidlab documentation build configuration file, created by +# sphinx-quickstart on Sun Mar 2 12:15:31 2014. +# +# This file is execfile() with the current directory set to its containing dir. +# +# Note that not all possible configuration values are present in this +# autogenerated file. +# +# All configuration values have a default; values that are commented out +# serve to show the default. + +import sys +import os + +import fluidsim + + +# If extensions (or modules to document with autodoc) are in another directory, +# add these directories to sys.path here. If the directory is relative to the +# documentation root, use os.path.abspath to make it absolute, like shown here. +# sys.path.insert(0, os.path.abspath('../examples')) +sys.path.insert(0, os.path.abspath('./')) + +# -- General configuration ---------------------------------------------------- + +# If your documentation needs a minimal Sphinx version, state it here. +#needs_sphinx = '1.0' + +# Add any Sphinx extension module names here, as strings. They can be +# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom +# ones. +extensions = [ + 'sphinx.ext.autodoc', 'sphinx.ext.doctest', + 'sphinx.ext.todo', + # 'sphinx.ext.pngmath', + 'sphinx.ext.mathjax', + 'sphinx.ext.viewcode', 'sphinx.ext.autosummary', + 'numpydoc', + 'mathmacro', + 'IPython.sphinxext.ipython_directive' +] + +# Add any paths that contain templates here, relative to this directory. +templates_path = ['_templates'] + +# The suffix of source filenames. +source_suffix = '.rst' + +# The encoding of source files. +#source_encoding = 'utf-8-sig' + +# The master toctree document. +master_doc = 'index' + +# General information about the project. +project = u'FluidSim' +copyright = u'2015, Pierre Augier' + +# The version info for the project you're documenting, acts as replacement for +# |version| and |release|, also used in various other places throughout the +# built documents. +# +# The short X.Y version. +version = fluidsim.__version__.split('.') +version = '{}.{}'.format(version[0], version[1]) +# The full version, including alpha/beta/rc tags. +release = fluidsim.__version__ + +# The language for content autogenerated by Sphinx. Refer to documentation +# for a list of supported languages. +#language = None + +# There are two options for replacing |today|: either, you set today to some +# non-false value, then it is used: +#today = '' +# Else, today_fmt is used as the format for a strftime call. +#today_fmt = '%B %d, %Y' + +# List of patterns, relative to source directory, that match files and +# directories to ignore when looking for source files. +exclude_patterns = ['_build'] + +# The reST default role (used for this markup: `text`) to use for all +# documents. +#default_role = None + +# If true, '()' will be appended to :func: etc. cross-reference text. +#add_function_parentheses = True + +# If true, the current module name will be prepended to all description +# unit titles (such as .. function::). +#add_module_names = True + +# If true, sectionauthor and moduleauthor directives will be shown in the +# output. They are ignored by default. +#show_authors = False + +# The name of the Pygments (syntax highlighting) style to use. +pygments_style = 'sphinx' + +# A list of ignored prefixes for module index sorting. +#modindex_common_prefix = [] + + +# -- Options for HTML output -------------------------------------------------- + +# The theme to use for HTML and HTML Help pages. See the documentation for +# a list of builtin themes. +#html_theme = 'default' +html_theme = 'sphinxdoc' + + +# Theme options are theme-specific and customize the look and feel of a theme +# further. For a list of options available for each theme, see the +# documentation. +#html_theme_options = {} + +# Add any paths that contain custom themes here, relative to this directory. +#html_theme_path = [] + +# The name for this set of Sphinx documents. If None, it defaults to +# " v documentation". +#html_title = None + +# A shorter title for the navigation bar. Default is the same as html_title. +html_short_title = 'FluidDyn '+release + +# The name of an image file (relative to this directory) to place at the top +# of the sidebar. +#html_logo = None + +# The name of an image file (within the static path) to use as favicon of the +# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 +# pixels large. +#html_favicon = None + +# Add any paths that contain custom static files (such as style sheets) here, +# relative to this directory. They are copied after the builtin static files, +# so a file named "default.css" will overwrite the builtin "default.css". +# html_static_path = ['_static'] + +# If not '', a 'Last updated on:' timestamp is inserted at every page bottom, +# using the given strftime format. +#html_last_updated_fmt = '%b %d, %Y' + +# If true, SmartyPants will be used to convert quotes and dashes to +# typographically correct entities. +#html_use_smartypants = True + +# Custom sidebar templates, maps document names to template names. +#html_sidebars = {} + +# Additional templates that should be rendered to pages, maps page names to +# template names. +#html_additional_pages = {} + +# If false, no module index is generated. +#html_domain_indices = True + +# If false, no index is generated. +#html_use_index = True + +# If true, the index is split into individual pages for each letter. +#html_split_index = False + +# If true, links to the reST sources are added to the pages. +#html_show_sourcelink = True + +# If true, "Created using Sphinx" is shown in the HTML footer. Default is True. +#html_show_sphinx = True + +# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True. +#html_show_copyright = True + +# If true, an OpenSearch description file will be output, and all pages will +# contain a tag referring to it. The value of this option must be the +# base URL from which the finished HTML is served. +#html_use_opensearch = '' + +# This is the file name suffix for HTML files (e.g. ".xhtml"). +#html_file_suffix = None + +# Output file base name for HTML help builder. +htmlhelp_basename = 'fluiddyndoc' + + +# -- Options for LaTeX output -------------------------------------------------- + +latex_elements = { +# The paper size ('letterpaper' or 'a4paper'). +#'papersize': 'letterpaper', + +# The font size ('10pt', '11pt' or '12pt'). +#'pointsize': '10pt', + +# Additional stuff for the LaTeX preamble. +#'preamble': '', +} + +# Grouping the document tree into LaTeX files. List of tuples +# (source start file, target name, title, author, documentclass [howto/manual]). +latex_documents = [ + ('index', 'fluidlab.tex', u'fluidlab Documentation', + u'Pierre Augier', 'manual'), +] + +# The name of an image file (relative to this directory) to place at the top of +# the title page. +#latex_logo = None + +# For "manual" documents, if this is true, then toplevel headings are parts, +# not chapters. +#latex_use_parts = False + +# If true, show page references after internal links. +#latex_show_pagerefs = False + +# If true, show URL addresses after external links. +#latex_show_urls = False + +# Documents to append as an appendix to all manuals. +#latex_appendices = [] + +# If false, no module index is generated. +#latex_domain_indices = True + + +# -- Options for manual page output -------------------------------------------- + +# One entry per manual page. List of tuples +# (source start file, name, description, authors, manual section). +man_pages = [ + ('index', 'FluidDyn', u'FluidDyn Documentation', + [u'Pierre Augier'], 1) +] + +# If true, show URL addresses after external links. +#man_show_urls = False + + +# -- Options for Texinfo output ------------------------------------------------ + +# Grouping the document tree into Texinfo files. List of tuples +# (source start file, target name, title, author, +# dir menu entry, description, category) +texinfo_documents = [ + ('index', 'FluidDyn', u'FluidDyn Documentation', + u'Pierre Augier', 'FluidDyn', 'One line description of project.', + 'Miscellaneous'), +] + +# Documents to append as an appendix to all manuals. +#texinfo_appendices = [] + +# If false, no module index is generated. +#texinfo_domain_indices = True + +# How to display URL addresses: 'footnote', 'no', or 'inline'. +#texinfo_show_urls = 'footnote' + + + +# -- Other options --------------------------------------------------------- + +numpydoc_show_class_members = False + +autosummary_generate = True + +autodoc_default_flags = ['show-inheritance'] +autodoc_member_order = 'bysource' + +todo_include_todos = True diff --git a/doc/example_from_numpy_doc.py b/doc/example_from_numpy_doc.py new file mode 100644 index 00000000..0445a78e --- /dev/null +++ b/doc/example_from_numpy_doc.py @@ -0,0 +1,125 @@ +"""This is the docstring for the example.py module. Modules names should +have short, all-lowercase names. The module name may have underscores if +this improves readability. + +Every module should have a docstring at the very top of the file. The +module's docstring may extend over multiple lines. If your docstring does +extend over multiple lines, the closing three quotation marks must be on +a line by itself, preferably preceeded by a blank line. + +""" +from __future__ import division, absolute_import, print_function + +import os # standard library imports first + +# Do NOT import using *, e.g. from numpy import * +# +# Import the module using +# +# import numpy +# +# instead or import individual functions as needed, e.g +# +# from numpy import array, zeros +# +# If you prefer the use of abbreviated module names, we suggest the +# convention used by NumPy itself:: + +import numpy as np +import matplotlib as mpl +import matplotlib.pyplot as plt + +# These abbreviated names are not to be used in docstrings; users must +# be able to paste and execute docstrings after importing only the +# numpy module itself, unabbreviated. + +from my_module import my_func, other_func + +def foo(var1, var2, long_var_name='hi') : + r"""A one-line summary that does not use variable names or the + function name. + + Several sentences providing an extended description. Refer to + variables using back-ticks, e.g. `var`. + + Parameters + ---------- + var1 : array_like + Array_like means all those objects -- lists, nested lists, etc. -- + that can be converted to an array. We can also refer to + variables like `var1`. + var2 : int + The type above can either refer to an actual Python type + (e.g. ``int``), or describe the type of the variable in more + detail, e.g. ``(N,) ndarray`` or ``array_like``. + Long_variable_name : {'hi', 'ho'}, optional + Choices in brackets, default first when optional. + + Returns + ------- + type + Explanation of anonymous return value of type ``type``. + describe : type + Explanation of return value named `describe`. + out : type + Explanation of `out`. + + Other Parameters + ---------------- + only_seldom_used_keywords : type + Explanation + common_parameters_listed_above : type + Explanation + + Raises + ------ + BadException + Because you shouldn't have done that. + + See Also + -------- + otherfunc : relationship (optional) + newfunc : Relationship (optional), which could be fairly long, in which + case the line wraps here. + thirdfunc, fourthfunc, fifthfunc + + Notes + ----- + Notes about the implementation algorithm (if needed). + + This can have multiple paragraphs. + + You may include some math: + + .. math:: X(e^{j\omega } ) = x(n)e^{ - j\omega n} + + And even use a greek symbol like :math:`omega` inline. + + References + ---------- + Cite the relevant literature, e.g. [1]_. You may also cite these + references in the notes section above. + + .. [1] O. McNoleg, "The integration of GIS, remote sensing, + expert systems and adaptive co-kriging for environmental habitat + modelling of the Highland Haggis using object-oriented, fuzzy-logic + and neural-network techniques," Computers & Geosciences, vol. 22, + pp. 585-588, 1996. + + Examples + -------- + These are written in doctest format, and should illustrate how to + use the function. + + >>> a=[1,2,3] + >>> print [x + 3 for x in a] + [4, 5, 6] + >>> print "a\n\nb" + a + b + + """ + + pass + + diff --git a/doc/index.rst b/doc/index.rst new file mode 100644 index 00000000..b15f7fc2 --- /dev/null +++ b/doc/index.rst @@ -0,0 +1,63 @@ +.. FluidDyn documentation master file, created by + sphinx-quickstart on Sun Mar 2 12:15:31 2014. + +Welcome to FluidSim's documentation! +==================================== + +FluidSim is a framework for studying fluid dynamics with numerical +simulations using Python. It is part of the wider project `FluidDyn +`_. + +The package is still in a planning stage so it is still pretty +unstable and many of its planned features have not yet been +implemented. + +User Guide +---------- + +.. toctree:: + :maxdepth: 2 + + install + tutorials + + +Modules Reference +----------------- + +.. autosummary:: + :toctree: generated/ + + fluidsim + + +Scripts +------- + +FluidSim also comes with scripts and examples. They are organised in +the following directories: + +.. autosummary:: + :toctree: generated/ + + examples + +More +---- + +.. toctree:: + :maxdepth: 1 + + FluidSim forge in Bitbucket + FluidSim in PyPI + to_do + changes + + +Indices and tables +================== + +* :ref:`genindex` +* :ref:`modindex` +* :ref:`search` + diff --git a/doc/install.rst b/doc/install.rst new file mode 100644 index 00000000..23544916 --- /dev/null +++ b/doc/install.rst @@ -0,0 +1,45 @@ +Installation +============ + +FluidSim is part of the FluidDyn project. Some issues regarding the +installation of Python packages are discussed in `the main +documentation of the project +`_. + +Dependencies +------------ + +- FFTW3 (and some modules take advantage of libfftw3_mpi, but this one + is optional) and on the python package pyfftw, + +The first thing to do before installing FluidSim is to installed these +libraries (in contrast, the Python packages should automatically be +installed by the installer)! + +Optional dependencies +--------------------- + +- optionally, mpi4py (which depends on a MPI implementation). + + +Install commands +---------------- + +FluidSim can be installed by running the following commands:: + + hg clone https://bitbucket.org/fluiddyn/fluidsim + cd fluidsim + python setup.py develop + +Installation with Pip should also work:: + + pip install fluidsim + +Run the tests +------------- + +You can run some unit tests by running ``python -m unittest discover`` +from the root directory of FluidDyn or from any of the "test" +directories. + + diff --git a/doc/ipynb/tuto_simul_user.ipynb b/doc/ipynb/tuto_simul_user.ipynb new file mode 100644 index 00000000..82a27a1a --- /dev/null +++ b/doc/ipynb/tuto_simul_user.ipynb @@ -0,0 +1,709 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 1, + "metadata": { + "collapsed": false + }, + "outputs": [], + "source": [ + "from __future__ import print_function\n", + "%matplotlib inline\n", + "import fluiddyn as fld" + ] + }, + { + "cell_type": "raw", + "metadata": {}, + "source": [ + ".. _tutosimuluser:" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Tutorial: running a simulation (user perspective)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "In this tutorial, I'm going to show how to run a simple simulation with a solver already written that solves the 2 dimensional Navier-Stokes equations. I'm also going to present some useful concepts and objects used in the simulation part of FluidDyn." + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Importing a solver" + ] + }, + { + "cell_type": "raw", + "metadata": {}, + "source": [ + "The first thing to do is to import a \"solver\" module. Any solver module has to provide a class called \"Simul\" and an object called \"info_solver\", which is an instance of the class :class:`fluiddyn.simul.base.info_solver_params.InfoSolverPseudoSpectral`. The solver module that we are going to use can be imported like this:" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "data": { + "text/plain": [ + "'/home/pierre/Dev/fluiddyn/fluiddyn/simul/solvers/ns2d/solver.pyc'" + ] + }, + "execution_count": 2, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "from fluiddyn.simul.solvers.ns2d import solver\n", + "solver.__file__" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "There is also another quite convenient way to import a solver from a string, here \"NS2D\":" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "data": { + "text/plain": [ + "'/home/pierre/Dev/fluiddyn/fluiddyn/simul/solvers/ns2d/solver.pyc'" + ] + }, + "execution_count": 3, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "solver = fld.simul.import_module_solver_from_key('NS2D')\n", + "solver.__file__" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Create an instance of the class Parameters" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "The next step is to create an object `params` from the information contained in the module `solver`:" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "metadata": { + "collapsed": false + }, + "outputs": [], + "source": [ + "params = fld.simul.create_params(solver)" + ] + }, + { + "cell_type": "raw", + "metadata": {}, + "source": [ + "The object ``params`` is an instance of the class :class:`fluiddyn.simul.base.info_solver_params.Parameters` (which inherit of :class:`fluiddyn.util.containerxml.ContainerXML`). It is usually a quite complex object containing many attributes. In this case, it contains parameters (if you don't understand the next command, have a look at this section of the official Python tutorial on `the list comprehension `_):" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "data": { + "text/plain": [ + "['FORCING',\n", + " 'NEW_DIR_RESULTS',\n", + " 'ONLY_COARSE_OPER',\n", + " 'beta',\n", + " 'forcing',\n", + " 'init_fields',\n", + " 'nu_2',\n", + " 'nu_4',\n", + " 'nu_8',\n", + " 'nu_m4',\n", + " 'oper',\n", + " 'output',\n", + " 'short_name_type_run',\n", + " 'time_stepping']" + ] + }, + "execution_count": 5, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "[attr for attr in dir(params) if not attr.startswith(('_', 'set_', 'xml_'))]" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "and some useful functions (whose names all start with 'set_' or 'xml_'): " + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "data": { + "text/plain": [ + "['set_as_child',\n", + " 'set_attrib',\n", + " 'set_attribs',\n", + " 'set_child',\n", + " 'xml_attrib',\n", + " 'xml_print',\n", + " 'xml_produce_text',\n", + " 'xml_save',\n", + " 'xml_tag',\n", + " 'xml_tag_children',\n", + " 'xml_to_hdf5']" + ] + }, + "execution_count": 6, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "[attr for attr in dir(params) if attr.startswith(('set_', 'xml_'))]" + ] + }, + { + "cell_type": "raw", + "metadata": {}, + "source": [ + "Some of the attributes of ``params`` are simple Python objects and others can be other :class:`fluiddyn.simul.base.info_solver_params.Parameters`:" + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n", + "\n" + ] + } + ], + "source": [ + "print(type(params.nu_2))\n", + "print(type(params.output))" + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "data": { + "text/plain": [ + "['HAS_TO_SAVE',\n", + " 'ONLINE_PLOT_OK',\n", + " 'increments',\n", + " 'period_show_plot',\n", + " 'periods_plot',\n", + " 'periods_print',\n", + " 'periods_save',\n", + " 'phys_fields',\n", + " 'spatial_means',\n", + " 'spect_energy_budg',\n", + " 'spectra']" + ] + }, + "execution_count": 8, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "[attr for attr in dir(params.output) if not attr.startswith(('_', 'set_', 'xml_'))]" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Therefore, the object `params` contains a tree of parameters. This tree can be represented as xml code:" + ] + }, + { + "cell_type": "code", + "execution_count": 9, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n", + "\n", + "\n", + " \n", + "\n", + " \n", + "\n", + " \n", + "\n", + " \n", + " \n", + "\n", + " \n", + "\n", + " \n", + "\n", + " \n", + "\n", + " \n", + "\n", + " \n", + "\n", + " \n", + "\n", + " \n", + "\n", + " \n", + "\n", + " \n", + " \n", + "\n", + " \n", + "\n", + "\n", + "\n" + ] + } + ], + "source": [ + "print(params)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Set the parameters for your simulation" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "The user can change any parameters" + ] + }, + { + "cell_type": "code", + "execution_count": 10, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "data": { + "text/plain": [ + "'NOISE'" + ] + }, + "execution_count": 10, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "params.nu_2 = 1.\n", + "params.FORCING = False\n", + "params.init_fields.type_flow_init" + ] + }, + { + "cell_type": "raw", + "metadata": {}, + "source": [ + "but she/he can not create accidentally a parameter which is actually not used:" + ] + }, + { + "cell_type": "code", + "execution_count": 11, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "KeyError: 'this_param_does_not_exit is not a proper key.'\n" + ] + } + ], + "source": [ + "try:\n", + " params.this_param_does_not_exit = 10\n", + "except KeyError as e:\n", + " print('KeyError:', e)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "This behaviour is much safer than using a text file or a python file for the parameters. " + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Instantiate a simulation object" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "The next step is to create a simulation object (instance of the class solver.Simul) with the parameters in `params`:" + ] + }, + { + "cell_type": "code", + "execution_count": 12, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "*************************************\n", + "Program FluidDyn\n", + "\n", + "solver NS2D, RK4 and sequenciel,\n", + "nx = 48 ; ny = 48\n", + "Lx = 8. ; Ly = 8.\n", + "path_run =\n", + "/home/pierre/Sim_data/NS2D_L=8.x8._48x48_2015-03-23_23-44-59\n", + "type_flow_init = NOISE\n", + "Initialization outputs:\n", + " increments\n", + " phys_fields\n", + " spectra\n", + " spatial_means\n", + " spect_energy_budg\n", + "\n", + "Memory usage at the end of init. (equiv. seq.): 80.390625 Mo\n", + "Size of state_fft (equiv. seq.): 0.0192 Mo\n" + ] + } + ], + "source": [ + "sim = solver.Simul(params)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "which initializes everything needed to run the simulation. The object `sim` has few attributes:" + ] + }, + { + "cell_type": "code", + "execution_count": 13, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "data": { + "text/plain": [ + "['compute_freq_diss',\n", + " 'info',\n", + " 'init_fields',\n", + " 'name_run',\n", + " 'oper',\n", + " 'output',\n", + " 'params',\n", + " 'state',\n", + " 'tendencies_nonlin',\n", + " 'time_stepping']" + ] + }, + "execution_count": 13, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "[attr for attr in dir(sim) if not attr.startswith('_')]" + ] + }, + { + "cell_type": "raw", + "metadata": {}, + "source": [ + "The object ``sim.info`` is a :class:`fluiddyn.util.containerxml.ContainerXML` which contains all the information on the solver (in ``sim.info.solver``) and on specific parameters for this simulation (in ``sim.info.solver``, which is actually the same object as ``sim.params``):" + ] + }, + { + "cell_type": "code", + "execution_count": 14, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n", + "['params', 'solver']\n" + ] + } + ], + "source": [ + "print(sim.info.__class__)\n", + "print([attr for attr in dir(sim.info) if not attr.startswith(('_', 'set_', 'xml_'))])" + ] + }, + { + "cell_type": "code", + "execution_count": 15, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n", + "\n", + "\n", + " \n", + " \n", + "\n", + " \n", + " \n", + " \n", + "\n", + " \n", + "\n", + " \n", + "\n", + " \n", + "\n", + " \n", + " \n", + " \n", + "\n", + " \n", + "\n", + " \n", + "\n", + " \n", + "\n", + " \n", + "\n", + " \n", + "\n", + " \n", + "\n", + " \n", + "\n", + " \n", + "\n", + " \n", + "\n", + " \n", + "\n", + " \n", + "\n", + "\n", + "\n" + ] + } + ], + "source": [ + "print(sim.info.solver)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Run the simulation" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "We are ready to launch the simulation!" + ] + }, + { + "cell_type": "code", + "execution_count": 16, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "*************************************\n", + "Beginning of the computation\n", + "save state_phys in file state_phys_t=000.000.hd5\n", + " compute until t = 10\n", + "it = 1 ; t = 0.097 ; deltat = 0.1499\n", + " energy = 4.033e-02 ; Delta energy = -5.126e-02\n", + " estimated remaining duration = 0 s\n", + "it = 7 ; t = 1.247 ; deltat = 0.2\n", + " energy = 1.938e-03 ; Delta energy = -3.840e-02\n", + " estimated remaining duration = 0 s\n", + "it = 13 ; t = 2.447 ; deltat = 0.2\n", + " energy = 3.661e-04 ; Delta energy = -1.572e-03\n", + " estimated remaining duration = 0 s\n", + "it = 18 ; t = 3.447 ; deltat = 0.2\n", + " energy = 1.024e-04 ; Delta energy = -2.637e-04\n", + " estimated remaining duration = 0 s\n", + "it = 23 ; t = 4.447 ; deltat = 0.2\n", + " energy = 2.945e-05 ; Delta energy = -7.291e-05\n", + " estimated remaining duration = 0 s\n", + "it = 28 ; t = 5.447 ; deltat = 0.2\n", + " energy = 8.545e-06 ; Delta energy = -2.090e-05\n", + " estimated remaining duration = 0 s\n", + "it = 33 ; t = 6.447 ; deltat = 0.2\n", + " energy = 2.486e-06 ; Delta energy = -6.059e-06\n", + " estimated remaining duration = 0 s\n", + "it = 38 ; t = 7.447 ; deltat = 0.2\n", + " energy = 7.237e-07 ; Delta energy = -1.762e-06\n", + " estimated remaining duration = 0 s\n", + "it = 44 ; t = 8.647 ; deltat = 0.2\n", + " energy = 1.646e-07 ; Delta energy = -5.590e-07\n", + " estimated remaining duration = 0 s\n", + "it = 50 ; t = 9.847 ; deltat = 0.2\n", + " energy = 3.746e-08 ; Delta energy = -1.272e-07\n", + " estimated remaining duration = 0 s\n", + "Computation completed in 0.295216 s\n", + "path_run =\n", + "/home/pierre/Sim_data/NS2D_L=8.x8._48x48_2015-03-23_23-44-59\n", + "save state_phys in file state_phys_t=010.047.hd5\n" + ] + } + ], + "source": [ + "sim.time_stepping.start()" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 2", + "language": "python", + "name": "python2" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 2 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython2", + "version": "2.7.8" + } + }, + "nbformat": 4, + "nbformat_minor": 0 +} diff --git a/doc/make.bat b/doc/make.bat new file mode 100644 index 00000000..e4855301 --- /dev/null +++ b/doc/make.bat @@ -0,0 +1,190 @@ +@ECHO OFF + +REM Command file for Sphinx documentation + +if "%SPHINXBUILD%" == "" ( + set SPHINXBUILD=sphinx-build +) +set BUILDDIR=_build +set ALLSPHINXOPTS=-d %BUILDDIR%/doctrees %SPHINXOPTS% . +set I18NSPHINXOPTS=%SPHINXOPTS% . +if NOT "%PAPER%" == "" ( + set ALLSPHINXOPTS=-D latex_paper_size=%PAPER% %ALLSPHINXOPTS% + set I18NSPHINXOPTS=-D latex_paper_size=%PAPER% %I18NSPHINXOPTS% +) + +if "%1" == "" goto help + +if "%1" == "help" ( + :help + echo.Please use `make ^` where ^ is one of + echo. html to make standalone HTML files + echo. dirhtml to make HTML files named index.html in directories + echo. singlehtml to make a single large HTML file + echo. pickle to make pickle files + echo. json to make JSON files + echo. htmlhelp to make HTML files and a HTML help project + echo. qthelp to make HTML files and a qthelp project + echo. devhelp to make HTML files and a Devhelp project + echo. epub to make an epub + echo. latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter + echo. text to make text files + echo. man to make manual pages + echo. texinfo to make Texinfo files + echo. gettext to make PO message catalogs + echo. changes to make an overview over all changed/added/deprecated items + echo. linkcheck to check all external links for integrity + echo. doctest to run all doctests embedded in the documentation if enabled + goto end +) + +if "%1" == "clean" ( + for /d %%i in (%BUILDDIR%\*) do rmdir /q /s %%i + del /q /s %BUILDDIR%\* + goto end +) + +if "%1" == "html" ( + %SPHINXBUILD% -b html %ALLSPHINXOPTS% %BUILDDIR%/html + if errorlevel 1 exit /b 1 + echo. + echo.Build finished. The HTML pages are in %BUILDDIR%/html. + goto end +) + +if "%1" == "dirhtml" ( + %SPHINXBUILD% -b dirhtml %ALLSPHINXOPTS% %BUILDDIR%/dirhtml + if errorlevel 1 exit /b 1 + echo. + echo.Build finished. The HTML pages are in %BUILDDIR%/dirhtml. + goto end +) + +if "%1" == "singlehtml" ( + %SPHINXBUILD% -b singlehtml %ALLSPHINXOPTS% %BUILDDIR%/singlehtml + if errorlevel 1 exit /b 1 + echo. + echo.Build finished. The HTML pages are in %BUILDDIR%/singlehtml. + goto end +) + +if "%1" == "pickle" ( + %SPHINXBUILD% -b pickle %ALLSPHINXOPTS% %BUILDDIR%/pickle + if errorlevel 1 exit /b 1 + echo. + echo.Build finished; now you can process the pickle files. + goto end +) + +if "%1" == "json" ( + %SPHINXBUILD% -b json %ALLSPHINXOPTS% %BUILDDIR%/json + if errorlevel 1 exit /b 1 + echo. + echo.Build finished; now you can process the JSON files. + goto end +) + +if "%1" == "htmlhelp" ( + %SPHINXBUILD% -b htmlhelp %ALLSPHINXOPTS% %BUILDDIR%/htmlhelp + if errorlevel 1 exit /b 1 + echo. + echo.Build finished; now you can run HTML Help Workshop with the ^ +.hhp project file in %BUILDDIR%/htmlhelp. + goto end +) + +if "%1" == "qthelp" ( + %SPHINXBUILD% -b qthelp %ALLSPHINXOPTS% %BUILDDIR%/qthelp + if errorlevel 1 exit /b 1 + echo. + echo.Build finished; now you can run "qcollectiongenerator" with the ^ +.qhcp project file in %BUILDDIR%/qthelp, like this: + echo.^> qcollectiongenerator %BUILDDIR%\qthelp\fluidlab.qhcp + echo.To view the help file: + echo.^> assistant -collectionFile %BUILDDIR%\qthelp\fluidlab.ghc + goto end +) + +if "%1" == "devhelp" ( + %SPHINXBUILD% -b devhelp %ALLSPHINXOPTS% %BUILDDIR%/devhelp + if errorlevel 1 exit /b 1 + echo. + echo.Build finished. + goto end +) + +if "%1" == "epub" ( + %SPHINXBUILD% -b epub %ALLSPHINXOPTS% %BUILDDIR%/epub + if errorlevel 1 exit /b 1 + echo. + echo.Build finished. The epub file is in %BUILDDIR%/epub. + goto end +) + +if "%1" == "latex" ( + %SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex + if errorlevel 1 exit /b 1 + echo. + echo.Build finished; the LaTeX files are in %BUILDDIR%/latex. + goto end +) + +if "%1" == "text" ( + %SPHINXBUILD% -b text %ALLSPHINXOPTS% %BUILDDIR%/text + if errorlevel 1 exit /b 1 + echo. + echo.Build finished. The text files are in %BUILDDIR%/text. + goto end +) + +if "%1" == "man" ( + %SPHINXBUILD% -b man %ALLSPHINXOPTS% %BUILDDIR%/man + if errorlevel 1 exit /b 1 + echo. + echo.Build finished. The manual pages are in %BUILDDIR%/man. + goto end +) + +if "%1" == "texinfo" ( + %SPHINXBUILD% -b texinfo %ALLSPHINXOPTS% %BUILDDIR%/texinfo + if errorlevel 1 exit /b 1 + echo. + echo.Build finished. The Texinfo files are in %BUILDDIR%/texinfo. + goto end +) + +if "%1" == "gettext" ( + %SPHINXBUILD% -b gettext %I18NSPHINXOPTS% %BUILDDIR%/locale + if errorlevel 1 exit /b 1 + echo. + echo.Build finished. The message catalogs are in %BUILDDIR%/locale. + goto end +) + +if "%1" == "changes" ( + %SPHINXBUILD% -b changes %ALLSPHINXOPTS% %BUILDDIR%/changes + if errorlevel 1 exit /b 1 + echo. + echo.The overview file is in %BUILDDIR%/changes. + goto end +) + +if "%1" == "linkcheck" ( + %SPHINXBUILD% -b linkcheck %ALLSPHINXOPTS% %BUILDDIR%/linkcheck + if errorlevel 1 exit /b 1 + echo. + echo.Link check complete; look for any errors in the above output ^ +or in %BUILDDIR%/linkcheck/output.txt. + goto end +) + +if "%1" == "doctest" ( + %SPHINXBUILD% -b doctest %ALLSPHINXOPTS% %BUILDDIR%/doctest + if errorlevel 1 exit /b 1 + echo. + echo.Testing of doctests in the sources finished, look at the ^ +results in %BUILDDIR%/doctest/output.txt. + goto end +) + +:end diff --git a/doc/mathmacro.py b/doc/mathmacro.py new file mode 100644 index 00000000..e44e5f28 --- /dev/null +++ b/doc/mathmacro.py @@ -0,0 +1,103 @@ +"""Sphinx extension provide a new directive *mathmacro*. + +This extension has to be added after the other math extension since it +redefined the math directive and the math role. For example, like this +(in the conf.py file):: + + extensions = [ + 'sphinx.ext.autodoc', 'sphinx.ext.doctest', + 'sphinx.ext.mathjax', + 'sphinx.ext.viewcode', 'sphinx.ext.autosummary', + 'numpydoc', + 'mathmacro'] + +""" + +from __future__ import print_function + +import re + +from docutils.parsers.rst.directives.misc import Replace + +from sphinx.ext.mathbase import MathDirective +from sphinx.ext.mathbase import math_role + + +def multiple_replacer(replace_dict): + """Return a function replacing doing multiple replacements. + + The produced function replace `replace_dict.keys()` by + `replace_dict.values`, respectively. + + """ + def replacement_function(match): + s = match.group(0) + end = s[-1] + if re.match(r'[\W_]', end): + return replace_dict[s[:-1]]+end + else: + return replace_dict[s] + + pattern = "|".join([re.escape(k)+r'[\W_]' + for k in replace_dict.keys()]) + pattern = re.compile(pattern, re.M) + return lambda string: pattern.sub(replacement_function, string) + +def multiple_replace(string, replace_dict): + mreplace = multiple_replacer(replace_dict) + return mreplace(string) + + +class MathMacro(Replace): + """Directive defining a math macro.""" + def run(self): + if not hasattr(self.state.document, 'math_macros'): + self.state.document.math_macros = {} + + latex_key = '\\'+self.state.parent.rawsource.split('|')[1] + self.state.document.math_macros[latex_key] = ''.join(self.content) + + self.content[0] = ':math:`'+self.content[0] + self.content[-1] = self.content[-1]+'`' + + return super(MathMacro, self).run() + + +class NewMathDirective(MathDirective): + """New math block directive parsing the latex code.""" + def run(self): + try: + math_macros = self.state.document.math_macros + except AttributeError: + pass + else: + if math_macros: + multiple_replace = multiple_replacer(math_macros) + for i, c in enumerate(self.content): + self.content[i] = multiple_replace(c) + for i, a in enumerate(self.arguments): + self.arguments[i] = multiple_replace(a) + return super(NewMathDirective, self).run() + + +def new_math_role(role, rawtext, text, lineno, inliner, + options={}, content=[]): + """New math role parsing the latex code.""" + try: + math_macros = inliner.document.math_macros + except AttributeError: + pass + else: + if math_macros: + rawtext = multiple_replace(rawtext, math_macros) + text = rawtext.split('`')[1] + + return math_role(role, rawtext, text, lineno, inliner, + options=options, content=content) + + +def setup(app): + app.add_role('math', new_math_role) + app.add_directive('math', NewMathDirective) + app.add_directive('mathmacro', MathMacro) + diff --git a/doc/to_do.rst b/doc/to_do.rst new file mode 100644 index 00000000..32f87408 --- /dev/null +++ b/doc/to_do.rst @@ -0,0 +1,33 @@ +To do list +========== + +FluidSim is still in a planning stage so there is still A LOT to do!! + +Long term +--------- + +- Library for 2D pencil decomposition and distributed Fast Fourier + Transform: http://www.2decomp.org + +- Parallel Three-Dimensional Fast Fourier Transforms: + https://code.google.com/p/p3dfft/ + +- VAPOR is the Visualization and Analysis Platform for Ocean, + Atmosphere, and Solar Researchers (https://www.vapor.ucar.edu/) + +- VisIt is a free [and open-source], interactive parallel + visualization and graphical analysis tool + (https://wci.llnl.gov/simulation/computer-codes/visit) + +Questions +--------- + +- String, unicode and byte in Python 2 and 3. + + +Inline to do items +------------------ + +.. todolist:: + + diff --git a/doc/tuto_simul_dev.rst b/doc/tuto_simul_dev.rst new file mode 100644 index 00000000..60bbffb3 --- /dev/null +++ b/doc/tuto_simul_dev.rst @@ -0,0 +1,92 @@ +Tutorial: how to develop a new solver +===================================== + +A solver is defined by the equations that it solves, its numerical +methods, the possible initialization methods and the treatments +performed on the raw data produced. + +Moreover, a solver can be decomposed in different parts that do +different tasks. In FluidDyn, this principle is followed as much as +possible and a solver is organized in few big parts using Python +classes. Thus, a solver is defined by the classes used to performed to +different tasks. We here present the classes used for the simulations +in FluidDyn. + +The main class representing a simulation: Simul +----------------------------------------------- + +The main classes representing a simulation are usually just called +"Simul" and thus are uniquely defined by the full path of the module +where they are defined as for example +:class:`fluiddyn.simul.solvers.ns2d.solver.Simul`. A Simul class +should inherit from +:class:`fluiddyn.simul.base.solvers.base.SimulBase` (or from a child +of this base class). + +In :ref:`tutosimuluser`, we have instantiate the Simul class like +this:: + + sim = solver.Simul(params) + +The Simul class is the main class from which the solvers are +organized. In particular, the other big parts of a solver are +attributes of the object Simul. The class takes care of importing the +module where the other main classes are defined and it instantiates +them. This class has also the important functions that implement the +equations and that are used by the other main classes (as +tendencies_nonlin, compute_freq_diss, compute_freq_complex, +operator_linear...). + +The other classes responsible for the main tasks +------------------------------------------------ + +- Operators class (need only the parameters); + + The class Operators contains the information on the grid and + functions to compute operators like the gradient, the curl, the + divergence... + +- State (need the parameters, the operators and the time stepping + instances, so its ``__init__`` function takes as argument the + simulation object); + + The class State contains the data (i.e. big arrays of numbers, more + precisely + :class:`fluiddyn.simul.operators.setofvariables.SetOfVariables`) + representing the state of the simulation (for example the + out-of-plane vorticity in spectral space for the pseudo-spectral + ns2d solver). This class is also able to compute different + quantities from the state, meaning that it knows about the + relationships between the variables. The State classes inherit from + the :class:`fluiddyn.simul.base.state.StateBase` class. + +- InitState (the ``__init__`` function takes as argument the + simulation object); + + The task of this class is to initialize the state before the + simulation. + +- TimeStepping (the ``__init__`` function takes as argument the + simulation object); + + The TimeStepping class contains functions for the time advancement: + time looping, Runge-Kutta scheme, CFL condition... + +- Forcing + + ... + +- Output + + * stdout + io + * post-processing + * plotting + +Other very important classes: ContainerXML, Parameters, InfoSolver +------------------------------------------------------------------ + +- ContainerXML + +- Parameters + +- InfoSolver diff --git a/doc/tutorials.rst b/doc/tutorials.rst new file mode 100644 index 00000000..85bc969d --- /dev/null +++ b/doc/tutorials.rst @@ -0,0 +1,8 @@ +Tutorials +========= + +.. toctree:: + :maxdepth: 2 + + ipynb/tuto_simul_user + tuto_simul_dev diff --git a/examples/__init__.py b/examples/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/examples/launch/Old/examples_commands.txt b/examples/launch/Old/examples_commands.txt new file mode 100644 index 00000000..a90bbe57 --- /dev/null +++ b/examples/launch/Old/examples_commands.txt @@ -0,0 +1,17 @@ + +cd ${SOLVEQ2D_PATH}/scripts/simuls/ + +spattach -i -p2 +./job_mpi_python simul_profile.py + +esubmit -n2 -t15 ./job_mpi_python simul_profile.py +spq -u $USER + +esubmit -n1 -t15 ./job_serial_python modif_resol_all_dir.py + + + + + + + diff --git a/examples/launch/Old/job_mpi_python b/examples/launch/Old/job_mpi_python new file mode 100755 index 00000000..586636a6 --- /dev/null +++ b/examples/launch/Old/job_mpi_python @@ -0,0 +1,43 @@ +#!/bin/bash + +PYTHONCOMMAND="$@" + +if [ -z "$PYTHONCOMMAND" ]; +then + echo "This script takes at least one argument (the name of the python script)" + exit 0 +fi + +processes_per_node=`cat /proc/cpuinfo | grep processor | wc -l` + +if [ -n "$SP_PROCS" ]; +then + total_processes=`expr $processes_per_node \* $SP_PROCS` +else + total_processes=$processes_per_node +fi + +if [[ "$HOSTNAME" = "pierre-KTH" ]]; +then + total_processes=2 +elif [[ "$HOSTNAME" = "pelvoux" ]]; +then + total_processes=4 +fi + +while [ $# -gt 0 ]; do +case "$1" in + -np) shift ; total_processes=$1;; + *) shift +esac +done + +echo "run mpirun with $total_processes processes" + +if [ -n "$SP_HOSTFILE" ]; +then + source ~/.profile + mpirun -np $total_processes -machinefile $SP_HOSTFILE -x PYTHONPATH -x SOLVEQ2D_RESULTS -x SOLVEQ2D_SCRATCH python -u $PYTHONCOMMAND +else + mpirun -np $total_processes python -u $PYTHONCOMMAND +fi \ No newline at end of file diff --git a/examples/launch/Old/job_serial_python b/examples/launch/Old/job_serial_python new file mode 100755 index 00000000..e1f7e475 --- /dev/null +++ b/examples/launch/Old/job_serial_python @@ -0,0 +1,16 @@ +#!/bin/bash + +PYTHONCOMMAND="$@" + +if [ -z "$PYTHONCOMMAND" ]; +then + echo "This script takes at least one argument (the name of the python script)" + exit 0 +fi + +if [ -n "$SP_HOSTFILE" ]; +then + source ~/.profile +fi + +python -u $PYTHONCOMMAND diff --git a/examples/launch/Old/launch_runs_esubmit.py b/examples/launch/Old/launch_runs_esubmit.py new file mode 100644 index 00000000..bab7f898 --- /dev/null +++ b/examples/launch/Old/launch_runs_esubmit.py @@ -0,0 +1,53 @@ +"""Launch many runs from a base directory containing.""" + +import numpy as np +from solveq2d import solveq2d +import sys +import os + +nh_approach = 3840 +nh = nh_approach*2 +t_end = 196. + +# -n1Q for 1 Q node (64 GB Ram) +# command_base = "esubmit -n1Q -t10 ./job_mpi_python simul_from_file_arg.py" +command_base = "esubmit -n1Q -t11520 ./job_mpi_python simul_from_file_arg.py" +# command_base = "python simul_from_file_arg.py" + +command_base = ( + command_base + +' t_end='+repr(t_end) + ) + +dir_base = ( + '~/Storage/Results_SW1lw/' + 'Pure_standing_waves_'+repr(nh_approach)+'x'+repr(nh_approach) +) + +set_of_dir_results = solveq2d.SetOfDirResults(dir_base=dir_base) + +values_c2 = set_of_dir_results.values_c2 +values_c = np.sqrt(values_c2) +values_c = np.array([40.]) +# values_c = np.array([10, 20, 40, 70, 100, 200, 400, 700, 1000]) + +values_solver = set_of_dir_results.values_solver +values_solver = ['SW1lwaves'] + +values_c2 = values_c**2 +tuple_loop = [(c2,name_solver) + for c2 in values_c2 + for name_solver in values_solver] +for c2, name_solver in tuple_loop: + path_dir = set_of_dir_results.one_path_from_values( + solver=name_solver, + c2=c2) + + command = ( + command_base+ + ' solver='+name_solver+ + ' path_dir='+path_dir+'/State_phys_'+repr(nh)+'x'+repr(nh) + ) + + print "run command:\n", command + os.system(command) diff --git a/examples/launch/Old/loop_simuls_forcing.py b/examples/launch/Old/loop_simuls_forcing.py new file mode 100644 index 00000000..c963486b --- /dev/null +++ b/examples/launch/Old/loop_simuls_forcing.py @@ -0,0 +1,99 @@ +#!/usr/bin/env python +#coding=utf8 +# +# nohup mpirun -np 8 python -u loop_simuls_forcing.py & + +import numpy as np +from solveq2d import solveq2d + +param = solveq2d.Param() + +param.short_name_type_run = 'forcing' + +nh = 2*128 +param['nx'] = nh +param['ny'] = nh + +param['f'] = 0. + +param['t_end'] = 140. + + +param['FORCING'] = True +param['type_forcing'] = 'WAVES' +param['nkmax_forcing'] = 8 +param['nkmin_forcing'] = 5 +param['forcing_rate'] = 1. + +Lh = np.round(2*np.pi*param['nkmax_forcing']) +param['Lx'] = Lh +param['Ly'] = Lh + +k_f = 2*np.pi*param['nkmax_forcing']/Lh +P_Z = param['forcing_rate'] +P_E = P_Z/k_f**2 +delta_x = param['Lx']/param['nx'] + +# dissipation at the smallest scales: +# k^{-3}: nu_n \simeq P_Z^{1/3} {\delta_x}^{n} +# k^{-5/3}: nu_n \simeq P_E^{1/3} {\delta_x}^{n-2/3} +param['nu_8'] = 3.*10e-2*P_E**(1./3)*delta_x**(8-2./3) + +# dissipation at the largest scales: +param['nu_m4'] = 8.*10e0*P_E**(1./3)*(Lh/2)**(-4-2./3) + + + + +param['coef_dealiasing'] = 8./9 + +param['type_flow_init'] = 'NOISE' +param['lambda_noise'] = 2*np.pi/k_f +param['max_velo_noise'] = 0.01 + + +param['period_print_simple'] = 2. +param['period_spatial_means'] = 0.1 +param['period_save_state_phys'] = 20. +param['period_save_spectra'] = 0.5 +param['period_save_seb'] = 0.5 +param['period_save_pdf'] = 0.5 +param['SAVE_time_sigK'] = True + +param['ONLINE_PLOT_OK'] = False +# param['period_plot_field'] = 0. +# param['field_to_plot'] = 'rot' +# param['PLOT_spatial_means'] = False +# param['PLOT_spectra'] = True +# param['PLOT_seb'] = True +# param['PLOT_pdf'] = True + + +values_solver = ['SW1lexlin', 'SW1l'] + +dico_solvers = solveq2d.ModulesSolvers(values_solver) + +values_c2 = [100, 200, 400, 600] + + +tuple_loop = [(c2, name_solver) + for c2 in values_c2 + for name_solver in values_solver] +for c2, name_solver in tuple_loop: + + param['c2'] = c2 + + solver = dico_solvers[name_solver] + + sim = solver.Simul(param) + sim.time_stepping.start() + + + + + +# solver.plt.show(block=True) +# solver.plt.show() + + + diff --git a/examples/launch/Old/loop_simuls_forcingw.py b/examples/launch/Old/loop_simuls_forcingw.py new file mode 100644 index 00000000..f1b4589a --- /dev/null +++ b/examples/launch/Old/loop_simuls_forcingw.py @@ -0,0 +1,90 @@ +#!/usr/bin/env python +#coding=utf8 +# +# nohup mpirun -np 4 python -u loop_simuls_forcingw.py & +# nohup mpirun -np 8 python -u loop_simuls_forcingw.py & +# esubmit -n1 -t300 ./job_mpi_python loop_simuls_forcingw.py + +import numpy as np +from solveq2d import solveq2d + +param = solveq2d.Param() + +param.short_name_type_run = 'forcingw' + +nh = 240 +param['nx'] = nh +param['ny'] = nh + +param['f'] = 0. + +param['t_end'] = 120. + + +param['FORCING'] = True +param['type_forcing'] = 'WAVES' +param['nkmax_forcing'] = 8 +param['nkmin_forcing'] = 5 +param['forcing_rate'] = 1. + +Lh = np.round(2*np.pi*param['nkmax_forcing']) +param['Lx'] = Lh +param['Ly'] = Lh + +k_f = 2*np.pi*param['nkmax_forcing']/Lh +P_Z = param['forcing_rate'] +P_E = P_Z/k_f**2 +delta_x = param['Lx']/param['nx'] + +# dissipation at the smallest scales: +# k^{-3}: nu_n \simeq P_Z^{1/3} {\delta_x}^{n} +# k^{-5/3}: nu_n \simeq P_E^{1/3} {\delta_x}^{n-2/3} +param['nu_8'] = 4.*10e-2*P_E**(1./3)*delta_x**(8-2./3) + +# dissipation at the largest scales: +# param['nu_m4'] = 8.*10e0*P_E**(1./3)*(Lh/2)**(-4-2./3) + + + + +param['coef_dealiasing'] = 8./9 + +param['type_flow_init'] = 'NOISE' +param['lambda_noise'] = 2*np.pi/k_f +param['max_velo_noise'] = 0.01 + + +param['period_print_simple'] = 2. +param['period_spatial_means'] = 0.1 +param['period_save_state_phys'] = 20. +param['period_save_spectra'] = 0.5 +param['period_save_seb'] = 0.5 +param['period_save_pdf'] = 0.5 +param['period_save_incr'] = 0.5 +param['SAVE_time_sigK'] = True + +param['ONLINE_PLOT_OK'] = False + + +values_solver = ['SW1lwaves'] +dico_solvers = solveq2d.ModulesSolvers(values_solver) + +values_c = np.array([10, 20, 40, 70, 100, 200, 400, 700, 1000]) +# values_c =np.array([10]) + +values_c2 = values_c**2 + +print values_c2 + +tuple_loop = [(c2, name_solver) + for c2 in values_c2 + for name_solver in values_solver] +for c2, name_solver in tuple_loop: + param['c2'] = c2 + solver = dico_solvers[name_solver] + + sim = solver.Simul(param) + sim.time_stepping.start() + del(sim) + + diff --git a/examples/launch/Old/loop_simuls_from_file.py b/examples/launch/Old/loop_simuls_from_file.py new file mode 100644 index 00000000..d07d9c5d --- /dev/null +++ b/examples/launch/Old/loop_simuls_from_file.py @@ -0,0 +1,84 @@ +#!/usr/bin/env python +#coding=utf8 +# +# nohup mpirun -np 4 python -u loop_simuls_from_file.py & +# nohup mpirun -np 8 python -u loop_simuls_from_file.py & + +import numpy as np +from solveq2d import solveq2d + +def modify_param(param): + """Modify the param object for the new simul.""" + param['NEW_DIR_RESULTS'] = True + param['t_end'] = 140. + + Lh = param['Lx'] + k_f = 2*np.pi*param['nkmax_forcing']/Lh + P_Z = param['forcing_rate'] + P_E = P_Z/k_f**2 + delta_x = param['Lx']/param['nx'] + + # param['FORCING'] = True + + # dissipation at the smallest scales: + # k^{-3}: nu_n \simeq P_Z^{1/3} {\delta_x}^{n} + # k^{-5/3}: nu_n \simeq P_E^{1/3} {\delta_x}^{n-2/3} + param['nu_8'] = 4.*10e-2*P_E**(1./3)*delta_x**(8-2./3) + + # dissipation at the largest scales: + param['nu_m4'] = 8.*10e0*P_E**(1./3)*(Lh/2)**(-4-2./3) + + param['period_print_simple'] = 0.05 + param['period_spatial_means'] = 0.01 + param['period_save_state_phys'] = 2. + param['period_save_spectra'] = 0.25 + param['period_save_seb'] = 0.25 + param['period_save_pdf'] = 0.5 + param['period_save_incr'] = 0.25 + param['SAVE_time_sigK'] = True + + param['ONLINE_PLOT_OK'] = False + + param['type_flow_init'] ='LOAD_FILE' + param['dir_load'] = path_dir + param['file_load'] = name_file + + +dico_solvers = solveq2d.ModulesSolvers(['SW1lexlin']) + +t_approx = 10.e10 +nh = 1024 + +nh_approach = nh/4 +# dir_base = 'Approach_runs_'+repr(nh_approach)+'x'+repr(nh_approach) +dir_base = 'Waves_standing_'+repr(nh_approach)+'x'+repr(nh_approach) + +# dir_base = '/scratch/augier/Results_for_article_SW1l/'+dir_base +# print dir_base + +set_of_dir_results = solveq2d.SetOfDirResults(dir_base=dir_base) + +values_c2 = set_of_dir_results.values_c2 +# values_c2 = [400.] +values_solver = set_of_dir_results.values_solver +values_solver = ['SW1lexlin'] + +tuple_loop = [(c2,name_solver) + for c2 in values_c2 + for name_solver in values_solver] +for c2, name_solver in tuple_loop: + path_dir = set_of_dir_results.one_path_from_values( + solver=name_solver, + c2=c2) + path_dir = path_dir+'/State_phys_'+repr(nh)+'x'+repr(nh) + + name_file = solveq2d.name_file_from_time_approx(path_dir, t_approx) + path_file=path_dir+'/'+name_file + param = solveq2d.Param(path_file=path_file) + modify_param(param) + + solver = dico_solvers[name_solver] + sim = solver.Simul(param) + sim.time_stepping.start() + del(sim) + diff --git a/examples/launch/Old/simul_dipole.py b/examples/launch/Old/simul_dipole.py new file mode 100644 index 00000000..393bdc1a --- /dev/null +++ b/examples/launch/Old/simul_dipole.py @@ -0,0 +1,53 @@ +#!/usr/bin/env python +#coding=utf8 +# +# mpirun -np 8 python simul_dipole.py + +key_solver = 'NS2D' +key_solver = 'SW1l' +key_solver = 'SW1l.onlywaves' +key_solver = 'SW1l.exactlin' + +import numpy as np +import fluiddyn as fld + +solver = fld.import_module_solver_from_key(key_solver) +param = fld.Param() + +nh = 2*128 +param['nx'] = nh +param['ny'] = nh +Lh = 10. +param['Lx'] = Lh +param['Ly'] = Lh + +delta_x = param.Lx/param.nx +param['nu_8'] = 2.*10e-1*param.forcing_rate**(1./3)*delta_x**8 +param['f'] = 0. +param['coef_dealiasing'] = 2./3 + +param['t_end'] = 1. + +param['type_flow_init'] = 'DIPOLE' +param['short_name_type_run'] = 'dipole' + +param['period_print_simple'] = 0.25 +param['period_spatial_means'] = .02 +param['period_save_state_phys'] = 0 +param['period_save_spectra'] = 0.1 +# param['period_save_seb'] = 0.1 + +# param['ONLINE_PLOT_OK'] = False +param['period_plot_field'] = 2. +param['field_to_plot'] = 'rot' +param['PLOT_spatial_means'] = True +param['PLOT_spectra'] = True +# param['PLOT_seb'] = True + +sim = solver.Simul(param) + +sim.output.phys_fields.plot(numfig=0) +sim.time_stepping.start() +sim.output.phys_fields.plot(numfig=1) + +fld.show() diff --git a/examples/launch/Old/simul_forcing.py b/examples/launch/Old/simul_forcing.py new file mode 100644 index 00000000..a1c3e7e4 --- /dev/null +++ b/examples/launch/Old/simul_forcing.py @@ -0,0 +1,92 @@ +#!/usr/bin/env python +#coding=utf8 +# +# run simul_forcing.py +# mpirun -np 8 python simul_forcing.py +# nohup mpirun -np 4 python -u simul_forcing.py + +key_solver = 'NS2D' +key_solver = 'SW1l' +key_solver = 'SW1l.onlywaves' +key_solver = 'SW1l.exactlin' + +import numpy as np +import fluiddyn as fld + +solver = fld.import_module_solver_from_key(key_solver) +param = fld.Param() + +param.short_name_type_run = 'forcing' + + +nh = 2*64 +param['nx'] = nh +param['ny'] = nh + +param['f'] = 0. +param['c2'] = 200. # c = sqrt(g*H) + +param['t_end'] = 1. + + +param['FORCING'] = False +param['type_forcing'] = 'WAVES' +param['nkmax_forcing'] = 8 +param['nkmin_forcing'] = 5 +param['forcing_rate'] = 1. + +Lh = np.round(2*np.pi*param['nkmax_forcing']) +param['Lx'] = Lh +param['Ly'] = Lh + +k_f = 2*np.pi*param['nkmax_forcing']/Lh +P_Z = param['forcing_rate'] +P_E = P_Z/k_f**2 +delta_x = param['Lx']/param['nx'] + +# dissipation at the smallest scales: +# k^{-3}: nu_n \simeq P_Z^{1/3} {\delta_x}^{n} +# k^{-5/3}: nu_n \simeq P_E^{1/3} {\delta_x}^{n-2/3} +param['nu_8'] = 2.*10e-2*P_E**(1./3)*delta_x**(8-2./3) + +# dissipation at the largest scales: +param['nu_m4'] = 8.*10e0*P_E**(1./3)*(Lh/2)**(-4-2./3) + +param['coef_dealiasing'] = 8./9 + +param['type_flow_init'] = 'NOISE' +param['lambda_noise'] = 2*np.pi/k_f +param['max_velo_noise'] = 0.000001 + + +param['period_print_simple'] = 2. +param['period_spatial_means'] = 0.01 +param['period_save_state_phys'] = 10. +param['period_save_spectra'] = 0.5 +param['period_save_seb'] = 0.1 +param['period_save_pdf'] = 0.1 +param['period_save_incr'] = 0.1 +param['SAVE_time_sigK'] = True + +# param['ONLINE_PLOT_OK'] = False +param['period_plot_field'] = 0. +param['field_to_plot'] = 'eta' +# param['PLOT_spatial_means'] = True +param['PLOT_spectra'] = True +param['PLOT_seb'] = True +param['PLOT_pdf'] = True +param['PLOT_incr'] = True + +# import resource + +# np.seterr(all='raise') + +sim = solver.Simul(param) + +# sim.output.phys_fields.plot(numfig=0) +sim.time_stepping.start() +# sim.output.phys_fields.plot(numfig=1) + + +fld.show() + diff --git a/examples/launch/Old/simul_from_file.py b/examples/launch/Old/simul_from_file.py new file mode 100644 index 00000000..8032bf95 --- /dev/null +++ b/examples/launch/Old/simul_from_file.py @@ -0,0 +1,103 @@ +#!/usr/bin/env python +#coding=utf8 +# +# run simul_from_file.py +# mpirun -np 8 python simul_from_file.py +# nohup mpirun -np 4 python -u simul_from_file.py & + +key_solver = 'NS2D' +key_solver = 'SW1l' +key_solver = 'SW1l.onlywaves' +key_solver = 'SW1l.exactlin' + +import numpy as np +import fluiddyn as fld + +from fluiddyn.simul.util import name_file_from_time_approx + + +solver = fld.import_module_solver_from_key(key_solver) + + +#name_dir = '' +name_dir = ( +'/afs/pdc.kth.se/home/a/augier/Storage' +'/Results_SW1lw' +'/Pure_standing_waves_1920x1920' +'/SE2D_SW1lwaves_forcingw_L=50.x50._1920x1920_c=20_f=0_2013-07-15_10-40-51' +) +# path_dir = solveq2d.path_dir_results+'/'+name_dir +path_dir = name_dir + + +# choose the file with the time closer to t_approx +t_approx = 10.e10 +name_file = name_file_from_time_approx(path_dir, t_approx) +# or ... +#name_file = '' + +path_file=path_dir+'/'+name_file + +param = fld.Param(path_file=path_file) + +param['NEW_DIR_RESULTS'] = True +param['t_end'] = 155. + +Lh = param['Lx'] +k_f = 2*np.pi*param['nkmax_forcing']/Lh +P_Z = param['forcing_rate'] +P_E = P_Z/k_f**2 +delta_x = param['Lx']/param['nx'] + +# dissipation at the smallest scales: +# k^{-3}: nu_n \simeq P_Z^{1/3} {\delta_x}^{n} +# k^{-5/3}: nu_n \simeq P_E^{1/3} {\delta_x}^{n-2/3} +param['nu_8'] = 4.*10e-2*P_E**(1./3)*delta_x**(8-2./3) +# param['nu_2'] = 1.5*10e-0*P_E**(1./3)*delta_x**(2-2./3) + +# dissipation at the largest scales: +# param['nu_m4'] = 0. #8.*10e0*P_E**(1./3)*(Lh/2)**(-4-2./3) + +param['FORCING'] = True + + + +ROTATION = True +if ROTATION: + Bu = 2. + c = np.sqrt(param['c2']) + Kf = 6*2*np.pi/Lh + f = c*Kf/np.sqrt(Bu) + param['f'] = f + + +param['period_print_simple'] = 0.001 +param['period_spatial_means'] = 0.01 +param['period_save_state_phys'] = 2. +param['period_save_spectra'] = 0.2 +param['period_save_seb'] = 0.2 +param['period_save_pdf'] = 0.5 +param['period_save_incr'] = 0.1 +param['SAVE_time_sigK'] = False + + +param['ONLINE_PLOT_OK'] = False +# param['period_plot_field'] = 0. +# param['field_to_plot'] = 'rot' +# param['PLOT_spectra'] = True +# param['PLOT_spatial_means'] = False +# param['PLOT_seb'] = False +# param['PLOT_incr'] = False + + +param['type_flow_init'] ='LOAD_FILE' +param['dir_load'] = path_dir +param['file_load'] = name_file + +sim = solver.Simul(param) + +# sim.output.phys_fields.plot(numfig=0) +sim.time_stepping.start() +# sim.output.phys_fields.plot(numfig=1) + +fld.show() diff --git a/examples/launch/Old/simul_from_file_arg.py b/examples/launch/Old/simul_from_file_arg.py new file mode 100644 index 00000000..a9a43180 --- /dev/null +++ b/examples/launch/Old/simul_from_file_arg.py @@ -0,0 +1,86 @@ +#!/usr/bin/env python +#coding=utf8 +# esubmit -n1 -t15 ./job_mpi_python simul_from_file_arg.py t_end=120.2 solver=SW1lwaves path_dir=/afs/pdc.kth.se/home/a/augier/Storage/Results_SW1lw/Pure_standing_waves_240x240/SE2D_SW1lwaves_forcingw_L=50.x50._240x240_c=700_f=0_2013-07-10_17-44-01/State_phys_480x480 + +import numpy as np +from solveq2d import solveq2d + +import sys + +def variable_from_args(strvar): + for arg in sys.argv: + if arg.startswith(strvar): + var = arg.replace(strvar, '', 1) + try: + var = float(var) + except ValueError: + pass + try: var + except NameError: + raise ValueError('One of the arg have to start with \"'+strvar+'\"') + return var + + +t_end = variable_from_args("t_end=") +name_solver = variable_from_args("solver=") +path_dir = variable_from_args("path_dir=") + + +solver = solveq2d.import_module_solver_from_name(name_solver) + +# choose the file with the time closer to t_approx +t_approx = 10.e10 +name_file = solveq2d.name_file_from_time_approx(path_dir, t_approx) + +path_file=path_dir+'/'+name_file + +param = solveq2d.Param(path_file=path_file) + +param['NEW_DIR_RESULTS'] = True +param['t_end'] = t_end + +Lh = param['Lx'] +k_f = 2*np.pi*param['nkmax_forcing']/Lh +P_Z = param['forcing_rate'] +P_E = P_Z/k_f**2 +delta_x = param['Lx']/param['nx'] + +# dissipation at the smallest scales: +# k^{-3}: nu_n \simeq P_Z^{1/3} {\delta_x}^{n} +# k^{-5/3}: nu_n \simeq P_E^{1/3} {\delta_x}^{n-2/3} +param['nu_8'] = 4.*10e-2*P_E**(1./3)*delta_x**(8-2./3) + +# dissipation at the largest scales: +# param['nu_m4'] = 8.*10e0*P_E**(1./3)*(Lh/2)**(-4-2./3) + +param['FORCING'] = True + +param['period_print_simple'] = 0.001 + +param['period_spatial_means'] = 0.01 +param['period_save_state_phys'] = 1. +param['period_save_spectra'] = 0.25 +param['period_save_seb'] = 0.25 +param['period_save_pdf'] = 0.5 +param['period_save_incr'] = 0.25 +param['SAVE_time_sigK'] = True + +param['ONLINE_PLOT_OK'] = False +param['period_plot_field'] = 0. +param['field_to_plot'] = 'rot' +param['PLOT_spectra'] = False +param['PLOT_spatial_means'] = False +# param['PLOT_seb'] = False +param['PLOT_incr'] = True + +param['type_flow_init'] ='LOAD_FILE' +param['dir_load'] = path_dir +param['file_load'] = name_file + +sim = solver.Simul(param) + +# sim.output.phys_fields.plot(numfig=0) +sim.time_stepping.start() +# sim.output.phys_fields.plot(numfig=1) + +# solveq2d.show() diff --git a/examples/launch/Old/simul_noise.py b/examples/launch/Old/simul_noise.py new file mode 100644 index 00000000..96c6cfd9 --- /dev/null +++ b/examples/launch/Old/simul_noise.py @@ -0,0 +1,100 @@ +#!/usr/bin/env python +#coding=utf8 +# +# run simul_noise.py +# mpirun -np 8 python simul_noise.py + +key_solver = 'NS2D' +key_solver = 'SW1l' +key_solver = 'SW1l.onlywaves' +key_solver = 'SW1l.exactlin' + +import numpy as np +import fluiddyn as fld + +solver = fld.import_module_solver_from_key(key_solver) +param = fld.Param() + + + +nh = 64 +param['nx'] = nh +param['ny'] = nh + +param['f'] = 2. +param['c2'] = 200. #(2.*np.pi)**2 # c = sqrt(g*H) + +param['t_end'] = 5. + +param['FORCING'] = False +param['type_forcing'] = '' +param['nkmax_forcing'] = 8 +param['nkmin_forcing'] = 7 +param['forcing_rate'] = 1. + +Lh = np.round(2*np.pi*param['nkmax_forcing']) + +param['Lx'] = Lh +param['Ly'] = Lh + +k_f = 2*np.pi*param['nkmax_forcing']/Lh +P_Z = param['forcing_rate'] +P_E = P_Z/k_f**2 +delta_x = param['Lx']/param['nx'] + +# dissipation at the smallest scales: +# k^{-3}: nu_n \simeq P_Z^{1/3} {\delta_x}^{n} +# k^{-5/3}: nu_n \simeq P_E^{1/3} {\delta_x}^{n-2/3} +param['nu_8'] = 3.*10e-2*P_E**(1./3)*delta_x**(8-2./3) + +# dissipation at the largest scales: +# param['nu_m4'] = 8.*10e0*P_E**(1./3)*(Lh/2)**(-4-2./3) + + +param['type_flow_init'] = 'NOISE' +param['lambda_noise'] = 2*np.pi/k_f +param['max_velo_noise'] = 15. +param['short_name_type_run'] = 'noise' + + + +param['period_print_simple'] = 0.5 +# param['period_spatial_means'] = 0.01 +# param['period_save_state_phys'] = 10. +# param['period_save_spectra'] = 0.25 +# param['period_save_SEB'] = 0.1 +# param['period_save_pdf'] = 0.5 +param['period_save_incr'] = 0.1 +# param['SAVE_time_sigK'] = True + +param['ONLINE_PLOT_OK'] = False +param['period_plot_field'] = 0. +param['field_to_plot'] = 'rot' +# param['PLOT_spatial_means'] = True +# param['PLOT_spectra'] = True +# param['PLOT_SEB'] = True +# param['PLOT_pdf'] = True +param['PLOT_incr'] = True + +sim = solver.Simul(param) + +# sim.output.phys_fields.plot(numfig=0, key_field='rot') +# sim.output.phys_fields.plot(numfig=1, key_field='h') + + + +# print 'ap_fft', sim.state('ap_fft')[0, sim.param.ikx] +# print 'am_fft', sim.state('am_fft')[0, sim.param.ikx] + +sim.time_stepping.start() + +# print 'ap_fft', sim.state('ap_fft')[0, sim.param.ikx] +# print 'am_fft', sim.state('am_fft')[0, sim.param.ikx] + + + +# sim.output.phys_fields.plot(numfig=2, key_field='div') +# sim.output.phys_fields.plot(numfig=3, key_field='eta') + + +fld.show() diff --git a/examples/launch/Old/simul_wave.py b/examples/launch/Old/simul_wave.py new file mode 100644 index 00000000..92d538ac --- /dev/null +++ b/examples/launch/Old/simul_wave.py @@ -0,0 +1,87 @@ +#!/usr/bin/env python +#coding=utf8 +# +# run simul_noise.py +# mpirun -np 8 python simul_noise.py + +key_solver = 'NS2D' +key_solver = 'SW1l' +key_solver = 'SW1l.onlywaves' +key_solver = 'SW1l.exactlin' + +import numpy as np +import fluiddyn as fld + +solver = fld.import_module_solver_from_key(key_solver) +param = fld.Param() + + +nh = 64 +param['nx'] = nh +param['ny'] = nh + +param['f'] = 5. +param['c2'] = (2.*np.pi)**2 # c = sqrt(g*H) + +param['t_end'] = 0.4 + +ik_wave = 4 +Lh = np.round(2*np.pi*ik_wave) + +param['Lx'] = Lh +param['Ly'] = Lh + +param['short_name_type_run'] = 'wave' + +param['type_flow_init'] = 'WAVE' +param.ikx = ik_wave +param.eta0 = 0.01 +param['deltat0'] = 2.e-2 +param['USE_CFL'] = False + + + +param['period_print_simple'] = 0.1 +param['period_spatial_means'] = 0.01 +param['period_save_state_phys'] = 10. +# param['period_save_spectra'] = 0.25 +# param['period_save_SEB'] = 0.1 +# param['period_save_pdf'] = 0.5 + +param['SAVE_time_sigK'] = True + +# param['ONLINE_PLOT_OK'] = False +param['period_plot_field'] = 0.2 +param['field_to_plot'] = 'eta' +param['PLOT_spatial_means'] = True +# param['PLOT_spectra'] = True +# param['PLOT_SEB'] = True +# param['PLOT_pdf'] = True + + +sim = solver.Simul(param) + +# sim.output.phys_fields.plot(numfig=0, key_field='rot') +# sim.output.phys_fields.plot(numfig=1, key_field='h') + + + +# print 'ap_fft', sim.state('ap_fft')[0, ik_wave] +# print 'am_fft', sim.state('am_fft')[0, ik_wave] + +sim.time_stepping.start() + +# print 'ap_fft', sim.state('ap_fft')[0, ik_wave] +# print 'am_fft', sim.state('am_fft')[0, ik_wave] + + + +sim.output.phys_fields.plot(numfig=2, key_field='div') +sim.output.phys_fields.plot(numfig=3, key_field='eta') +sim.output.phys_fields.plot(numfig=4, key_field='h') +sim.output.phys_fields.plot(numfig=5, key_field='rot') + + + +fld.show() + diff --git a/examples/launch/__init__.py b/examples/launch/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/examples/launch/simul_profile.py b/examples/launch/simul_profile.py new file mode 100644 index 00000000..b909bca3 --- /dev/null +++ b/examples/launch/simul_profile.py @@ -0,0 +1,75 @@ +#!/usr/bin/env python +# +# run simul_profile.py +# mpirun -np 8 python simul_profile.py + +# key_solver = 'NS2D' +# key_solver = 'SW1l' +# key_solver = 'SW1l.onlywaves' +# key_solver = 'SW1l.exactlin' +key_solver = 'PLATE2D' + +import pstats +import cProfile + +import fluiddyn as fld + +solver = fld.simul.import_module_solver_from_key(key_solver) +params = fld.simul.create_params(solver) + +params.short_name_type_run = 'profile' + +nh = 192 +params.oper.nx = nh +params.oper.ny = nh +Lh = 6. +params.oper.Lx = Lh +params.oper.Ly = Lh + +params.oper.coef_dealiasing = 2./3 + +params.FORCING = False +params.forcing.type_forcing = 'noWAVES' +params.forcing.nkmax_forcing = 5 +params.forcing.nkmin_forcing = 4 +params.forcing.forcing_rate = 1. + + +delta_x = Lh/nh +params.nu_8 = 2.*10e-1*params.forcing.forcing_rate**(1./3)*delta_x**8 + +try: + params.f = 1. + params.c2 = 200. +except KeyError: + pass + +params.time_stepping.deltat0 = 1.e-4 +params.time_stepping.USE_CFL = False + +params.time_stepping.it_end = 50 +params.time_stepping.USE_T_END = False + +params.oper.type_fft = 'FFTWPY' + +# params.init_fields.type_flow_init = 'DIPOLE' + + +params.output.periods_print.print_stdout = 0 + +params.output.HAS_TO_SAVE = False +params.output.periods_save.phys_fields = 0. +params.output.periods_save.spatial_means = 0. +params.output.periods_save.spectra = 0. +# params.output.periods_save.spect_energy_budg = 0. +# params.output.periods_save.increments = 0. + + +sim = solver.Simul(params) +cProfile.runctx("sim.time_stepping.start()", + globals(), locals(), "Profile.prof") + + +if sim.oper.rank == 0: + s = pstats.Stats("Profile.prof") + s.strip_dirs().sort_stats("time").print_stats(10) diff --git a/examples/launch/simul_test_conserveE.py b/examples/launch/simul_test_conserveE.py new file mode 100644 index 00000000..932ca131 --- /dev/null +++ b/examples/launch/simul_test_conserveE.py @@ -0,0 +1,74 @@ +# !/usr/bin/env python +#coding=utf8 +# +# run simul_test_conserveE.py +# mpirun -np 8 python simul_test_conserveE.py + +key_solver = 'NS2D' +# key_solver = 'SW1l' +# key_solver = 'SW1l.onlywaves' +# key_solver = 'SW1l.exactlin' +# key_solver = 'SW1l.modified' + +import numpy as np +import fluiddyn as fld + +solver = fld.simul.import_module_solver_from_key(key_solver) +params = fld.simul.create_params(solver) + +params.short_name_type_run = 'conservE' + +nh = 16*4*8 +Lh = 2*np.pi +params.oper.nx = nh +params.oper.ny = nh +params.oper.Lx = Lh +params.oper.Ly = Lh + +params.oper.coef_dealiasing = 2./3 + +params.nu_8 = 0. +params.nu_4 = 0. +params.nu_2 = 0. +params.nu_m4 = 0. + +try: + params.f = 1. + params.c2 = 200. +except KeyError: + pass + +params.time_stepping.USE_CFL = False + +params.time_stepping.it_end = 5 +params.time_stepping.USE_T_END = False + +params.time_stepping.type_time_scheme = 'RK4' + +params.init_fields.type_flow_init = 'DIPOLE' + + +params.output.periods_print.print_stdout = 10.e-15 + +params.output.periods_save.phys_fields = 0. +params.output.periods_save.spectra = 0. +params.output.periods_save.spect_energy_budg = 0. +params.output.periods_save.increments = 0. + +try: + params.output.periods_save.pdf = 0. + params.output.periods_save.time_signals_fft = False +except KeyError: + pass + + +params.output.periods_plot.phys_fields = 0. + + +params.time_stepping.deltat0 = 1.e-1 +sim = solver.Simul(params) +sim.time_stepping.start() + +params.time_stepping.deltat0 = 1.e-2 +sim = solver.Simul(params) +sim.time_stepping.start() diff --git a/examples/plot_results/dispersion_relationship_SW1l.py b/examples/plot_results/dispersion_relationship_SW1l.py new file mode 100644 index 00000000..d5665c80 --- /dev/null +++ b/examples/plot_results/dispersion_relationship_SW1l.py @@ -0,0 +1,56 @@ +#!/usr/bin/env python +# -*- coding: UTF-8 -*- + +import numpy as np + +import matplotlib.pyplot as plt + + +f = 1. +c= 1. + +L_D = c/f + +Lx = 30. +nx = 64 +nkx = nx/2. +1 + +kx = 2*np.pi/Lx* np.arange(nkx) + +omega_theo = np.sqrt( f**2 + (c*kx)**2 ) + +# numerical results +k_num = np.array([0.63, 1.88, 2.51, 4.19 +]) + +frequency = np.array([0.1875, 0.34, 0.43, 0.7 +]) + + + + + +ikx = 14 + + + + + +fig = plt.figure(2) +fig.clf() +plt.hold(True) + +plt.plot(kx*L_D, omega_theo/(2*np.pi), 'k', linewidth=2 ) + +plt.plot(kx*L_D, kx*L_D/(2*np.pi), 'k--', linewidth=0.5 ) + +plt.plot(kx[ikx]*L_D, omega_theo[ikx]/(2*np.pi), 'rx', linewidth=2 ) + +plt.plot(k_num*L_D, frequency, 'bo', linewidth=2 ) + + +plt.xlabel('k L_D') +plt.ylabel('frequency') +plt.show() + + diff --git a/examples/plot_results/fig_spectra_forcingq.py b/examples/plot_results/fig_spectra_forcingq.py new file mode 100644 index 00000000..e93d45fb --- /dev/null +++ b/examples/plot_results/fig_spectra_forcingq.py @@ -0,0 +1,119 @@ +#!/usr/bin/env python +#coding=utf8 + +import numpy as np +import matplotlib.pyplot as plt + +from solveq2d import solveq2d + +from create_figs_articles import CreateFigArticles + + +num_fig = 1000 +SAVE_FIG = 1 +name_file = 'spectra_forcingq.eps' + +create_fig = CreateFigArticles( + short_name_article='SW1l', + SAVE_FIG=SAVE_FIG, + FOR_BEAMER=False, + fontsize=19 + ) + + + + +name_dir_results = ( +create_fig.path_base_dir+'/Results_for_article_SW1l' +'/Approach_runs_2048x2048' +'/SE2D_SW1lexlin_forcing_L=50.x50._2048x2048_c2=400_f=0_2013-05-29_23-54-57' +) + +sim = solveq2d.create_sim_plot_from_dir(name_dir_results) +tmin = 30 +dico_results = sim.output.spectra.load2D_mean(tmin=tmin) + +kh = dico_results['kh'] + +EK = dico_results['spectrum2D_EK'] +EA = dico_results['spectrum2D_EA'] +EKr = dico_results['spectrum2D_EKr'] +E_tot = EK + EA +EKd = EK - EKr +Edlin = dico_results['spectrum2D_Edlin'] + +fig, ax1 = create_fig.figure_axe(name_file=name_file) +ax1.set_xscale('log') +ax1.set_yscale('log') + +coef_compensate = 5./3 +coef_norm = kh**coef_compensate + +l_Etot = ax1.plot(kh, E_tot*coef_norm, 'k', linewidth=4) +l_EK = ax1.plot(kh, EK*coef_norm, 'r', linewidth=2) +l_EA = ax1.plot(kh, EA*coef_norm, 'b', linewidth=2) +ax1.plot(kh, EKr*coef_norm, 'r--', linewidth=2) +ax1.plot(kh, EKd*coef_norm, 'r:', linewidth=2) + +ax1.plot(kh, -EK*coef_norm, 'm', linewidth=2) +ax1.plot(kh, -EKd*coef_norm, 'm:', linewidth=2) + +ax1.plot(kh, Edlin*coef_norm, 'y:', linewidth=2) + + +cond = np.logical_and(kh > 1 , kh < 20) +ax1.plot(kh[cond], 1e1*kh[cond]**(-3.)*coef_norm[cond], 'k--', linewidth=1) +plt.figtext(0.6, 0.78, '$k^{-3}$', fontsize=20) + +cond = np.logical_and(kh > 0.3 , kh < 10) +ax1.plot(kh[cond], 4e-2*kh[cond]**(-2.)*coef_norm[cond], 'k:', linewidth=1) +plt.figtext(0.25, 0.55, '$k^{-2}$', fontsize=20) + +cond = np.logical_and(kh > 0.3 , kh < 15) +ax1.plot(kh[cond], 1e-2*kh[cond]**(-5./3)*coef_norm[cond], + 'k-.', linewidth=1) +plt.figtext(0.5, 0.45, '$k^{-5/3}$', fontsize=20) + + + + + + + + + + +ax1.set_xlabel('$k_h$') +ax1.set_ylabel('2D spectra') + + + + +plt.rc('legend', numpoints=1) +leg1 = plt.figlegend( + [l_Etot[0], l_EK[0], l_EA[0]], + ['$E$', '$E_K$', '$E_A$'], + loc=(0.78, 0.7), + labelspacing = 0.2 +) + + + +ax1.set_xlim([0.1,150]) +ax1.set_ylim([1e-5,2e1]) + + +create_fig.save_fig() + +plt.show() + + + + + + + + + + + diff --git a/examples/plot_results/fig_spectra_forcingq_diff_c.py b/examples/plot_results/fig_spectra_forcingq_diff_c.py new file mode 100644 index 00000000..69851716 --- /dev/null +++ b/examples/plot_results/fig_spectra_forcingq_diff_c.py @@ -0,0 +1,139 @@ +#!/usr/bin/env python +#coding=utf8 + +import numpy as np +import matplotlib.pyplot as plt + +from solveq2d import solveq2d + +from create_figs_articles import CreateFigArticles + + +num_fig = 1000 +SAVE_FIG = 1 +name_file = 'spectra_forcingq_diff_c.eps' + +create_fig = CreateFigArticles( + short_name_article='SW1l', + SAVE_FIG=SAVE_FIG, + FOR_BEAMER=False, + fontsize=19 + ) + +dir_base = ( +create_fig.path_base_dir+'/Results_for_article_SW1l' +'/Approach_runs_2048x2048' +) +set_of_dir_results = solveq2d.SetOfDirResults(dir_base=dir_base) +dirs = set_of_dir_results.dirs_from_values(solver='SW1lexlin', + FORCING=True) + +print dirs + +tmin = 264 + + +def sprectra_from_namedir(name_dir_results): + path_dir_results = set_of_dir_results.path_dirs[name_dir_results] + sim = solveq2d.create_sim_plot_from_dir(path_dir_results) + dico_results = sim.output.spectra.load2D_mean(tmin=tmin) + kh = dico_results['kh'] + EK = dico_results['spectrum2D_EK'] + EA = dico_results['spectrum2D_EA'] + EKr = dico_results['spectrum2D_EKr'] + EKd = EK - EKr + return kh, EKr, EKd + + + +kh, EKr0, EKd0 = sprectra_from_namedir(dirs[0]) +kh, EKr1, EKd1 = sprectra_from_namedir(dirs[1]) +kh, EKr2, EKd2 = sprectra_from_namedir(dirs[2]) +kh, EKr3, EKd3 = sprectra_from_namedir(dirs[3]) + + + + + + +fig, ax1 = create_fig.figure_axe(name_file=name_file) +ax1.set_xscale('log') +ax1.set_yscale('log') + +coef_compensate = 5./3 +coef_norm = kh**coef_compensate + +ax1.plot(kh, EKr0*coef_norm, 'k--', linewidth=2) +ax1.plot(kh, EKd0*coef_norm, 'k:', linewidth=2) + +ax1.plot(kh, EKr1*coef_norm, 'r--', linewidth=2) +ax1.plot(kh, EKd1*coef_norm, 'r:', linewidth=2) + +ax1.plot(kh, EKr2*coef_norm, 'b--', linewidth=2) +ax1.plot(kh, EKd2*coef_norm, 'b:', linewidth=2) + +ax1.plot(kh, EKr3*coef_norm, 'c--', linewidth=2) +ax1.plot(kh, EKd3*coef_norm, 'c:', linewidth=2) + + + + + +cond = np.logical_and(kh > 1 , kh < 20) +ax1.plot(kh[cond], 1e1*kh[cond]**(-3.)*coef_norm[cond], + 'k--', linewidth=1) +plt.figtext(0.6, 0.78, '$k^{-3}$', fontsize=20) + +cond = np.logical_and(kh > 0.3 , kh < 10) +ax1.plot(kh[cond], 4e-2*kh[cond]**(-2.)*coef_norm[cond], + 'k:', linewidth=1) +plt.figtext(0.25, 0.55, '$k^{-2}$', fontsize=20) + +cond = np.logical_and(kh > 0.3 , kh < 15) +ax1.plot(kh[cond], 1e-2*kh[cond]**(-5./3)*coef_norm[cond], + 'k-.', linewidth=1) +plt.figtext(0.5, 0.45, '$k^{-5/3}$', fontsize=20) + + + + + + + + + + +ax1.set_xlabel('$k_h$') +ax1.set_ylabel('2D spectra') + + + + +# plt.rc('legend', numpoints=1) +# leg1 = plt.figlegend( +# [l_Etot[0], l_EK[0], l_EA[0]], +# ['$E$', '$E_K$', '$E_A$'], +# loc=(0.78, 0.7), +# labelspacing = 0.2 +# ) + + + +ax1.set_xlim([0.1,150]) +ax1.set_ylim([1e-5,2e1]) + + +create_fig.save_fig() + +plt.show() + + + + + + + + + + + diff --git a/examples/plot_results/plot_interm.py b/examples/plot_results/plot_interm.py new file mode 100644 index 00000000..4dc84854 --- /dev/null +++ b/examples/plot_results/plot_interm.py @@ -0,0 +1,229 @@ + + +import matplotlib.pylab as plt +import glob +import numpy as np + +from solveq2d import solveq2d + + +from create_figs_articles import CreateFigArticles + + +SAVE_FIG = False + +create_fig = CreateFigArticles( + short_name_article='SW1l', + SAVE_FIG=SAVE_FIG, + FOR_BEAMER=False, + fontsize=19 + ) + +dir_base = create_fig.path_base_dir+'/Results_SW1lw' + +c = 40 + +resol = 240*2**5 + +str_resol = repr(resol) +str_to_find_path = ( + dir_base+'/Pure_standing_waves_'+ + str_resol+'*/SE2D*c='+repr(c))+'_*' +print str_to_find_path + +paths_dir = glob.glob(str_to_find_path) + +print paths_dir + + +sim = solveq2d.create_sim_plot_from_dir(paths_dir[0]) + +tmin = sim.output.spatial_means.first_saved_time() +tstatio = tmin + 4. + + + +tmax = 1000 + + + + +key_var = 'uy' + +(pdf_timemean, values_inc_timemean, nb_rx_to_plot + ) = sim.output.increments.load_pdf_from_file( + tmin=tmin, tmax=tmax, key_var=key_var) + + + + + + +deltax = sim.param.Lx/sim.param.nx +rxs = np.array(sim.output.increments.rxs, dtype=np.float64)*deltax + + +# if 7680 +rmin = 8*deltax +rmax = 40*deltax + +# rmin = 0.6 +# rmax = 3 + + +# if 4096 +# rmin = 8e-2 +# rmin = 8*deltax +# rmax = 5e-1 +# rmax = 50*deltax + +# if 2048 +# rmin = 1.5e-1 +# rmin = 5*deltax +# rmax = 20*deltax +# rmax = 3e-1 + + + + +condr = np.logical_and(rxs>rmin, rxsmaxv] = maxv + var[var