Package nMOLDYN :: Package Core :: Module Mathematics
[hide private]
[frames] | no frames]

Module Mathematics

source code

This modules implements the mathematics-related classes, functions and procedures.

Classes:
    * QVectors: the class that actually performs the q vectors generation.

Functions:
    * differentiate      : performs a numerical differentiation of 1D Numeric array
    * correlation        : performs the numerical correlation between two 1D Numeric arrays
    * convolution        : performs the numerical convolution between two 1D Numeric arrays
    * FFT                : performs the FFT of a 1D Numeric array
    * invFFT             : performs the inverse FFT of a 1D Numeric array
    * gaussianWindow     : performs a Gaussian smoothing of 1D Numeric array.
    * factorial          : computes factorial (n) where n is an integer.
    * basisVectors       : computes the basis vectors of the simulation cell from a set of values defining its geometry (3 distances and 3 angles).
    * randomPointInCircle: returns a vector within a circle of radius |r| and orthogonal to a given direction.
    * randomDirection2D  : returns a normalized vector generated from a unit circle orthogonal to a given direction.
    * randomPlane2D      : generates a normalized random q-vector on a plane defined by vect1, vect2.
    * qVectorGenerator   : sets up and returns a set of q vectors generated from different user-defined parameters.
    * sphericalHarmonics : calculates the spherical functions Y from a set of j, m, n Wigner indexes
    * preparePP          : sets up the calculation of spherical harmonics.

Functions [hide private]
NumPy array
differentiate(inputSeries, order, dx)
Returns the numerical derivative of order |order| of the signal |inputSeries| using the differentiation step |dx|.
source code
 
myautocorrelation(inputSeries) source code
NumPy array
correlation(inputSeries1, inputSeries2=None)
Returns the numerical correlation between |inputSeries1| and |inputSeries2| multidimensional NumPy arrays.
source code
NumPy array
convolution(inputSeries1, inputSeries2)
Returns the numerical convolution between |inputSeries1| and |inputSeries2| one-dimensional NumPy arrays.
source code
NumPy array
FFT(inputSeries)
Returns the FFT of |inputSeries| multidimensional NumPy array.
source code
NumPy array
invFFT(inputSeries)
Returns the inverse FFT of |inputSeries| multidimensional NumPy array.
source code
NumPy array
gaussianWindow(inputSeries, alpha)
Returns a smoothed signal using |inputSeries| input signal and a gaussian kernel of width |alpha|.
source code
integer
factorial(n)
Returns n!
source code
 
preparePP(j, m, n)
Intermediate function used to setup the calculation of spherical harmonics.
source code
a list of three floats
sphericalCoordinates(x, y, z)
This function returns the r, theta and phi spherical coordinates from the x, y z cartesian coordinates.
source code
Scientific Vector
changeBasis(pt, op, ip, jp, kp)
This function return the coordinates
source code
list
basisVectors(parameters)
Returns the basis vectors for the simulation cell from the six crystallographic parameters.
source code
Scientific.Geometry.Vector object
randomPointInCircle(r, axis)
Returns a vector drawn from an uniform distribution within a circle of radius |r| and orthogonal to vector |axis|.
source code
Scientific.Geometry.Vector object
randomDirection2D(axis)
Returns a normalized vector drawn from an uniform distribution on the surface of a unit circle on a plane orthogonal to |axis|.
source code
Scientific.Geometry.Vector object
randomVector(directions=None)
Returns a normalized random vector on a plane or in space.
source code
Variables [hide private]
  a2 = N.array([[-3., 4.,-1.], [-1., 0., 1.], [1.,-4., 3.]])
