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.Placeholder

Class that represents terms of the systems field variable x(z, t).

Note

Use TemporalDerivedFieldVariable and SpatialDerivedFieldVariable if no mixed derivatives occur.

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:

  • \frac{\partial^{2}}{\partial t \partial z}x(z, t)
>>> x_dtdz = FieldVariable("phi", order=(1, 1))
  • \frac{\partial^2}{\partial t^2}x(3, t)
>>> x_ddt_at_3 = FieldVariable("phi", order=(2, 0), location=3)
  • \frac{\partial}{\partial t}x^2(z, t)
>>> x_dt_squared = FieldVariable("phi", order=(1, 0), exponent=2)
class TestFunction(function_label, order=0, location=None)[source]

Bases: pyinduct.placeholder.SpatialPlaceholder

Class 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.Placeholder

Placeholder 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.SpatialPlaceholder

Class 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 Product class. 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 ScalarFunction from 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 Function and 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:

ScalarFunction

class Input(function_handle, index=0, order=0, exponent=1)[source]

Bases: pyinduct.placeholder.Placeholder

Class 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 has to provide the temporal derivatives.

class Product(a, b=None)[source]

Bases: object

Represents a product.

Parameters:
  • a
  • b
get_arg_by_class(cls)[source]

Extract element from product that is an instance of cls.

Parameters:cls
Returns:
Return type:list
class ScalarTerm(argument, scale=1.0)[source]

Bases: pyinduct.placeholder.EquationTerm

Class that represents a scalar term in a weak equation.

Parameters:
  • argument
  • scale
class IntegralTerm(integrand, limits, scale=1.0)[source]

Bases: pyinduct.placeholder.EquationTerm

Class that represents an integral term in a weak equation.

Parameters:
  • integrand
  • limits (tuple) –
  • scale
class Placeholder(data, order=(0, 0), location=None)[source]

Bases: object

Base 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.

derive(temp_order=0, spat_order=0)[source]

Mimics a copy constructor and adds the given derivative orders.

Note

The desired derivative order order is added to the original order.

Parameters:
  • temp_order – Temporal derivative order to be added.
  • spat_order – Spatial derivative order to be added.
Returns:

New Placeholder instance with the desired derivative order.