pyopmnearwell.utils.formulas module#
Provide useful mathematical formulas for reservoir modelling.
TODO: The typing is off in this module. Instead of returning an ArrayLike, most functions should return an np.ndarray, however that does not work when a float is passed as then an np.float64 or similar is returned. Not sure how to fix this.
- pyopmnearwell_correction(angle=1.0471975511965976)[source]#
Calculate a correction factor that scales cell volume, equivalent radius etc. from a 2D triangle grid to a radial grid.
In pyopmnearwell, when using the cake grid, a 2D triangle grid is used. As the scaling for cell volumes between a radial and a triangular grid is linear, the radial solution can be recovered. This function calculates the ratio
\[r_{radial_grid} / x_{triangle_grid},\]where \(x_{triangle_grid}\) is the altitude of the triangle, s.t. the solution on the triangle grid is equal to the solution on a radial grid with the given cell radii.
- equivalent_well_radius(delta_x)[source]#
Calculate the equivalent Peaceman well-block radius for square cells.
- Parameters:
delta_x (ArrayLike) -- Square-cell side length.
- Returns:
Result produced by the operation.
- Return type:
np.ndarray
- peaceman_matrix_WI(k_h, r_e, r_w)[source]#
- Compute the well productivity index (without taking into account density and
viscosity) from the Peaceman well model.
\[WI = \frac{2 \pi h \mathbf{k}}{\ln(r_e/r_w)}\]- Parameters:
- Returns:
\(WI\). Unit: [m^3].
- Return type:
WI (ArrayLike)
- Raises:
ValueError -- If r_w is zero for any point.
ValueError -- If either r_e or r_w contains a negative value
- peaceman_WI(k_h, r_e, r_w, rho, mu)[source]#
Compute the well productivity index (adjusted for density and viscosity) from the Peaceman well model.
\[WI = \frac{2 \pi h \mathbf{k} \frac{\mu}{\rho}}{\ln(r_e/r_w)}\]- Parameters:
k_h (ArrayLike) -- Permeability times the cell thickness. Unit: [m^3].
r_e (ArrayLike) -- Equivalent well-block radius. Needs to have the same unit as
r_w.r_w (ArrayLike) -- Wellbore radius. Needs to have the same unit as
r_e.rho (ArrayLike) -- Density. Unit: [kg/m^3].
mu (ArrayLike) -- Viscosity. Unit: [Pa*s].
- Returns:
\(WI\). Unit: [m*s].
- Return type:
WI (ArrayLike)
- two_phase_peaceman_WI(k_h, r_e, r_w, rho_1, mu_1, k_r1, rho_2, mu_2, k_r2)[source]#
Compute the well productivity index (adjusted for density, viscosity and relative permeabilties) from the Ptwo-phase eaceman well model.
Cf. [A. Yapparova, B. Lamy-Chappuis, S. W. Scott, and T. Driesner, “A Peaceman-type well model for the 3D Control Volume Finite Element Method and numerical simulations of supercritical geothermal resource utilization” 2022, doi: 10.1016/j.geothermics.2022.102516.]
\[WI = \frac{2 \pi h \mathbf{k}}{\ln(r_e/r_w)} \left(\frac{k_{r,1}}{\mu_1} + \frac{k_{r,2}}{\mu_2})\right)\]Note
The result is only accurate for fine grid sizes.
- Parameters:
k_h (ArrayLike) -- Permeability times the cell thickness. Unit: [m^3].
r_e (ArrayLike) -- Equivalent well-block radius. Needs to have the same unit as
r_w.r_w (ArrayLike) -- Wellbore radius. Needs to have the same unit as
r_e.rho_1 (ArrayLike) -- Density of phase 1. Unit: [kg/m^3].
mu_1 (ArrayLike) -- Viscosity of phase 1. Unit: [Pa*s].
k_r1 (ArrayLike) -- Relative permeability of phase 1.
rho_2 (ArrayLike) -- Density of phase 2. Unit: [kg/m^3].
mu_2 (ArrayLike) -- Viscosity of phase 2. Unit: [Pa*s].
k_r2 (ArrayLike) -- Relative permeability of phase 2.
- Returns:
\(WI\). Unit: [m*s].
- Return type:
WI (ArrayLike)
- data_WI(q, p_w, p_gb, well_type='injector')[source]#
Compute the well productivity index from given data.
\[WI = \frac{q}{p_w - p_{gb}\]- Parameters:
- Returns:
\(WI\). Unit: [m^4*s/kg].
- Return type:
WI (ArrayLike)
- Raises:
ValueError -- If bottom hole pressure and grid block pressure are equal for any point.
- co2brinepvt(pressure, temperature, phase_property, phase, OPM)[source]#
Call OPM's
co2brinepvtto calculate density/viscosity.- Parameters:
pressure (float) -- Unit: [Pa].
temperature (float) -- Unit: [K].
property (Literal["density", "viscosity"]) -- Phase property to return.
phase (Literal["CO2", "water"]) -- Phase of interest.
OPM (str | Path) -- (str | pathlib.Path): Path to OPM installation.
phase_property (Literal['density', 'viscosity'])
- Returns:
Density (unit: [kg/m^3]) or viscosity (unit: [Pa*s])
- Return type:
quantity (float)
- hydrostatic_fluid(rho, height, gravity=9.8067)[source]#
Calculate the pressure due to hydrostatic fluid.
This function calculates the pressure due to hydrostatic fluid using the formula:
\[P = rho * g * h,\]where \(P\) is the pressure, \(rho\) is the fluid density, \(g\) is the acceleration due to gravity, and \(h\) is the height.
- Parameters:
- Returns:
Hydrostatic pressure at the given height. Unit [Pa].
- Return type:
Examples
>>> hydrostatic_fluid(1000, 10) 98067.0
- hydrostatic_gas(reference_pressure, height, temperature, molecule_mass, gravity=9.8067)[source]#
Calculate the pressure due to a column of gas in hydrostatic equilibrium.
This function calculates the pressure due to a column of gas in hydrostatic equilibrium using the ideal gas law and the hydrostatic equilibrium formula. The formula is:
\[P = P_0 * e^((-m * g * h) / (R^* * T)),\]where \(P is the pressure,\) \(P_0 is the reference pressure,\) \(m is the molecular mass of the gas,\) \(g is the acceleration due to gravity,\) \(h is the height,\) \(R^* is the universal gas constant, and\) \(T is the temperature.\)
- Parameters:
reference_pressure (ArrayLike) -- Reference pressure at height 0. Unit [Pa].
height (ArrayLike) -- Height of the gas column. Unit [m].
temperature (ArrayLike) -- Temperature. Unit [K].
molecule_mass (ArrayLike) -- Molecular mass of the gas. Unit [kg/mol].
gravity (ArrayLike, optional) -- Acceleration due to gravity. Unit [m/s^2].
units.GRAVITATIONAL_ACCELERATION (Defaults to)
i.e.
9.8`. (ca.)
- Returns:
Hydrostatic pressure at the given height. Unit [Pa].
- Return type:
Examples
>>> hydrostatic_gas(101325, 5000, 300, 0.029, 9.81) 75819.90376642203
- area_squaredcircle(radius, sidelength)[source]#
Calculate the area that lies both inside a circle and inside a square centered at the origin.
- Parameters:
- Returns:
The calculated area.
- Return type:
- Raises:
ValueError -- If
radiusorsidelengthcontain a negative value.
Examples
>>> area_squaredcircle(3.0, 3.0) 9.0 # Area of a sqare with sidelength 3.0
>>> area_squaredcircle(2.0, 4.0) 12.566370614359172 # Area of a circle with radius 2.0
>>> area_squaredcircle(2.0, 3.0) 6.283185307179586 # Area inside a 2.0