Mathematical and geometrical functions#

These functions are used to perform mathematical and geometrical operations.

Mathematical functions#

Notes

This module contains some general mathematical functions, e.g. series expansions and Cauchy integrals.

The mathematical functions are used by the element classes in the andfn module.

andfn.math_functions.asym_expansion(chi, coef)[source]#

Function that calculates the asymptotic expansion starting from 0 for a given point chi and an array of coefficients.

\[f(\chi) = \sum_{n=0}^{\infty} c_n \chi^{-n}\]
Parameters:
  • chi (complex | np.ndarray) – A point in the complex chi-plane

  • coef (np.ndarray) – An array of coefficients

Returns:

res – The resulting value for the asymptotic expansion

Return type:

complex | np.ndarray

andfn.math_functions.asym_expansion_d1(chi, coef)[source]#

Function that calculates the first derivative of the asymptotic expansion starting from 0 for a given point chi and an array of coefficients.

\[f(\chi) = -\sum_{n=0}^{\infty} n c_n \chi^{-n-1}\]
Parameters:
  • chi (complex | np.ndarray) – A point in the complex chi-plane

  • coef (np.ndarray) – An array of coefficients

Returns:

res – The resulting value for the asymptotic expansion

Return type:

complex | np.ndarray

andfn.math_functions.cauchy_integral_domega(n, m, thetas, dpsi_corr, omega_func, z_func)[source]#

FUnction that calculates the Cauchy integral with the stream function for a given array of thetas.

Parameters:
  • n (int) – Number of integration points

  • m (int) – Number of coefficients

  • thetas (np.ndarray) – Array with thetas along the unit circle

  • dpsi_corr (np.ndarray) – Correction for the stream function

  • omega_func (function) – The function for the complex potential

  • z_func (function) – The function for the mapping of chi to z

Returns:

coef – Array of coefficients

Return type:

np.ndarray

andfn.math_functions.cauchy_integral_imag(n, m, thetas, omega_func, z_func)[source]#

FUnction that calculates the Cauchy integral with the stream function for a given array of thetas.

Parameters:
  • n (int) – Number of integration points

  • m (int) – Number of coefficients

  • thetas (np.ndarray) – Array with thetas along the unit circle

  • omega_func (function) – The function for the complex potential

  • z_func (function) – The function for the mapping of chi to z

Returns:

coef – Array of coefficients

Return type:

np.ndarray

andfn.math_functions.cauchy_integral_real(n, m, thetas, omega_func, z_func)[source]#

Function that calculates the Cauchy integral with the discharge potential for a given array of thetas.

Parameters:
  • n (int) – Number of integration points

  • m (int) – Number of coefficients

  • thetas (np.ndarray) – Array with thetas along the unit circle

  • omega_func (function) – The function for the complex potential

  • z_func (function) – The function for the mapping of chi to z

Returns:

coef – Array of coefficients

Return type:

np.ndarray

andfn.math_functions.taylor_series(chi, coef)[source]#

Function that calculates the Taylor series starting from 0 for a given point chi and an array of coefficients.

\[f(\chi) = \sum_{n=0}^{\infty} c_n \chi^{n}\]
Parameters:
  • chi (complex) – A point in the complex chi-plane

  • coef (np.ndarray) – An array of coefficients

Returns:

res – The resulting value for the asymptotic expansion

Return type:

complex

andfn.math_functions.taylor_series_d1(chi, coef)[source]#

Function that calculates the first derivative of the Taylor series starting from 0 for a given point chi and an array of coefficients.

\[f(\chi) = \sum_{n=1}^{\infty} n c_n \chi^{n-1}\]
Parameters:
  • chi (complex) – A point in the complex chi-plane

  • coef (array_like) – An array of coefficients

Returns:

res – The resulting value for the asymptotic expansion

Return type:

complex

andfn.math_functions.well_chi(chi, q)[source]#

Function that return the complex potential for a well as a function of chi.

\[\omega = \frac{q}{2\pi} \log(\chi)\]
Parameters:
  • chi (np.ndarray | complex) – A point in the complex chi plane

  • q (float) – The discharge eof the well.

Returns:

omega – The complex discharge potential

Return type:

np.ndarray

Geometry functions#

Notes

This module contains some geometrical functions for e.g. conformal mappings and mapping between 3D space and fracture planes.

The geometrical functions are used by the element classes and to create the DFN in the andfn module.

andfn.geometry_functions.convert_normal_to_strike_dip(normal)[source]#

Function that converts a normal vector to a strike and dip

