Cartesian with MPI

Cartesian grids with MPI

shift.cart.mpi_grid1D(boxsize, ngrid, MPI, origin=0.0)[source]

Returns the x coordinates of a cartesian grid.

Parameters:
  • boxsize (float) – Box size.

  • ngrid (int) – Grid division along one axis.

  • MPI (object) – MPIutils MPI object.

  • origin (float, optional) – Start point of the grid.

Returns:

  • xedges (array) – x coordinate bin edges.

  • x (array) – X coordinates bin centers.

shift.cart.mpi_grid2D(boxsize, ngrid, MPI, origin=0.0)[source]

Returns the x, y coordinates of a cartesian grid.

Parameters:
  • boxsize (float) – Box size or list of length along each axis.

  • ngrid (int) – Grid division along one axis or a list of the grid divisions along each axis.

  • MPI (object) – MPIutils MPI object.

  • origin (float, optional) – Origin of the grid. If all axes begin at the same origin this can be a scalar, if you instead wish to specify different origins for each axis this should be added as a list.

Returns:

  • x2D (array) – X coordinates on a 2D cartesian grid.

  • y2D (array) – Y coordinates on a 2D cartesian grid.

shift.cart.mpi_grid3D(boxsize, ngrid, MPI, origin=0.0)[source]

Returns the x, y, z coordinates of a cartesian grid.

Parameters:
  • boxsize (float) – Box size or list of length along each axis.

  • ngrid (int) – Grid division along one axis or a list of the grid divisions along each axis.

  • MPI (object) – MPIutils MPI object.

  • origin (float, optional) – Origin of the grid. If all axes begin at the same origin this can be a scalar, if you instead wish to specify different origins for each axis this should be added as a list.

Returns:

  • x3D (array) – X coordinates on a 3D cartesian grid.

  • y3D (array) – Y coordinates on a 3D cartesian grid.

  • z3D (array) – Z coordinates on a 3D cartesian grid.

FFT with MPI

Fourier grids

shift.cart.mpi_kgrid1D(boxsize, ngrid, MPI)[source]

Returns the Fourier modes for the Fast Fourier Transform on a 1D cartesian grid.

Parameters:
  • boxsize (float) – Box size.

  • ngrid (int) – Grid division along one axis.

  • MPI (object) – MPIutils MPI object.

Returns:

k – Fourier modes.

Return type:

array

shift.cart.mpi_kgrid2D(boxsize, ngrid, MPI)[source]

Returns the Fourier modes for the Fast Fourier Transform on a 2D cartesian grid.

Parameters:
  • boxsize (float or list) – Box size or a list of the dimensions of each axis.

  • ngrid (int or list) – Grid division along one axis or a list for each axis.

  • MPI (object) – MPIutils MPI object.

Returns:

  • kx2D (array) – Fourier x-mode.

  • ky2D (array) – Fourier y-mode.

shift.cart.mpi_kgrid3D(boxsize, ngrid, MPI)[source]

Returns the Fourier modes for the Fast Fourier Transform on a 3D cartesian grid.

Parameters:
  • boxsize (float or list) – Box size or a list of the dimensions of each axis.

  • ngrid (int or list) – Grid division along one axis or a list for each axis.

  • MPI (object) – MPIutils MPI object.

Returns:

  • kx3D (array) – Fourier x-mode.

  • ky3D (array) – Fourier y-mode.

  • kz3D (array) – Fourier z-mode.

Forward/Backward Transforms

shift.cart.mpi_fft2D(f_real, boxsize, ngrid, MPI)[source]

Performs MPI forward FFT on real space data.

Parameters:
  • f_real (1darray or ndarray) – Real space data.

  • boxsize (float or list) – Box size or a list of the dimensions of each axis.

  • ngrid (int or list) – Grid division along one axis or a list for each axis.

  • MPI (obj) – MPIutils MPI object.

Returns:

f_fourier – Fourier modes.

Return type:

ndarray

shift.cart.mpi_ifft2D(f_fourier, boxsize, ngrid, MPI)[source]

Performs MPI backward FFT on Fourier modes.

Parameters:
  • f_fourier (ndarray) – Fourier modes.

  • boxsize (float or list) – Box size or a list of the dimensions of each axis.

  • ngrid (int or list) – Grid division along one axis or a list for each axis.

  • MPI (obj) – MPIutils MPI object.

