Skip to content

Tutorial fluid modelling #1385

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 19 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 28 additions & 9 deletions src/porepy/compositional/compositional_mixins.py
Original file line number Diff line number Diff line change
Expand Up @@ -1107,8 +1107,22 @@ def create_fluid(self) -> None:
components: list[pp.FluidComponent] = [c for c in self.get_components()]

for config in self.get_phase_configuration(components):
eos, type_, name = config
phases.append(Phase(eos, type_, name))
if len(config) == 3:
eos, phase_state, name = config
# If no EoS is given by the user, use the base EoS as a dummy.
elif len(config) == 2:
phase_state, name = config
eos = EquationOfState(components)
assert isinstance(eos, EquationOfState), (
f"Expecting an instance of `EquationOfState`, got {type(eos)}."
)
assert phase_state in PhysicalState, (
f"Expecting a valid `PhysicalState`, got {phase_state}."
)
assert isinstance(name, str), (
f"Expecting a string as name for phase, got {type(name)}."
)
phases.append(Phase(eos, phase_state, name))

self.set_components_in_phases(components, phases)

Expand Down Expand Up @@ -1138,12 +1152,14 @@ def get_components(self) -> Sequence[pp.FluidComponent]:

def get_phase_configuration(
self, components: Sequence[ComponentLike]
) -> Sequence[tuple[EquationOfState, PhysicalState, str]]:
) -> Sequence[
tuple[EquationOfState, PhysicalState, str] | tuple[PhysicalState, str]
]:
"""Method to return a configuration of modelled phases.

The default implementation returns a liquid-like phase with an abstract EoS
instance (to be used in the standard set-up with heuristic fluid properties
implemented for 1-phase fluids).
The default implementation returns a liquid-like phase named ``'liquid'``
(to be used in the standard set-up with heuristic fluid properties implemented
for 1-phase fluids).

Parameters:
components: The list of components modelled by :meth:`get_components`.
Expand All @@ -1154,18 +1170,21 @@ def get_phase_configuration(
The user can use only a single EoS instance for all phases f.e.

Returns:
A sequence of 3-tuples containing
A sequence of 3-tuples or 2-tuples containing

1. An instance of an EoS.
1. (optional) An instance of an EoS.
2. The phase state.
3. A name for the phase.

Each tuple will be used to create a phase in the fluid mixture.
For more information on the required return values see
:class:`~porepy.compositional.base.Phase`.

Phase configurations which do not return an EoS are assumed to use
heuristics.

"""
return [(EquationOfState(components), PhysicalState.liquid, "liquid")]
return [(PhysicalState.liquid, "liquid")]

def set_components_in_phases(
self, components: Sequence[Component], phases: Sequence[Phase]
Expand Down
6 changes: 3 additions & 3 deletions src/porepy/models/fluid_property_library.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
""" "Module containing some constant heuristic fluid property implementations and
"""Module containing some constant heuristic fluid property implementations and
the mixin :class:`FluidMobility`, which is required in all flow & transport problems.

Most of the laws implemented here are meant for 1-phase, 1-component mixtures, using
Expand Down Expand Up @@ -67,7 +67,7 @@ def fluid_compressibility(self, subdomains: Sequence[pp.Grid]) -> pp.ad.Operator
)

def density_of_phase(self, phase: pp.Phase) -> ExtendedDomainFunctionType:
""" "Mixin method for :class:`~porepy.compositional.compositional_mixins.
"""Mixin method for :class:`~porepy.compositional.compositional_mixins.
FluidMixin` to provide a density exponential law for the fluid's phase.

.. math::
Expand Down Expand Up @@ -139,7 +139,7 @@ def fluid_thermal_expansion(self, subdomains: Sequence[pp.Grid]) -> pp.ad.Operat
return Scalar(val, "fluid_thermal_expansion")

def density_of_phase(self, phase: pp.Phase) -> ExtendedDomainFunctionType:
""" "Analogous to :meth:`FluidDensityFromPressure.density_of_phase`, but using
"""Analogous to :meth:`FluidDensityFromPressure.density_of_phase`, but using
temperature and the thermal expansion of the reference component.

.. math::
Expand Down
2 changes: 1 addition & 1 deletion tests/numerics/test_time_step_control.py
Original file line number Diff line number Diff line change
Expand Up @@ -488,7 +488,7 @@ def test_non_recomputed_solution_conditions(self):
assert time_manager._recomp_sol and (msg in str(excinfo.value))

def test_recompute_solution_false_by_default(self):
""" "Checks if recompute solution is False by default"""
"""Checks if recompute solution is False by default"""
time_manager = pp.TimeManager([0, 1], 0.1)
time_manager.compute_time_step(iterations=3)
assert not time_manager._recomp_sol
Expand Down
3 changes: 2 additions & 1 deletion tutorials/Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,5 @@ For the more experienced user, some more specific tutorials are also available:
14. [Mandel's problem](./mandels_problem.ipynb) shows how to set up and run the Mandel's consolidation problem based on the Biot equations of poroelasticity.
15. [Flux discretizations](./flux_discretizations.ipynb) shows different discretization methods available for diffusive fluxes. These are used for Darcy's law for fluid fluxes in a mass balance equation.
16. [Stress discretization](./stress_discretization.ipynb) describes the discretization method used for the vector version of tutorial #15, which arises in the linear elastisity equations.
17. [Linear Tracer Flow](./tracer_flow.ipynb) describes the setup of a linear single-phase, 2-component model based on tutorial #6, and showcases a simulation of tracer transport through a fractured domain.
17. [Linear Tracer Flow](./tracer_flow.ipynb) describes the setup of a linear single-phase, 2-component model based on tutorial #6, and showcases a simulation of tracer transport through a fractured domain.
19 [Fluid modeling](./fluid_modeling.ipynb) explains how to set up multicomponent, multiphase fluids in a model, and various approaches to modeling fluid properties.
Loading