Parameters:

normal (np.ndarray) – The normal vector of the fracture plane.

Returns:

  • strike (float) – The strike of the fracture plane.

  • dip (float) – The dip of the fracture plane.

andfn.geometry_functions.convert_strike_dip_to_normal(strike, dip)[source]#

Function that converts a strike and dip to a normal vector

Parameters:
  • strike (float) – The strike of the fracture plane.

  • dip (float) – The dip of the fracture plane.

Returns:

normal – The normal vector of the fracture plane.

Return type:

np.ndarray

andfn.geometry_functions.convert_trend_plunge_to_normal(trend, plunge)[source]#

Function that converts a trend and plunge to a normal vector

Parameters:
  • trend (float) – The trend of the fracture plane.

  • plunge (float) – The plunge of the fracture plane.

Returns:

normal – The normal vector of the fracture plane.

Return type:

np.ndarray

andfn.geometry_functions.fracture_intersection(frac0, frac1)[source]#

Function that calculates the intersection between two fractures.

Parameters:
  • frac0 (Fracture) – The first fracture.

  • frac1 (Fracture) – The second fracture.

Returns:

  • endpoints0 (np.ndarray) – The endpoints of the intersection line in the first fracture. If no intersection is found, None is returned.

  • endpoints1 (np.ndarray) – The endpoints of the intersection line in the second fracture. If no intersection is found, None is returned.

andfn.geometry_functions.generate_fractures(n_fractures, radius_factor=1.0, center_factor=10.0, ncoef=10, nint=20)[source]#

Function that generates a number of fractures with random radii, centers and normals.

Parameters:
  • n_fractures (int) – Number of fractures to generate.

  • radius_factor (float) – The maximum radius of the fractures.

  • center_factor (float) – The maximum distance from the origin of the centers of the fractures.

  • ncoef (int) – The number of coefficients for the bounding circle.

  • nint (int) – The number of integration points for the bounding circle.

Returns:

fractures – A list of the generated fractures.

Return type:

list

andfn.geometry_functions.get_chi_from_theta(nint, start, stop)[source]#

Function that creates an array with chi values for a given number of points along the unit circle.

Parameters:
  • nint (int) – Number of instances to generate

  • start (float) – Start point

  • stop (float) – Stop point

Returns:

chi – Array with chi values

Return type:

np.ndarray

andfn.geometry_functions.get_connected_fractures(fractures, se_factor, ncoef=5, nint=10, fracture_surface=None)[source]#

Function that finds all connected fractures in a list of fractures. Starting from the first fracture in the list, or a given fracture, the function iterates through the list of fractures and finds all connected fractures.

Parameters:
  • fractures (list) – A list of fractures.

  • se_factor (float) – The shortening element factor. This is used to shorten the intersection line between two fractures.

  • ncoef (int) – The number of coefficients for the intersection elements.

  • nint (int) – The number of integration points for the intersection elements.

  • fracture_surface (Fracture) – The fracture to start the search from. If None, the first fracture in the list is used.

Returns:

connected_fractures – A list of connected fractures.

Return type:

list

andfn.geometry_functions.get_fracture_intersections(fractures, se_factor, ncoef=5, nint=10)[source]#

Function that finds all connected fractures in a list of fractures. Starting from the first fracture in the list, or a given fracture, the function iterates through the list of fractures and finds all connected fractures.

Parameters:
  • fractures (list) – A list of fractures.

  • se_factor (float) – The shortening element factor. This is used to shorten the intersection line between two fractures.

  • ncoef (int) – The number of coefficients for the intersection elements.

  • nint (int) – The number of integration points for the intersection elements.

Returns:

connected_fractures – A list of connected fractures.

Return type:

list

andfn.geometry_functions.line_circle_intersection(z0, z1, radius)[source]#

Function that calculates the intersection between a line and a circle.

Parameters:
  • z0 (complex) – A point on the line.

  • z1 (complex) – Another point on the line.

  • radius (float) – The radius of the circle.

Returns:

  • z_0 (complex) – The first intersection point. If no intersection is found, None is returned.

  • z_1 (complex) – The second intersection point. If no intersection is found, None is returned.

andfn.geometry_functions.line_line_intersection(z0, z1, z2, z3)[source]#

Function that calculates the intersection between two lines.

Parameters:
  • z0 (complex) – A point on the first line.

  • z1 (complex) – Another point on the first line.

  • z2 (complex) – A point on the second line.

  • z3 (complex) – Another point on the second line.

Returns:

