|
| 1 | +import numpy as np |
| 2 | +import scipy.optimize |
| 3 | +import shapely.affinity |
| 4 | +from shapely import Polygon |
| 5 | + |
| 6 | +from . import helpers |
| 7 | +from ..asymmetric_two_roll_pass import AsymmetricTwoRollPass |
| 8 | +from ...grooves import GenericElongationGroove |
| 9 | + |
| 10 | + |
| 11 | +@AsymmetricTwoRollPass.usable_width |
| 12 | +def usable_width(self: AsymmetricTwoRollPass): |
| 13 | + return min(self.upper_roll.groove.usable_width, self.lower_roll.groove.usable_width) |
| 14 | + |
| 15 | + |
| 16 | +@AsymmetricTwoRollPass.tip_width |
| 17 | +def tip_width(self: AsymmetricTwoRollPass): |
| 18 | + if isinstance(self.upper_roll.groove, GenericElongationGroove) and isinstance( |
| 19 | + self.lower_roll.groove, GenericElongationGroove |
| 20 | + ): |
| 21 | + return min( |
| 22 | + self.upper_roll.groove.usable_width + self.gap / 2 / np.tan(self.upper_roll.groove.flank_angle), |
| 23 | + self.lower_roll.groove.usable_width + self.gap / 2 / np.tan(self.lower_roll.groove.flank_angle), |
| 24 | + ) |
| 25 | + |
| 26 | + |
| 27 | +@AsymmetricTwoRollPass.usable_cross_section |
| 28 | +def usable_cross_section(self: AsymmetricTwoRollPass) -> Polygon: |
| 29 | + return helpers.out_cross_section(self, self.usable_width) |
| 30 | + |
| 31 | + |
| 32 | +@AsymmetricTwoRollPass.tip_cross_section |
| 33 | +def tip_cross_section(self: AsymmetricTwoRollPass) -> Polygon: |
| 34 | + return helpers.out_cross_section(self, self.tip_width) |
| 35 | + |
| 36 | + |
| 37 | +@AsymmetricTwoRollPass.gap |
| 38 | +def gap(self: AsymmetricTwoRollPass): |
| 39 | + if self.has_set_or_cached("height"): |
| 40 | + return self.height - self.upper_roll.groove.depth - self.lower_roll.groove.depth |
| 41 | + |
| 42 | + |
| 43 | +@AsymmetricTwoRollPass.height |
| 44 | +def height(self: AsymmetricTwoRollPass): |
| 45 | + if self.has_set_or_cached("gap"): |
| 46 | + return self.gap + self.upper_roll.groove.depth + self.lower_roll.groove.depth |
| 47 | + |
| 48 | + |
| 49 | +@AsymmetricTwoRollPass.contact_area |
| 50 | +def contact_area(self: AsymmetricTwoRollPass): |
| 51 | + return self.upper_roll.contact_area + self.lower_roll.contact_area |
| 52 | + |
| 53 | + |
| 54 | +@AsymmetricTwoRollPass.target_cross_section_area |
| 55 | +def target_cross_section_area_from_target_width(self: AsymmetricTwoRollPass): |
| 56 | + if self.has_value("target_width"): |
| 57 | + target_cross_section = helpers.out_cross_section(self, self.target_width) |
| 58 | + return target_cross_section.area |
| 59 | + |
| 60 | + |
| 61 | +@AsymmetricTwoRollPass.power |
| 62 | +def roll_power(self: AsymmetricTwoRollPass): |
| 63 | + return self.upper_roll.roll_power + self.lower_roll.roll_power |
| 64 | + |
| 65 | + |
| 66 | +@AsymmetricTwoRollPass.velocity |
| 67 | +def velocity(self: AsymmetricTwoRollPass): |
| 68 | + if self.upper_roll.has_value("neutral_angle") and self.lower_roll.has_value("neutral_angle"): |
| 69 | + return ( |
| 70 | + self.upper_roll.working_velocity * np.cos(self.upper_roll.neutral_angle) |
| 71 | + + self.lower_roll.working_velocity * np.cos(self.lower_roll.neutral_angle) |
| 72 | + ) / 2 |
| 73 | + else: |
| 74 | + return (self.upper_roll.working_velocity + self.lower_roll.working_velocity) / 2 |
| 75 | + |
| 76 | + |
| 77 | +@AsymmetricTwoRollPass.roll_force |
| 78 | +def roll_force(self: AsymmetricTwoRollPass): |
| 79 | + return ( |
| 80 | + (self.in_profile.flow_stress + 2 * self.out_profile.flow_stress) |
| 81 | + / 3 |
| 82 | + * (self.upper_roll.contact_area + self.lower_roll.contact_area) |
| 83 | + / 2 |
| 84 | + ) |
| 85 | + |
| 86 | + |
| 87 | +@AsymmetricTwoRollPass.InProfile.pass_line |
| 88 | +def pass_line(self: AsymmetricTwoRollPass.InProfile) -> tuple[float, float, float]: |
| 89 | + rp = self.roll_pass |
| 90 | + |
| 91 | + if not self.has_set("pass_line"): |
| 92 | + height_change = self.height - rp.height |
| 93 | + x_guess = -( |
| 94 | + np.sqrt(height_change) |
| 95 | + * np.sqrt( |
| 96 | + (2 * rp.upper_roll.min_radius - height_change) |
| 97 | + * (2 * rp.lower_roll.min_radius - height_change) |
| 98 | + * (2 * rp.upper_roll.min_radius + 2 * rp.lower_roll.min_radius - height_change) |
| 99 | + ) |
| 100 | + ) / (2 * (rp.upper_roll.min_radius + rp.lower_roll.min_radius - height_change)) |
| 101 | + y_guess = 0 |
| 102 | + else: |
| 103 | + x_guess, y_guess, _ = self.pass_line |
| 104 | + |
| 105 | + def contact_objective(xy): |
| 106 | + shifted_cross_section = shapely.affinity.translate(rp.rotated_in_profile.cross_section, yoff=xy[1]) |
| 107 | + |
| 108 | + upper_contour = shapely.geometry.LineString(np.stack([ |
| 109 | + rp.upper_roll.surface_z, |
| 110 | + rp.upper_roll.surface_interpolation(xy[0], rp.upper_roll.surface_z).squeeze(axis=1) |
| 111 | + ], axis=1)) |
| 112 | + upper_contour = shapely.affinity.translate(upper_contour,yoff=self.roll_pass.gap / 2) |
| 113 | + lower_contour = shapely.geometry.LineString(np.stack([ |
| 114 | + rp.lower_roll.surface_z, |
| 115 | + rp.lower_roll.surface_interpolation(xy[0], rp.lower_roll.surface_z).squeeze(axis=1) |
| 116 | + ], axis=1)) |
| 117 | + lower_contour = shapely.affinity.scale(shapely.affinity.translate(lower_contour, yoff=self.roll_pass.gap / 2), xfact=1, yfact=-1, origin=(0,0)) |
| 118 | + |
| 119 | + upper_intersection = shapely.intersection(upper_contour, shifted_cross_section) |
| 120 | + lower_intersection = shapely.intersection(lower_contour, shifted_cross_section) |
| 121 | + |
| 122 | + upper_value = upper_intersection.length if not upper_intersection.is_empty else shapely.shortest_line(upper_contour, shifted_cross_section).length |
| 123 | + lower_value = lower_intersection.length if not lower_intersection.is_empty else shapely.shortest_line(lower_contour, shifted_cross_section).length |
| 124 | + |
| 125 | + return upper_value ** 2 + lower_value ** 2 |
| 126 | + |
| 127 | + sol = scipy.optimize.minimize(contact_objective, (x_guess, y_guess), method="BFGS", options=dict(xrtol=1e-2)) |
| 128 | + |
| 129 | + return sol.x[0], sol.x[1], 0 |
| 130 | + |
| 131 | + |
| 132 | +@AsymmetricTwoRollPass.InProfile.cross_section |
| 133 | +def in_cross_section(self:AsymmetricTwoRollPass.InProfile): |
| 134 | + return shapely.affinity.translate(self.roll_pass.rotated_in_profile.cross_section, xoff=self.pass_line[2], yoff=self.pass_line[1]) |
| 135 | + |
| 136 | + |
| 137 | +@AsymmetricTwoRollPass.entry_point |
| 138 | +def entry_point(self: AsymmetricTwoRollPass): |
| 139 | + return self.in_profile.pass_line[0] |
| 140 | + |
0 commit comments