porepy.models.energy_balance module

Energy balance with advection and diffusion.

Local thermal equilibrium is assumed, i.e., the solid and fluid temperatures are assumed to be constant within each cell. This leads to a single equation with “effective” or “total” quantities and parameters.

Since the current implementation assumes a flow field provided by a separate model, the energy balance equation is not stand-alone. Thus, no class EnergyBalance is provided, as would be consistent with the other models. However, the class is included in coupled models, notably MassAndEnergyBalance.

class BoundaryConditionsEnergyBalance[source]

Bases: object

Boundary conditions for the energy balance.

Boundary type and value for both diffusive Fourier flux and advective enthalpy flux.

bc_type_enthalpy(sd)[source]

Dirichlet conditions on all external boundaries.

Parameters

sd (Grid) – Subdomain grid on which to define boundary conditions.

Returns

Boundary condition object.

Return type

BoundaryCondition

bc_type_fourier(sd)[source]

Dirichlet conditions on all external boundaries.

Parameters

sd (Grid) – Subdomain grid on which to define boundary conditions.

Returns

Boundary condition object.

Return type

BoundaryCondition

bc_values_enthalpy_flux(subdomains)[source]

Boundary values for the enthalpy.

SI units for Dirichlet: [J/m^3] SI units for Neumann: TODO

Parameters

subdomains (list[porepy.grids.grid.Grid]) – List of subdomains.

Returns

Array with boundary values for the enthalpy.

Return type

Array

bc_values_fourier(subdomains)[source]

Boundary values for the Fourier flux.

Parameters

subdomains (list[porepy.grids.grid.Grid]) – List of subdomains.

Returns

Ad array representing the boundary condition values for the Fourier flux.

Return type

Array

domain_boundary_sides: Callable[[Grid], tuple[numpy.ndarray, numpy.ndarray, numpy.ndarray, numpy.ndarray, numpy.ndarray, numpy.ndarray, numpy.ndarray]]

Boundary sides of the domain. Normally defined in a mixin instance of ModelGeometry.

class ConstitutiveLawsEnergyBalance[source]

Bases: EnthalpyFromTemperature, FouriersLaw, ThermalConductivityLTE, DimensionReduction, AdvectiveFlux, FluidDensityFromTemperature, ConstantSolidDensity

Collect constitutive laws for the energy balance.

fluid: pp.FluidConstants

Fluid constant object that takes care of scaling of fluid-related quantities. Normally, this is set by a mixin of instance SolutionStrategy.

perturbation_from_reference: Callable[[str, list[pp.Grid]], pp.ad.Operator]

Function that returns a perturbation from reference state. Normally provided by a mixin of instance VariableMixin.

solid: pp.SolidConstants

Solid constant object that takes care of scaling of solid-related quantities. Normally, this is set by a mixin of instance SolutionStrategy.

temperature: Callable[[list[pp.Grid]], pp.ad.MixedDimensionalVariable]

Temperature variable. Normally defined in a mixin instance of VariablesEnergyBalance.

class EnergyBalanceEquations[source]

Bases: BalanceEquation

Mixed-dimensional energy balance equation.

Balance equation for all subdomains and advective and diffusive fluxes internally and on all interfaces of codimension one.

The class is not meant to be used stand-alone, but as a mixin in a coupled model.

energy_balance_equation(subdomains)[source]

Energy balance equation for subdomains.

Parameters

subdomains (list[porepy.grids.grid.Grid]) – List of subdomains.

Returns

Operator representing the energy balance equation.

Return type

Operator

energy_flux(subdomains)[source]

Energy flux.

Energy flux is the sum of the advective and diffusive fluxes.

Parameters

subdomains (list[porepy.grids.grid.Grid]) – List of subdomains.

Returns

Operator representing the energy flux.

Return type

Operator

energy_source(subdomains)[source]

Energy source term.

Note

When overriding this method to assign internal energy sources, one is advised to call the base class method and add the new contribution, thus ensuring that the source term includes the contribution from the interface fluxes.

Parameters

subdomains (list[porepy.grids.grid.Grid]) – List of subdomains.

Returns

Operator representing the source term.

Return type

Operator

enthalpy_flux(subdomains)[source]

Enthalpy flux.

Parameters

subdomains (list[porepy.grids.grid.Grid]) – List of subdomains.

Returns

Operator representing the enthalpy flux.

Return type

Operator

fluid_internal_energy(subdomains)[source]

Internal energy of the fluid.

Parameters

subdomains (list[porepy.grids.grid.Grid]) – List of subdomains.

Returns

Operator representing the fluid energy.

