Physics¶
The voids.physics sub-package provides petrophysics helpers and the single-phase
flow solver.
Petrophysics¶
voids.physics.petrophysics
¶
PorosityBreakdown
dataclass
¶
Minimal porosity bookkeeping container.
Attributes:
| Name | Type | Description |
|---|---|---|
void_volume |
float
|
Total connected or absolute void volume used in the calculation. |
bulk_volume |
float
|
Reference bulk volume of the sample. |
porosity |
float
|
Ratio |
Source code in src/voids/physics/petrophysics.py
absolute_porosity
¶
Compute absolute porosity of the networked sample.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
net
|
Network
|
Network with pore and throat volumes plus sample bulk-volume metadata. |
required |
Returns:
| Type | Description |
|---|---|
float
|
Absolute porosity defined as
|
Source code in src/voids/physics/petrophysics.py
effective_porosity
¶
Compute an effective porosity based on connected void space.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
net
|
Network
|
Network with pore and throat volumes. |
required |
axis
|
str | None
|
Cartesian axis used for spanning connectivity. When provided, only pores in components spanning the requested inlet/outlet labels contribute. |
None
|
mode
|
str | None
|
Effective-porosity mode used when |
None
|
Returns:
| Type | Description |
|---|---|
float
|
Effective porosity based on the selected connected subset. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If an unsupported mode is requested. |
Notes
Two selection rules are supported:
axis is not None: use components spanning inlet/outlet labels along that axis.axis is Noneandmode == "boundary_connected": include any component touching a pore label whose name starts withinletoroutlet, or the genericboundarylabel.
Source code in src/voids/physics/petrophysics.py
connectivity_metrics
¶
Return graph-level connectivity metrics for a network.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
net
|
Network
|
Network to analyze. |
required |
Returns:
| Type | Description |
|---|---|
ConnectivitySummary
|
Convenience wrapper around :func: |
Source code in src/voids/physics/petrophysics.py
Single-Phase Flow¶
voids.physics.singlephase
¶
FluidSinglePhase
dataclass
¶
Single-phase fluid properties used by the flow solver.
Attributes:
| Name | Type | Description |
|---|---|---|
viscosity |
float | None
|
Reference dynamic viscosity of the fluid. For constant-viscosity solves,
this is the viscosity used everywhere. When |
density |
float | None
|
Optional fluid density. It is stored for bookkeeping but is not used by the
incompressible Darcy-scale solver in |
viscosity_model |
TabulatedWaterViscosityModel | None
|
Optional pressure-temperature viscosity model used to evaluate local pore and throat viscosities during conductance assembly. |
Source code in src/voids/physics/singlephase.py
has_variable_viscosity
property
¶
Return whether a pressure-dependent viscosity model is active.
reference_viscosity
¶
Return the scalar reference viscosity used for reporting.
Notes
If self.viscosity is specified explicitly it always takes precedence.
Otherwise, when viscosity_model is active, the midpoint viscosity
between pin and pout is used.
Source code in src/voids/physics/singlephase.py
PressureBC
dataclass
¶
Dirichlet pressure boundary conditions.
Attributes:
| Name | Type | Description |
|---|---|---|
inlet_label, outlet_label |
Names of pore labels identifying fixed-pressure pores. |
|
pin, pout |
Pressure values imposed on inlet and outlet pores. |
Notes
For the current incompressible single-phase formulation, the physically
relevant quantity is the imposed pressure drop pin - pout. Adding the
same constant offset to both values is therefore only a gauge choice.
Source code in src/voids/physics/singlephase.py
SinglePhaseOptions
dataclass
¶
Numerical and constitutive options for the single-phase solver.
Attributes:
| Name | Type | Description |
|---|---|---|
conductance_model |
str
|
Name of the hydraulic conductance model passed to
:func: |
solver |
str
|
Linear solver backend name. |
check_mass_balance |
bool
|
If |
regularization |
float | None
|
Optional diagonal shift added to the matrix before Dirichlet elimination. |
nonlinear_max_iterations |
int
|
Maximum number of Picard iterations used when viscosity depends on pressure. |
nonlinear_pressure_tolerance |
float
|
Relative infinity-norm pressure-change tolerance for the Picard loop. |
nonlinear_relaxation |
float
|
Under-relaxation factor applied to the Picard pressure update. |
solver_parameters |
dict[str, Any]
|
Optional linear-solver configuration dictionary passed to the inner
SciPy linear solves. For Krylov methods, this can include
|
nonlinear_solver |
str
|
Nonlinear strategy used when viscosity depends on pressure. Supported
values are |
nonlinear_line_search_reduction |
float
|
Backtracking reduction factor used by the damped Newton update. |
nonlinear_line_search_max_steps |
int
|
Maximum number of backtracking steps attempted by the damped Newton update. |
Source code in src/voids/physics/singlephase.py
SinglePhaseResult
dataclass
¶
Results returned by :func:solve.
Attributes:
| Name | Type | Description |
|---|---|---|
pore_pressure |
ndarray
|
Pressure solution at pores. |
throat_flux |
ndarray
|
Volumetric flux on each throat, positive when flowing from
|
throat_conductance |
ndarray
|
Throat conductance values used during assembly. |
total_flow_rate |
float
|
Net inlet flow rate associated with the imposed pressure drop. |
permeability |
dict[str, float] | None
|
Dictionary containing the apparent permeability for the simulated axis. |
residual_norm |
float
|
Algebraic residual norm of the solved linear system. |
mass_balance_error |
float
|
Normalized divergence residual on free pores. |
pore_viscosity |
ndarray | None
|
Final pore-wise dynamic viscosity values used by the conductance model. |
throat_viscosity |
ndarray | None
|
Final throat-wise dynamic viscosity values used by the conductance model. |
reference_viscosity |
float | None
|
Scalar viscosity used when reporting apparent permeability. |
solver_info |
dict[str, Any]
|
Backend-specific diagnostic information. |
Source code in src/voids/physics/singlephase.py
solve
¶
Solve steady incompressible single-phase flow on a pore network.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
net
|
Network
|
Network containing topology, geometry, and sample metadata. |
required |
fluid
|
FluidSinglePhase
|
Fluid properties. Constant viscosity is supported directly; when
|
required |
bc
|
PressureBC
|
Pressure boundary conditions. |
required |
axis
|
str
|
Macroscopic flow axis used when converting total flow to apparent permeability. |
required |
options
|
SinglePhaseOptions | None
|
Optional solver and conductance settings. |
None
|
Returns:
| Type | Description |
|---|---|
SinglePhaseResult
|
Pressure, flux, conductance, and derived transport metrics. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the imposed pressure drop is zero, if the viscosity inputs are invalid, or if a thermodynamic viscosity model is used with non-positive boundary pressures. |
Notes
The solver assembles a graph-Laplacian system
A p = b
with throat fluxes
q_t = g_t * (p_i - p_j)
where g_t is the hydraulic conductance of throat t. After solving for
pore pressure, the apparent permeability is computed from Darcy's law:
K = |Q| * mu * L / (A * |delta_p|)
where Q is total inlet flow rate, mu is a scalar reference viscosity,
L is the sample length along axis, and A is the corresponding
cross-sectional area. If fluid.viscosity is provided explicitly that
value is used as the reference viscosity. Otherwise, when
fluid.viscosity_model is active, the midpoint viscosity between
pin and pout is used.
Thermodynamic viscosity backends interpret pressure as absolute pressure in Pa. In that case, unlike the constant-viscosity solver, adding a constant offset to both boundary pressures changes the local viscosity field.
Connected components that do not touch any Dirichlet pore are excluded from the
linear solve because they form floating pressure blocks. Returned pressures and
fluxes on those excluded components are reported as nan.
Source code in src/voids/physics/singlephase.py
814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 | |
Transport Utilities¶
voids.physics.transport
¶
Transport post-processing placeholders for future versions.