field_treatment module

IMTreatment.field_treatment.field_treatment.extrapolate_until_wall(field, direction='x', position=0.0, kind_interp='linear')[source]

Interpolate the given fiels until it reach wall (0 velocity) at the given position.

Parameters:
  • field (ScalarField or VectorField object.) – Field to extend
  • direction (string) – Axe on which the wall is placed (default to ‘x’)
  • position (number) – position of the wall (in the same unit as the field)
  • kind_interp (string) – Type of algorithm used to fill. ‘linear’ (default): fill using linear interpolation ‘cubic’ : fill using cubic interpolation
Returns:

extended_field – Extended field.

Return type:

ScalarField or VectorField

IMTreatment.field_treatment.field_treatment.get_Kenwright_field(field, raw=False)[source]

Return a field with the vector product between the velocity field and the eigen vectors of the velocity jacobian. Values of 0 on these field should represent separation lines or re-attachment lines (See Kenwright et al (1998)).

Parameters:
  • field (VectorField) –

    .

  • raw (bool, optional) – If ‘False’ (default), ScalarFields are returned If ‘True’, arrays are returned
Returns:

  • K1_field (ScalarField) – Vector product with the principal eigen vector
  • K2_field (ScalarField) – Vector product with the oher eigen vector

IMTreatment.field_treatment.field_treatment.get_divergence(vf)[source]

Return the divergence.

IMTreatment.field_treatment.field_treatment.get_fieldlines(VF, xys, reverse=False, rel_err=1e-08, max_steps=1000, resolution=0.25, resolution_kind='length', boundary_tr='stop')[source]