Returns:

f_real – Real space data.

Return type:

1darray or ndarray

shift.cart.mpi_fft3D(f_real, boxsize, ngrid, MPI)[source]

Performs MPI forward FFT on real space data.

Parameters:
  • f_real (ndarray) – Real space data.

  • boxsize (float or list) – Box size or a list of the dimensions of each axis.

  • ngrid (int or list) – Grid division along one axis or a list for each axis.

  • MPI (obj) – MPIutils MPI object.

Returns:

f_fourier – Fourier modes.

Return type:

ndarray

shift.cart.mpi_ifft3D(f_fourier, boxsize, ngrid, MPI)[source]

Performs MPI backward FFT on Fourier modes.

Parameters:
  • f_fourier (ndarray) – Fourier modes.

  • boxsize (float or list) – Box size or a list of the dimensions of each axis.

  • ngrid (int or list) – Grid division along one axis or a list for each axis.

  • MPI (obj) – MPIutils MPI object.

Returns:

f – Real space data.

Return type:

ndarray

DCT with MPI

Fourier grids

shift.cart.mpi_kgrid1D_dct(boxsize, ngrid, MPI)[source]

Returns the Fourier modes for the Discrete Cosine Transform on a 1D cartesian grid.

Parameters:
  • boxsize (float) – Box size.

  • ngrid (int) – Grid division along one axis.

  • MPI (object) – MPIutils MPI object.

Returns:

k – Fourier modes.

Return type:

array

shift.cart.mpi_kgrid2D_dct(boxsize, ngrid, MPI)[source]

Returns the Fourier modes for the Discrete Cosine Transform on a 2D cartesian grid.

Parameters:
  • boxsize (float or list) – Box size or a list of the dimensions of each axis.

  • ngrid (int or list) – Grid division along one axis or a list for each axis.

  • MPI (object) – MPIutils MPI object.

Returns:

  • kx2D (array) – Fourier x-mode.

  • ky2D (array) – Fourier y-mode.

shift.cart.mpi_kgrid3D_dct(boxsize, ngrid, MPI)[source]

Returns the Fourier modes for the Discrete Cosine Transform on a 3D cartesian grid.

Parameters:
  • boxsize (float or list) – Box size or a list of the dimensions of each axis.

  • ngrid (int or list) – Grid division along one axis or a list for each axis.

  • MPI (object) – MPIutils MPI object.

Returns:

  • kx3D (array) – Fourier x-mode.

  • ky3D (array) – Fourier y-mode.

  • kz3D (array) – Fourier z-mode.

Forward/Backward Transforms

shift.cart.mpi_dct2D(f_real, boxsize, ngrid, MPI, type=2)[source]

Performs MPI forward DCT on real space data.

Parameters:
  • f_real (1darray or ndarray) – Real space data.

  • boxsize (float or list) – Box size or a list of the dimensions of each axis.

  • ngrid (int or list) – Grid division along one axis or a list for each axis.

  • MPI (obj) – MPIutils MPI object.

  • type (int, optional) – Type of DCT for scipy to perform.

Returns:

f_fourier – Fourier modes.

Return type:

ndarray

shift.cart.mpi_idct2D(f_fourier, boxsize, ngrid, MPI, type=2)[source]

Performs MPI backward DCT on Fourier modes.

Parameters:
  • f_fourier (ndarray) – Fourier modes.

  • boxsize (float or list) – Box size or a list of the dimensions of each axis.

  • ngrid (int or list) – Grid division along one axis or a list for each axis.

  • MPI (obj) – MPIutils MPI object.

  • type (int, optional) – Type of iDCT for scipy to perform.

Returns:

f_real – Real space data.

Return type:

1darray or ndarray

shift.cart.mpi_dct3D(f_real, boxsize, ngrid, MPI, type=2)[source]

Performs MPI forward DCT on real space data.

Parameters:
  • f_real (ndarray) – Real space data.

  • boxsize (float or list) – Box size or a list of the dimensions of each axis.

  • ngrid (int or list) – Grid division along one axis or a list for each axis.

  • MPI (obj) – MPIutils MPI object.

  • type (int, optional) – Type of DCT for scipy to perform.

Returns:

f_fourier – Fourier modes.

Return type:

ndarray

