def construct_single_ply_piece(self, fraction=1.0): """Construct a ply piece for shape A (trapezium)""" th_nom = np.radians(self.fiber_angle) # Step 1: Define origin line L0 origin_point = Point2D(self.starting_position, 0.0) L0 = Line2D.from_point_angle(origin_point, th_nom) # Step 2: Define line L2, perpendicular to L0, tangent to circle s4 tangent_point = Point2D.from_polar(self.cg.s4, th_nom) L2 = Line2D.from_point_angle(tangent_point, th_nom + np.pi / 2) P0 = L0.intersection_line(L2) # Step 3: Position P2 and P3 based on max_width and eccentricity P2_dist = self.max_width * self.eccentricity P3_dist = self.max_width * (1 - self.eccentricity) P2 = P0 + Point2D.from_polar(P2_dist, L2.angle()) P3 = P0 + Point2D.from_polar(P3_dist, L2.angle() + np.pi) # Step 4: Calculate the spanned angle (both deltas should be >= 0) T2 = L0.intersection_circle_near(P2.norm(), P0) T3 = L0.intersection_circle_near(P3.norm(), P0) delta_phi_1 = fraction * (P2.angle() - T2.angle()) delta_phi_2 = fraction * (T3.angle() - P3.angle()) # Step 5: Calculate the side lines L1 and L3 L1 = L0.rotate(delta_phi_1) L3 = L0.rotate(-delta_phi_2) near_pt = Point2D(self.cg.s1, 0) P1a = L1.intersection_circle_near(self.cg.s1, near_pt) P4a = L3.intersection_circle_near(self.cg.s1, near_pt) # Redefine P2 and P3 if needed (for rest pieces) if fraction != 1.0: P2 = L2.intersection_line(L1) P3 = L2.intersection_line(L3) # Step 6: Construct L4, parallel to L2, through either P1a or P4a, # whichever is furthest from L2 if L2.distance_point(P1a) > L2.distance_point(P4a): L4_through_point = P1a else: L4_through_point = P4a L4 = Line2D.from_point_angle(L4_through_point, L2.angle()) # now redefine P1 and P4 as the intersection points: P1b = L4.intersection_line(L1) P4b = L4.intersection_line(L3) ip_L1_L3 = L1.intersection_line(L3) if L2.distance_point(ip_L1_L3) < L2.distance_point(P4b): # Line segments L1 and L3 intersect within the polygon, so we have # a 'hourglass' shape. Move P1 and P4 to the intersection point, # effectively forming a triangle. We could just drop P4, if not # for some other code expeccting 4-point polygons. P1, P4 = ip_L1_L3, ip_L1_L3 else: P1, P4 = P1b, P4b # Step 7: Return the final ply piece return PlyPiece(Polygon2D((P1, P2, P3, P4)), 0.0, -delta_phi_2, delta_phi_1)
def construct_single_ply_piece(self, fraction=1.0): """Construct a ply piece for shape A (trapezium)""" th_nom = np.radians(self.fiber_angle) # Step 1: Define origin line L0 origin_point = Point2D(self.starting_position, 0.0) L0 = Line2D.from_point_angle(origin_point, th_nom) # Step 2: Define line L2, perpendicular to L0, tangent to circle s4 tangent_point = Point2D.from_polar(self.cg.s4, th_nom) L2 = Line2D.from_point_angle(tangent_point, th_nom + np.pi/2) P0 = L0.intersection_line(L2) # Step 3: Position P2 and P3 based on max_width and eccentricity P2_dist = self.max_width * self.eccentricity P3_dist = self.max_width * (1 - self.eccentricity) P2 = P0 + Point2D.from_polar(P2_dist, L2.angle()) P3 = P0 + Point2D.from_polar(P3_dist, L2.angle() + np.pi) # Step 4: Calculate the spanned angle (both deltas should be >= 0) T2 = L0.intersection_circle_near(P2.norm(), P0) T3 = L0.intersection_circle_near(P3.norm(), P0) delta_phi_1 = fraction*(P2.angle() - T2.angle()) delta_phi_2 = fraction*(T3.angle() - P3.angle()) # Step 5: Calculate the side lines L1 and L3 L1 = L0.rotate(delta_phi_1) L3 = L0.rotate(-delta_phi_2) near_pt = Point2D(self.cg.s1, 0) P1a = L1.intersection_circle_near(self.cg.s1, near_pt) P4a = L3.intersection_circle_near(self.cg.s1, near_pt) # Redefine P2 and P3 if needed (for rest pieces) if fraction != 1.0: P2 = L2.intersection_line(L1) P3 = L2.intersection_line(L3) # Step 6: Construct L4, parallel to L2, through either P1a or P4a, # whichever is furthest from L2 if L2.distance_point(P1a) > L2.distance_point(P4a): L4_through_point = P1a else: L4_through_point = P4a L4 = Line2D.from_point_angle(L4_through_point, L2.angle()) # now redefine P1 and P4 as the intersection points: P1b = L4.intersection_line(L1) P4b = L4.intersection_line(L3) ip_L1_L3 = L1.intersection_line(L3) if L2.distance_point(ip_L1_L3) < L2.distance_point(P4b): # Line segments L1 and L3 intersect within the polygon, so we have # a 'hourglass' shape. Move P1 and P4 to the intersection point, # effectively forming a triangle. We could just drop P4, if not # for some other code expeccting 4-point polygons. P1, P4 = ip_L1_L3, ip_L1_L3 else: P1, P4 = P1b, P4b # Step 7: Return the final ply piece return PlyPiece(Polygon2D((P1, P2, P3, P4)), 0.0, -delta_phi_2, delta_phi_1)
def construct_single_ply_piece(self, fraction=1.0): """Construct a ply piece for shape C (rectangle)""" th_nom = np.radians(self.fiber_angle) # Define origin line L0 origin_point = Point2D(self.starting_position, 0.0) L0 = Line2D.from_point_angle(origin_point, th_nom) # Define line L4 L4 = Line2D.from_point_angle(Point2D(0.0, 0.0), th_nom + np.pi / 2) ip_L0_L4 = L0.intersection_line(L4) # Construct P1 and P4 P1_dist = self.max_width * self.eccentricity P4_dist = self.max_width * (1 - self.eccentricity) P1 = ip_L0_L4 + Point2D.from_polar(P1_dist, L4.angle()) P4 = ip_L0_L4 + Point2D.from_polar(P4_dist, L4.angle() + np.pi) # Construct side lines L1, L3, parallel to L0 L1 = Line2D.from_point_angle(P1, L0.angle()) L3 = Line2D.from_point_angle(P4, L0.angle()) # Intersection points L0, L1, L3 with circle P0 = L0.intersection_circle_near(self.cg.s4, origin_point) P2 = L1.intersection_circle_near(self.cg.s4, P0) P3 = L3.intersection_circle_near(self.cg.s4, P0) # Handle creation of rest pieces, with fraction < 1.0 delta_phi_1 = (P2.angle() - P0.angle()) delta_phi_2 = (P0.angle() - P3.angle()) if fraction != 1.0: P2 = P2.rotate((fraction - 1.0) * delta_phi_1) P3 = P3.rotate((1.0 - fraction) * delta_phi_2) L1 = Line2D.from_point_angle(P2, L1.angle()) L3 = Line2D.from_point_angle(P3, L3.angle()) P1 = L4.intersection_line(L1) P4 = L4.intersection_line(L3) delta_phi_1 *= fraction delta_phi_2 *= fraction # Construct L2 through P2 or P3, whichever is furthest from L4 # Adjust the other point if L4.distance_point(P2) > L4.distance_point(P3): L2 = Line2D.from_point_angle(P2, L4.angle()) P3 = L2.intersection_line(L3) else: L2 = Line2D.from_point_angle(P3, L4.angle()) P2 = L2.intersection_line(L1) # Return the final ply piece return PlyPiece(Polygon2D((P1, P2, P3, P4)), 0.0, -delta_phi_2, delta_phi_1)
def construct_single_ply_piece(self, fraction=1.0): """Construct a ply piece for shape C (rectangle)""" th_nom = np.radians(self.fiber_angle) # Define origin line L0 origin_point = Point2D(self.starting_position, 0.0) L0 = Line2D.from_point_angle(origin_point, th_nom) # Define line L4 L4 = Line2D.from_point_angle(Point2D(0.0, 0.0), th_nom + np.pi/2) ip_L0_L4 = L0.intersection_line(L4) # Construct P1 and P4 P1_dist = self.max_width * self.eccentricity P4_dist = self.max_width * (1 - self.eccentricity) P1 = ip_L0_L4 + Point2D.from_polar(P1_dist, L4.angle()) P4 = ip_L0_L4 + Point2D.from_polar(P4_dist, L4.angle() + np.pi) # Construct side lines L1, L3, parallel to L0 L1 = Line2D.from_point_angle(P1, L0.angle()) L3 = Line2D.from_point_angle(P4, L0.angle()) # Intersection points L0, L1, L3 with circle P0 = L0.intersection_circle_near(self.cg.s4, origin_point) P2 = L1.intersection_circle_near(self.cg.s4, P0) P3 = L3.intersection_circle_near(self.cg.s4, P0) # Handle creation of rest pieces, with fraction < 1.0 delta_phi_1 = (P2.angle() - P0.angle()) delta_phi_2 = (P0.angle() - P3.angle()) if fraction != 1.0: P2 = P2.rotate((fraction - 1.0) * delta_phi_1) P3 = P3.rotate((1.0 - fraction) * delta_phi_2) L1 = Line2D.from_point_angle(P2, L1.angle()) L3 = Line2D.from_point_angle(P3, L3.angle()) P1 = L4.intersection_line(L1) P4 = L4.intersection_line(L3) delta_phi_1 *= fraction delta_phi_2 *= fraction # Construct L2 through P2 or P3, whichever is furthest from L4 # Adjust the other point if L4.distance_point(P2) > L4.distance_point(P3): L2 = Line2D.from_point_angle(P2, L4.angle()) P3 = L2.intersection_line(L3) else: L2 = Line2D.from_point_angle(P3, L4.angle()) P2 = L2.intersection_line(L1) # Return the final ply piece return PlyPiece(Polygon2D((P1, P2, P3, P4)), 0.0, -delta_phi_2, delta_phi_1)
def all_local_orientations(self, eta, zeta): """Determine the local fiber orientations of all plies at a point. Parameters ---------- eta : float Horizontal coordinate of point, in the coordinate system of the unfolded cone. zeta : float Vertical coordinate of point, in the coordinate system of the unfolded cone. Returns ------- local_angles : list Lists of floats representing the local fiber angle of each (possibly overlapping) ply piece at this point, in degrees. """ point = Point2D(eta, zeta) phi = point.angle() return len([ self.fiber_angle + pp.angle_deviation(point) for pp in self.ply_pieces if pp.contains_point(point, phi) ])
def local_orientation(self, eta, zeta): """Determine the local fiber orientation at a given point. If the given point is not inside any ply piece, NaN is returned. If there are multiple overlapping ply pieces, the orientation belonging to one of them (the first in the ply piece list) is returned. Parameters ---------- eta : float Horizontal coordinate of point, in the coordinate system of the unfolded cone. zeta : float Vertical coordinate of point, in the coordinate system of the unfolded cone. Returns ------- local_angle : float Local fiber angle at the given point in the given ply, in degrees. """ point = Point2D(eta, zeta) phi = point.angle() for pp in self.ply_pieces: if pp.contains_point(point, phi): return self.fiber_angle + pp.angle_deviation(point) return np.nan
def plotPlyPieces(self, state): L0 = Line2D.from_point_angle(Point2D(self.start, 0.0), math.radians(self.angle)) if len(L0.all_intersections_circle(self.data_handle.cg.s1)) == 0: ErrorMsg = QtGui.QMessageBox.critical( self, 'Error', "The Start Value is too high for this Fiber Angle. \n The fibers do not reach to the upper cone edge.", QtGui.QMessageBox.Ok, QtGui.QMessageBox.Ok) return model = self.buildModel() # Evaluate the model Phi = model.corner_orientations() num_pieces = model.num_pieces() A_piece = model.ply_piece_area() A_ply = A_piece * num_pieces R_DoC = A_ply / self.data_handle.cg.cone_area Aeff = model.effective_area()[0] R_Aeff = Aeff / A_piece R_cont = model.ratio_continuous_fibers() R_total = R_DoC * R_Aeff * R_cont R_SumAeff = R_DoC * R_Aeff result = GUIHandle.Result(angle=self.angle, start=self.start, width=self.width, var=self.var, Phi1=Phi[0], Phi2=Phi[1], Phi3=Phi[2], Phi4=Phi[3], num_pieces=num_pieces, R_DoC=R_DoC, R_Aeff=R_Aeff, R_cont=R_cont, R_SumAeff=R_SumAeff, R_total=R_total) self.plot_window = PlotWindow() if self.type == 1: self.printLP(model, self.plot_window.qmc.fig) elif self.type == 2: self.printAngleThickness(model, self.plot_window.qmc.fig, True) elif self.type == 3: self.printAngleThickness(model, self.plot_window.qmc.fig, False) else: assert False self.plot_window.show() self.result_window = ResultTable(model, result)
def construct_single_ply_piece(self, fraction=1.0): """Construct a ply piece for shape A (trapezium)""" th_nom = np.radians(self.fiber_angle) # Step 1: Define origin line L0 origin_point = Point2D(self.starting_position, 0.0) L0 = Line2D.from_point_angle(origin_point, th_nom ) # Step 2: Define line L2, perpendicular to L0, tangent to circle s4 tangent_point = Point2D.from_polar(self.cg.s4, th_nom) L2 = Line2D.from_point_angle(tangent_point, th_nom + np.pi/2) P0 = L0.intersection_line(L2) # Step 3: Position P2 and P3 based on max_width and eccentricity P2_dist = self.max_width * self.eccentricity P3_dist = self.max_width * (1 - self.eccentricity) P2 = P0 + Point2D.from_polar(P2_dist, L2.angle()) P3 = P0 + Point2D.from_polar(P3_dist, L2.angle() + np.pi) # Step 4: Calculate a rough estimate of the spanned angle delta_phi_1 = (P2.angle() - P0.angle()) delta_phi_2 = (P0.angle() - P3.angle()) ip_L0_s2 = L0.intersection_circle_near(self.cg.s2, origin_point) ip_L0_s4 = L0.intersection_circle_near(self.cg.s4, origin_point) ratio = 0.0 REQ_RATIO = 2.0 # Step 5: Iterate until the ratio of spanned angles on s4 and s2 is (nearly) correct while abs(ratio - REQ_RATIO) > TOL: delta_phi_on_s2 = REQ_RATIO * (delta_phi_1 + delta_phi_2) ip_L1_s2 = ip_L0_s2.rotate(REQ_RATIO * delta_phi_1) ip_L3_s2 = ip_L0_s2.rotate(-REQ_RATIO * delta_phi_2) L1 = Line2D.from_points(ip_L1_s2, P2) L3 = Line2D.from_points(ip_L3_s2, P3) ip_L1_s4 = L1.intersection_circle_near(self.cg.s4, P0) ip_L3_s4 = L3.intersection_circle_near(self.cg.s4, P0) delta_phi_1 = ip_L1_s4.angle() - ip_L0_s4.angle() delta_phi_2 = ip_L0_s4.angle() - ip_L3_s4.angle() delta_phi_on_s4 = delta_phi_1 + delta_phi_2 ratio = delta_phi_on_s2 / delta_phi_on_s4 # Redefine P2 and P3 if needed (for rest pieces) if fraction != 1.0: ip_L1_s2 = ip_L1_s2.rotate((fraction - 1.0) * delta_phi_1) ip_L3_s2 = ip_L3_s2.rotate((1.0 - fraction) * delta_phi_2) # Apply an additional rotation to avoid having more than one overlap ip_L3_s2 = ip_L3_s2.rotate(delta_phi_1 + delta_phi_2) ip_L1_s4 = ip_L1_s4.rotate((fraction - 1.0) * delta_phi_1) ip_L3_s4 = ip_L3_s4.rotate((1.0 - fraction) * delta_phi_2) L1 = Line2D.from_points(ip_L1_s2, ip_L1_s4) L3 = Line2D.from_points(ip_L3_s2, ip_L3_s4) delta_phi_1 *= fraction delta_phi_2 *= fraction # Step 6: redefine P1 to P4 as the intersection points L4 = Line2D.from_point_angle(Point2D(0.0, 0.0), L2.angle()) P1 = L1.intersection_line(L4) P2 = L2.intersection_line(L1) P3 = L3.intersection_line(L2) P4 = L4.intersection_line(L3) # Step 7: Return the final ply piece return PlyPiece(Polygon2D((P1, P2, P3, P4)), 0.0, -delta_phi_2, delta_phi_1)
def make_intersection(L, s): return L.intersection_circle_near(s, Point2D.from_polar(s, phi_nom))
def construct_single_ply_piece(self, fraction=1.0): """Construct a ply piece for shape A (trapezium)""" th_nom = np.radians(self.fiber_angle) # Step 1: Define origin line L0 origin_point = Point2D(self.starting_position, 0.0) L0 = Line2D.from_point_angle(origin_point, th_nom) # Step 2: Define line L2, perpendicular to L0, tangent to circle s4 tangent_point = Point2D.from_polar(self.cg.s4, th_nom) L2 = Line2D.from_point_angle(tangent_point, th_nom + np.pi / 2) P0 = L0.intersection_line(L2) # Step 3: Position P2 and P3 based on max_width and eccentricity P2_dist = self.max_width * self.eccentricity P3_dist = self.max_width * (1 - self.eccentricity) P2 = P0 + Point2D.from_polar(P2_dist, L2.angle()) P3 = P0 + Point2D.from_polar(P3_dist, L2.angle() + np.pi) # Step 4: Calculate a rough estimate of the spanned angle delta_phi_1 = (P2.angle() - P0.angle()) delta_phi_2 = (P0.angle() - P3.angle()) ip_L0_s2 = L0.intersection_circle_near(self.cg.s2, origin_point) ip_L0_s4 = L0.intersection_circle_near(self.cg.s4, origin_point) ratio = 0.0 REQ_RATIO = 2.0 # Step 5: Iterate until the ratio of spanned angles on s4 and s2 is (nearly) correct while abs(ratio - REQ_RATIO) > TOL: delta_phi_on_s2 = REQ_RATIO * (delta_phi_1 + delta_phi_2) ip_L1_s2 = ip_L0_s2.rotate(REQ_RATIO * delta_phi_1) ip_L3_s2 = ip_L0_s2.rotate(-REQ_RATIO * delta_phi_2) L1 = Line2D.from_points(ip_L1_s2, P2) L3 = Line2D.from_points(ip_L3_s2, P3) ip_L1_s4 = L1.intersection_circle_near(self.cg.s4, P0) ip_L3_s4 = L3.intersection_circle_near(self.cg.s4, P0) delta_phi_1 = ip_L1_s4.angle() - ip_L0_s4.angle() delta_phi_2 = ip_L0_s4.angle() - ip_L3_s4.angle() delta_phi_on_s4 = delta_phi_1 + delta_phi_2 ratio = delta_phi_on_s2 / delta_phi_on_s4 # Redefine P2 and P3 if needed (for rest pieces) if fraction != 1.0: ip_L1_s2 = ip_L1_s2.rotate((fraction - 1.0) * delta_phi_1) ip_L3_s2 = ip_L3_s2.rotate((1.0 - fraction) * delta_phi_2) # Apply an additional rotation to avoid having more than one overlap ip_L3_s2 = ip_L3_s2.rotate(delta_phi_1 + delta_phi_2) ip_L1_s4 = ip_L1_s4.rotate((fraction - 1.0) * delta_phi_1) ip_L3_s4 = ip_L3_s4.rotate((1.0 - fraction) * delta_phi_2) L1 = Line2D.from_points(ip_L1_s2, ip_L1_s4) L3 = Line2D.from_points(ip_L3_s2, ip_L3_s4) delta_phi_1 *= fraction delta_phi_2 *= fraction # Step 6: redefine P1 to P4 as the intersection points L4 = Line2D.from_point_angle(Point2D(0.0, 0.0), L2.angle()) P1 = L1.intersection_line(L4) P2 = L2.intersection_line(L1) P3 = L3.intersection_line(L2) P4 = L4.intersection_line(L3) # Step 7: Return the final ply piece return PlyPiece(Polygon2D((P1, P2, P3, P4)), 0.0, -delta_phi_2, delta_phi_1)
def effective_area(self, ply_piece=None, max_angle_dev=2.0): """Get the effective area of a single ply piece. This is the area on useful section of the cone, where the deviation of the fiber angle is less than a given maximum. Parameters ---------- ply_piece : :class:`PlyPiece`, optional Ply piece to get the effective area for. If not set, the base piece is used. max_angle_dev : float, optional Maximum deviation from the nominal fiber angle to consider the material 'effective'. In degrees. Returns ------- out : tuple 2-tuple, where ``out[0]`` is the effective surface area and ``out[1]`` is the corresponding polygon. Notes ----- Note that the polygon has straight edges, while the calculation of the effective area takes into account that some edges of the effective area may be arc sections. """ if ply_piece is None: ply_piece = self.base_piece poly, pts_on_s2, pts_on_s3 = self._useful_polygon(ply_piece) # Construct lines through those corner points of the polygon, # that are on s2/s3. They will be useful later line_s2 = Line2D.from_points(*pts_on_s2) line_s3 = Line2D.from_points(*pts_on_s3) # Lines to cut away the non-effective area cut_line_1 = Line2D.from_point_angle( Point2D(0., 0.), ply_piece.phi_nom - np.radians(max_angle_dev)) cut_line_2 = Line2D.from_point_angle( Point2D(0., 0.), ply_piece.phi_nom + np.pi + np.radians(max_angle_dev)) # Slice the polygon, with some corrections for cut_line in (cut_line_1, cut_line_2): outp = [] for p in poly.slice_line(cut_line).points(): # Polygon intersection can result in points that are not # exactly on circles s2/s3, while they should be. Correct that. if cut_line.distance_point(p) < TOL: if line_s2.distance_point(p) < TOL: p = cut_line.intersection_circle_near(self.cg.s2, p) elif line_s3.distance_point(p) < TOL: p = cut_line.intersection_circle_near(self.cg.s3, p) outp.append(p) poly = Polygon2D(outp) # Calculate area area = poly.area() # Correct polygon area for arc sections s2/s3, if needed pts_on_s2 = [ p for p in poly.points() if abs(p.norm() - self.cg.s2) < TOL ] if len(pts_on_s2) >= 2: angles = [p.angle() for p in pts_on_s2] area -= circle_segment_area(self.cg.s2, max(angles) - min(angles)) pts_on_s3 = [ p for p in poly.points() if abs(p.norm() - self.cg.s3) < TOL ] if len(pts_on_s3) >= 2: angles = [p.angle() for p in pts_on_s3] area += circle_segment_area(self.cg.s3, max(angles) - min(angles)) return area, poly