Hypervehicle Utilities#

class hypervehicle.utilities.SensitivityStudy(vehicle_constructor, verbosity: int | None = 1)[source]#

Computes the geometric sensitivities using finite differencing.

static _combine(nominal_instance, sensitivities)[source]#

Combines the sensitivity information for multiple parameters.

static _compare_meshes(mesh1, mesh2, dp, parameter_name: str) DataFrame[source]#

Compares two meshes with each other and applies finite differencing to quantify their differences.

Parameters:
  • mesh1 (Mesh) – The reference mesh.

  • mesh1 – The perturbed mesh.

  • dp (float) – The parameter perturbation.

  • parameter_name (str) – The name of the parameter.

Returns:

df – A DataFrame of the finite difference results.

Return type:

pd.DataFrame

dvdp(parameter_dict: dict[str, any], overrides: dict[str, any] | None = None, perturbation: float | None = 5, write_nominal_stl: bool | None = True, nominal_stl_prefix: str | None = None)[source]#

Computes the sensitivity of the geometry with respect to the parameters.

Parameters:
  • parameter_dict (dict) – A dictionary of the design parameters to perturb, and their nominal values.

  • overrides (dict, optional) – Optional vehicle generator overrides to provide along with the parameter dictionary without variation. The default is None.

  • perturbation (float, optional) – The design parameter perturbation amount, specified as percentage. The default is 20.

  • vehicle_creator_method (str, optional) – The name of the method which returns a hypervehicle.Vehicle instance, ready for generation. The default is ‘create_instance’.

  • write_nominal_stl (bool, optional) – A boolean flag to write the nominal geometry STL(s) to file. The default is True.

  • nominal_stl_prefix (str, optional) – The prefix to append when writing STL files for the nominal geometry. If None, no prefix will be used. The default is None.

Returns:

sensitivities – A dictionary containing the sensitivity information for all components of the geometry, relative to the nominal geometry.

Return type:

dict

to_csv(outdir: str | None = None)[source]#

Writes the sensitivity information to CSV file.

Parameters:

outdir (str, optional) – The output directory to write the sensitivity files to. If None, the current working directory will be used. The default is None.

Returns:

combined_data_filepath – The filepath to the combined sensitivity data.

Return type:

str

hypervehicle.utilities.append_sensitivities_to_tri(dp_filenames: List[str], components_filepath: str | None = 'Components.i.tri', match_tolerance: float | None = 1e-05, rounding_tolerance: float | None = 1e-08, combined_sens_fn: str | None = 'all_components_sensitivity.csv', outdir: str | None = None, verbosity: int | None = 1) float[source]#

Appends shape sensitivity data to .i.tri file, and writes the sensitivity data to csv file too. This step is required for geometries with multiple components. The .tri file is used to match individual sensitivity files (dp_filenames) to the geometry. The combined sensitivity file is required to calculate flow sensitivities with the .plt file, which has local flow conditions attached.

Parameters:
  • dp_files (list[str]) – A list of the file names of the sensitivity data.

  • components_filepath (str, optional) – The filepath to the .tri file to be appended to. The default is ‘Components.i.tri’.

  • match_tolerance (float, optional) – The precision tolerance for matching point coordinates. The default is 1e-5.

  • rounding_tolerance (float, optional) – The tolerance to round data off to. The default is 1e-8.

  • combined_sens_fn (str, optional) – The filename of the combined geometry sensitivity data. The default is “all_components_sensitivity.csv”.

  • outdir (str, optional) – The output directory to write the combined sensitivity file to. If None, the current working directory will be used. The default is None.

  • verbosity (int, optional) – The verbosity of the code. The defualt is 1.

Returns:

match_fraction – The fraction of cells which got matched. If this is below 100%, try decreasing the match tolerance and run again.

Return type:

float

Examples

>>> dp_files = ['wing_0_body_width_sensitivity.csv',
                'wing_1_body_width_sensitivity.csv']
hypervehicle.utilities.assess_inertial_properties(vehicle, component_densities: Dict[str, float])[source]#
Parameters:
  • vehicle (Vehicle) – A hypervehicle Vehicle instance.

  • component_densities (Dict[str, float]) – A dictionary containing the effective densities for each component. Note that the keys of the dict must match the keys of vehicle._named_components.

Returns:

  • vehicle_properties (dict) – A dictionary containing the vehicle’s mass, volume, location of CoG and moment of inertia matrix.

  • component_properties (dict) – A dictionary containing the same keys as vehicle_properties, but the values are now dictionaries for each component of the vehicle.

hypervehicle.utilities.csv_to_delaunay(filepath: str)[source]#

Converts a csv file of points to a Delaunay3D surface.

Parameters:

filepath (str) – The filepath to the CSV file.

hypervehicle.utilities.merge_stls(stl_files: List[str], name: str | None = None, verbosity: int | None = 1) str[source]#

Merge STL files into a single file. Note that this function depends on having PyMesh installed.

Parameters:
  • stl_files (list[str]) – A list of the STL file names to be merged.

  • name (str, optional) – The prefix of the combined STL filename output.

  • verbosity (int, optional) – The function verbosity. The default is 1.

Returns:

outfile – The filename of the merged STL.

Return type:

str

hypervehicle.utilities.parametricSurfce2stl(parametric_surface, triangles_per_edge: int, si: float = 1.0, sj: float = 1.0, mirror_y=False, flip_faces=False, i_clustering_func: callable = None, j_clustering_func: callable = None) Mesh[source]#

Function to convert parametric_surface generated using the Eilmer Geometry Package into a stl mesh object.

Parameters:
  • parametric_surface (Any) – The parametric surface object.

  • si (float, optional) – The clustering in the i-direction. The default is 1.0.

  • sj (float, optional) – The clustering in the j-direction. The default is 1.0.

  • triangles_per_edge (int) – The resolution for the stl object.

  • mirror_y (bool, optional) – Create mirror image about x-z plane. The default is False.

  • i_clustering_func (callable, optional) – A custom clustering function to apply in the i direction. The default is None.

  • j_clustering_func (callable, optional) – A custom clustering function to apply in the j direction. The default is None.

Returns:

stl_mesh – The numpy-stl mesh.

Return type:

Mesh

hypervehicle.utilities.print_banner()[source]#

Prints the hypervehicle banner