Coverage for /opt/hostedtoolcache/Python/3.11.10/x64/lib/python3.11/site-packages/hypervehicle/hangar/wedge.py: 87%

30 statements  

« prev     ^ index     » next       coverage.py v7.6.4, created at 2024-10-29 02:51 +0000

1from hypervehicle import Vehicle 

2from hypervehicle.generator import Generator 

3from hypervehicle.geometry import Vector3, Line 

4from hypervehicle.components import SweptComponent 

5 

6 

7class ParametricWedge(Generator): 

8 def __init__(self, **kwargs) -> None: 

9 # Wedge parameters 

10 self.wingspan = 1 

11 self.chord = 1 

12 self.thickness = 0.1 

13 

14 # Complete instantiation 

15 super().__init__(**kwargs) 

16 

17 def create_instance(self) -> Vehicle: 

18 # Create vehicle object 

19 wedge = Vehicle() 

20 wedge.configure(name="Wedge", verbosity=1) 

21 

22 # Define wedge cross-section points 

23 # ^ +y 

24 # | 

25 # W _ - _ N ___ 

26 # _ - | - _ | 

27 # +x <--- < -------------- > | thickness 

28 # - _ | _ - | 

29 # S - _ - E ___ 

30 # 

31 # |-----------------| 

32 # wingspan 

33 

34 NW = Vector3(x=0, y=0.5 * self.thickness) 

35 NE = Vector3( 

36 x=-0.5 * self.chord, 

37 y=0, 

38 ) 

39 SE = Vector3(x=0, y=-0.5 * self.thickness) 

40 SW = Vector3(x=0.5 * self.chord, y=0) 

41 

42 # Define sections forming wedge 

43 sections = [] 

44 for i in [-1, 1]: 

45 z_loc = 0.5 * i * self.wingspan 

46 axial_shift = Vector3(x=0, y=0, z=z_loc) 

47 sections.append( 

48 [ 

49 Line(p0=NW + axial_shift, p1=NE + axial_shift), 

50 Line(p0=NE + axial_shift, p1=SE + axial_shift), 

51 Line(p0=SE + axial_shift, p1=SW + axial_shift), 

52 Line(p0=SW + axial_shift, p1=NW + axial_shift), 

53 ] 

54 ) 

55 

56 fuselage = SweptComponent( 

57 cross_sections=sections, 

58 stl_resolution=10, 

59 ) 

60 wedge.add_component(fuselage) 

61 

62 # Generate STL 

63 return wedge 

64 

65 

66if __name__ == "__main__": 

67 # To create the nominal geometry 

68 parametric_wedge_generator = ParametricWedge() 

69 wedge = parametric_wedge_generator.create_instance() 

70 wedge.generate() 

71 wedge.to_stl("wedge") 

72 

73 # # To run sensitivity study 

74 # from hypervehicle.utilities import SensitivityStudy 

75 

76 # # Construct sensitivity study 

77 # ss = SensitivityStudy(ParametricWedge) 

78 

79 # # Define parameters to get sensitivities to 

80 # parameters = {'thickness': 0.1, 'chord': 1, 'wingspan': 1} 

81 

82 # # Perform study 

83 # sensitivities = ss.dvdp(parameters) 

84 

85 # # Save to CSV 

86 # ss.to_csv()