Return type

Operator

interface_energy_flux(interfaces)[source]

Interface fluid flux.

Parameters

interfaces (list[porepy.grids.mortar_grid.MortarGrid]) – List of interface grids.

Returns

Operator representing the interface fluid flux.

Return type

Operator

interface_enthalpy_flux_equation(interfaces)[source]

Interface enthalpy flux.

Parameters

interfaces (list[porepy.grids.mortar_grid.MortarGrid]) – List of interface grids.

Returns

Operator representing the interface enthalpy flux.

Return type

Operator

set_equations()[source]

Set the equations for the energy balance problem.

A energy balance equation is set for each subdomain, and advective and diffusive fluxes are set for each interface of codimension one.

solid_internal_energy(subdomains)[source]

Internal energy of the solid.

Parameters

subdomains (list[porepy.grids.grid.Grid]) – List of subdomains.

Returns

Operator representing the solid energy.

Return type

Operator

total_internal_energy(subdomains)[source]

Total energy.

Parameters

subdomains (list[porepy.grids.grid.Grid]) – List of subdomains.

Returns

Operator representing the total energy, i.e. the sum of the fluid and solid energy.

Return type

Operator

advective_flux: Callable[[list[pp.Grid], pp.ad.Operator, pp.ad.UpwindAd, pp.ad.Operator, Callable[[list[pp.MortarGrid]], pp.ad.Operator]], pp.ad.Operator]

Ad operator representing the advective flux. Normally provided by a mixin instance of AdvectiveFlux.

bc_values_enthalpy_flux: Callable[[list[pp.Grid]], pp.ad.Array]

Boundary condition for enthalpy flux. Normally defined in a mixin instance of BoundaryConditionsEnergyBalance.

enthalpy_keyword: str

Keyword used to identify the enthalpy flux discretization. Normally set by a mixin instance of SolutionStrategyEnergyBalance.

equation_system: pp.ad.EquationSystem

EquationSystem object for the current model. Normally defined in a mixin class defining the solution strategy.

fluid_density: Callable[[list[pp.Grid]], pp.ad.Operator]

Fluid density. Defined in a mixin class with a suitable constitutive relation.

fluid_enthalpy: Callable[[list[pp.Grid]], pp.ad.Operator]

Fluid enthalpy. Defined in a mixin class with a suitable constitutive relation.

fourier_flux: Callable[[list[pp.Grid]], pp.ad.Operator]

Fourier flux. Normally provided by a mixin instance of FouriersLaw.

interface_advective_flux: Callable[[list[pp.MortarGrid], pp.ad.Operator, pp.ad.UpwindCouplingAd], pp.ad.Operator]

Ad operator representing the advective flux on internal boundaries. Normally provided by a mixin instance of AdvectiveFlux.

interface_enthalpy_flux: Callable[[list[pp.MortarGrid]], pp.ad.MixedDimensionalVariable]

Variable for interface enthalpy flux. Normally provided by a mixin instance of VariablesEnergyBalance.

interface_fourier_flux: Callable[[list[pp.MortarGrid]], pp.ad.MixedDimensionalVariable]

Fourier flux variable on interfaces. Normally defined in a mixin instance of VariablesEnergyBalance.

interfaces_to_subdomains: Callable[[list[pp.MortarGrid]], list[pp.Grid]]

Map from interfaces to the adjacent subdomains. Normally defined in a mixin instance of ModelGeometry.

mdg: pp.MixedDimensionalGrid

Mixed dimensional grid for the current model. Normally defined in a mixin instance of ModelGeometry.

mobility: Callable[[list[pp.Grid]], pp.ad.Operator]

Fluid mobility. Normally provided by a mixin instance of FluidMobility.

porosity: Callable[[list[pp.Grid]], pp.ad.Operator]

Porosity of the rock. Normally provided by a mixin instance of ConstantPorosity or a subclass thereof.

pressure: Callable[[list[pp.Grid]], pp.ad.MixedDimensionalVariable]

Pressure variable. Normally defined in a mixin instance of VariablesSinglePhaseFlow.

solid_density: Callable[[list[pp.Grid]], pp.ad.Scalar]

Solid density. Defined in a mixin class with a suitable constitutive relation.

solid_enthalpy: Callable[[list[pp.Grid]], pp.ad.Operator]

Solid enthalpy. Defined in a mixin class with a suitable constitutive relation.

subdomains_to_interfaces: Callable[[list[pp.Grid], list[int]], list[pp.MortarGrid]]

Map from subdomains to the adjacent interfaces. Normally defined in a mixin instance of ModelGeometry.

