aurel.numerical

numerical.py

This module contains numerical methods for various calculations.

aurel.numerical.dichotomy(y_wanted, function, lower_bound, upper_bound, tolerance)[source]

Find the root of a function using the bisection method.

Numerically solving for x: function(x) = y_wanted

Parameters:
  • y_wanted (float) – The value of the function to find the root for.

  • function (callable) – The function for which to find the root.

  • lower_bound (float) – The lower bound of the interval to search for the root.

  • upper_bound (float) – The upper bound of the interval to search for the root.

  • tolerance (float) – The tolerance for the convergence of the method.

Returns:

The x value for which the function is equal to y_wanted.

Return type:

float

aurel.numerical.interpolate(val, grid_points, target_points, method='linear')[source]

Interpolate scalar field from one grid to a new grid.

Parameters:
  • val (ndarray) – Scalar field values on the regular grid. Shape should match the grid dimensions.

  • grid_points (tuple of ndarray) – Tuple of coordinate arrays defining the regular grid coordinates. Each array should be 1D.

  • target_points (tuple of ndarray) – Tuple of target coordinate positions. Arrays can be any shape but must have matching dimensions.

  • method (str, optional) – Interpolation method used. See scipy.interpolate.RegularGridInterpolator documentation

Returns:

Interpolated values at the target points, with the same shape as the target coordinate arrays.

Return type:

ndarray