sympde.expr package

Submodules

sympde.expr.basic module

class sympde.expr.basic.BasicExpr(*args)[source]

Bases: Expr

property constants
default_assumptions = {}
property fields
is_Function = True
is_bilinear = False
is_functional = False
is_linear = False
class sympde.expr.basic.BasicForm(*args)[source]

Bases: Expr

property constants
default_assumptions = {}
property domain
property fields
get_free_variables()[source]
is_Function = True
is_bilinear = False
is_functional = False
is_linear = False
is_norm = False
property ldim

sympde.expr.equation module

class sympde.expr.equation.BasicBoundaryCondition(*args)[source]

Bases: Basic

default_assumptions = {}
class sympde.expr.equation.BasicConstraint(*args)[source]

Bases: Basic

default_assumptions = {}
class sympde.expr.equation.Equation(lhs, rhs, trials, tests, bc=None, constraint=None)[source]

Bases: Basic

property bc
property constraint
default_assumptions = {}
property lhs
property rhs
property test_functions
property trial_functions
class sympde.expr.equation.EssentialBC(lhs, rhs, boundary, position=None, index_component=None)[source]

Bases: BasicBoundaryCondition

property boundary
default_assumptions = {}
property index_component
property lhs
property normal_component
property order
property position
property rhs
set_position(value)[source]
property variable
class sympde.expr.equation.Mean(lhs, rhs)[source]

Bases: BasicConstraint

default_assumptions = {}
property lhs
property rhs
class sympde.expr.equation.NewtonIteration(form, fields, bc=None, trials=None)[source]

Bases: Equation

default_assumptions = {}
sympde.expr.equation.find(trials, *, forall, lhs, rhs, bc=None, constraint=None)[source]

sympde.expr.errors module

exception sympde.expr.errors.UnconsistentArgumentsError(*args, **kwargs)[source]

Bases: UnconsistentError

exception sympde.expr.errors.UnconsistentBCError(*args, **kwargs)[source]

Bases: UnconsistentError

exception sympde.expr.errors.UnconsistentError(*args, **kwargs)[source]

Bases: Exception

exception sympde.expr.errors.UnconsistentLhsError(*args, **kwargs)[source]

Bases: UnconsistentError

exception sympde.expr.errors.UnconsistentLinearExpressionError(*args, **kwargs)[source]

Bases: UnconsistentError

exception sympde.expr.errors.UnconsistentRhsError(*args, **kwargs)[source]

Bases: UnconsistentError

sympde.expr.evaluation module

class sympde.expr.evaluation.Advection(axis, weight=1)[source]

Bases: Basic1dForm

default_assumptions = {}
class sympde.expr.evaluation.AdvectionT(axis, weight=1)[source]

Bases: Basic1dForm

default_assumptions = {}
class sympde.expr.evaluation.Basic1dForm(name, axis, weight=1)[source]

Bases: AtomicExpr

property axis
default_assumptions = {}
property name
property weight
class sympde.expr.evaluation.Bilaplacian(axis, weight=1)[source]

Bases: Basic1dForm

default_assumptions = {}
class sympde.expr.evaluation.BoundaryExpression(target, expr)[source]

Bases: KernelExpression

default_assumptions = {}
class sympde.expr.evaluation.DomainExpression(target, expr)[source]

Bases: KernelExpression

default_assumptions = {}
class sympde.expr.evaluation.InterfaceExpression(target, u, v, expr)[source]

Bases: KernelExpression

default_assumptions = {}
property test
property trial
class sympde.expr.evaluation.KernelExpression(target, expr)[source]

Bases: Basic

A generic SymPDE expression expr defined over the target domain. This is a lightweight object which stores just the input values. In addition, if the expression is a 1x1 matrix, the content of its only entry is taken.

Parameters

targetBasicDomain (from sympde.topology.basic)

The domain in which the expression is defined. This may be a Domain, a Boundary, an Interface, or an object of any subclasses.

exprExpr (from sympy)

The mathematical expression.

default_assumptions = {}
property expr
property target
class sympde.expr.evaluation.Mass(axis, weight=1)[source]

Bases: Basic1dForm

default_assumptions = {}
class sympde.expr.evaluation.Stiffness(axis, weight=1)[source]

Bases: Basic1dForm

default_assumptions = {}
class sympde.expr.evaluation.TensorExpr(*_args, **kwargs)[source]

Bases: CalculusFunction

default_assumptions = {}
classmethod eval(*_args, **kwargs)[source]

.

class sympde.expr.evaluation.TerminalExpr(expr, domain)[source]

Bases: CalculusFunction

This class takes a SymPDE expression and transforms its vector operators into atomic ones for a specified domain.

Parameters

exprExpr or Matrix or ImmutableDenseMatrix or LogicalExpr

The mathematical expression.

domainBasicDomain (from sympde.topology.basic)

The domain in which the expression is defined. This may be a Domain, a Boundary, an Interface, or an object of any subclasses.

evaluatebool, optional

Whether the input expression should be evaluated (default = True).

Returns

Expr | tuple[Expr] | TerminalExpr