z – The intersection point. If no intersection is found, None is returned.

Return type:

complex

andfn.geometry_functions.map_2d_to_3d(z, fractures)[source]#

Function that maps a point in the complex z-plane to a point in the 3D plane

\[x_i = x u_i + y v_i + x_{i,0}\]
Parameters:
  • z (complex | np.ndarray) – A point in the complex z-plane

  • fractures (Fracture) – The fracture object

Returns:

point – The corresponding point in the 3D plane

Return type:

np.ndarray

andfn.geometry_functions.map_3d_to_2d(point, fractures)[source]#

Function that maps a point in the 3D plane to a point in the complex z-plane.

\[x = \left( x_i - x_{i,0}\]

ight) u_i

\[y = \left( x_i - x_{i,0}\]

ight) v_i

\[z = x + iy\]
pointnp.ndarray

A point in the 3D plane

fracturesFracture

The fracture object

zcomplex

The corresponding point in the complex z-plane

andfn.geometry_functions.map_chi_to_z_circle(chi, r, center=0.0)[source]#

Function that maps the unit circle in the complex chi-plane to a circle in the complex z-plane.

\[z = \chi r + \text{center}\]
Parameters:
  • chi (complex | np.ndarray) – A point in the complex chi-plane

  • r (float) – Radius of the circle

  • center (complex or np.ndarray) – Center point of the circle

Returns:

z – The corresponding point in the complex z-plane

Return type:

complex | np.ndarray

andfn.geometry_functions.map_chi_to_z_line(chi, endpoints)[source]#

Function that maps the exterior of the unit circle in the complex chi-plane onto the exterior of a line in the complex z-plane.

\[Z = \frac{1}{2} \left( \chi + \frac{1}{\chi} \right)\]
\[z = \frac{1}{2} \left( Z \left(\text{endpoints}[1] - \text{endpoints}[0] \right) + \text{endpoints}[0] + \text{endpoints}[1]\right)\]
Parameters:
  • chi (complex | np.ndarray) – A point in the complex chi-plane

  • endpoints (list | np.ndarray) – Endpoints of the line in the complex z-plane

Returns:

z – The corresponding point in the complex z-plane

Return type:

complex | np.ndarray

andfn.geometry_functions.map_z_circle_to_chi(z, r, center=0.0)[source]#

Function that maps a circle in the complex z-plane onto a unit circle in the complex chi-plane.

\[\chi = \frac{z - \text{center}}{r}\]
Parameters:
  • z (complex | np.ndarray) – A point in the complex z-plane

  • r (float) – Radius of the circle

  • center (complex | np.ndarray) – Center point of the circle in the complex z-plane

Returns:

chi – The corresponding point in the complex chi-plane

Return type:

np.ndarray

andfn.geometry_functions.map_z_line_to_chi(z, endpoints)[source]#

Function that maps the exterior of a line in the complex z-plane onto the exterior of the unit circle in the complex chi-plane.

\[Z =\]

rac{ 2z - ext{endpoints}[0] - ext{endpoints}[1] }{ ext{endpoints}[1] - ext{endpoints}[0]}

\[\chi =\]

rac{1}{2} left( z + sqrt{z - 1} sqrt{z + 1} ight)

zcomplex | np.ndarray

A complex point in the complex z-plane

endpointsnp.ndarray

Endpoints of the line in the complex z-plane

chicomplex | np.ndarray

The corresponding point in the complex chi-plane

andfn.geometry_functions.set_head_boundary(fractures, ncoef, nint, head, center, radius, normal, label, se_factor)[source]#

Function that sets a constant head boundary condition on the intersection line between a fracture and a defined fracture. The constant head lines are added to the fractures in the list.

Parameters:
  • fractures (list) – A list of fractures.

  • ncoef (int) – The number of coefficients for the constant head line.

  • nint (int) – The number of integration points for the constant head line.

  • head (float) – The hydraulic head value.

  • center (np.ndarray) – The center of the constant head fracture plane.

  • radius (float) – The radius of the constant head fracture plane.

  • normal (np.ndarray) – The normal vector of the constant head fracture plane.

  • label (str) – The label of the constant head fracture plane.

  • se_factor (float) – The shortening element factor. This is used to shorten the constant head line.

Return type:

None

andfn.geometry_functions.shorten_line(z0, z1, se_factor)[source]#

Function that shortens a line segment by a given se_factor and keeps the same center point.

Parameters:
  • z0 (complex)

  • z1 (complex)

  • se_factor (float)

Return type:

np.ndarray