Skip to content

Commit

Permalink
more very minor updates of the docs
Browse files Browse the repository at this point in the history
  • Loading branch information
RolfSander committed Jun 29, 2022
1 parent f1affbd commit 18f4955
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 77 deletions.
71 changes: 30 additions & 41 deletions docs/source/using_kpp/04_input_for_kpp.rst
Original file line number Diff line number Diff line change
Expand Up @@ -792,13 +792,13 @@ Inlined Code
In order to offer maximum flexibility, KPP allows the user to include
pieces of code in the kinetic description file. Inlined code begins on a
new line with :command:`#INLINE` and the *inline_type*. Next, one or
more lines of code follow, written in the target language (Fortran90,
C, or Matlab) as specified by the *inline_type*. The inlined code ends
with :command:`#ENDINLINE`. The code is inserted into the KPP output
at a position which is also determined by *inline_type* as explained
in :ref:`table-inl-type`. If two inline commands with the same inline
type are declared, then the contents of the second is appended to the
first one.
more lines of code follow, written in the target language (Fortran90, C,
or Matlab) as specified by the *inline_type*. The inlined code ends with
:command:`#ENDINLINE`. The code is inserted into the KPP output at a
position which is also determined by *inline_type* as shown in
:ref:`table-inl-type`. If two inline commands with the same inline type
are declared, then the contents of the second is appended to the first
one.

.. _list-of-inlined-types:

Expand All @@ -807,8 +807,7 @@ List of inlined types

In this manual, we show the inline types for Fortran90. The inline
types for the other languages are produced by replacing :code:`F90`
by :code:`C`, or :code:`matlab`, respectively, as shown in
:ref:`table-inl-type`:
by :code:`C`, or :code:`matlab`, respectively.

.. _table-inl-type:

Expand Down Expand Up @@ -863,11 +862,9 @@ Inlining code can be useful to introduce additional state variables
(such as temperature, humidity, etc.) for use by KPP routines, such as
for calculating rate coefficients.

If a large number of state variables need to be held in inline code, or
If a large number of state variables needs to be held in inline code, or
require intermediate computation that may be repeated for many rate
coefficients, a derived type object should be used for efficiency.

An example of a derived-type object being included:
coefficients, a derived type object should be used for efficiency, e.g.:

.. code-block:: F90
Expand All @@ -877,21 +874,20 @@ An example of a derived-type object being included:
END TYPE ObjGlobal_t
TYPE(ObjGlobal_t), TARGET, PUBLIC :: ObjGlobal
!$OMP THREADPRIVATE( ObjGlobal )
#ENDINLINE
This global variable :code:`ObjGlobal` can then be used globally in KPP.

Another way to avoid cluttering up the KPP input file is to add global
variables into a header file that can be :code:`#include`-d:
Another way to avoid cluttering up the KPP input file is to
:code:`#include` a header file with global variables:

.. code-block:: F90
#INLINE F90_GLOBAL
! Inline common variables into KPP_ROOT_Global.F90
#include "commonIncludeVars.H"
! Inline common variables into KPP_ROOT_Global.f90
#include "commonIncludeVars.f90"
#ENDINLINE
where extra code is included in a separate file, :code:`commonIncludeVars.H`.

In future versions of KPP, the global state will be reorganized into
derived type objects as well.

Expand All @@ -901,7 +897,7 @@ F90_INIT
--------

This inline type can be used to define initial values before the start of the
integartion, e.g.:
integration, e.g.:

.. code-block:: F90
Expand Down Expand Up @@ -975,15 +971,15 @@ This inline type can be used to define utility subroutines.
Auxiliary files and the substitution preprocessor
=================================================

The `auxiliary files <auxiliary-files-for-fortran-90_>`_ are
templates for integrators, drivers, and utilities. They are inserted
into the KPP output after being run through the substitution
preprocessor. This preprocessor replaces `several placeholder symbols
<list-of-symbols-replaced_>`_ in the template files
with their particular values in the model at hand. Usually, only
:command:`KPP_ROOT` and :command:`KPP_REAL` are needed because the other
values can also be obtained via the variables listed in
:ref:`table-inl-type`.
The `auxiliary files <auxiliary-files-for-fortran-90_>`_ in the
:file:`$KPP_HOME/util` subdirectory are templates for integrators,
drivers, and utilities. They are inserted into the KPP output after
being run through the substitution preprocessor. This preprocessor
replaces `several placeholder symbols <list-of-symbols-replaced_>`_ in
the template files with their particular values in the model at hand.
Usually, only :command:`KPP_ROOT` and :command:`KPP_REAL` are needed
because the other values can also be obtained via the variables listed
in :ref:`table-inl-type`.

