Run benchmark for a single solver and mesh configuration.
(
solver_name: str,
solver_setup: Callable[[], None],
numberer: str,
mesh_factor: float,
mesh_size: float,
counts: Tuple[int, int, int],
num_steps: int = 5,
tol: float = 1.0e-7,
max_iter: int = 50,
)
| 242 | |
| 243 | |
| 244 | def run_benchmark( |
| 245 | solver_name: str, |
| 246 | solver_setup: Callable[[], None], |
| 247 | numberer: str, |
| 248 | mesh_factor: float, |
| 249 | mesh_size: float, |
| 250 | counts: Tuple[int, int, int], |
| 251 | num_steps: int = 5, |
| 252 | tol: float = 1.0e-7, |
| 253 | max_iter: int = 50, |
| 254 | ) -> BenchmarkRow: |
| 255 | """Run benchmark for a single solver and mesh configuration.""" |
| 256 | nx, ny, nz = counts |
| 257 | build_solid_bar_model(nx, ny, nz) |
| 258 | |
| 259 | # Calculate load |
| 260 | total_load = 1.25 * YIELD_STRESS * (BAR_THICKNESS * BAR_HEIGHT**2) / (6 * BAR_LENGTH) |
| 261 | apply_load_pattern(total_load) |
| 262 | |
| 263 | # Static analysis |
| 264 | configure_static_analysis(solver_setup, numberer, num_steps, tol, max_iter) |
| 265 | start_time = time.perf_counter() |
| 266 | status = ops.analyze(num_steps) |
| 267 | time_seconds = time.perf_counter() - start_time |
| 268 | |
| 269 | # Get system information |
| 270 | num_elements = len(ops.getEleTags()) |
| 271 | num_nodes = len(ops.getNodeTags()) |
| 272 | try: |
| 273 | neq = ops.systemSize() |
| 274 | except AttributeError: |
| 275 | neq = -1 |
| 276 | |
| 277 | # Get displacement at far corner |
| 278 | displacement = None |
| 279 | if status == 0: |
| 280 | for node in ops.getNodeTags(): |
| 281 | x = ops.nodeCoord(node, 1) |
| 282 | y = ops.nodeCoord(node, 2) |
| 283 | z = ops.nodeCoord(node, 3) |
| 284 | if np.isclose( |
| 285 | [x, y, z], |
| 286 | [BAR_LENGTH, BAR_THICKNESS / 2.0, BAR_HEIGHT / 2.0], |
| 287 | atol=1e-9, |
| 288 | ).all(): |
| 289 | dx = ops.nodeDisp(node, 1) |
| 290 | dy = ops.nodeDisp(node, 2) |
| 291 | dz = ops.nodeDisp(node, 3) |
| 292 | displacement = (dx, dy, dz) |
| 293 | break |
| 294 | |
| 295 | if displacement is not None: |
| 296 | dx, dy, dz = displacement |
| 297 | else: |
| 298 | dx = dy = dz = None |
| 299 | |
| 300 | return BenchmarkRow( |
| 301 | solver_name=solver_name, |
no test coverage detected