The atomized expression. A tuple of expressions is returned in the case of expr being a BasicForm (i.e. a BilinearForm, LinearForm, or Functional), as the domain could contain multiple patches. The transformation applied to the input argument expr depends on its exact type. If expr does not match any of the specific isinstance checks, the input object is returned unchanged.

default_assumptions = {}
property domain
classmethod eval(expr, domain)[source]

Process the whole AST of expr to generate a new expression where the vector operators have been replaced by atomic operators. The input domain is used to determine essential information like the number of dimensions, the coordinate variables, the boundary orientation, etc.

Parameters

exprExpr (from sympy)

The mathematical expression.

domainBasicDomain (from sympde.topology.basic)

The domain in which the expression is defined. This may be a Domain, a Boundary, an Interface, or an object of any subclasses.

Returns

Expr | tuple[Expr] | TerminalExpr

The atomized expression. A tuple of expressions is returned in the case of expr being a BasicForm (i.e. a BilinearForm, LinearForm, or Functional), as the domain could contain multiple patches. An unevaluated TerminalExpr object (which only stores its arguments) is returned if evaluate is False.

property expr
sympde.expr.evaluation.is_sequence(a)[source]

sympde.expr.expr module

class sympde.expr.expr.BilinearForm(arguments, expr, check_linearity=True, ignore_linearity_errors=False, **options)[source]

Bases: BasicForm

property coordinates
default_assumptions = {}
property domain
property expr
is_bilinear = True
property is_symmetric
property ldim
property test_functions
property test_spaces
property trial_functions
property trial_spaces
property variables
class sympde.expr.expr.Functional(expr, domain, evaluate=True, **options)[source]

Bases: BasicForm

property coordinates
default_assumptions = {}
property domain
property expr
is_functional = True
property space
class sympde.expr.expr.IntAdd(*args, **options)[source]

Bases: Add

default_assumptions = {}
class sympde.expr.expr.Integral(*args)[source]

Bases: CalculusFunction

default_assumptions = {}
property domain
property expr
is_boundary_integral = None
is_domain_integral = None
is_interface_integral = None
classmethod subs_boundary_expr(expr, domain)[source]
class sympde.expr.expr.LinearExpr(arguments, expr, **options)[source]

Bases: BasicExpr

default_assumptions = {}
property expr
is_linear = True
property variables
class sympde.expr.expr.LinearForm(arguments, expr, check_linearity=True, ignore_linearity_errors=False, **options)[source]

Bases: BasicForm

property coordinates
default_assumptions = {}
property domain
property expr
is_linear = True
property ldim
property test_functions
property test_spaces
property variables
class sympde.expr.expr.Norm(expr, domain, kind='l2', evaluate=True, **options)[source]

Bases: Functional

default_assumptions = {}
property exponent
is_norm = True
property kind

Default kind for all SymPy object. If the kind is not defined for the object, or if the object cannot infer the kind from its arguments, this will be returned.

Examples

>>> from sympy import Expr
>>> Expr().kind
UndefinedKind
class sympde.expr.expr.SemiNorm(expr, domain, kind='l2', evaluate=True, **options)[source]

Bases: Functional

default_assumptions = {}
property exponent
is_norm = True
property kind

Default kind for all SymPy object. If the kind is not defined for the object, or if the object cannot infer the kind from its arguments, this will be returned.

Examples

>>> from sympy import Expr
>>> Expr().kind
UndefinedKind
sympde.expr.expr.add_int(expr)[source]
sympde.expr.expr.expand(expr)[source]

Expand an expression by making sure that Mul objects are evaluated by using the * operator (which might be overloaded by the types in the expression).

sympde.expr.expr.integral(domain, expr)[source]
sympde.expr.expr.is_linear_expression(expr, args, debug=True)[source]

Checks if expression is linear with respect to each argument in args:

  1. Additivity: f(x + y) = f(x) + f(y)

  2. Homogeneity: f(alpha * x) = alpha * f(x)

In general, f may have an arbitrary number of arguments: x and y represent independent copies of the same list of arguments.

Parameters

exprExpr

Symbolic expression to test.

argsiterable

Arguments with respect to which expr is tested for linearity. Only one instance of each argument needs to be provided; the function internally creates the independent copies required for the additivity and homogeneity checks. Each argument must be ScalarFunction or VectorFunction.

debugbool, optional

Print diagnostic info if a check fails.

Returns

bool

True if the expression is linear with respect to all given arguments, False otherwise.

sympde.expr.expr.linearize(form, fields, trials=None)[source]

Parameters

formLinearForm

Linear form F(v; u) to be linearized. F is nonlinear in the parameter u

fields{Scalar|Vector}Function or tuple

Function u with respect to which F should be differentiated. Tuple if element of ProductSpace.

trials{Scalar|Vector}Function or tuple

Trial function to be used in resulting bilinear form.

Results

aBilinearForm

a(u, v) is bilinear form obtained from linearization of F(v; u).

sympde.expr.expr.mul_add(expr)[source]
sympde.expr.expr.mul_integral(expr)[source]

Module contents