fluidsim.operators.operators3d

Operators 3d (fluidsim.operators.operators3d)

Provides

class fluidsim.operators.operators3d.OperatorsPseudoSpectral3D(params=None)[source]

Bases: OperatorsPseudoSpectral3D, OperatorBase

Provides fast Fourier transform functions and 3D operators.

Uses fft operators that implement the methods:

  • ifft

  • fft

  • get_shapeX_loc

  • get_shapeX_seq

  • get_shapeK_loc

  • get_shapeK_seq

  • get_dimX_K

  • get_seq_indices_first_K

  • get_k_adim_loc

  • sum_wavenumbers

  • build_invariant_arrayK_from_2d_indices12X

static _complete_params_with_default(params)[source]

This static method is used to complete the params container.

build_invariant_arrayX_from_2d_indices12X(arr2d, oper2d=None)[source]

Build a 3D array from a 2D array

build_invariant_arrayK_from_2d_indices12X(arr2d)[source]

Build a 3D array from a 2D array

dealiasing(*args)[source]

Dealiasing of SetOfVariables or np.ndarray

put_coarse_array_in_array_fft(arr_coarse, arr, oper_coarse, shapeK_coarse)[source]

Put the values contained in a coarse array in an array.

Both arrays are in Fourier space.

coarse_seq_from_fft_loc(f_fft, shapeK_coarse)[source]

Return a coarse field in K space.

where_is_wavenumber(ik0, ik1, ik2)[source]

Give local indices and rank from the sequential indices

urudfft_from_vxvyfft(vx_fft: Array_complex128_3d, vy_fft: Array_complex128_3d)[source]

Compute toroidal and poloidal horizontal velocities.

urx_fft, ury_fft contain shear modes!

project_kradial3d(vx_fft: Array_complex128_3d, vy_fft: Array_complex128_3d, vz_fft: Array_complex128_3d)[source]

Project (inplace) a vector field parallel to the k-radial direction of the wavevector.

Parameters:
Arrays containing the velocity in Fourier space.

Notes

The radial unitary vector for the mode \(\mathbf{k}\) is

\[\mathbf{e}_\mathbf{k} = \frac{\mathbf{k}}{|\mathbf{k}|} = \sin \theta_\mathbf{k} \cos \varphi_\mathbf{k} ~ \mathbf{e}_x + \sin \theta_\mathbf{k} \sin \varphi_\mathbf{k} ~ \mathbf{e}_y + \cos \theta_\mathbf{k} ~ \mathbf{e}_z,\]

and the projection of a velocity mode \(\hat{\mathbf{v}}_\mathbf{k}\) along \(\mathbf{e}_\mathbf{k}\) is

\[\hat{v}_\mathbf{k} ~ \mathbf{e}_\mathbf{k} \equiv \hat{\mathbf{v}}_\mathbf{k} \cdot \mathbf{e}_\mathbf{k} ~ \mathbf{e}_\mathbf{k}\]

This function set \(\hat{\mathbf{v}}_\mathbf{k} = \hat{v}_\mathbf{k} ~ \mathbf{e}_\mathbf{k}\) for all modes.

project_poloidal(vx_fft: Array_complex128_3d, vy_fft: Array_complex128_3d, vz_fft: Array_complex128_3d)[source]

Project (inplace) a vector field parallel to the k-poloidal (or polar) direction.

Parameters:
Arrays containing the velocity in Fourier space.

Notes

The poloidal unitary vector for the mode \(\mathbf{k}\) is

\[\mathbf{e}_{\mathbf{k}\theta} = \cos \theta_\mathbf{k} \cos \varphi_\mathbf{k} ~ \mathbf{e}_x + \cos \theta_\mathbf{k} \sin \varphi_\mathbf{k} ~ \mathbf{e}_y - \sin \theta_\mathbf{k} ~ \mathbf{e}_z,\]

and the projection of a velocity mode \(\hat{\mathbf{v}}_\mathbf{k}\) along \(\mathbf{e}_{\mathbf{k}\theta}\) is

\[\hat{v}_{\mathbf{k}\theta} ~ \mathbf{e}_{\mathbf{k}\theta} \equiv \hat{\mathbf{v}}_\mathbf{k} \cdot \mathbf{e}_{\mathbf{k}\theta} ~ \mathbf{e}_{\mathbf{k}\theta}\]

