multi_transform

Class summary

_NTransform(func, transforms, transvars, opts) Recursively perform integral transforms
_OptFunc(opt) When called the object will return the variable used to initialize it

Function summary

ntransform(func, transforms, transvars[, ...]) Multi-dimensional integral transforms over multiple variables.

Module listing

Some routines related multi dimensional integral transforms

geotecha.mathematics.multi_transform.ntransform(func, transforms, transvars, args=None, opts=None)[source]

Multi-dimensional integral transforms over multiple variables.

General idea and organisation of code is from scipy.integrate.nquad

Parameters:

func : callable

The function to be integrated. Has arguments of x0, ... xn, t0, tm, where integration is carried out over x0, ... xn, which must be floats. Function signature should be func(x0, x1, ..., xn, t0, t1, ..., tm). Integral transforms are carried out in order. That is, integration over x0 is the innermost integral/transform, and xn is the outermost.

transform : iterable object of string

Each elmement of transforms is a string corresponding to one of the available transforms. Current options are:

  • Hankel
  • Hankel_inverse
  • Fourier
  • Fourier_inverse
  • Laplace_inverse

transvars : iterable

Transformation variable for each transformation.

args : iterable object, optional

Additional arguments t0, ..., tn, required by func.

opts : iterable object or dict, optional

Options to be passed to each transform. May be empty, a dict, or a sequence of dicts, or functions that return a dict. If empty, the default options of each transform are used. If a dict, the same options are used for all levels of integration. If a sequence, then each element of the sequence corresponds to a particular integration/ transform. e.g. opts[0] corresponds to integration/transform over x0, and so on. See the individual transforms for options.

Returns:

result : float

The result of the integration.

abserr : float

The maximum of the estimates of the absolute error in the various integration results.

Notes

ntransform is quite temperamental. Be careful with the following:

  • For some reason performing repeated multi dimensional fourier transforms with the default integration limit of np.inf does not work (I get a very small number... the wrong number). This problem also happens when doing the same transforms using scipy’s nquad for multidemensional integration. There is some issue with the recursion and use of the underlying QUADPACK integration routines when performing integrations with a cos or sin weight function with infinte integration limits. To get around this you could try truncating the integral by setting the b keyword agument to the FourierTransform object. You will probably have to trial a few values; larger values give more accuracy but too large and the solution is gibberish.
  • Because the inverse laplace transform uses imaginary and any QUADPACK integations can only use real numbers. A laplace transfrom usually must be the inner most intergal, i.e. first in the transform list. If performing multi-dimensional inverse lapace transforms then they must be at the front of the transform list; all inverse laplace transforms other than the first in the transform list must have {‘vectorised’: False}, in the corresponding opts dict. If f is not vectorised then the first inverse Laplace transform must also have {‘vectorised’: False}
  • Because the Hankel transform uses numpy broadcasting, it must always be the inner most integral, i.e. first in the transform list. If also doing an inverse laplace transform, then ‘Laplace_inverse` must be second in the transform list with {‘vectorised’: False} in the corresponding opts dict.
  • Rules of thumb are 1. ‘Hankel_transform’, if it occurs, must be first in the transform list, 2. ‘Laplace_inverse’ must be before any ‘Fourier’ or ‘Fourier_inverse’ instance in the transform list, 3. For any but the first ‘Laplace_inverse’ instance in the transform list, the corresponding opts dict must contain ‘vectorized’:False, 4. ‘Fourier’ or ‘Fourier_inverse’ may fail using the default b=np.inf, try truncating the integral with ‘b’:35 in the corresponding opts dict.
  • Make sure that the order of the transform list matches the order or the args in function f. First in list transforms first arg of f, 2nd in list transforms secnod arg of f.