`run(step_functions..., until=condition/time)` ##sig-keep Run the simulation until a certain time or condition, calling the given step functions (if any) at each timestep. The keyword argument `until` is *either* a number, in which case it is an additional time (in
(self, *step_funcs, **kwargs)
| 4526 | self.dft_objects = [] |
| 4527 | |
| 4528 | def run(self, *step_funcs, **kwargs): |
| 4529 | """ |
| 4530 | `run(step_functions..., until=condition/time)` ##sig-keep |
| 4531 | |
| 4532 | Run the simulation until a certain time or condition, calling the given step |
| 4533 | functions (if any) at each timestep. The keyword argument `until` is *either* a |
| 4534 | number, in which case it is an additional time (in Meep units) to run for, *or* it |
| 4535 | is a function (of no arguments) which returns `True` when the simulation should |
| 4536 | stop. `until` can also be a list of stopping conditions which may include a number |
| 4537 | of additional functions. |
| 4538 | |
| 4539 | `run(step_functions..., until_after_sources=condition/time)` ##sig-keep |
| 4540 | |
| 4541 | Run the simulation until all sources have turned off, calling the given step |
| 4542 | functions (if any) at each timestep. The keyword argument `until_after_sources` is |
| 4543 | either a number, in which case it is an *additional* time (in Meep units) to run |
| 4544 | for after the sources are off, *or* it is a function (of no arguments). In the |
| 4545 | latter case, the simulation runs until the sources are off *and* `condition` |
| 4546 | returns `True`. Like `until` above, `until_after_sources` can take a list of |
| 4547 | stopping conditions. |
| 4548 | """ |
| 4549 | until = kwargs.pop("until", None) |
| 4550 | until_after_sources = kwargs.pop("until_after_sources", None) |
| 4551 | |
| 4552 | if self.fields is None: |
| 4553 | self.init_sim() |
| 4554 | |
| 4555 | self._evaluate_dft_objects() |
| 4556 | self._check_material_frequencies() |
| 4557 | |
| 4558 | if kwargs: |
| 4559 | raise ValueError(f"Unrecognized keyword arguments: {kwargs.keys()}") |
| 4560 | |
| 4561 | if until_after_sources is not None: |
| 4562 | self._run_sources_until(until_after_sources, step_funcs) |
| 4563 | elif until is not None: |
| 4564 | self._run_until(until, step_funcs) |
| 4565 | else: |
| 4566 | raise ValueError("Invalid run configuration") |
| 4567 | |
| 4568 | def print_times(self): |
| 4569 | """ |