This function set \(\hat{\mathbf{v}}_\mathbf{k} = \hat{v}_{\mathbf{k}\theta} ~ \mathbf{e}_{\mathbf{k}\theta}\) for all modes.

vpfft_from_vecfft(vx_fft: Array_complex128_3d, vy_fft: Array_complex128_3d, vz_fft: Array_complex128_3d)[source]

Return the poloidal component of a vector field.

vecfft_from_vpfft(vp_fft: Array_complex128_3d)[source]

Return a vector field from the poloidal component.

project_toroidal(vx_fft: Array_complex128_3d, vy_fft: Array_complex128_3d, vz_fft: Array_complex128_3d)[source]

Project (inplace) a vector field parallel to the k-toroidal (or azimutal) direction.

Parameters:
Arrays containing the velocity in Fourier space.

Notes

The toroidal unitary vector for the mode \(\mathbf{k}\) is

\[\mathbf{e}_{\mathbf{k}\varphi} = - \sin \varphi_\mathbf{k} ~ \mathbf{e}_x + \cos \varphi_\mathbf{k} ~ \mathbb{e}_y,\]

and the projection of a velocity mode \(\hat{\mathbf{v}}_\mathbf{k}\) along \(\mathbf{e}_{\mathbf{k}\varphi}\) is

\[\hat{v}_{\mathbf{k}\varphi} ~ \mathbf{e}_{\mathbf{k}\varphi} \equiv \hat{\mathbf{v}}_\mathbf{k} \cdot \mathbf{e}_{\mathbf{k}\varphi} ~ \mathbf{e}_{\mathbf{k}\varphi}\]

This function compute \(\hat{\mathbf{v}}_\mathbf{k} = \hat{v}_{\mathbf{k}\varphi} ~ \mathbf{e}_{\mathbf{k}\varphi}\) for all modes.

vtfft_from_vecfft(vx_fft: Array_complex128_3d, vy_fft: Array_complex128_3d, vz_fft: Array_complex128_3d)[source]

Return the toroidal component of a vector field.

vecfft_from_vtfft(vt_fft: Array_complex128_3d)[source]

Return a 3D vector field from the toroidal component.

divhfft_from_vxvyfft(vx_fft: Array_complex128_3d, vy_fft: Array_complex128_3d)[source]

Compute the horizontal divergence in spectral space.

_ikxyzseq_from_ik012rank(ik0, ik1, ik2, rank=0)[source]

Give the sequential indices (xyz) from the local indices and the rank

_ik012rank_from_ikxyzseq(ikx, iky, ikz)[source]

Give the local indices and the rank from “sequential” indices (xyz)

_kadim_from_ikxyzseq(ikx, iky, ikz)[source]

Give the adimensional wavenumbers from sequential indices

_ikxyzseq_from_kadim(kx_adim, ky_adim, kz_adim)[source]

Give the sequential indices from the adimensional wavenumbers

kadim_from_ik012rank(ik0, ik1, ik2, rank=0)[source]

Give the adimensional wavenumbers from local indices and rank

ik012rank_from_kadim(kx_adim, ky_adim, kz_adim)[source]

Give the local indices and rank from the adimensional wavenumbers

set_value_spect(arr_fft, value, kx_adim, ky_adim, kz_adim, from_rank=0)[source]

Set a value in a spectral array given the adimensional wavenumber

get_value_spect(arr_fft, kx_adim, ky_adim, kz_adim, to_rank=0)[source]

Get a value in a spectral array given the adimensional wavenumber

Functions

compute_energy_from_1field(arr)

compute_energy_from_1field_with_coef(arr, coef)

compute_energy_from_2fields(vx, vy)

compute_energy_from_3fields(vx, vy, vz)

dealiasing_setofvar(sov, where_dealiased)

dealiasing_setofvar_numpy(sov, where_dealiased)

dealiasing_variable(ff_fft, where_dealiased)

dealiasing_variable_numpy(ff_fft, ...)

Classes

OperatorsPseudoSpectral3D([params])

Provides fast Fourier transform functions and 3D operators.