Coefficient(self, deriv_order, function, dimension, weights)

Prepare custom coefficients to pass to a Substitutions object.


Name Type Description Default
deriv_order int The order of the derivative being taken. required
function Function The function for which the supplied coefficients will be used. required
dimension Dimension The dimension with respect to which the derivative is being taken. required
weights numpy.numpy.ndarray The set of finite difference weights intended to be used in place of the standard weights (obtained from a Taylor expansion). required


>>> import numpy as np
>>> from devito import Grid, Function, Coefficient
>>> grid = Grid(shape=(4, 4))
>>> u = Function(name='u', grid=grid, space_order=2, coefficients='symbolic')
>>> x, y = grid.dimensions

Now define some partial d/dx FD coefficients of the Function u:

>>> u_x_coeffs = Coefficient(1, u, x, np.array([-0.6, 0.1, 0.6]))

And some partial d2/dy2 FD coefficients:

>>> u_y2_coeffs = Coefficient(2, u, y, np.array([0.0, 0.0, 0.0]))


Name Description
deriv_order The derivative order.
dimension The dimension to which the coefficients will be applied.
function The function to which the coefficients belong.
index The dimension to which the coefficients will be applied plus the offset
weights The set of weights.
Back to top