shift.cart.mpi_idct3D(f_fourier, boxsize, ngrid, MPI, type=2)[source]

Performs MPI backward DCT on Fourier modes.

Parameters:
  • f_fourier (ndarray) – Fourier modes.

  • boxsize (float or list) – Box size or a list of the dimensions of each axis.

  • ngrid (int or list) – Grid division along one axis or a list for each axis.

  • MPI (obj) – MPIutils MPI object.

  • type (int, optional) – Type of iDCT for scipy to perform.

Returns:

f – Real space data.

Return type:

ndarray

DST with MPI

Fourier grids

shift.cart.mpi_kgrid1D_dst(boxsize, ngrid, MPI)[source]

Returns the Fourier modes for the Discrete Sine Transform on a 1D cartesian grid.

Parameters:
  • boxsize (float) – Box size.

  • ngrid (int) – Grid division along one axis.

  • MPI (object) – MPIutils MPI object.

Returns:

k – Fourier modes.

Return type:

array

shift.cart.mpi_kgrid2D_dst(boxsize, ngrid, MPI)[source]

Returns the Fourier modes for the Discrete Sine Transform on a 2D cartesian grid.

Parameters:
  • boxsize (float or list) – Box size or a list of the dimensions of each axis.

  • ngrid (int or list) – Grid division along one axis or a list for each axis.

  • MPI (object) – MPIutils MPI object.

Returns:

  • kx2D (array) – Fourier x-mode.

  • ky2D (array) – Fourier y-mode.

shift.cart.mpi_kgrid3D_dst(boxsize, ngrid, MPI)[source]

Returns the Fourier modes for the Discrete Sine Transform on a 3D cartesian grid.

Parameters:
  • boxsize (float or list) – Box size or a list of the dimensions of each axis.

  • ngrid (int or list) – Grid division along one axis or a list for each axis.

  • MPI (object) – MPIutils MPI object.

Returns:

  • kx3D (array) – Fourier x-mode.

  • ky3D (array) – Fourier y-mode.

  • kz3D (array) – Fourier z-mode.

Forward/Backward Transforms

shift.cart.mpi_dst2D(f_real, boxsize, ngrid, MPI, type=2)[source]

Performs MPI forward DST on real space data.

Parameters:
  • f_real (1darray or ndarray) – Real space data.

  • boxsize (float or list) – Box size or a list of the dimensions of each axis.

  • ngrid (int or list) – Grid division along one axis or a list for each axis.

  • MPI (obj) – MPIutils MPI object.

  • type (int, optional) – Type of DST for scipy to perform.

Returns:

f_fourier – Fourier modes.

Return type:

ndarray

shift.cart.mpi_idst2D(f_fourier, boxsize, ngrid, MPI, type=2)[source]

Performs MPI backward DST on Fourier modes.

Parameters:
  • f_fourier (ndarray) – Fourier modes.

  • boxsize (float or list) – Box size or a list of the dimensions of each axis.

  • ngrid (int or list) – Grid division along one axis or a list for each axis.

  • MPI (obj) – MPIutils MPI object.

  • type (int, optional) – Type of iDST for scipy to perform.

Returns:

f_real – Real space data.

Return type:

1darray or ndarray

shift.cart.mpi_dst3D(f_real, boxsize, ngrid, MPI, type=2)[source]

Performs MPI forward DST on real space data.

Parameters:
  • f_real (ndarray) – Real space data.

  • boxsize (float or list) – Box size or a list of the dimensions of each axis.

  • ngrid (int or list) – Grid division along one axis or a list for each axis.

  • MPI (obj) – MPIutils MPI object.

  • type (int, optional) – Type of DST for scipy to perform.

Returns:

f_fourier – Fourier modes.

Return type:

ndarray

shift.cart.mpi_idst3D(f_fourier, boxsize, ngrid, MPI, type=2)[source]

Performs MPI backward DST on Fourier modes.

Parameters:
  • f_fourier (ndarray) – Fourier modes.

  • boxsize (float or list) – Box size or a list of the dimensions of each axis.

  • ngrid (int or list) – Grid division along one axis or a list for each axis.

  • MPI (obj) – MPIutils MPI object.

  • type (int, optional) – Type of iDST for scipy to perform.

Returns:

f – Real space data.

Return type:

ndarray