def build_areas(self, i): areas = list() edge_area = NeckArea( self.get_inner_rail(i), self.get_outer_rail(i), self.get_outer_curve(i), NeckCurve(1, 0, 0, 2), ) areas.append(edge_area) if self.get_outer_curve(i).y(0) < -.75 - 1e-8: break_x = self.get_outer_curve(i).x(-.75) areas.append( NeckArea(0, break_x, NeckCurve(0, 0, -.75, 0), self.get_inner_curve(i))) areas.append( NeckArea(break_x, self.get_inner_rail(i), self.get_outer_curve(i), self.get_inner_curve(i))) else: areas.append( NeckArea(0, self.get_inner_rail(i), self.get_outer_curve(i), self.get_inner_curve(i))) return areas
def get_outer_curve(self, i): return NeckCurve( self.scale_value(i / self.n, *self.minor_as[0::2]), self.scale_value(i / self.n, *self.minor_bs[0::2]), self.scale_value(i / self.n, *self.minor_bs[0::2] - self.depths[0::2]), self.r_outer)
def build_areas_with_medial_rib(self, i): areas = self.build_areas(i) medial_rib_area = NeckArea( (self.get_inner_rail(i) - .25) / 2 + .25 - .07, (self.get_inner_rail(i) - .25) / 2 + .25 + .07, self.get_inner_curve(i), NeckCurve(1, 0, 0, 2), ) areas.append(medial_rib_area) return areas
def build_areas_with_open_rib(self, i): areas = self.build_areas(i) rib_area = NeckArea( # inner rail .125, .125 + self.inner_rib, self.get_inner_curve(i), NeckCurve(1, 0, 0, 2), ) areas.append(rib_area) return areas
def build_areas_with_longitudinal_ribs(self, i, n): areas = self.build_areas(i) rib_thickness = .06 for j in range(n): areas.append( NeckArea( (self.get_inner_rail(i) - (.125 + self.inner_rib)) / n * (j + 1) - rib_thickness / 2, (self.get_inner_rail(i) - (.125 + self.inner_rib)) / n * (j + 1) + rib_thickness / 2, self.get_inner_curve(i), NeckCurve(1, 0, 0, 2), )) return areas
if self._y_bar is None: self._y_bar = self.integral_yda()[0] / self.integral_da()[0] return self._y_bar def y(self, x): return (self.y_max(x) + self.y_min(x)) / 2 def integral_da(self): def f(x): return self.y_max(x) - self.y_min(x) return quad(f, self.x_min, self.x_max) def integral_yda(self): def f(x): return self.y(x) * (self.y_max(x) - self.y_min(x)) return quad(f, self.x_min, self.x_max) if __name__ == '__main__': from model34_maths.neck_curve import NeckCurve y0 = NeckCurve(1, 1, 0, 2) y1 = NeckCurve(.75, .75, 0, 2) area = NeckArea(0, .75, y0, y1) print(area.integral_y()) print('area:', area.area) print('y_bar:', area.y_bar) print('1st:', area.first_moment) print('2nd:', area.second_moment)