PythonΒΆ

Type:section
Appearance:simple
Excludes:OutputQuantity

This section is used to define a density expression by means of a Python script. JCMsuite comes with a Python interpreter, therefore an installation of Python is not required.

Note

Since Version 4.4 JCMsuite uses Python 3.9 as available from http://www.python.org. It further includes the NumPy-package, see http://www.scipy.org.

The Python script based integrand definition is very flexible and general, since it is possible to define parameter-dependent expressions. These parameters may not only contain user-defined fixed values, but may also describe dependencies on tensor fields. Furthermore, it offers a simple way to compute mutual overlap integrals.

To explain this in more detail, let us denote the density - tensor field we want to define by \mathcal{D} (\pvec{x}, t), where \pvec{x} is the position vector and t is the time. The density - tensor field which may depend on the values of other tensor fields \TField{t}_1, \TField{t}_2, \dots, \TField{t}_n at the same position (\pvec{x}, t) is described as:

\begin{eqnarray*}
\mathcal{D} (\pvec{x}, t) & = &  {\tt{python\_script}} \left( \pvec{x}, t, \TField{t}_1(\pvec{x}, t), \TField{t}_2(\pvec{x}, t), \dots, \TField{t}_n(\pvec{x}, t) \right)
\end{eqnarray*}

The Python script \tt{python\_script} is provided by the user. There are two options to do this:

  1. Inline definition of a python expression directly within the post-process file, see section Expression.
  2. Reference to a function contained in a python module, see section Function.

The argument values \TField{t}_1, \TField{t}_2, \dots, \TField{t}_n as well as the positions (\pvec{x}, t) should be passed from JCMsolve to the python script when evaluating the density field. For being able to do this, the user has to inform JCMsolve which parameters are actually needed. In the words of a computer programming language the user has to specify the signature of the python script. This is done by filling the Parameter section.

JCMsolve computes the integral values for each physical domain \Omega_i separately (i is the domain index):

\begin{eqnarray*}
I_{\Omega_i} & = &  \int_{\Omega_i} \mathcal{D}(\pvec{x}, t)\dd \pvec{x}
\end{eqnarray*}

A tensor field parameter is ambiguous when imported from a JCM fieldbag which contains more than one field of the desired type. In this case, JCMsolve should compute the integral values for each field separately. This necessitates an additional integral index.

More generally, we allow for more than one integral indices to compute mutual overlap integrals. For each tensor field parameter \TField{t}_k one specifies which integral index runs with the field index:

\begin{eqnarray*}
I_{\Omega_i; k,l} & = &  \int_{\Omega_i} {\tt{python\_script}} \left( \pvec{x}, t, \TField{t}_1^{(k)}, \TField{t}_2^{(l)}, \dots) \right) \dd \pvec{x}
\end{eqnarray*}

Here, the super indices (k) and (l) denote the field index of the tensor field parameters. In the above, the field index of the first tensor field parameter \TField{t}_1 runs with the first integral index l, whereas the field index of \TField{t}_2 runs with the second index k.