ModelXsection#

class timflow.steady.model.ModelXsection(naq=1)#

Bases: Model

Model for cross-section (2D vertical slice) problems.

A cross-section model represents flow in a vertical plane, typically used for analyzing flow patterns in aquifers along a transect.

Parameters:

naq (int, optional) – Number of aquifers in the model, by default 1. Each Xsection added to this model must have the same number of aquifers.

Notes

A ModelXsection may consist of an arbitrary number of Xsection3D or XsectionMaq sections. The combined domain of all sections must span from $x = -infty$ to $x = +infty$, with no gaps.

check_inhoms()#

Check inhoms.

Checks that the number of aquifers in each inhomogeneity matches the number of aquifers in the model, and whether the inhoms span from -inf to inf.

remove_element(e)#

Remove element e from model.

disvec(x, y, aq=None)#

Discharge vector at x, y.

Returns:

qxqy – first row is Qx in each aquifer layer, second row is Qy

Return type:

array size (2, naq)

normflux(x, y, theta)#

Flux at point x, y in direction of angle theta.

Parameters:
  • x (float)

  • y (float)

  • theta (float) – angle for which to calculate flux, defined relative to positive x-axis.

Returns:

flux in direction theta

Return type:

flux

intnormflux_segment(x1, y1, x2, y2, method='legendre', ndeg=10)#

Integrated normal (perpendicular) flux over specified line segment.

Flux to the left is positive when going from (x1, y1) to (x2, y2).

Parameters:
  • x1 (float)

  • y1 (float)

  • x2 (float)

  • y2 (float)

  • method (str, optional) – integration method, either “quad” (numerical integration using scipy) or “legendre” (approximate integral using Gauss-Legendre quadrature), by default “legendre”.

  • ndeg (int, optional) – degree for legendre polynomial, by default 10, only used when method=”legendre”

Returns:

Qn – integrated normal flux along specified line

Return type:

np.array

intnormflux(xy, method='legendre', ndeg=10)#

Integrated normal (perpendicular) flux over polyline.

Computes the flux per segment and per aquifer. Flux to the left is positive when going from (x1, y1) to (x2, y2).

Parameters:
  • xy (list [(x0, y0), (x1, y1),... , (xn, yn)] or 2D array) – if 2D-array, x in first column and y in second column

  • method (str, optional) – integration method, either “quad” (numerical integration using scipy) or “legendre” (approximate integral using Gauss-Legendre quadrature), by default “legendre”.

  • ndeg (int, optional) – degree for legendre polynomial, by default 10, only used when method=”legendre”

Returns:

Qn – integrated normal flux along specified polyline

Return type:

np.array of shape (naq, nsegments)

Examples

Total flow across polyline can be obtained using:

>>> np.sum(Qn)

Total flow across segments summed over aquifers using

>>> np.sum(Qn, axis=0)
head(x, y, layers=None, aq=None)#

Head at x, y.

Returns:

h – head in all layers (if not None), or all layers of aquifer (otherwise)

Return type:

array length naq or len(layers)

head_array(x, y, layers=None, show_progress=False, parallel=False)#

Head for array of points.

Parameters:
  • x (1D array or list) – x values of points

  • y (1D array or list) – y values of points

  • layers (integer, list or array, optional) – layers for which grid is returned

  • show_progress (bool) – show computation progress, by printing dots per row or with tqdm progressbar when parallel is True. Default is False.

  • parallel (bool or int, optional) – if True, computes head_array in parallel using multiprocessing, by default False. If an integer is provided, it is interpreted as the number of processes to use.

Returns:

h – heads array with size (nlayers, npoints)

Return type:

array

headgrid(xg, yg, layers=None, printrow=False, show_progress=False, parallel=False)#

Grid of heads.

Parameters:
  • xg (1d-array) – x values of grid

  • yg (1d-array) – y values of grid

  • layers (integer, list or array, optional) – layers for which grid is returned

  • show_progress (bool) – show computation progress, by printing dots per row or with tqdm progressbar when parallel is True. Default is False.

  • parallel (bool or int, optional) – if True, computes headgrid in parallel using multiprocessing, by default False. If an integer is provided, it is interpreted as the number of processes to use.

  • printrow (bool, optional) –

    Deprecated since version 0.2.0: prints dot to screen for each row of grid if set to True

Returns:

h

Return type:

array size nlayers, ny, nx

See also

head_array(), headgrid2()

headgrid2(x1, x2, nx, y1, y2, ny, layers=None, show_progress=False, printrow=False, parallel=False)#

Grid of heads.

