FunctionΒΆ

Type:string
Range:[]
Default:-/-
Appearance:simple
Excludes:Expression

Used in combination with Module to specify the python function containing the surface density field definition.

In the most simple case a Python module is a .py-file which contains one or several python function definition. In this case the name of the module is simply the file name without its .py suffix. The parameter Function is used to pick out the desired function.

The so specified Python function must return a scalar and must accept a single argument which is a dictionary containing the parameters as defined by the Parameter sections.

The syntax is identical to a Python based definition of a source field, see for example the section Function for the definition of an electric field intensity.

The post-process may be defined as follows:

SurfaceDensityIntegration {
  FieldBagPath = ...
  OutputFileName = ...
  InterfaceType = ...
  Module = "PythonTensorFieldLibrary"
  Function = "PoyntingVector"
  Python {
    IntegralName = "ElectromagneticEnergyFlux"

    Parameter {
      Name = "E"
      FieldValue {
        Quantity = ElectricFieldStrength
      }
    }
    Parameter {
      Name = "H"
      FieldValue {
        Quantity = MagneticFieldStrength
      }
    }
  }
}

In the above, the tag FieldBagPath defines the underlying fieldbag which supplies the meshing for integration. When the underlying fieldbag contains more than one electromagnetic fields, JCMsolve computes all fluxes separately. When choosing InterfaceType=ExteriorDomain the scattered fields \VField{E}_{\scat} and \VField{H}_{\scat} are passed on the interior-exterior domain interfaces.

The used Python function may have the following form:

from numpy import *

def ElectricEnergyDensity(parameter):
  E = parameter['E'] # retrieving the E-field vector
  H = parameter['E'] # retrieving the H-field vector
  return 0.5*cross(E, H)

As a second example, we want to compute overlap integrals of the form

\begin{eqnarray*}
S_{kl} & = & \int_{\Omega_{i}^{(2D)}} \frac{1}{2} \VField{E}_k  \cdot  \VField{H}^{*}_l
\end{eqnarray*}

on the cross-section domains of a two-dimensional problem with an infinite z-direction. This requires to set InterfaceType=CrossSection.

This example involves two fieldbags: One fieldbag delivers the electric field \VField{E}, the other the magnetic field \VField{H}. The two fieldbags may coincide. The JCM input snippet for this example looks like this:

SurfaceDensityIntegration {
  FieldBagPath = ... # path to first fieldbag
  OutputFileName = ...
  InterfaceType = CrossSection
  Python {
    IntegralName = "OverlapCrossSectionEnergyFlux"
    Module = "PythonTensorFieldLibrary"
    Function = "PoyntingVector"

    Parameter {
      Name = "E"
      FieldValue {
        Quantity = ElectricFieldStrength
      }
    }
    Parameter {
      Name = "H"
      FieldValue {
        FieldBagPath = ... # path to second fieldbag
        Quantity = MagneticFieldStrength
      }
    }
  }
}

The Python code is identical to the previous example. However, the field index of the \VField{E}-field parameter runs with the first integral index k, where as the field index of the \VField{H}-fields runs with the second integral index l. This way the overlap flux integrals of all \VField{E}-fields in the first fieldbag with all \VField{H}-fields in the second fieldbag are computed.