symcad.parts.fixed
1#!/usr/bin/env python3 2# Copyright (C) 2022, Will Hedgecock 3# 4# This program is free software: you can redistribute it and/or modify 5# it under the terms of the GNU General Public License as published by 6# the Free Software Foundation, either version 3 of the License, or 7# (at your option) any later version. 8# 9# This program is distributed in the hope that it will be useful, 10# but WITHOUT ANY WARRANTY; without even the implied warranty of 11# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12# GNU General Public License for more details. 13# 14# You should have received a copy of the GNU General Public License 15# along with this program. If not, see <http://www.gnu.org/licenses/>. 16 17from __future__ import annotations 18from ...core.SymPart import SymPart 19from typing import Callable, Tuple, Union 20from sympy import Expr 21import abc, os 22 23class FixedPart(SymPart, metaclass=abc.ABCMeta): 24 """Base class from which all fixed-geometry parts should derive.""" 25 26 def __init__(self, identifier: str, 27 cad_representation: Union[str, Callable], 28 material_density_kg_m3: float) -> None: 29 """Initializes a fixed-geometry `SymPart`. 30 31 Parameters 32 ---------- 33 identifier : `str` 34 Unique, identifying name for the `FixedPart`. 35 cad_representation : `Union[str, Callable]` 36 Either the path to a representative CAD model for the given `FixedPart` or a 37 callable method that can create such a model. 38 material_density_kg_m3 : `float` 39 Uniform material density in `kg/m^3` to be used in mass property calculations. 40 """ 41 super().__init__(identifier, 42 os.path.join('fixed', cad_representation) 43 if isinstance(cad_representation, str) else 44 cad_representation, 45 None, 46 material_density_kg_m3) 47 self.__cad_props__ = self.__cad__.get_physical_properties({}, 48 (0.0, 0.0, 0.0), 49 (0.0, 0.0, 0.0), 50 self.material_density, 51 True) 52 53 def set_geometry(self) -> FixedPart: 54 """Unused dummy function for all fixed-geometry parts of type `FixedPart`.""" 55 return self 56 57 def get_geometric_parameter_bounds(self, parameter: str) -> Tuple[float, float]: 58 """Unused dummy function for all fixed-geometry parts of type `FixedPart`.""" 59 return 0, 0 60 61 @property 62 def material_volume(self) -> Union[float, Expr]: 63 return self.__cad_props__['material_volume'] 64 65 @property 66 def displaced_volume(self) -> Union[float, Expr]: 67 return self.__cad_props__['displaced_volume'] 68 69 @property 70 def surface_area(self) -> Union[float, Expr]: 71 return self.__cad_props__['surface_area'] 72 73 @property 74 def unoriented_center_of_gravity(self) -> Tuple[Union[float, Expr], 75 Union[float, Expr], 76 Union[float, Expr]]: 77 return self.__cad_props__['cg_x'], self.__cad_props__['cg_y'], self.__cad_props__['cg_z'] 78 79 @property 80 def unoriented_center_of_buoyancy(self) -> Tuple[Union[float, Expr], 81 Union[float, Expr], 82 Union[float, Expr]]: 83 return self.__cad_props__['cb_x'], self.__cad_props__['cb_y'], self.__cad_props__['cb_z'] 84 85 @property 86 def unoriented_length(self) -> Union[float, Expr]: 87 return self.__cad_props__['xlen'] 88 89 @property 90 def unoriented_width(self) -> Union[float, Expr]: 91 return self.__cad_props__['ylen'] 92 93 @property 94 def unoriented_height(self) -> Union[float, Expr]: 95 return self.__cad_props__['zlen'] 96 97 @property 98 def oriented_length(self) -> Union[float, Expr]: 99 cad_props = self.__cad__.get_physical_properties({}, 100 (0.0, 0.0, 0.0), 101 self.orientation.as_tuple(), 102 self.material_density, 103 True) 104 return cad_props['xlen'] 105 106 @property 107 def oriented_width(self) -> Union[float, Expr]: 108 cad_props = self.__cad__.get_physical_properties({}, 109 (0.0, 0.0, 0.0), 110 self.orientation.as_tuple(), 111 self.material_density, 112 True) 113 return cad_props['ylen'] 114 115 @property 116 def oriented_height(self) -> Union[float, Expr]: 117 cad_props = self.__cad__.get_physical_properties({}, 118 (0.0, 0.0, 0.0), 119 self.orientation.as_tuple(), 120 self.material_density, 121 True) 122 return cad_props['zlen'] 123 124 125from .CatPumps3CP1221Pump import CatPumps3CP1221Pump 126from .Garmin15HGpsReceiver import Garmin15HGpsReceiver 127from .IridiumCore9523Radio import IridiumCore9523Radio 128from .iXbluePhinsCompactC7Ins import iXbluePhinsCompactC7Ins 129from .NortekDVL1000_4000mDvl import NortekDVL1000_4000mDvl 130from .OceanBottomSeismometer import OceanBottomSeismometer 131from .RaspberryPiZero2Computer import RaspberryPiZero2Computer 132from .TecnadyneModel550Thruster import TecnadyneModel550Thruster 133from .TecnadyneModel2050Thruster import TecnadyneModel2050Thruster 134from .TecnadyneModel2051Thruster import TecnadyneModel2051Thruster 135from .TecnadyneModel2061Thruster import TecnadyneModel2061Thruster 136from .TecnadyneModel8050Thruster import TecnadyneModel8050Thruster 137from .TeledyneBenthosATM926AcousticModem import TeledyneBenthosATM926AcousticModem 138from .TeledyneTasman600kHzDvl import TeledyneTasman600kHzDvl 139from .TridentSensorsDualGpsIridiumAntenna import TridentSensorsDualGpsIridiumAntenna
24class FixedPart(SymPart, metaclass=abc.ABCMeta): 25 """Base class from which all fixed-geometry parts should derive.""" 26 27 def __init__(self, identifier: str, 28 cad_representation: Union[str, Callable], 29 material_density_kg_m3: float) -> None: 30 """Initializes a fixed-geometry `SymPart`. 31 32 Parameters 33 ---------- 34 identifier : `str` 35 Unique, identifying name for the `FixedPart`. 36 cad_representation : `Union[str, Callable]` 37 Either the path to a representative CAD model for the given `FixedPart` or a 38 callable method that can create such a model. 39 material_density_kg_m3 : `float` 40 Uniform material density in `kg/m^3` to be used in mass property calculations. 41 """ 42 super().__init__(identifier, 43 os.path.join('fixed', cad_representation) 44 if isinstance(cad_representation, str) else 45 cad_representation, 46 None, 47 material_density_kg_m3) 48 self.__cad_props__ = self.__cad__.get_physical_properties({}, 49 (0.0, 0.0, 0.0), 50 (0.0, 0.0, 0.0), 51 self.material_density, 52 True) 53 54 def set_geometry(self) -> FixedPart: 55 """Unused dummy function for all fixed-geometry parts of type `FixedPart`.""" 56 return self 57 58 def get_geometric_parameter_bounds(self, parameter: str) -> Tuple[float, float]: 59 """Unused dummy function for all fixed-geometry parts of type `FixedPart`.""" 60 return 0, 0 61 62 @property 63 def material_volume(self) -> Union[float, Expr]: 64 return self.__cad_props__['material_volume'] 65 66 @property 67 def displaced_volume(self) -> Union[float, Expr]: 68 return self.__cad_props__['displaced_volume'] 69 70 @property 71 def surface_area(self) -> Union[float, Expr]: 72 return self.__cad_props__['surface_area'] 73 74 @property 75 def unoriented_center_of_gravity(self) -> Tuple[Union[float, Expr], 76 Union[float, Expr], 77 Union[float, Expr]]: 78 return self.__cad_props__['cg_x'], self.__cad_props__['cg_y'], self.__cad_props__['cg_z'] 79 80 @property 81 def unoriented_center_of_buoyancy(self) -> Tuple[Union[float, Expr], 82 Union[float, Expr], 83 Union[float, Expr]]: 84 return self.__cad_props__['cb_x'], self.__cad_props__['cb_y'], self.__cad_props__['cb_z'] 85 86 @property 87 def unoriented_length(self) -> Union[float, Expr]: 88 return self.__cad_props__['xlen'] 89 90 @property 91 def unoriented_width(self) -> Union[float, Expr]: 92 return self.__cad_props__['ylen'] 93 94 @property 95 def unoriented_height(self) -> Union[float, Expr]: 96 return self.__cad_props__['zlen'] 97 98 @property 99 def oriented_length(self) -> Union[float, Expr]: 100 cad_props = self.__cad__.get_physical_properties({}, 101 (0.0, 0.0, 0.0), 102 self.orientation.as_tuple(), 103 self.material_density, 104 True) 105 return cad_props['xlen'] 106 107 @property 108 def oriented_width(self) -> Union[float, Expr]: 109 cad_props = self.__cad__.get_physical_properties({}, 110 (0.0, 0.0, 0.0), 111 self.orientation.as_tuple(), 112 self.material_density, 113 True) 114 return cad_props['ylen'] 115 116 @property 117 def oriented_height(self) -> Union[float, Expr]: 118 cad_props = self.__cad__.get_physical_properties({}, 119 (0.0, 0.0, 0.0), 120 self.orientation.as_tuple(), 121 self.material_density, 122 True) 123 return cad_props['zlen']
Base class from which all fixed-geometry parts should derive.
27 def __init__(self, identifier: str, 28 cad_representation: Union[str, Callable], 29 material_density_kg_m3: float) -> None: 30 """Initializes a fixed-geometry `SymPart`. 31 32 Parameters 33 ---------- 34 identifier : `str` 35 Unique, identifying name for the `FixedPart`. 36 cad_representation : `Union[str, Callable]` 37 Either the path to a representative CAD model for the given `FixedPart` or a 38 callable method that can create such a model. 39 material_density_kg_m3 : `float` 40 Uniform material density in `kg/m^3` to be used in mass property calculations. 41 """ 42 super().__init__(identifier, 43 os.path.join('fixed', cad_representation) 44 if isinstance(cad_representation, str) else 45 cad_representation, 46 None, 47 material_density_kg_m3) 48 self.__cad_props__ = self.__cad__.get_physical_properties({}, 49 (0.0, 0.0, 0.0), 50 (0.0, 0.0, 0.0), 51 self.material_density, 52 True)
Initializes a fixed-geometry SymPart.
Parameters
- identifier (
str): Unique, identifying name for theFixedPart. - cad_representation (
Union[str, Callable]): Either the path to a representative CAD model for the givenFixedPartor a callable method that can create such a model. - material_density_kg_m3 (
float): Uniform material density inkg/m^3to be used in mass property calculations.
54 def set_geometry(self) -> FixedPart: 55 """Unused dummy function for all fixed-geometry parts of type `FixedPart`.""" 56 return self
Unused dummy function for all fixed-geometry parts of type FixedPart.
58 def get_geometric_parameter_bounds(self, parameter: str) -> Tuple[float, float]: 59 """Unused dummy function for all fixed-geometry parts of type `FixedPart`.""" 60 return 0, 0
Unused dummy function for all fixed-geometry parts of type FixedPart.
Material volume (in m^3) of the SymPart (read-only).
Displaced volume (in m^3) of the SymPart (read-only).
Surface/wetted area (in m^2) of the SymPart (read-only).
Center of gravity (in m) of the unoriented SymPart (read-only).
Center of buoyancy (in m) of the unoriented SymPart (read-only).
X-axis length (in m) of the bounding box of the unoriented SymPart (read-only).
Y-axis width (in m) of the bounding box of the unoriented SymPart (read-only).
Z-axis height (in m) of the bounding box of the unoriented SymPart (read-only).
X-axis length (in m) of the bounding box of the oriented SymPart (read-only).
Y-axis length (in m) of the bounding box of the oriented SymPart (read-only).
Z-axis length (in m) of the bounding box of the oriented SymPart (read-only).
Inherited Members
- symcad.core.SymPart.SymPart
- name
- geometry
- attachment_points
- attachments
- connection_ports
- connections
- static_origin
- static_placement
- orientation
- material_density
- current_states
- is_exposed
- clone
- set_placement
- set_orientation
- set_state
- set_unexposed
- set_material_density
- add_attachment_point
- add_connection_port
- attach
- connect
- get_cad_physical_properties
- export
- get_valid_states
- mass
- oriented_center_of_gravity
- oriented_center_of_buoyancy