Parameters:
  • x1 – x values are generated as linspace(x1, x2, nx)

  • x2 – x values are generated as linspace(x1, x2, nx)

  • nx – x values are generated as linspace(x1, x2, nx)

  • y1 – y values are generated as linspace(y1, y2, ny)

  • y2 – y values are generated as linspace(y1, y2, ny)

  • ny – y values are generated as linspace(y1, y2, ny)

  • layers (integer, list or array, optional) – layers for which grid is returned

  • show_progress (bool) – show computation progress, by printing dots per row or with tqdm progressbar when parallel is True. Default is False.

  • parallel (bool or int, optional) – if True, computes headgrid in parallel using multiprocessing, by default False. If an integer is provided, it is interpreted as the number of processes to use.

  • printrow (boolean, optional) –

    Deprecated since version 0.2.0: prints dot to screen for each row of grid if set to True

Returns:

h

Return type:

array size nlayers, ny, nx

See also

head_array(), headgrid()

headalongline(x, y, layers=None)#

Head along line or curve.

Parameters:
  • x (array) – x values of line

  • y (array) – y values of line

  • layers (integer, list or array, optional) – layers for which grid is returned

Returns:

h

Return type:

array size nlayers, nx

disvecgrid(xg, yg, layers=None, show_progress=True, parallel=False)#

Compute grid of discharge vectors.

Parameters:
  • xg (1d-array) – x values of grid

  • yg (1d-array) – y values of grid

  • layers (integer, list or array, optional) – layers for which grid is returned

  • show_progress (bool) – show computation progress, by printing dots per row or with tqdm progressbar when parallel is True. Default is True.

  • parallel (bool, optional) – if True, computes discharge vector grid in parallel using multiprocessing, by default False

Returns:

  • qx (array size (Nlayers, ny, nx)) – x component of discharge vector at each point in grid

  • qy (array size (Nlayers, ny, nx)) – y component of discharge vector at each point in grid

disvecalongline(x, y, layers=None)#

Compute discharge vector along line.

Notes

Assumes same number of layers for each x and y. Layers may be None or list of layers for which head is computed.

Returns:

  • Qx – [Nlayers,len(x)]

  • Qy – [Nlayers,len(x)]

stream_function(x, radial=False)#

Stream function along line x (or r).

Only applicable to models where flow is 1D (along a line), e.g. flow in a vertical cross-section or flow in a radially symmetric model.

Parameters:
  • x (array) – x values of line

  • radial (bool, optional) – if True, assumes that flow is radially symmetric and multiplies result by x, by default False

Returns:

  • stream_function (array) – stream function along line, size (2*naq, len(x))

  • zflow (array) – z values of flow grid, size (2*naq,)

velocity(x, y, z)#

Compute velocity at point x, y, z.

Parameters:
  • x (float)

  • y (float)

  • z (float)

Returns:

velocity – velocity vector (vx, vy, vz) at point x, y, z

Return type:

array

velocity_array(x, y, z, show_progress=True, parallel=False)#

Compute velocity grid.

Parameters:
  • x (1d-array) – x values

  • y (1d-array) – y values

  • z (1d-array) – z values

  • show_progress (bool) – show computation progress with tqdm progressbar if tqdm is installed. Default is True.

  • parallel (bool or int, optional) – if True, computes velocity grid in parallel using multi processing, by default False. If an integer is provided, it is interpreted as the number of processes to use.

Returns:

velocity – velocity vector (vx, vy, vz) at each point in grid, size (3, len(x))

Return type:

array

velocity_grid(xg, yg, zg, show_progress=True, parallel=False)#

Compute velocities for an array of points.

Parameters:
  • xg (1d-array) – x values of grid

  • yg (1d-array) – y values of grid

  • zg (1d-array) – z values of grid

  • show_progress (bool, optional) – if True, shows progress bar when computing velocity grid, by default True

  • parallel (bool or int, optional) – if True, computes velocity grid in parallel using multiprocessing, by default False. If an integer is provided, it specifies the number of processes to use.

Returns:

velocity – velocity vector (vx, vy, vz) at each point in grid, size (3, len(zg), len(yg), len(xg))

Return type:

array

solve(printmat=0, sendback=0, silent=False)#

Compute solution.

solve_mp(nproc=4, printmat=0, sendback=0, silent=False)#

Compute solution, multiprocessing implementation.

Notes

Estimated speedup approximately by factor of number of physical cores (virtual cores do not improve calculation time).

aquifer_summary()#

Return DataFrame with summary of aquifer(s) parameters in model.

Returns:

dataframe with summary of aquifer(s) parameters

Return type:

pandas.DataFrame