Shapefunctions

The shapefunctions module contains generic shapefunctions that can be used to approximate distributed systems without giving any information about the systems themselves. This is achieved by projecting them on generic, piecewise smooth functions.

Shapefunction Types

class LagrangeFirstOrder(start, top, end, **kwargs)[source]

Bases: pyinduct.core.Function

Lagrangian shape functions of order 1.

Parameters:
  • start – start node
  • top – top node, where f(x) = 1
  • end – end node
Keyword Arguments:
 
  • half
  • right_border
  • left_border

Example plot of the functions funcs generated with

>>> nodes, funcs = cure_interval(LagrangeFirstOrder, (0, 1), node_count=7)
../_images/lag1st_order.png
static cure_hint(domain, **kwargs)[source]

Hint function that will cure the given interval with LagrangeFirstOrder.

Parameters:domain (pyinduct.simulation.Domain) – domain to be cured
Returns:(domain, funcs), where funcs is set of LagrangeFirstOrder shapefunctions.
Return type:tuple
class LagrangeSecondOrder(start, mid, end, **kwargs)[source]

Bases: pyinduct.core.Function

Lagrangian shape functions of order 2.

Parameters:
  • start – start node
  • mid – middle node, where f(x) = 1
  • end – end node
Keyword Arguments:
 
  • curvature (str) – “concave” or “convex”
  • half (str) – Generate only “left” or “right” half.

Example plot of the functions funcs generated with

>>> nodes, funcs = cure_interval(LagrangeSecondOrder, (0, 1), node_count=7)
../_images/lag2nd_order.png
static cure_hint(domain, **kwargs)[source]

Hint function that will cure the given interval with LagrangeSecondOrder.

Parameters:domain (pyinduct.simulation.Domain) – domain to be cured
Returns:(domain, funcs), where funcs is set of LagrangeSecondOrder shapefunctions.
Return type:tuple

Curing an Interval

All classes contained in this module can easily be used to cure a given interval. For example let’s approximate the interval from z=0 to z=1 with 3 piecewise linear functions:

>>> nodes, funcs = cure_interval(LagrangeFirstOrder, (0, 1), node_count=3)

The approximation nodes of the functions are chosen automatically:

>>> list(nodes)
[0.0, 0.5, 1.0]
cure_interval(shapefunction_class, interval, node_count=None, node_distance=None, **kwargs)[source]

Use shape functions to cure an interval with either node_count nodes or nodes with node_distance.

Parameters:
  • shapefunction_class – Class to cure the interval (e.g. LagrangeFirstOrder). The given class has to provide a cure_hint().
  • interval (tuple) – Limits that constrain the interval.
  • node_count (int) – Amount of nodes to use.
  • node_distance (numbers.Number) – Distance of nodes.

Note

Either node_count or node_node_distance can be specified. If both are given and are not consistent, an exception will be raised by pyinduct.simulation.Domain .

Raises:TypeError – If given class does not provide a static cure_hint() method.
Returns:(domain, funcs): Where domain is a pyinduct.simulation.Domain instance and funcs is a list of (e.g. LagrangeFirstOrder) shapefunctions.
Return type:tuple