Return the field lines associated to a set of particules initialy at the positions xys. Use Fortran integration of the VODE algorithm. (Source: http://www.netlib.org/ode/vode.f)

Parameters:
  • VF (VectorField or velocityField object) – Field on which compute the fieldlines
  • xys (2xN tuple of number) – Initial points positions
  • rel_err (number) – relative maximum error for rk4 algorithm
  • max_steps (integer) – Maximum number of steps (default = 1000).
  • resolution (number,) – resolution of the resulting fieldline (do not impact accuracy).
  • resolution_kind (string in ['time', 'length']) – if ‘time’, returned points time space are homogeneous, if ‘length’, returned points space interval are homogeneous.
  • boundary_tr (string) – Method to treat the field boundaries. If ‘stop’, fieldlines are stopped when encountering a boundary, If ‘hide’, fieldlines that encounter a boundary are not returned.
IMTreatment.field_treatment.field_treatment.get_grad_field(field, direction='x')[source]

Return a field based on original field gradients. (Vx = dV/dx, Vy = DV/Vy)

Parameters:
  • field (VectorField object) –

    .

  • direction (string in ['x', 'y']) – if ‘x’, return Vx gradients if ‘y’, return Vy gradients.
Returns:

gfield – .

Return type:

VectorField object

IMTreatment.field_treatment.field_treatment.get_gradients(field, raw=False)[source]

Return gradients along x and y.

(Obtained arrays corespond to components of the Jacobian matrix)

Parameters:
  • vf (VelocityField, ScalarField or Profile object) – Field/profile to compute gradient from.
  • raw (boolean) – If ‘False’ (default), ScalarFields objects are returned. If ‘True’, arrays are returned.
Returns:

grad – For VectorField input : (dVx/dx, dVx/dy, dVy/dx, dVy/dy), for ScalarField input : (dV/dx, dV/dy). for Profile input : dy/dx.

Return type:

tuple of ScalarField or arrays or Profile

IMTreatment.field_treatment.field_treatment.get_jacobian_eigenproperties(field, raw=False, eig_val=True, eig_vect=True)[source]

Return eigenvalues and eigenvectors of the jacobian matrix on all the field.

Parameters:
  • field (VectorField object) –

    .

  • raw (boolean) – If ‘False’ (default), ScalarFields objects are returned. If ‘True’, arrays are returned.
  • eig_val (boolean, optional) – If ‘True’, eigenvalues are returned.
  • eig_vect (boolean, optional) – If ‘True’, eigenvectors are returned.
Returns:

  • eig_val1_re (ScalarField object, or array) – Real part of the first eigenvalue.
  • eig_val1_im (ScalarField object, or array) – Imaginary part of the first eigenvalue.
  • eig_val2_re (ScalarField object, or array) – Real part of the second eigenvalue.
  • eig_val2_im (ScalarField object, or array) – Imaginary part of the second eigenvalue.
  • eig1_vf (VectorField object, or tuple of arrays) – Eigenvector associated with first eigenvalue.
  • eig2_vf (VectorField object, or tuple of arrays) – Eigenvector associated with second eigenvalue.

IMTreatment.field_treatment.field_treatment.get_shear_stress(vf, raw=False)[source]

Return a vector field with the shear stress.

Parameters:
  • vf (VectorField or Velocityfield) – Field on which compute shear stress
  • raw (boolean, optional) – If ‘True’, return two arrays, if ‘False’ (default), return a VectorField object.
IMTreatment.field_treatment.field_treatment.get_streamlines(VF, xys, reverse=False, rel_err=1e-08, max_steps=1000, resolution=0.25, resolution_kind='length', boundary_tr='stop')[source]

Return the lagrangien displacement of a set of particules initialy at the positions xys. Use Fortran integration of the VODE algorithm. (Source: http://www.netlib.org/ode/vode.f)

Parameters:
  • VF (VectorField or velocityField object) – Field on which compute the streamlines
  • xys (2xN tuple of number) – Initial points positions
  • rel_err (number) – relative maximum error for rk4 algorithm
  • max_steps (integer) – Maximum number of steps (default = 1000).
  • resolution (number,) – resolution of the resulting streamline (do not impact accuracy).
  • resolution_kind (string in ['time', 'length']) – if ‘time’, returned points time space are homogeneous, if ‘length’, returned points space interval are homogeneous.
  • boundary_tr (string) – Method to treat the field boundaries. If ‘stop’, streamlines are stopped when encountering a boundary, If ‘hide’, streamlines that encounter a boundary are not returned.
IMTreatment.field_treatment.field_treatment.get_streamlines_fast(vf, xy, delta=0.25, interp='linear', reverse=False)[source]

Return a tuples of Points object representing the streamline begining at the points specified in xy. Is called fast because use simpler integration method than the ‘get_streamlines()’ method and can be tuned with the ‘delta’ and ‘interp’ parameters.

Parameters:
  • vf (VectorField or velocityField object) – Field on which compute the streamlines
  • xy (tuple) – Tuple containing each starting point for streamline.
  • delta (number, optional) – Spatial discretization of the stream lines, relative to a the spatial discretization of the field.
  • interp (string, optional) – Used interpolation for streamline computation. Can be ‘linear’(default) or ‘cubic’
  • reverse (boolean, optional) – If True, the streamline goes upstream.
Returns:

streams – Each Points object represent a streamline

Return type:

tuple of Points object

IMTreatment.field_treatment.field_treatment.get_swirling_vector(vf, raw=False)[source]

Return a vector field with the swirling vectors (eigenvectors of the velocity laplacian matrix ponderated by eigenvalues) (Have to be adjusted : which part of eigenvalues and eigen vectors take ?)

Parameters:
  • vf (VectorField or Velocityfield) – Field on which compute shear stress
  • raw (boolean, optional) – If ‘True’, return an arrays, if ‘False’ (default), return a ScalarField object.
IMTreatment.field_treatment.field_treatment.get_track_field(vf)[source]

Return the track field. (Vx, Vy) => (-Vy, Vx)

IMTreatment.field_treatment.field_treatment.get_tracklines(VF, xys, reverse=False, rel_err=1e-08, max_steps=1000, resolution=0.25, resolution_kind='length', boundary_tr='stop')[source]

Return a tuples of Points object representing the tracklines begining at the points specified in xy. Warning : fill the field before computing streamlines, can give bad results if the field have a lot of masked values.

Parameters:
  • VF (VectorField or velocityField object) – Field on which compute the streamlines
  • xys (2xN tuple of number) – Initial points positions
  • rel_err (number) – relative maximum error for rk4 algorithm
  • max_steps (integer) – Maximum number of steps (default = 1000).
  • resolution (number,) – resolution of the resulting streamline (do not impact accuracy).
  • resolution_kind (string in ['time', 'length']) – if ‘time’, returned points time space are homogeneous, if ‘length’, returned points space interval are homogeneous.
  • boundary_tr (string) – Method to treat the field boundaries. If ‘stop’, streamlines are stopped when encountering a boundary, If ‘hide’, streamlines that encounter a boundary are not returned.
Returns:

tracks – Each Points object represent a trackline

Return type:

tuple of Points object

IMTreatment.field_treatment.field_treatment.reconstruct_from_gradients(field_dx, field_dy, field2_dx=None, field2_dy=None, ols=False, maxiter=10)[source]

Reconstruct a field with the gradients of this field.

Parameters:
  • field_dy (field2_dx,) – Gradients along x and y.
  • field_dy – Gradients for the second component, if the reconstructed field is a vector field.
  • ols (boolean, optional) – If ‘True’, ordinary least square is used to get a more precise result (can be quite long). If ‘False’ (default), a simple reconstruction based on taylor developement is used.
  • maxiter (integer, optional) – Maximum number of iteration for the ols solver (default: 10) (more mean accurate results but slower computation).
Returns:

rec_field – Reconstructed field.

Return type:

ScalarField or VectorField object

Notes

Given result can only be relative values (because of the information lost while derivating). The returned result are normalized so that the mean of the field is egal to zero.