:command:`KPP_REAL` is replaced by the appropriate single or double
precision declaration type. Depending on the target language KPP will
Expand All @@ -995,14 +991,15 @@ must be used:
KPP_REAL :: BIG(1000)
When used with the option :code:`DOUBLE on`, the above line will be
When used with the command :command:`#DOUBLE ON`, the above line will be
automatically translated into:

.. code-block:: F90
REAL(kind=dp) :: BIG(1000)
and when used with the option :code:`DOUBLE off`, the same line will become:
and when used with the command :command:`#DOUBLE OFF`, the same line will
become:

.. code-block:: F90
Expand Down Expand Up @@ -1031,9 +1028,6 @@ in the generated Fortran90 output file.
List of auxiliary files for Fortran90
--------------------------------------

KPP inline codes or other instructions contained in the following
files, as shown in :ref:`table-aux-files`.

.. _table-aux-files:

.. table:: Table 2: Auxiliary files for Fortran90
Expand Down Expand Up @@ -1074,9 +1068,6 @@ files, as shown in :ref:`table-aux-files`.
List of symbols replaced by the substitution preprocessor
---------------------------------------------------------

The following symbols in KPP-generated source code will be replaced
with corresponding values, as highlighted in :ref:`table-sym-repl`.

.. _table-sym-repl:

.. table:: Table 3: Symbols and their replacements
Expand Down Expand Up @@ -1119,10 +1110,8 @@ In order to offer more control over the integrator, KPP provides the
arrays :code:`ICNTRL` (integer) and :code:`RCNTRL` (real). Each of them
is an array of 20 elements that allow the fine-tuning of the integrator.
All integrators (except for :code:`tau_leap` and :code:`gillespie`) use
:code:`ICNTRL` and :code:`RCNTRL`. Array elements not listed here are
either not used or are integrator-specific options. Details can be found
in the comment lines of the individual integrator files in
:code:`$KPP_HOME/int/`.
:code:`ICNTRL` and :code:`RCNTRL`. Details can be found in the comment
lines of the individual integrator files in :code:`$KPP_HOME/int/`.