a3 = array used to perform order 3 numerical differentiation scheme.
  a3 = N.array([[-11., 18.,-9., 2.], [-2.,-3., 6.,-1.], [1.,-6.,...
a4 = array used to perform order 4 numerical differentiation scheme.
  a4 = N.array([[-50., 96.,-72., 32.,-6.], [-6.,-20., 36.,-12., ...
a5 = N.array used to perform order 5 numerical differentiation scheme.
  a5 = N.array([[-274., 600.,-600., 400.,-150., 24.], [-24.,-130...
Function Details [hide private]

differentiate(inputSeries, order, dx)

source code 

Returns the numerical derivative of order |order| of the signal |inputSeries| using the differentiation step |dx|.

Parameters:
  • inputSeries - the signal to differentiate.
  • order - an integer in [1,5] specifying the numerical differentiation order.
  • dx - a float specifying the differentiation step. Assumed to be constant over all the spectrum.
Returns: NumPy array
the differentiated signal.

See Also: M. Abramowitz, I.A. Stegun; 'Handbook of mathematical functions', Dover, New-York, 1972 p.914.

correlation(inputSeries1, inputSeries2=None)

source code 

Returns the numerical correlation between |inputSeries1| and |inputSeries2| multidimensional NumPy arrays.

Parameters:
  • inputSeries1 (NumPy array) - the first signal
  • inputSeries2 (NumPy array) - if not None, the second signal to correlate with |inputSeries1| otherwise the correlation will be an autocorrelation.
Returns: NumPy array
an array (length(|inputSeries1|)) storing the result of the correlation.
Notes:
  • if |inputSeries1| is a multidimensional array the correlation calculation is performed on the first dimension.
  • The correlation is computed using the FCA algorithm.

convolution(inputSeries1, inputSeries2)

source code 

Returns the numerical convolution between |inputSeries1| and |inputSeries2| one-dimensional NumPy arrays.

Parameters:
  • inputSeries1 (NumPy array) - the first signal
  • inputSeries2 (NumPy array) - the second signal to convolve with |inputSeries1|.
Returns: NumPy array
an array (length(|inputSeries1|)) storing the result of the convolution.
Notes:
  • if |inputSeries1| is a multidimensional array the convolution calculation is performed on the first dimension.
  • the convolution is computed using the convolve function of NumPy package.

FFT(inputSeries)

source code 

Returns the FFT of |inputSeries| multidimensional NumPy array.

Parameters:
  • inputSeries (NumPy array) - the array on which to computes the FFT.
Returns: NumPy array
the FFT transformed array.

Note: the FFT is computed using the fft function of Scientific.FFT package.

invFFT(inputSeries)

source code 

Returns the inverse FFT of |inputSeries| multidimensional NumPy array.

Parameters:
  • inputSeries (NumPy array) - the array on which to computes the inverse FFT.
Returns: NumPy array
the inverse FFT transformed array.

Note: the inverse FFT is computed using the inverse_fft function of Scientific.FFT package.

gaussianWindow(inputSeries, alpha)

source code 

Returns a smoothed signal using |inputSeries| input signal and a gaussian kernel of width |alpha|.

Parameters:
  • inputSeries (NumPy array) - the signal to smooth.
  • alpha (float) - a float specifying the width of the Gaussian.
Returns: NumPy array
an array (length = 2*len(|inputSeries|) - 1) containing the smoothed signal.

factorial(n)

source code 

Returns n!

Parameters:
  • n - the n of n!.
Returns: integer
n!.

sphericalCoordinates(x, y, z)

source code 

This function returns the r, theta and phi spherical coordinates from the x, y z cartesian coordinates.

Parameters:
  • x (float) - the cartesian x.
  • y (float) - the cartesian y.
  • z (float) - the cartesian z.
Returns: a list of three floats
the r, theta and phi spherical coordinates..

changeBasis(pt, op, ip, jp, kp)

source code 

This function return the coordinates

Parameters:
  • pt (Scientific Vector) - the coordinates of the point in the old basis.
  • op (Scientific Vector) - the coordinates of the new origin in the old basis.
  • ip (Scientific Vector) - the coordinates of the new x axis in the old basis.
  • jp (Scientific Vector) - the coordinates of the new y axis in the old basis.
  • kp (Scientific Vector) - the coordinates of the new z axis in the old basis.
Returns: Scientific Vector
the coordinates of the point in the new basis.

basisVectors(parameters)

source code 

Returns the basis vectors for the simulation cell from the six crystallographic parameters.

Parameters:
  • parameters - a list of six floats defining the simulation cell geometry.
Returns: list
a list of three Scientific.Geometry.Vector objects representing respectively a, b and c basis vectors.

randomPointInCircle(r, axis)

source code 

Returns a vector drawn from an uniform distribution within a circle of radius |r| and orthogonal to vector |axis|.

Parameters:
  • r (float) - float specifying the radius of the circle.
  • axis (Scientific.Geometry.Vector object) - the axis orthogonal to the plane where the vectors have to be generated.
Returns: Scientific.Geometry.Vector object
a vector pointing to a random point of the circle.

randomDirection2D(axis)

source code 

Returns a normalized vector drawn from an uniform distribution on the surface of a unit circle on a plane orthogonal to |axis|.

Parameters:
  • axis (Scientific.Geometry.Vector object) - the axis orthogonal to the plane where the vectors have to be generated.
Returns: Scientific.Geometry.Vector object
A normalized vector defined in a unit disk orthogonal to |axis|

randomVector(directions=None)

source code 

Returns a normalized random vector on a plane or in space.

Parameters:
  • directions (list of 2 Scientific.Vector or None) - if not None, a list of 2 Scientific.Vector that will define the plane on which the vector should be generated.
Returns: Scientific.Geometry.Vector object
a normalized random vector on a plane defined by |directions| or in space (|directions| = None).

Variables Details [hide private]

a3

a4 = array used to perform order 4 numerical differentiation scheme.

Value:
N.array([[-11., 18.,-9., 2.], [-2.,-3., 6.,-1.], [1.,-6., 3., 2.], [-2\
., 9.,-18., 11.]])

a4

a5 = N.array used to perform order 5 numerical differentiation scheme.

Value:
N.array([[-50., 96.,-72., 32.,-6.], [-6.,-20., 36.,-12., 2.], [2.,-16.\
, 0., 16.,-2.], [-2., 12.,-36., 20., 6.], [6.,-32., 72.,-96., 50.]])

a5

Value:
N.array([[-274., 600.,-600., 400.,-150., 24.], [-24.,-130., 240.,-120.\
, 40.,-6.], [6.,-60.,-40., 120.,-30., 4.], [-4., 30.,-120., 40., 60.,-\
6.], [6.,-40., 120.,-240., 130., 24.], [-24., 150.,-400., 600.,-600., \
274.]])