Placeholder¶
In pyinduct.placeholder you find placeholders for symbolic Term
definitions.
-
class
FieldVariable(function_label, order=(0, 0), weight_label=None, location=None, exponent=1, raised_spatially=False)[source]¶ Bases:
pyinduct.placeholder.PlaceholderClass that represents terms of the systems field variable
.Parameters: - function_label (str) – Label of shapefunctions to use for approximation,
see
register_base()for more information about how to register an approximation basis. - tuple of int (order) – Tuple of temporal_order and spatial_order derivation order.
- weight_label (str) – Label of weights for which coefficients are to be calculated (defaults to function_label).
- location – Where the expression is to be evaluated.
- exponent – Exponent of the term.
Examples
Assuming some shapefunctions have been registered under the label
"phi"the following expressions hold:>>> x_dtdz = FieldVariable("phi", order=(1, 1))
>>> x_ddt_at_3 = FieldVariable("phi", order=(2, 0), location=3)
>>> x_dt_squared = FieldVariable("phi", order=(1, 0), exponent=2)
- function_label (str) – Label of shapefunctions to use for approximation,
see
-
class
TestFunction(function_label, order=0, location=None)[source]¶ Bases:
pyinduct.placeholder.SpatialPlaceholderClass that works as a placeholder for test-functions in an equation.
Parameters: - function_label (str) –
- order (int) –
- location –
-
class
Scalars(values, target_term=None, target_form=None)[source]¶ Bases:
pyinduct.placeholder.PlaceholderPlaceholder for scalar values that scale the equation system, gained by the projection of the pde onto the test basis.
Note
The arguments target_term and target_form are used inside the parser. For frontend use, just specify the values.
Parameters: - values – Iterable object containing the scalars for every k-th equation.
- target_term – Coefficient matrix to
add_to(). - target_form – Desired weight set.
-
class
ScalarFunction(function_label, order=0, location=None)[source]¶ Bases:
pyinduct.placeholder.SpatialPlaceholderClass that works as a placeholder for spatial functions in an equation. An example could be spatial dependent coefficients.
Parameters: - function_label (str) – label under which the function is registered
- order (int) – spatial derivative order to use
- location – location to evaluate at
- Warn:
- There seems to be a problem when this function is used in combination
with the
Productclass. Make sure to provide this class as first argument to any product you define.
Todo
see warning.
-
static
from_scalar(scalar, label, **kwargs)[source]¶ create a
ScalarFunctionfrom scalar values.Parameters: - scalar (array like) – Input that is used to generate the
placeholder. If a number is given, a constant function will be
created, if it is callable it will be wrapped in a
Functionand registered. - label (string) – Label to register the created base.
- **kwargs – All kwargs that are not mentioned below will be passed
to
Function.
Keyword Arguments: - order (int) – See constructor.
- location (int) – See constructor.
- overwrite (bool) – See
register_base()
Returns: Placeholder object that can be used in a weak formulation.
Return type: - scalar (array like) – Input that is used to generate the
placeholder. If a number is given, a constant function will be
created, if it is callable it will be wrapped in a
-
class
Input(function_handle, index=0, order=0, exponent=1)[source]¶ Bases:
pyinduct.placeholder.PlaceholderClass that works as a placeholder for an input of the system.
Parameters: - function_handle (callable) – Handle that will be called by the simulation unit.
- index (int) – If the system’s input is vectorial, specify the element to be used.
- order (int) – temporal derivative order of this term
(See
Placeholder). - exponent (numbers.Number) – See
FieldVariable.
Note
if order is nonzero, the callable is expected to return the temporal derivatives of the input signal by returning an array of
len(order)+1.
-
class
ScalarTerm(argument, scale=1.0)[source]¶ Bases:
pyinduct.placeholder.EquationTermClass that represents a scalar term in a weak equation.
Parameters: - argument –
- scale –
-
class
IntegralTerm(integrand, limits, scale=1.0)[source]¶ Bases:
pyinduct.placeholder.EquationTermClass that represents an integral term in a weak equation.
Parameters: - integrand –
- limits (tuple) –
- scale –
-
class
Placeholder(data, order=(0, 0), location=None)[source]¶ Bases:
objectBase class that works as a placeholder for terms that are later parsed into a canonical form.
Parameters: - data (arbitrary) – data to store in the placeholder.
- order (tuple) – (temporal_order, spatial_order) derivative orders that are to be applied before evaluation.
- location (numbers.Number) – Location to evaluate at before further computation.
Todo
convert order and location into attributes with setter and getter methods. This will close the gap of unchecked values for order and location that can be sneaked in by the copy constructors by circumventing code doubling.
-
derivative(temp_order=0, spat_order=0)[source]¶ Mimics a copy constructor and adds the given derivative orders.
Note
The desired derivative order
orderis added to the original order.Parameters: - temp_order – Temporal derivative order to be added.
- spat_order – Spatial derivative order to be added.
Returns: New
Placeholderinstance with the desired derivative order.


