| 5516 | |
| 5517 | |
| 5518 | def display_progress(t0, t, dt): |
| 5519 | t_0 = mp.wall_time() |
| 5520 | closure = {"tlast": mp.wall_time()} |
| 5521 | |
| 5522 | def _disp(sim): |
| 5523 | t1 = mp.wall_time() |
| 5524 | if t1 - closure["tlast"] >= dt: |
| 5525 | msg_fmt = "Meep progress: {}/{} = {:.1f}% done in {:.1f}s, {:.1f}s to go" |
| 5526 | val1 = sim.meep_time() - t0 |
| 5527 | val2 = val1 / (0.01 * t) |
| 5528 | val3 = t1 - t_0 |
| 5529 | val4 = (val3 * (t / val1) - val3) if val1 != 0 else 0 |
| 5530 | |
| 5531 | if do_progress: |
| 5532 | sim.progress.value = val1 |
| 5533 | sim.progress.description = f"{int(val2)}% done " |
| 5534 | |
| 5535 | if verbosity.meep > 0: |
| 5536 | print(msg_fmt.format(val1, t, val2, val3, val4)) |
| 5537 | closure["tlast"] = t1 |
| 5538 | |
| 5539 | return _disp |
| 5540 | |
| 5541 | |
| 5542 | def data_to_str(d): |