porepy.models.verification_setups.manu_flow_comp_frac module

This module contains a code verification implementation for a manufactured solution for the two-dimensional, compressible, single phase flow with a single, fully embedded vertical fracture in the middle of the domain.

The exact solution was obtained by extending the solution from the incompressible case, see https://doi.org/10.1515/jnma-2022-0038

TODO: Explain what are the modifications w.r.t. the incompressible case. FIXME: There is significant code duplication with the incompressible verification.

Consider recycling classes.

class ExactSolution[source]

Bases: object

Parent class for the exact solution.

fracture_accumulation(sd_frac, time)[source]
Parameters
Return type

ndarray

fracture_darcy_flux(sd_frac, time)[source]

Evaluate exact fracture Darcy flux at the face centers.

Parameters
  • sd_frac (Grid) – Fracture grid.

  • time (float) – float

Returns

Array of shape=(sd_frac.num_faces, ) containing the exact Darcy fluxes at the face centers at the given time.

Return type

ndarray

Note

The returned fluxes are already scaled with sd_face.face_normals.

fracture_density(sd_frac, time)[source]

Evaluate exact fracture density at the cell centers.

Parameters
  • sd_frac (Grid) – Fracture grid.

  • time (float) – time in seconds.

Returns

Array of shape=(sd_frac.num_cells, ) containing the exact densities at the cell centers at the given time.

Return type

ndarray

fracture_mass_flux(sd_frac, time)[source]
Parameters
Return type

ndarray

fracture_pressure(sd_frac, time)[source]

Evaluate exact fracture pressure at the cell centers.

Parameters
  • sd_frac (Grid) – Fracture grid.

  • time (float) – time in seconds.

Returns

Array of shape=(sd_frac.num_cells, ) containing the exact pressures at the cell centers at the given time.

Return type

ndarray

fracture_source(sd_frac, time)[source]

Compute exact integrated fracture source.

Parameters
  • sd_frac (Grid) – Fracture grid.

  • time (float) – time in seconds.

Returns

Array of shape=(sd_frac.num_cells, ) containing the exact integrated sources for a the given time.

Return type

ndarray

interface_darcy_flux(intf, time)[source]

Compute exact mortar fluxes at the interface.

Parameters
Returns

Array of shape=(intf.num_cells, ) containing the exact mortar fluxes at the given time.

Return type

ndarray

Note

The returned mortar fluxes are already scaled with intf.cell_volumes.

interface_mass_flux(intf, time)[source]
Parameters
Return type

ndarray

rock_accumulation(sd_rock, time)[source]
Parameters
Return type

ndarray

rock_boundary_density(sd_rock, time)[source]

Exact density at the boundary faces.

Parameters
  • sd_rock (Grid) – Rock grid.

  • time (float) – time in seconds.

Returns

Array of shape=(sd_rock.num_faces, ) with the exact density values on the exterior boundary faces for the given time.

Return type

ndarray

rock_boundary_pressure(sd_rock, time)[source]

Exact pressure at the boundary faces.

Parameters
  • sd_rock (Grid) – Rock grid.

  • time (float) – time in seconds.

Returns

Array of shape=(sd_rock.num_faces, ) with the exact pressure values on the exterior boundary faces at the given time.

Return type

ndarray

rock_darcy_flux(sd_rock, time)[source]

Evaluate exact rock Darcy flux [m^3 * s^-1] at the face centers .

Parameters
  • sd_rock (Grid) – Rock grid.

  • time (float) – Time in seconds.

Returns

Array of shape=(sd_rock.num_faces, ) containing the exact Darcy fluxes at the face centers at the given time.

Return type

ndarray

Note

The returned fluxes are already scaled with sd_rock.face_normals.

rock_density(sd_rock, time)[source]

Evaluate exact fluid density [kg * m^-3] in the rock at the cell centers.

Parameters
  • sd_rock (Grid) – Rock grid.

  • time (float) – Time in seconds.

Returns

Array of shape=(sd_rock.num_cells, ) containing the exact densities at the cell centers at the given time.

Return type

ndarray

rock_mass_flux(sd_rock, time)[source]

Evaluate exact mass flux [kg * s^-1] at the face centers.

Parameters
  • sd_rock (Grid) – Rock grid.

  • time (float) – Time in seconds.

Returns

Array of shape=(sd_rock.num_faces, ) containing the exact mass fluxes at the face centers for the given time.

Return type

ndarray

Note

The returned mass fluxes are already scaled with sd_rock.face_normals.

rock_pressure(sd_rock, time)[source]

Evaluate exact rock pressure [Pa] at the cell centers.

Parameters
  • sd_rock (Grid) – Rock grid.

  • time (float) – Time in seconds.

Returns

