Finite Volumes¶
The voids.fvm sub-package provides finite-volume single-phase solvers on
regular coefficient maps.
For the TPFA balance equations, transmissibilities, boundary conditions, and permeability reporting convention, see Map-Based Single-Phase Solvers.
TPFA Darcy Flow¶
voids.fvm.singlephase.tpfa
¶
TPFAResult
dataclass
¶
Result of a cell-centered two-point flux approximation solve.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pressure
|
ndarray
|
Cell-centered pressure field. It has the same shape as the input permeability field. |
required |
flow_axis
|
str
|
Axis along which the pressure drop was imposed. |
required |
permeability
|
float
|
Effective permeability inferred from the outlet flow rate through Darcy's law. |
required |
flow_rate
|
float
|
Total outlet flow rate. For 2-D maps this is the flow rate per unit out-of-plane thickness. |
required |
inlet_flow_rate
|
float
|
Boundary flow rates computed at the inlet and outlet faces. Their agreement is a finite-volume mass-balance diagnostic. |
required |
outlet_flow_rate
|
float
|
Boundary flow rates computed at the inlet and outlet faces. Their agreement is a finite-volume mass-balance diagnostic. |
required |
mass_balance_error
|
float
|
Absolute difference between inlet and outlet flow rates normalized by the larger boundary flow magnitude. |
required |
Source code in src/voids/fvm/singlephase/tpfa.py
solve_tpfa
¶
solve_tpfa(
permeability,
*,
flow_axis="x",
viscosity=1.0,
pressure_inlet=1.0,
pressure_outlet=0.0,
cell_size=None,
solver_method="direct",
solver_parameters=None,
)
Solve Darcy flow on a regular permeability map with TPFA.
The discrete unknown is one pressure value per map cell. Internal face transmissibilities use the harmonic mean of adjacent permeability values, while inlet and outlet Dirichlet pressures are imposed half a cell from the adjacent cell center. All transverse boundaries are no-flow boundaries.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
permeability
|
PermeabilityMap | ndarray
|
Cell-wise scalar permeability map. Zero values are treated as impermeable. Completely isolated zero-transmissibility cells may make the pressure system singular; use a small permeability floor before calling this solver if the map contains solid-like cells. |
required |
flow_axis
|
str
|
Axis along which |
'x'
|
viscosity
|
float
|
Dynamic viscosity multiplying Darcy resistance. |
1.0
|
pressure_inlet
|
float
|
Dirichlet pressure values imposed on the minimum and maximum faces of
|
1.0
|
pressure_outlet
|
float
|
Dirichlet pressure values imposed on the minimum and maximum faces of
|
1.0
|
cell_size
|
float | Sequence[float] | None
|
Physical cell size used when |
None
|
solver_method
|
str
|
Sparse linear solver backend passed to
:func: |
'direct'
|
solver_parameters
|
SolverParameters | None
|
Optional backend-specific controls. For example,
|
None
|
Source code in src/voids/fvm/singlephase/tpfa.py
221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 | |
solve_tpfa exposes the same sparse linear solver choices used elsewhere in
voids: direct SciPy sparse LU, PARDISO where available, CG, and GMRES. The
large image-map comparison notebooks use CG with PyAMG preconditioning when the
map system is symmetric positive definite and large enough that a direct solve
is not the preferred baseline.
Upscaling¶
voids.fvm.singlephase.upscaling
¶
TPFAUpscalingResult
dataclass
¶
Principal-direction TPFA permeability upscaling result.
Source code in src/voids/fvm/singlephase/upscaling.py
upscale_permeability_tpfa
¶
upscale_permeability_tpfa(
permeability_map,
*,
axes=None,
viscosity=1.0,
pressure_inlet=1.0,
pressure_outlet=0.0,
solver_method="direct",
solver_parameters=None,
)
Compute principal-direction TPFA permeability estimates.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
permeability_map
|
PermeabilityMap
|
Scalar cell-wise permeability map. |
required |
axes
|
tuple[str, ...] | None
|
Principal axes to solve. By default all axes supported by the map dimensionality are solved. |
None
|
viscosity
|
float
|
Physical coefficients passed to :func: |
1.0
|
pressure_inlet
|
float
|
Physical coefficients passed to :func: |
1.0
|
pressure_outlet
|
float
|
Physical coefficients passed to :func: |
1.0
|
solver_method
|
str
|
Sparse linear solver controls passed through to
:func: |
'direct'
|
solver_parameters
|
str
|
Sparse linear solver controls passed through to
:func: |
'direct'
|
Source code in src/voids/fvm/singlephase/upscaling.py
upscale_principal_permeabilities_tpfa
¶
upscale_principal_permeabilities_tpfa(
permeability_map,
*,
axes=None,
viscosity=1.0,
pressure_inlet=1.0,
pressure_outlet=0.0,
solver_method="direct",
solver_parameters=None,
)
Return only the principal TPFA permeability values.