ICNTRL
------
Expand Down
61 changes: 25 additions & 36 deletions docs/source/using_kpp/05_output_from_kpp.rst
Original file line number Diff line number Diff line change
Expand Up @@ -169,8 +169,8 @@ The code to update the rate constants is in :file:`ROOT_Rates.f90` (or
ROOT_Parameters
---------------

The global parameters listed in :ref:`table-par` are defined and
initialized in :file:`ROOT_Parameters.f90` (or :file:`.F90`).
Global parameters are defined and initialized in
:file:`ROOT_Parameters.f90` (or :file:`.F90`):

.. _table-par:

Expand Down Expand Up @@ -231,8 +231,8 @@ Hessian, etc.
ROOT_Global
-----------

The global variables listed in :ref:`table-glob` are declared in
:file:`ROOT_Global.f90` (or :file:`.F90`).
Several global variables are declared in :file:`ROOT_Global.f90` (or
:file:`.F90`):

.. _table-glob:

Expand All @@ -246,27 +246,27 @@ The global variables listed in :ref:`table-glob` are declared in
+-------------------------+---------------------------------------------+
| :code:`VAR(:)` | Concentrations, variable species (pointer) |
+-------------------------+---------------------------------------------+
| :code:`FIX(:)` | Concentrations, fixed species (pointer) |
| :code:`FIX(:)` | Concentrations, fixed species (pointer) |
+-------------------------+---------------------------------------------+
| :code:`RCONST(NREACT)` | Rate coefficient values |
| :code:`RCONST(NREACT)` | Rate coefficient values |
+-------------------------+---------------------------------------------+
| :code:`TIME` | Current integration time |
| :code:`TIME` | Current integration time |
+-------------------------+---------------------------------------------+
| :code:`SUN` | Sun intensity between 0 and 1 |
| :code:`SUN` | Sun intensity between 0 and 1 |
+-------------------------+---------------------------------------------+
| :code:`TEMP` | Temperature |
| :code:`TEMP` | Temperature |
+-------------------------+---------------------------------------------+
| :code:`TSTART, TEND` | Simulation start/end time |
| :code:`TSTART, TEND` | Simulation start/end time |
+-------------------------+---------------------------------------------+
| :code:`DT` | Simulation step |
| :code:`DT` | Simulation time step |
+-------------------------+---------------------------------------------+
| :code:`ATOL(NSPEC)` | Absolute tolerances |
| :code:`ATOL(NSPEC)` | Absolute tolerances |
+-------------------------+---------------------------------------------+
| :code:`RTOL(NSPEC)` | Relative tolerances |
| :code:`RTOL(NSPEC)` | Relative tolerances |
+-------------------------+---------------------------------------------+
| :code:`STEPMIN` | Lower bound for time step |
| :code:`STEPMIN` | Lower bound for time step |
+-------------------------+---------------------------------------------+
| :code:`STEPMAX` | Upper bound for time step |
| :code:`STEPMAX` | Upper bound for time step |
+-------------------------+---------------------------------------------+
| :code:`CFACTOR` | Conversion factor |
+-------------------------+---------------------------------------------+
Expand Down Expand Up @@ -420,7 +420,7 @@ The Jacobian matrix for our example contains 18 non-zero elements:
It defines how the temporal change of each chemical species depends on
all other species. For example, :math:`\mathbf{J}(5,2)` shows that :math:`NO_2`
(species number 5) is affected by :math:`O` (species number 2) via
reaction number R9. The sparse data structures for the Jacobian are
reaction R9. The sparse data structures for the Jacobian are
declared and initialized in :file:`ROOT_JacobianSP.f90` (or
:file:`.F90`). The code for the ODE Jacobian and
sparse multiplications is in :file:`ROOT_Jacobian.f90` (or
Expand All @@ -432,15 +432,14 @@ sparse multiplications is in :file:`ROOT_Jacobian.f90` (or
:command:`#JACOBIAN SPARSE_LU_ROW` to the KPP definition file will
create the file :file:`ROOT_JacobianSP.f90` (or :file:`.F90`).

The Jacobian of the ODE function is automatically constructed by
KPP. KPP generates the Jacobian subroutine :code:`Jac` or
:code:`JacSP` where the latter is generated when the sparse format is
required. Using the variable species :code:`V`, the fixed
species :code:`F`, and the rate coefficients :code:`RCT` as input, the
subroutine calculates the Jacobian :code:`JVS`. The default data
structures for the sparse compressed on rows Jacobian
representation are shown in :ref:`table-jac` (for the case where the LU fill-in
is accounted for).
The Jacobian of the ODE function is automatically constructed by KPP.
KPP generates the Jacobian subroutine :code:`Jac` or :code:`JacSP` where
the latter is generated when the sparse format is required. Using the
variable species :code:`V`, the fixed species :code:`F`, and the rate
coefficients :code:`RCT` as input, the subroutine calculates the
Jacobian :code:`JVS`. The default data structures for the sparse
compressed on rows Jacobian representation (for the case where the LU
fill-in is accounted for) are:

.. _table-jac:

Expand Down Expand Up @@ -530,16 +529,6 @@ in :file:`ROOT_Hessian.f90` (or :file:`.F90`). The Hessian
function and associated sparse multiplications are in
:code:`ROOT_HessianSP.f90` (or :code:`.F90`).

.. tip::

Adding :command:`#HESSIAN ON` to the KPP definition file will
create the file :file:`ROOT_Hessian.f90` (or :file:`.F90`)

Additionally, if either :command:`#JACOBIAN SPARSE ROW` or
:command:`#JACOBIAN SPARSE_LU_ROW` are also added to the KPP
definition file, the file :file:`ROOT_HessianSP.f90` (or
:file:`.F90`) will also be created.

The Hessian contains the second order derivatives of the time derivative
functions. More exactly, the Hessian is a 3-tensor such that

Expand All @@ -549,7 +538,7 @@ functions. More exactly, the Hessian is a 3-tensor such that
\qquad 1 \le i,j,k \le N_{\rm var}~.
\label{eqn:Hessian1}
KPP generates the routine :code:`Hessian` (see :ref:`table-hess-fun`) below:
KPP generates the routine :code:`Hessian`:

.. _table-hess-fun:

Expand Down

0 comments on commit 18f4955

Please sign in to comment.