Hypervehicle vehicle class#

class hypervehicle.vehicle.Vehicle(**kwargs)[source]#
add_component(component: Component, name: str = None, reflection_axis: str = None, append_reflection: bool = True, curvatures: List[Tuple[str, Callable, Callable]] = None, clustering: Dict[str, Callable] = None, transformations: List[Tuple[str, Any]] = None, modifier_function: Callable | None = None, ghost: bool | None = False) None[source]#

Adds a new component to the vehicle.

Parameters:
  • component (Component) – The component to add.

  • name (str, optional) – The name to assign to this component. If provided, it will be used when writing to STL. The default is None.

  • reflection_axis (str, optional) – Include a reflection of the component about the axis specified (eg. ‘x’, ‘y’ or ‘z’). The default is None.

  • append_reflection (bool, optional) – When reflecting a new component, add the reflection to the existing component, rather than making it a new component. This is recommended when the combined components will form a closed mesh, but if the components will remain as two isolated bodies, a new component should be created (ie. append_reflection=False). In this case, you can use copy.deepcopy to make a copy of the reflected component when adding it to the vehicle. See the finner example in the hypervehicle hangar. The default is True.

  • curvatures (List[Tuple[str, Callable, Callable]], optional) – A list of the curvatures to apply to the component being added. This list contains a tuple for each curvature. Each curvatue is defined by (axis, curve_func, curve_func_derivative). The default is None.

  • clustering (Dict[str, Callable], optional) – Optionally provide clustering options for the stl meshes. See parametricSurfce2stl for more information. The default is None.

  • transformations (List[Tuple[str, Any]], optional) – A list of transformations to apply to the nominal component. The default is None.

  • modifier_function (Callable, optional) – A function which accepts x,y,z coordinates and returns a Vector3 object with a positional offset. This function is used with an OffsetPatchFunction. The default is None.

  • ghost (bool, optional) – Add a ghost component. When True, this component will be excluded from the files written to STL.

add_property(name: str, value: float)[source]#

Add a named property to the vehicle. Currently only supports float property types.

add_vehicle_transformations(transformations: List[Tuple[str, Any]]) None[source]#

Add transformations to apply to the vehicle after running generate(). Each transformation in the list should be a tuple of the form (transform_type, *args), where transform_type can be “rotate”, or “translate”. Note that transformations can be chained.

Extended Summary#

  • “rotate” : rotate the entire vehicle. The *args for rotate are

angle (float) and axis (str). For example: [(“rotate”, 180, “x”), (“rotate”, 90, “y”)].

  • “translate” : translate the entire vehicle. The *args for translate

includes the translational offset, specified either as a function (Callable), or as Vector3 object.

analyse(densities: dict) Tuple[source]#

Evaluates the mesh properties of the vehicle instance.

Parameters:

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. These keys will be consistent with any name tags assigned to components.

Returns:

  • total_volume (float) – The total volume.

  • total_mass (float) – The toal mass.

  • composite_cog (np.array) – The composite center of gravity.

  • composite_inertia (np.array) – The composite mass moment of inertia.

analyse_after_generating(densities: Dict[str, Any]) None[source]#

Run the vehicle analysis method immediately after generating patches. Results will be saved to the analysis_results attribute of the vehicle.

Parameters:

densities (Dict[str, Any]) – A dictionary containing the effective densities for each component. Note that the keys of the dict must match the keys of vehicle._named_components. These keys will be consistent with any name tags assigned to components.

configure(name: str = None, verbosity: int = 1)[source]#

Configure the Vehicle instance.

generate()[source]#

Generate all components of the vehicle.

get_non_ghost_components() dict[str, Component][source]#

Returns all non-ghost components.

to_stl(prefix: str = None, merge: bool | List[str] = False) None[source]#

Writes the vehicle components to STL file. If analysis results are present, they will also be written to file, either as CSV, or using the Numpy tofile method.

Parameters:
  • prefix (str, optional) – The prefix to use when saving components to STL. Note that if components have been individually assigned name tags, the prefix provided will take precedence. If no prefix is specified, and no component name tag is available, the Vehicle name will be used. The default is None.

  • merge ([bool, list[str]], optional) – Merge components of the vehicle into a single STL file. The merge argument can either be a boolean (with True indicating to merge all components of the vehicle), or a list of the component names to merge. This functionality depends on PyMesh. The default is False.

See also

utilities.merge_stls

transform(transformations: List[Tuple[str, Any]]) None[source]#

Transform vehicle by applying the tranformations.