porepy.models.abstract_equations module

Abstract equation classes.

Contains:
  • BalanceEquation: Base class for vector and scalar balance equations.

  • VariableMixin: Base class for variables.

class BalanceEquation[source]

Bases: object

Generic class for vector balance equations.

In the only known use case, the balance equation is the momentum balance equation,

d_t(momentum) + div(stress) - source = 0,

with momentum frequently being zero. All terms need to be specified in order to define an equation.

balance_equation(subdomains, accumulation, surface_term, source, dim)[source]

Balance equation that combines an accumulation and a surface term.

The balance equation is given by .. math:

d_t(accumulation) + div(surface_term) - source = 0.
Parameters
  • subdomains (list[porepy.grids.grid.Grid]) – List of subdomains where the balance equation is defined.

  • accumulation (Operator) – Operator for the cell-wise accumulation term, integrated over the cells of the subdomains.

  • surface_term (Operator) – Operator for the surface term (e.g. flux, stress), integrated over the faces of the subdomains.

  • source (Operator) – Operator for the source term, integrated over the cells of the subdomains.

  • dim (int) – Spatial dimension of the balance equation.

Returns

Operator for the balance equation.

Return type

Operator

volume_integral(integrand, grids, dim)[source]

Numerical volume integral over subdomain or interface cells.

Includes cell volumes and specific volume.

Parameters
Returns

Operator for the volume integral.

Raises
  • ValueError – If the grids are not all subdomains or all interfaces.

  • NotImplementedError – If the grids are not all interfaces of dimension nd-1.

Return type

Operator

basis: Callable[[Sequence[Union[Grid, MortarGrid]], int], list[porepy.numerics.ad.operators.Matrix]]

Basis for the local coordinate system. Normally set by a mixin instance of porepy.models.geometry.ModelGeometry.

nd: int

Ambient dimension of the problem. Normally set by a mixin instance of porepy.models.geometry.ModelGeometry.

specific_volume: Callable[[list[porepy.grids.grid.Grid]], Operator]

Function that returns the specific volume of a subdomain. Normally provided by a mixin of instance DimensionReduction.

time_manager: TimeManager

Time manager. Normally set by a mixin instance of porepy.models.solution_strategy.SolutionStrategy.

wrap_grid_attribute: Callable[[Sequence[Union[Grid, MortarGrid]], str, int, bool], Matrix]

Wrap grid attributes as Ad operators. Normally set by a mixin instance of porepy.models.geometry.ModelGeometry.

class VariableMixin[source]

Bases: object

Mixin class for variables.

This class is intended to be used together with the other model classes providing generic functionality for variables.

TODO: Refactor depending on whether other abstract classes are needed. Also, not restricted to variables, but also to operators (e.g. representing a secondary variable) having a reference value.

perturbation_from_reference(variable_name, grids)[source]

Perturbation of a variable from its reference value.

The parameter variable_name should be the name of a variable so that self.variable_name() and self.reference_variable_name() are valid calls. These methods will be provided by mixin classes; normally this will be a subclass of VariableMixin.

The returned operator will be of the form self.variable_name(grids) - self.reference_variable_name(grids).

Parameters
  • variable_name (str) – Name of the variable.

  • grids (list[porepy.grids.grid.Grid]) – List of subdomain or interface grids on which the variable is defined.

Returns

Operator for the perturbation.