class SolutionStrategyEnergyBalance(params=None)[source]

Bases: SolutionStrategy

Solution strategy for the energy balance.

Parameters

params (Optional[dict]) – Parameters for the solution strategy.

before_nonlinear_iteration()[source]

Evaluate Darcy flux (super) and copy to the enthalpy flux keyword, to be used in upstream weighting.

initial_condition()[source]

Add darcy flux to discretization parameter dictionaries.

Return type

None

set_discretization_parameters()[source]

Set default (unitary/zero) parameters for the energy problem.

The parameter fields of the data dictionaries are updated for all subdomains and interfaces (of codimension 1).

Return type

None

bc_type_enthalpy: Callable[[pp.Grid], pp.BoundaryCondition]

Function that returns the boundary condition type for the enthalpy flux. Normally defined in a mixin instance of BoundaryConditionsEnergyBalance.

bc_type_fourier: Callable[[pp.Grid], pp.BoundaryCondition]

Function that returns the boundary condition type for the Fourier flux. Normally defined in a mixin instance of BoundaryConditionsEnergyBalance.

enthalpy_keyword: str

Keyword for enthalpy flux term.

Used to access discretization parameters and store discretization matrices.

fourier_keyword: str

Keyword for Fourier flux term.

Used to access discretization parameters and store discretization matrices.

interface_enthalpy_flux_variable: str

Name of the primary variable representing the enthalpy flux on the interface.

interface_fourier_flux_variable: str

Name of the primary variable representing the Fourier flux on the interface.

nd: int

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

specific_volume: Callable[[list[pp.Grid]], pp.ad.Operator]

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

temperature_variable: str

Name of the temperature variable.

thermal_conductivity: Callable[[list[pp.Grid]], np.ndarray]

Thermal conductivity. Normally defined in a mixin instance of ThermalConductivityLTE or a subclass.

class VariablesEnergyBalance[source]

Bases: object

Creates necessary variables (temperature, advective and diffusive interface flux) and provides getter methods for these and their reference values. Getters construct mixed-dimensional variables on the fly, and can be called on any subset of the grids where the variable is defined. Setter method (assign_variables), however, must create on all grids where the variable is to be used.

Note

Wrapping in class methods and not calling equation_system directly allows for easier changes of primary variables. As long as all calls to enthalpy_flux() accept Operators as return values, we can in theory add it as a primary variable and solved mixed form. Similarly for different formulations of enthalpy instead of temperature.

create_variables()[source]

Assign primary variables to subdomains and interfaces of the mixed-dimensional grid.

Return type

None

interface_enthalpy_flux(interfaces)[source]

Interface enthalpy flux.

Parameters

interfaces (list[porepy.grids.mortar_grid.MortarGrid]) – List of interface grids.

Returns

Variable representing the interface enthalpy flux.

Return type

MixedDimensionalVariable

interface_fourier_flux(interfaces)[source]

Interface Fourier flux.

Parameters

interfaces (list[porepy.grids.mortar_grid.MortarGrid]) – List of interface grids.

Returns

Variable representing the interface Fourier flux.

Return type

MixedDimensionalVariable

reference_temperature(subdomains)[source]

Reference temperature.

For now, we assume that the reference temperature is the same for solid and fluid. More sophisticated models may require different reference temperatures.

Parameters
Return type

Operator

temperature(subdomains)[source]

Temperature variable.

Parameters

subdomains (list[porepy.grids.grid.Grid]) – List of subdomains.

Returns

Mixed-dimensional variable representing the temperature.

Return type

MixedDimensionalVariable

equation_system: EquationSystem

EquationSystem object for the current model. Normally defined in a mixin class defining the solution strategy.

fluid: FluidConstants

Fluid constant object that takes care of scaling of fluid-related quantities. Normally, this is set by a mixin of instance SolutionStrategy.

interface_enthalpy_flux_variable: str

Name of the primary variable representing the enthalpy flux across an interface. Normally defined in a mixin of instance SolutionStrategyEnergyBalance.

interface_fourier_flux_variable: str

Name of the primary variable representing the Fourier flux across an interface. Normally defined in a mixin of instance SolutionStrategyEnergyBalance.

mdg: MixedDimensionalGrid

Mixed dimensional grid for the current model. Normally defined in a mixin instance of ModelGeometry.

solid: SolidConstants

Solid constant object that takes care of scaling of solid-related quantities. Normally, this is set by a mixin of instance SolutionStrategy.

temperature_variable: str

Name of the primary variable representing the temperature. Normally defined in a mixin of instance SolutionStrategyEnergyBalance.