Equation¶
User API to specify equations.

class
devito.equation.
Eq
[source]¶ Bases:
sympy.core.relational.Equality
An equal relation between two objects, the lefthand side and the righthand side.
The lefthand side may be a Function or a SparseFunction. The righthand side may be any arbitrary expressions with numbers, Dimensions, Constants, Functions and SparseFunctions as operands.
Parameters:  lhs (Function or SparseFunction) – The lefthand side.
 rhs (exprlike, optional) – The righthand side. Defaults to 0.
 subdomain (SubDomain, optional) – To restrict the computation of the Eq to a particular subregion in the computational domain.
 coefficients (Substitutions, optional) – Can be used to replace symbolic finite difference weights with user defined weights.
 implicit_dims (Dimension or list of Dimension, optional) – An ordered list of Dimensions that do not explicitly appear in either the lefthand side or in the righthand side, but that should be honored when constructing an Operator.
Examples
>>> from devito import Grid, Function, Eq >>> grid = Grid(shape=(4, 4)) >>> f = Function(name='f', grid=grid) >>> Eq(f, f + 1) Eq(f(x, y), f(x, y) + 1)
Any SymPy expressions may be used in the righthand side.
>>> from sympy import sin >>> Eq(f, sin(f.dx)**2) Eq(f(x, y), sin(f(x, y)/h_x  f(x + h_x, y)/h_x)**2)
Notes
An Eq can be thought of as an assignment in an imperative programming language (e.g.,
a[i] = b[i]*c
).
subdomain
¶ The SubDomain in which the Eq is defined.

class
devito.equation.
Inc
[source]¶ Bases:
devito.equation.Eq
An increment relation between two objects, the lefthand side and the righthand side.
Parameters:  lhs (Function or SparseFunction) – The lefthand side.
 rhs (exprlike) – The righthand side.
 subdomain (SubDomain, optional) – To restrict the computation of the Eq to a particular subregion in the computational domain.
 coefficients (Substitutions, optional) – Can be used to replace symbolic finite difference weights with user defined weights.
 implicit_dims (Dimension or list of Dimension, optional) – An ordered list of Dimensions that do not explicitly appear in either the lefthand side or in the righthand side, but that should be honored when constructing an Operator.
Examples
Inc may be used to express tensor contractions. Below, a summation along the userdefined Dimension
i
.>>> from devito import Grid, Dimension, Function, Inc >>> grid = Grid(shape=(4, 4)) >>> x, y = grid.dimensions >>> i = Dimension(name='i') >>> f = Function(name='f', grid=grid) >>> g = Function(name='g', shape=(10, 4, 4), dimensions=(i, x, y)) >>> Inc(f, g) Inc(f(x, y), g(i, x, y))
Notes
An Inc can be thought of as the augmented assignment ‘+=’ in an imperative programming language (e.g.,
a[i] += c
).

devito.equation.
solve
(eq, target, **kwargs)[source]¶ Algebraically rearrange an Eq w.r.t. a given symbol.
This is a wrapper around
sympy.solve
.Parameters:  eq (exprlike) – The equation to be rearranged.
 target (symbol) – The symbol w.r.t. which the equation is rearranged. May be a Function or any other symbolic object.
 **kwargs – Symbolic optimizations applied while rearranging the equation. For more
information. refer to
sympy.solve.__doc__
.