|
| 1 | +import logging |
| 2 | +import webbrowser |
| 3 | +from pathlib import Path |
| 4 | + |
| 5 | +from pyroll.basic import Profile, PassSequence, RollPass, Roll, CircularOvalGroove, Transport, RoundGroove, \ |
| 6 | + SwedishOvalGroove |
| 7 | +from pyroll.freiberg_flow_stress import FreibergFlowStressCoefficients |
| 8 | +from pyroll.report import report |
| 9 | + |
| 10 | + |
| 11 | +def test_solve(tmp_path: Path, caplog): |
| 12 | + caplog.set_level(logging.INFO, logger="pyroll") |
| 13 | + |
| 14 | + in_profile = Profile.round( |
| 15 | + radius=24e-3, |
| 16 | + temperature=1200 + 273.15, |
| 17 | + strain=0, |
| 18 | + material="BST 500", |
| 19 | + freiberg_flow_stress_coefficients=FreibergFlowStressCoefficients( |
| 20 | + a=4877.12 * 1e6, |
| 21 | + m1=-0.00273339, |
| 22 | + m2=0.302309, |
| 23 | + m3=-0.0407581, |
| 24 | + m4=0.000222222, |
| 25 | + m5=-0.000383134, |
| 26 | + m6=0, |
| 27 | + m7=-0.492672, |
| 28 | + m8=0.0000175044, |
| 29 | + m9=-0.0611783, |
| 30 | + baseStrain=0.1, |
| 31 | + baseStrainRate=0.1 |
| 32 | + ), |
| 33 | + density=7.5e3, |
| 34 | + thermal_capacity=690, |
| 35 | + ) |
| 36 | + |
| 37 | + sequence = PassSequence([ |
| 38 | + RollPass( |
| 39 | + label="K 02/001 - 1", |
| 40 | + roll=Roll( |
| 41 | + groove=SwedishOvalGroove( |
| 42 | + r1=6e-3, |
| 43 | + r2=26e-3, |
| 44 | + ground_width=38e-3, |
| 45 | + usable_width=60e-3, |
| 46 | + depth=7.25e-3 |
| 47 | + ), |
| 48 | + nominal_radius=321e-3 / 2, |
| 49 | + elastic_modulus=210e9, |
| 50 | + poissons_ratio=0.3 |
| 51 | + ), |
| 52 | + velocity=1, |
| 53 | + gap=13.5e-3, |
| 54 | + ), |
| 55 | + Transport( |
| 56 | + label="I -> II", |
| 57 | + duration=6.4 |
| 58 | + ), |
| 59 | + RollPass( |
| 60 | + label="K 05/001 - 2", |
| 61 | + roll=Roll( |
| 62 | + groove=RoundGroove( |
| 63 | + r1=4e-3, |
| 64 | + r2=18e-3, |
| 65 | + depth=17.5e-3 |
| 66 | + ), |
| 67 | + nominal_radius=321e-3 / 2, |
| 68 | + elastic_modulus=210e9, |
| 69 | + poissons_ratio=0.3 |
| 70 | + ), |
| 71 | + velocity=1, |
| 72 | + gap=1.5e-3, |
| 73 | + ), |
| 74 | + Transport( |
| 75 | + label="II -> III", |
| 76 | + duration=3.6 |
| 77 | + ), |
| 78 | + RollPass( |
| 79 | + label="K 02/001 - 3", |
| 80 | + roll=Roll( |
| 81 | + groove=SwedishOvalGroove( |
| 82 | + r1=6e-3, |
| 83 | + r2=26e-3, |
| 84 | + ground_width=38e-3, |
| 85 | + usable_width=60e-3, |
| 86 | + depth=7.25e-3 |
| 87 | + ), |
| 88 | + nominal_radius=321e-3 / 2, |
| 89 | + elastic_modulus=210e9, |
| 90 | + poissons_ratio=0.3 |
| 91 | + ), |
| 92 | + velocity=2, |
| 93 | + gap=1.5e-3, |
| 94 | + ), |
| 95 | + Transport( |
| 96 | + label="III -> IV", |
| 97 | + duration=3.4 |
| 98 | + ), |
| 99 | + RollPass( |
| 100 | + label="K 05/002 - 4", |
| 101 | + roll=Roll( |
| 102 | + groove=RoundGroove( |
| 103 | + r1=4e-3, |
| 104 | + r2=13.5e-3, |
| 105 | + depth=12.5e-3 |
| 106 | + ), |
| 107 | + nominal_radius=321e-3 / 2, |
| 108 | + elastic_modulus=210e9, |
| 109 | + poissons_ratio=0.3 |
| 110 | + ), |
| 111 | + velocity=2, |
| 112 | + gap=1e-3, |
| 113 | + ), |
| 114 | + Transport( |
| 115 | + label="IV -> V", |
| 116 | + duration=5.2 |
| 117 | + ), |
| 118 | + RollPass( |
| 119 | + label="K 03/001 - 5", |
| 120 | + roll=Roll( |
| 121 | + groove=CircularOvalGroove( |
| 122 | + r1=6e-3, |
| 123 | + r2=38e-3, |
| 124 | + depth=4e-3 |
| 125 | + ), |
| 126 | + nominal_radius=321e-3 / 2, |
| 127 | + elastic_modulus=210e9, |
| 128 | + poissons_ratio=0.3 |
| 129 | + ), |
| 130 | + velocity=2, |
| 131 | + gap=5.4e-3, |
| 132 | + ), |
| 133 | + Transport( |
| 134 | + label="V -> VI", |
| 135 | + duration=4.4 |
| 136 | + ), |
| 137 | + RollPass( |
| 138 | + label="K 05/003 - 6", |
| 139 | + roll=Roll( |
| 140 | + groove=RoundGroove( |
| 141 | + r1=3e-3, |
| 142 | + r2=10e-3, |
| 143 | + depth=9e-3 |
| 144 | + ), |
| 145 | + nominal_radius=321e-3 / 2, |
| 146 | + elastic_modulus=210e9, |
| 147 | + poissons_ratio=0.3 |
| 148 | + ), |
| 149 | + velocity=2, |
| 150 | + gap=1.8e-3, |
| 151 | + ), |
| 152 | + Transport( |
| 153 | + label="VI -> VII", |
| 154 | + duration=3.8 |
| 155 | + ), |
| 156 | + RollPass( |
| 157 | + label="K 03/001 - 7", |
| 158 | + roll=Roll( |
| 159 | + groove=CircularOvalGroove( |
| 160 | + r1=6e-3, |
| 161 | + r2=38e-3, |
| 162 | + depth=4e-3 |
| 163 | + ), |
| 164 | + nominal_radius=321e-3 / 2, |
| 165 | + elastic_modulus=210e9, |
| 166 | + poissons_ratio=0.3 |
| 167 | + ), |
| 168 | + velocity=2, |
| 169 | + gap=0.8e-3, |
| 170 | + ), |
| 171 | + Transport( |
| 172 | + label="VII -> IIX", |
| 173 | + duration=7.2 |
| 174 | + ), |
| 175 | + RollPass( |
| 176 | + label="K 05/004 - 8", |
| 177 | + roll=Roll( |
| 178 | + groove=RoundGroove( |
| 179 | + r1=2e-3, |
| 180 | + r2=7.5e-3, |
| 181 | + depth=5.5e-3 |
| 182 | + ), |
| 183 | + nominal_radius=321e-3 / 2, |
| 184 | + elastic_modulus=210e9, |
| 185 | + poissons_ratio=0.3 |
| 186 | + ), |
| 187 | + velocity=2, |
| 188 | + gap=3.8e-3, |
| 189 | + ), |
| 190 | + Transport( |
| 191 | + label="IIX -> IX", |
| 192 | + duration=6.2 |
| 193 | + ), |
| 194 | + RollPass( |
| 195 | + label="K 03/002 - 9", |
| 196 | + roll=Roll( |
| 197 | + groove=CircularOvalGroove( |
| 198 | + r1=6e-3, |
| 199 | + r2=21.2e-3, |
| 200 | + depth=2.5e-3 |
| 201 | + ), |
| 202 | + nominal_radius=321e-3 / 2, |
| 203 | + elastic_modulus=210e9, |
| 204 | + poissons_ratio=0.3 |
| 205 | + ), |
| 206 | + velocity=2, |
| 207 | + gap=3.5e-3, |
| 208 | + ), |
| 209 | + Transport( |
| 210 | + label="IX -> X", |
| 211 | + duration=4.5 |
| 212 | + ), RollPass( |
| 213 | + label="K 05/005 - 10", |
| 214 | + roll=Roll( |
| 215 | + groove=RoundGroove( |
| 216 | + r1=0.5e-3, |
| 217 | + r2=6e-3, |
| 218 | + depth=4e-3 |
| 219 | + ), |
| 220 | + nominal_radius=321e-3 / 2, |
| 221 | + elastic_modulus=210e9, |
| 222 | + poissons_ratio=0.3 |
| 223 | + ), |
| 224 | + velocity=2, |
| 225 | + gap=4e-3, |
| 226 | + ), |
| 227 | + Transport( |
| 228 | + label="X -> XI", |
| 229 | + duration=9 |
| 230 | + ), |
| 231 | + RollPass( |
| 232 | + label="F1 - K 3/50", |
| 233 | + roll=Roll( |
| 234 | + groove=CircularOvalGroove( |
| 235 | + r1=2.5e-3, |
| 236 | + r2=12.5e-3, |
| 237 | + depth=2.9e-3 |
| 238 | + ), |
| 239 | + nominal_radius=107.5e-3, |
| 240 | + elastic_modulus=210e9, |
| 241 | + poissons_ratio=0.3 |
| 242 | + ), |
| 243 | + velocity=4.89, |
| 244 | + gap=1.2e-3, |
| 245 | + ), |
| 246 | + Transport( |
| 247 | + label="XI -> XII", |
| 248 | + duration=1.5 / 4.89 |
| 249 | + ), |
| 250 | + RollPass( |
| 251 | + label="F2 - K 9/24", |
| 252 | + roll=Roll( |
| 253 | + groove=RoundGroove( |
| 254 | + r1=0.5e-3, |
| 255 | + r2=5.1e-3, |
| 256 | + depth=4.25e-3 |
| 257 | + ), |
| 258 | + nominal_radius=107.5e-3, |
| 259 | + elastic_modulus=210e9, |
| 260 | + poissons_ratio=0.3 |
| 261 | + ), |
| 262 | + velocity=6.1, |
| 263 | + gap=0.9e-3, |
| 264 | + ), |
| 265 | + Transport( |
| 266 | + label="XII -> XIII", |
| 267 | + duration=1.5 / 6.1 |
| 268 | + ), |
| 269 | + RollPass( |
| 270 | + label="F3 - K3/51", |
| 271 | + roll=Roll( |
| 272 | + groove=CircularOvalGroove( |
| 273 | + r1=2.5e-3, |
| 274 | + r2=11e-3, |
| 275 | + depth=2.12e-3 |
| 276 | + ), |
| 277 | + nominal_radius=107.5e-3, |
| 278 | + elastic_modulus=210e9, |
| 279 | + poissons_ratio=0.3 |
| 280 | + ), |
| 281 | + velocity=7.91, |
| 282 | + gap=1.75e-3, |
| 283 | + ), |
| 284 | + Transport( |
| 285 | + label="I -> II", |
| 286 | + duration=1.5 / 7.91 |
| 287 | + ), |
| 288 | + RollPass( |
| 289 | + label="F4 - K 9/23", |
| 290 | + roll=Roll( |
| 291 | + groove=RoundGroove( |
| 292 | + r1=0.5e-3, |
| 293 | + r2=3.5e-3, |
| 294 | + depth=3.5e-3 |
| 295 | + ), |
| 296 | + nominal_radius=85e-3, |
| 297 | + elastic_modulus=210e9, |
| 298 | + poissons_ratio=0.3 |
| 299 | + ), |
| 300 | + velocity=10, |
| 301 | + gap=1.5e-3, |
| 302 | + ), |
| 303 | + ]) |
| 304 | + |
| 305 | + |
| 306 | + try: |
| 307 | + sequence.solve(in_profile) |
| 308 | + finally: |
| 309 | + print("\nLog:") |
| 310 | + print(caplog.text) |
| 311 | + |
| 312 | + report_file = tmp_path / "report.html" |
| 313 | + |
| 314 | + rendered = report(sequence) |
| 315 | + print() |
| 316 | + |
| 317 | + report_file.write_text(rendered) |
| 318 | + |
| 319 | + webbrowser.open(report_file.as_uri()) |
0 commit comments