(self)
| 432 | sim.field_energy_in_box(v) |
| 433 | |
| 434 | def test_get_array_output(self): |
| 435 | sim = self.init_simple_simulation() |
| 436 | sim.use_output_directory(self.temp_dir) |
| 437 | sim.symmetries = [] |
| 438 | sim.geometry = [mp.Cylinder(0.2, material=mp.Medium(index=3))] |
| 439 | sim.filename_prefix = "test_get_array_output" |
| 440 | sim.run(until=20) |
| 441 | |
| 442 | mp.output_epsilon(sim) |
| 443 | mp.output_efield_z(sim) |
| 444 | mp.output_tot_pwr(sim) |
| 445 | mp.output_efield(sim) |
| 446 | |
| 447 | eps_arr = sim.get_epsilon(snap=True) |
| 448 | efield_z_arr = sim.get_efield_z(snap=True) |
| 449 | energy_arr = sim.get_tot_pwr(snap=True) |
| 450 | efield_arr = sim.get_efield(snap=True) |
| 451 | |
| 452 | fname_fmt = os.path.join(self.temp_dir, "test_get_array_output-{}-000020.00.h5") |
| 453 | |
| 454 | with h5py.File(fname_fmt.format("eps"), "r") as f: |
| 455 | eps = f["eps"][()] |
| 456 | |
| 457 | with h5py.File(fname_fmt.format("ez"), "r") as f: |
| 458 | efield_z = f["ez"][()] |
| 459 | |
| 460 | with h5py.File(fname_fmt.format("energy"), "r") as f: |
| 461 | energy = f["energy"][()] |
| 462 | |
| 463 | with h5py.File(fname_fmt.format("e"), "r") as f: |
| 464 | ex = f["ex"][()] |
| 465 | ey = f["ey"][()] |
| 466 | ez = f["ez"][()] |
| 467 | efield = np.stack([ex, ey, ez], axis=-1) |
| 468 | |
| 469 | np.testing.assert_allclose(eps, eps_arr) |
| 470 | np.testing.assert_allclose(efield_z, efield_z_arr) |
| 471 | np.testing.assert_allclose(energy, energy_arr) |
| 472 | np.testing.assert_allclose(efield, efield_arr) |
| 473 | |
| 474 | def test_synchronized_magnetic(self): |
| 475 | # Issue 309 |
nothing calls this directly
no test coverage detected