Expression¶
This parameter is used to define a tensor field of type “electric field strength” by means of a Python expression within the .jcm input file. The syntax is the following:
ElectricFieldStrength {
Python {
Expression = " ... # your python scripting
...
value = ... # set return value
"
# define one or more parameters
Parameter {
Name = "Para1"
...
}
Parameter {
Name = "Para2"
...
}
}
}
The string value Expression has to be valid Python code and is interpreted in the following way:
The NumPy-package is automatically imported when evaluating the expression.
Any parameter as defined by a
Parametersection is available within the Python expression as an NumPy object named accordingly to the value of the parameter Name.The position
and the time
are available as NumPy objects name Xandtrespectively.For time-harmonic electromagnetic problems the angular frequency
can be addressed by EMOmega, (EMstands for electromagnetic).The expression must define a NumPy object named
valuewhich contains the return value of appropriate shape (electric field strength is a 3-vector).Keep in mind the Python indentation rule.
As a practical example we want to define a plane wave with amplitude
and wave vector
:

This tensor field has the complex-valued vector parameters
and
. The inline Python definition may look like this:
ElectricFieldStrength {
Python {
Expression = "value = exp(1j*dot(k.T, X))*A"
Parameter {
Name = "k"
VectorValue = ... # set wave vector here
}
Parameter {
Name = "A"
VectorValue = ... # set amplitude vector here
}
}
}
We give more elaborated examples with field parameter dependencies in