Extend the supplied working Assignment 12 solver to compute flow between blocks
with different permeability, width, area, and porosity. Implement only
compute_transmissibility(i, j) and compute_accumulation(i) in assignment13.py.
Input parsing, conservative matrix assembly, boundary conditions, and all three
time-integration options are provided. Do not rewrite them.
The schematic shows a constant-area, constant-porosity example. inputs.yml
extends that example with block-dependent areas and porosities too. Pressure is
in psi, time in days, lengths in ft, areas in ft², permeability in mD, viscosity
in cP, and compressibility in psi⁻¹. The water properties are constant across the
reservoir; formation volume factor is dimensionless.
The parser supplies length-N floating-point arrays self.permeability,
self.area, self.porosity, and self.delta_x, and scalar self.viscosity,
self.formation_volume_factor, and self.compressibility.
Interblock transmissibility. Treat the two half blocks between neighboring
cell centers as resistances in series. For valid zero-based block indices i
and j, return the unconverted coefficient
This is symmetric in i and j. Do not take an arithmetic average of
permeabilities or ignore unequal half-block widths and areas. The same function
is called with i == j: it must then return k_i A_i / (mu B_w delta_x_i),
the conductance across a full block. The supplied boundary assembly multiplies
that value by two for the half-block distance to a prescribed-pressure face.
Do not double it inside your function.
Block accumulation. Return
Neither function applies self.conversion_factor. The supplied assembly
applies it once to face conductances and pressure-boundary sources, not to
accumulation. Include B_w in both coefficient functions; tests include
values other than one.
The discrete balance remains
T and B are sparse (N, N) matrices; p and Q are (N,) arrays. Each
interior face contributes equally and oppositely to its two cells. Boundary
conditions are prescribed pressure at a face or zero prescribed flux (no flow).
Nonzero prescribed flux is outside this assignment.
Permeability, cross-sectional area, porosity, and optional numerical: delta x
may each be a positive scalar (broadcast to every block), or a list, tuple, or
NumPy array with exactly N positive finite values. Without delta x, widths
are uniform, reservoir: length / N. With delta x, those widths define the
geometry; length is not used to rescale them. Files of property values are not
required. Parsing rejects malformed vectors, nonnumeric values, booleans,
nonfinite values, and nonpositive values with ValueError.
The existing solver strings implicit and explicit, and the dictionary
{'mixed method': {'theta': 0.5}}, work unchanged. The course convention is
theta = 0 implicit, theta = 1 explicit, theta = 0.5 Crank–Nicolson.
The supplied mixed solver handles intermediate theta values and checks the
conjugate-gradient return status. Your two functions must work with every
provided solver and with either boundary orientation.
Ask your agent to derive the series-resistance expression and explain why an arithmetic permeability average is inappropriate for unequal blocks. Review its plan, including the full-block versus half-block boundary factor and units, before approving edits. Have it change only the two coefficient functions, run the public tests, and show the diff. Independently rerun the tests and inspect both functions before accepting the implementation. Check a hand calculation for unequal blocks, not just the uniform-grid limit.
Open in Codespaces, or install environment.yml with conda/micromamba.
The container registers the Python 3 (Assignment 13) Jupyter kernel.
python -m unittest -v test.pyTests cover scalar and vector inputs, unequal block resistances, accumulation, conservation, both boundary orientations, nonunit fluid properties, and repeated time steps. The supplied parsing and submission checks pass in the starter; coefficient and flow checks fail until the two functions are implemented. Do not edit tests, inputs, or other provided infrastructure.
Only assignment13.py is submitted. When ready, tell the agent submit assignment 13, review its submission plan, and approve execution. Verify your pushed commit and GitHub Actions result.
Open verification.ipynb and click Run All after implementation to view the
pressure plots.
