Inner products module

Inner products definition module

Module containing classes to define the inner products used by the model.

Main classes

class layercake.inner_products.definition.InnerProductDefinition[source]

Bases: ABC

Base class to define the model’s basis inner products.

abstract inner_product(S, G)[source]

Definition of the inner product \((S, G)\).

Parameters:
  • S – Left-hand side function of the product.

  • G – Right-hand side function of the product.

Returns:

The result of the inner product.

Return type:

res

class layercake.inner_products.definition.StandardSymbolicInnerProductDefinition(coordinate_system, optimizer=None, complex=False, kwargs=None)[source]

Bases: InnerProductDefinition

Standard class to define symbolic inner products using Sympy.

Parameters:
  • coordinate_system (CoordinateSystem) – Coordinate system on which the basis is defined.

  • optimizer (None or callable or str, optional) – A function to optimize the computation of the integrals or the integrand. If a string, specifies pre-defined optimizers: * ‘trig’: Optimizer specifically designed for trigonometric functions. If None, does not optimize.

  • complex (bool, optional) – Whether to compute the inner products with complex conjugate expression for the second term. Default to False, i.e. real inner products.

  • kwargs (dict) – Specific keywords arguments to pass to the Sympy integrals, see integrate() and Integral.

coordinate_system

Coordinate system on which the basis is defined.

Type:

CoordinateSystem

complex

Whether to compute the inner products with complex conjugate expression for the second term.

Type:

bool, optional

optimizer

A function to optimize the computation of the integrals or the integrand. If None, does not optimize the computation.

Type:

None or callable

inner_product(S, G, symbolic_expr=False, integrand=False)[source]

Function defining the inner product to be computed symbolically: \((S, G) = \left(1 / \mathcal{N}\right) \int_a^b\int_c^d S(x,y)\, G(x,y)\, \mathrm{d} x \, \mathrm{d} y\) where \(\mathcal{N} = (b-a) \, (d-c)\) is the norm of the integrals.

Parameters:
  • S (Expr) – Left-hand side function of the product.

  • G (Expr) – Right-hand side function of the product.

  • symbolic_expr (bool, optional) – If True, return the integral as a symbolic expression object. Else, return the integral performed symbolically.

  • integrand (bool, optional) – If True, return the integrand of the integral and its integration limits as a list of symbolic expression object. Else, return the integral performed symbolically.

Returns:

The result of the symbolic integration

Return type:

Expr

integrate_over_domain(expr, symbolic_expr=False)[source]

Definition of the integrals over the spatial domain used by the inner products: \(\int_a^b\int_c^d \, \mathrm{expr}(x, y) \, \mathrm{d} x \, \mathrm{d} y\).

Parameters:
  • expr (Expr) – The expression to integrate.

  • symbolic_expr (bool, optional) – If True, return the integral as a symbolic expression object. Else, return the integral performed symbolically.

Returns:

The result of the symbolic integration.

Return type:

Expr

set_optimizer(optimizer)[source]

Function to set the optimizer.

Parameters:

optimizer (callable) – A function to optimize the computation of the integrals or the integrand.