airfrans

reorganize(in_order_points, out_order_points, quantity_to_reorder)[source]

Reorder points coming from different source of data with the same positions.

Parameters
  • in_order_points (np.ndarray) – Positions of the features we want to reorder (shape (N, 2)).

  • out_order_points (np.ndarray) – Positions for the new ordering (shape (N, 2)).

  • quantity_to_reorder (np.ndarray) – Features attached to the points we want to reorder (shape (N, F)).

class Simulation(root, name, T=298.15)[source]

Wrapper to make the study of AirfRANS simulations easier. It only takes in input the location of the .vtu and .vtp files from the internal and airfoil patches of the simulation.

Define the air properties at temperature T, the parameters, input features and targets for the simulation.

Parameters
  • root (str) – Root directory where the dataset is.

  • name (str) – Name of the simulation.

  • T (float, optional) – Temperature set for the simulation in Kelvin (in incompressible settings, this only defines the air properties. Simulations do not depend on temperature, only on the Reynolds number). Default: 298.15

sampling_volume(seed, n, density='uniform', targets=True)[source]

Sample points in the internal mesh following the given density. The outputs is a ndarray of shape (n, 2 + 1) or (n, 2 + 1 + 4) if targets is True. The two first columns are the position of the sampled points, followed by the distance to the airfoil and the targets (in the order x-velocity, y-velocity, pressure, and turbulent viscosity) if called.

Parameters
  • seed (int) – Seed for the random number generator.

  • n (int) – Number of sampled points.

  • density (str, optional) – Density from which the sampling is done. Choose between 'uniform' and 'mesh_density'. Default: 'uniform'

  • targets (bool, optional) – If True, velocity, pressure and kinematic turbulent viscosity will be returned in the output ndarray. Default: True

sampling_surface(seed, n, density='uniform', targets=True)[source]

Sample points in the airfoil mesh following the given density. The outputs is a ndarray of shape (n, 2 + 2) or (n, 2 + 2 + 4) if targets is True. The two first columns are the position of the sampled points, followed by the x and y components of the inward-pointing normals and the targets (in the order x-velocity, y-velocity, pressure, and turbulent viscosity) if called.

Parameters
  • seed (int) – Seed for the random number generator.

  • n (int) – Number of sampled points.

  • density (str, optional) – Density from which the sampling is done. Choose between 'uniform' and 'mesh_density'. Default: 'uniform'

  • targets (bool, optional) – If True, velocity, pressure and kinematic turbulent viscosity will be returned in the output ndarray. Default: True

sampling_mesh(seed, n, targets=True)[source]

Sample points over the simulation mesh without replacement. The outputs is a ndarray of shape (n, 2 + 6) or (n, 2 + 6 + 4) if targets is True. The two first columns are the position of the sampled points, followed by a boolean set to True if the sample points belongs to the surface, the distance to the airfoil, the x and y components of the normals (set to 0 if the sample points does not belong to the surface), the x and y components of the input velocity and the targets (in the order x-velocity, y-velocity, pressure, and turbulent viscosity) if called.

Parameters
  • seed (int) – Seed for the random number generator.

  • n (int) – Number of sampled points, this number has to be lower than the total number of points in the mesh.

  • targets (bool, optional) – If True, velocity, pressure and kinematic turbulent viscosity will be returned in the output ndarray. Default: True

wallshearstress(over_airfoil=False, reference=False)[source]

Compute the wall shear stress.

Parameters
  • over_airfoil (bool, optional) – If True, return the wall shear stress over the airfoil mesh. If False, return the wall shear stress over the internal mesh. Default: False

  • reference (bool, optional) – If True, return the wall shear stress computed with the reference velocity field. If False, compute the wall shear stress with the velocity attribute of the class. Default: False

force(compressible=False, reference=False)[source]

Compute the force acting on the airfoil. The output is a tuple of the form (f, fp, fv), where f is the force, fp the pressure contribution of the force and fv the viscous contribution of the force.

Parameters
  • compressible (bool, optional) – If False, multiply the force computed with the simulation field by the specific mass. Default: False

  • reference (bool, optional) – If True, return the force computed with the reference fields. If False, compute the force with the fields attribute of the class. Default: False

force_coefficient(compressible=False, reference=False)[source]

Compute the force coefficients for the simulation. The output is a tuple of the form ((cd, cdp, cdv), (cl, clp, clv)), where cd is the drag coefficient, cdp the pressure contribution of the drag coefficient and cdv the viscous contribution of the drag coefficient. Same for the lift coefficient cl.

Parameters
  • compressible (bool, optional) – If False, multiply the force computed with the simulation field by the specific mass. Default: False

  • reference (bool, optional) – If True, return the force coefficients computed with the reference fields. If False, compute the force coefficients with the fields attribute of the class. Default: False

mean_absolute_error()[source]

Compute the mean absolute error between the reference target fields and the attribute target fields of the class. The target fields are given in this order: velocity_x, velocity_y, pressure, kinematic turbulent viscosity.

mean_squared_error()[source]

Compute the mean squared error between the reference target fields and the attribute target fields of the class. The target fields are given in this order: velocity_x, velocity_y, pressure, kinematic turbulent viscosity.

r_squared()[source]

Compute the r_squared between the reference target fields and the attribute target fields of the class. The target fields are given in this order: velocity_x, velocity_y, pressure, kinematic turbulent viscosity.

coefficient_relative_error()[source]

Compute the mean relative error between the reference force coefficient and the force coefficient computed with the attribute target fields of the class. The force coefficients are given in this order: drag coefficient, lift coefficient.

boundary_layer(x, y=0.1, extrado=True, direction='vertical', local_frame=False, resolution=1000, compressible=False, reference=False)[source]

Return the boundary layer profile or the trail profile at abscissas x over a line of length y.

The fields are returned in the following order: the position on the line (in chord length), the first component of the velocity in the chosen frame normalized by the inlet velocity, the second component of the velocity in the chosen frame normalized by the inlet velocity, the pressure normalized by the inlet dynamic pressure, and the turbulent kinematic viscosity normalized by the knimatic viscosity.

Parameters
  • x (float) – Abscissa in chord length. It must be strictly positive. If x < 1, return the boundary layer. If x >= 1, return the trail profile.

  • y (float, optional) – Length of the sampling line. If x < 1, this length is taken from the airfoil surface. If x >= 1, this length is taken from one side to the other of the trail. Default: 0.1

  • extrado (bool, optional) – If True, the boundary layer of the extrado is returned, If False, the boundary layer of the intrado is returned. If x>= 1, this parameter is not taken into account. Default: True

  • direction (str, optional) – Choose between 'vertical' and 'normals'. If x < 1, the sampling line is defined as the line starting at the surface of the airfoil at abscissa x, of length y, in the direction of the normals if 'normals' and in the vertical direction if 'vertical'. If x>= 1, this parameter is not taken into account and the vertical direction is adopted. Default: 'vertical'

  • local_frame (bool, optional) – If True, the sampled velocity components along the lines are given in the local frame, i.e. the frame defined by the normals. Else, the sampled velocity components are given in the cartesian frame. If x>= 1, this parameter is not taken into account and the cartesian frame is adopted. Default: False resolution (int, optional): Resolution of the sampling. Default: 1000

  • compressible (bool, optional) – If True, add the specific mass to the normalization constant for the pressure. Default: False

  • reference (bool, optional) – If True, return the sampled fields of reference. If False, return the sampled fields from the class attribute. Default: False

save(root)[source]

Save the internal and the airfoil patches with the attribute targets fields of the class in the root directory.

Parameters

root (str) – Root directory where the files will be saved.