Function

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

Used in combination with Module to specify the python function containing the “%(Quantity)s”- tensor 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 Python tuple or, preferable, a NumPy array of the appropriate shape (%(Quantity)s is a %(ValueType)s) and must accept a single argument which is a dictionary containing the parameters as defined by the Parameter sections:

# import numpy package
from numpy import *

def your_function_name(parameter):
   x = parameter['X'] # retrieving the position

   # add your code here

   return value # returns a  %(ValueType)s

Note

The position \pvec{x} and the time t are implicitly inserted into the parameter dictionary with keys X and t respectively. For time-harmonic electromagnetic problems the angular frequency \omega is inserted with key EMOmega, if uniquely defined (EM stands for “electromagnetic”).

expression as shown in Expression.

The used Python function may have the following form:

from numpy import *

def ThermoOpticalCorrection(parameter):
  T0 = parameter['T0'] # retrieving T0
  a = parameter['a'] # retrieving a
  w = parameter['EMOmega'] # retrieving omega
  return a*eye(3, 3)*(T-T0)