Array of shape=(sd_rock.num_cells, ) containing the exact pressures at the cell centers at the given time.

Return type

ndarray

rock_source(sd_rock, time)[source]

Compute exact integrated rock source.

Parameters
  • sd_rock (Grid) – Rock grid.

  • time (float) – float

Returns

Array of shape=(sd_rock.num_cells, ) containing the exact integrated sources at the given time.

Return type

ndarray

class ManufacturedCompFlow2d(params)[source]

Bases: ModifiedGeometry, ModifiedBoundaryConditions, ModifiedBalanceEquation, ModifiedSolutionStrategy, SinglePhaseFlow

Mixer class for the verification setup.

Examples

# Import modules
import porepy as pp
from time import time

# Run verification setup
tic = time()
params = {"plot_results": True}
setup = ManufacturedCompFlow2d(params)
print("Simulation started...")
pp.run_time_dependent_model(setup, params)
toc = time()
print(f"Simulation finished in {round(toc - tic)} seconds.")
Parameters

params (dict) –

params: dict

Simulation model parameters.

class ModifiedBalanceEquation[source]

Bases: MassBalanceEquations

Modify balance equation to account for external sources.

fluid_source(subdomains)[source]
Parameters

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

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.

basis: Callable[[Sequence[pp.GridLike], int], list[pp.ad.Matrix]]

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

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

Mobility times density boundary conditions. Normally defined in a mixin instance of BoundaryConditionsSinglePhaseFlow.

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.

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_darcy_flux: Callable[[list[pp.MortarGrid]], pp.ad.MixedDimensionalVariable]

Darcy flux variable on interfaces. Normally defined in a mixin instance of VariablesSinglePhaseFlow.

interface_darcy_flux_equation: Callable[[list[pp.MortarGrid]], pp.ad.Operator]

Interface Darcy flux equation. Normally provided by a mixin instance of DarcysLaw.

interface_mobility_discretization: Callable[[list[pp.MortarGrid]], pp.ad.UpwindCouplingAd]

Discretization of the fluid mobility on internal boundaries. Normally provided by a mixin instance of FluidMobility.

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.

mobility_discretization: Callable[[list[pp.Grid]], pp.ad.UpwindAd]

Discretization of the fluid mobility. Normally provided by a mixin instance of FluidMobility.

nd: int

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

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

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

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.

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.

time_manager: pp.TimeManager

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

wrap_grid_attribute: Callable[[Sequence[pp.GridLike], str, int, bool], pp.ad.Matrix]

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

class ModifiedBoundaryConditions[source]

Bases: object

Set boundary conditions for the simulation model.

bc_type_darcy(sd)[source]
Parameters

sd (Grid) –

Return type

BoundaryCondition

bc_type_mobrho(sd)[source]
Parameters

sd (Grid) –

Return type

BoundaryCondition

bc_values_darcy(subdomains)[source]
Parameters

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

Return type

Array

bc_values_mobrho(subdomains)[source]
Parameters

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

Return type

Array

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

Utility function to access the domain boundary sides.

mdg: MixedDimensionalGrid

Mixed-dimensional grid object.

time_manager: TimeManager

Properly initialized time manager object.

class ModifiedGeometry[source]

Bases: ModelGeometry

Generate fracture network and mixed-dimensional grid.

mesh_arguments()[source]

Define mesh arguments for meshing.

Return type

dict

set_fracture_network()[source]

Create fracture network.

Note

Two horizontal fractures at y = 0.25 and y = 0.75 are included in the fracture network to force the grid to conform to certain regions of the domain. Note, however, that these fractures will not be part of the mixed-dimensional grid.

Return type

None

set_md_grid()[source]

Create mixed-dimensional grid. Ignore fractures 1 and 2.

Return type

None

params: dict

Simulation model parameters.

class ModifiedSolutionStrategy(params)[source]

Bases: SolutionStrategySinglePhaseFlow

Parameters

params (dict) –

after_nonlinear_convergence(solution, errors, iteration_counter)[source]

Method to be called after convergence

Parameters
Return type

None

after_simulation()[source]

Method to be called after the simulation has finished.

Return type

None

before_nonlinear_loop()[source]

Update values of external sources and boundary conditions

Return type

None

plot_results()[source]

Plotting results

Return type

None

darcy_flux: Callable[[list[pp.Grid]], pp.ad.Operator]
exact_sol

Exact solution object

fluid: pp.FluidConstants

Fluid constants. See also set_materials().

mdg: pp.MixedDimensionalGrid

Mixed-dimensional grid. Will normally be set by a mixin instance of ModelGeometry.

results: list[StoreResults]

Object that stores exact and approximated solutions and L2 errors

class StoreResults(setup)[source]

Bases: VerificationUtils

Class to store results.