Skip to content

Commit 1305201

Browse files
author
Christoph Renzing
committed
fixed impl. for asymmetric two roll pass for basic tests.
1 parent c76990a commit 1305201

File tree

7 files changed

+27
-12
lines changed

7 files changed

+27
-12
lines changed

pyroll/core/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
create_groove_by_type_name,
2828
)
2929
from .transport import Transport, CoolingPipe
30-
from .roll_pass import BaseRollPass, DeformationUnit, ThreeRollPass, SymmetricRollPass, TwoRollPass
30+
from .roll_pass import BaseRollPass, DeformationUnit, ThreeRollPass, SymmetricRollPass, TwoRollPass, AsymmetricTwoRollPass
3131
from .roll_pass import TwoRollPass as RollPass
3232
from .unit import Unit
3333
from .roll import Roll

pyroll/core/roll_pass/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,5 @@
1313
"ThreeRollPass",
1414
"DeformationUnit",
1515
"SymmetricRollPass",
16+
"AsymmetricTwoRollPass"
1617
]

pyroll/core/roll_pass/asymmetric_two_roll_pass.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,32 +3,37 @@
33
import numpy as np
44
from shapely.affinity import translate, scale
55
from shapely.geometry import LineString
6+
from shapely.geometry.multilinestring import MultiLineString
67

78
from .base import BaseRollPass
89
from ..hooks import Hook
910
from ..roll import Roll as BaseRoll
10-
11+
from ..engine import Engine as BaseEngine
1112

1213
class AsymmetricTwoRollPass(BaseRollPass):
13-
"""Represents a symmetric roll pass with equal upper and lower working roll."""
14+
"""Represents a symmetric roll pass with unequal upper and lower roll."""
1415

1516
def __init__(
1617
self,
1718
upper_roll: BaseRoll,
1819
lower_roll: BaseRoll,
20+
engine: BaseEngine = BaseEngine(),
1921
label: str = "",
2022
**kwargs
2123
):
2224
super().__init__(label, **kwargs)
2325

2426
self.upper_roll = self.Roll(upper_roll, self)
25-
"""The upper working roll of this pass."""
27+
"""The upper roll of this pass."""
2628

2729
self.lower_roll = self.Roll(lower_roll, self)
28-
"""The upper working roll of this pass."""
30+
"""The lower roll of this pass."""
31+
32+
self.engine = self.Engine(engine, self)
33+
"""The engine of this pass."""
2934

3035
@property
31-
def contour_lines(self) -> List[LineString]:
36+
def contour_lines(self) -> MultiLineString:
3237
if self._contour_lines:
3338
return self._contour_lines
3439

@@ -38,7 +43,7 @@ def contour_lines(self) -> List[LineString]:
3843
xfact=1, yfact=-1, origin=(0, 0)
3944
)
4045

41-
self._contour_lines = [upper, lower]
46+
self._contour_lines = MultiLineString([upper, lower])
4247
return self._contour_lines
4348

4449
@property

pyroll/core/roll_pass/base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ def init_solve(self, in_profile: BaseProfile):
135135

136136
def reevaluate_cache(self):
137137
super().reevaluate_cache()
138-
self.roll.reevaluate_cache()
138+
#self.roll.reevaluate_cache()
139139
self._contour_lines = None
140140
self.engine.reevaluate_cache()
141141

pyroll/core/roll_pass/hookimpls/asymmetric_two_roll_pass.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ def pass_line(self: AsymmetricTwoRollPass.InProfile) -> tuple[float, float, floa
103103
x_guess, y_guess, _ = self.pass_line
104104

105105
def contact_objective(xy):
106-
shifted_cross_section = shapely.affinity.translate(rp.rotated_in_profile.cross_section, yoff=xy[1])
106+
shifted_cross_section = shapely.affinity.translate(rp.in_profile.cross_section, yoff=xy[1])
107107

108108
upper_contour = shapely.geometry.LineString(np.stack([
109109
rp.upper_roll.surface_z,
@@ -131,7 +131,7 @@ def contact_objective(xy):
131131

132132
@AsymmetricTwoRollPass.InProfile.cross_section
133133
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])
134+
return shapely.affinity.translate(self.roll_pass.in_profile.cross_section, xoff=self.pass_line[2], yoff=self.pass_line[1])
135135

136136

137137
@AsymmetricTwoRollPass.entry_point

pyroll/core/roll_pass/hookimpls/helpers.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
import math
22

33
import numpy as np
4+
import shapely
45
from shapely import Polygon, clip_by_rect
56
from shapely.affinity import rotate
67

78
from ..two_roll_pass import TwoRollPass
89
from ..three_roll_pass import ThreeRollPass
9-
from ..asymmetric_two_roll_pass import AsymmetricTwoRollPass
1010
from ...profile.profile import refine_cross_section
1111

1212

13-
def out_cross_section(rp: TwoRollPass | AsymmetricTwoRollPass, width: float) -> Polygon:
13+
def out_cross_section(rp: TwoRollPass, width: float) -> Polygon:
1414
poly = Polygon(np.concatenate([cl.coords for cl in rp.contour_lines.geoms]))
1515
poly = clip_by_rect(poly, -width / 2, -math.inf, width / 2, math.inf)
1616
return refine_cross_section(poly)

pyroll/core/roll_pass/hookimpls/profile.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,15 @@ def cross_section_error(self: BaseRollPass.OutProfile):
6868
def cross_section(self: BaseRollPass.OutProfile) -> Polygon:
6969
in_profile_width = self.roll_pass.in_profile.width
7070

71+
if "asymmetric" in self.roll_pass.classifiers:
72+
cs = helpers.out_cross_section(self.roll_pass, self.width)
73+
if cs.width * 1.01 < self.width:
74+
raise ValueError(
75+
"Profile's width can not be larger than its contour lines."
76+
"May be caused by critical overfilling."
77+
)
78+
return cs
79+
7180
if "square" in self.roll_pass.in_profile.classifiers:
7281
horizontal_line = LineString([(-self.roll_pass.in_profile.width, 0), (self.roll_pass.in_profile.width, 0)])
7382
intersection_at_y0 = self.roll_pass.in_profile.cross_section.intersection(horizontal_line)

0 commit comments

Comments
 (0)