| 352 | self.assertAlmostEqual(fp, -0.002989654055823199, places=places) |
| 353 | |
| 354 | def test_set_materials(self): |
| 355 | def change_geom(sim): |
| 356 | t = sim.meep_time() |
| 357 | fn = t * 0.02 |
| 358 | geom = [ |
| 359 | mp.Cylinder( |
| 360 | radius=3, material=mp.Medium(index=3.5), center=mp.Vector3(fn, fn) |
| 361 | ), |
| 362 | mp.Ellipsoid(size=mp.Vector3(1, 2, mp.inf), center=mp.Vector3(fn, fn)), |
| 363 | ] |
| 364 | |
| 365 | sim.set_materials(geometry=geom) |
| 366 | |
| 367 | c = mp.Cylinder(radius=3, material=mp.Medium(index=3.5)) |
| 368 | e = mp.Ellipsoid(size=mp.Vector3(1, 2, mp.inf)) |
| 369 | |
| 370 | sources = mp.Source( |
| 371 | src=mp.GaussianSource(1, fwidth=0.1), component=mp.Hz, center=mp.Vector3() |
| 372 | ) |
| 373 | symmetries = [mp.Mirror(mp.X, -1), mp.Mirror(mp.Y, -1)] |
| 374 | |
| 375 | sim = mp.Simulation( |
| 376 | cell_size=mp.Vector3(10, 10), |
| 377 | geometry=[c, e], |
| 378 | boundary_layers=[mp.PML(1.0)], |
| 379 | sources=[sources], |
| 380 | symmetries=symmetries, |
| 381 | resolution=16, |
| 382 | ) |
| 383 | |
| 384 | eps = {"arr1": None, "arr2": None} |
| 385 | |
| 386 | def get_arr1(sim): |
| 387 | eps["arr1"] = sim.get_array( |
| 388 | mp.Dielectric, mp.Volume(mp.Vector3(), mp.Vector3(10, 10)) |
| 389 | ) |
| 390 | |
| 391 | def get_arr2(sim): |
| 392 | eps["arr2"] = sim.get_array( |
| 393 | mp.Dielectric, mp.Volume(mp.Vector3(), mp.Vector3(10, 10)) |
| 394 | ) |
| 395 | |
| 396 | sim.run( |
| 397 | mp.at_time(50, get_arr1), |
| 398 | mp.at_time(100, change_geom), |
| 399 | mp.at_end(get_arr2), |
| 400 | until=200, |
| 401 | ) |
| 402 | |
| 403 | self.assertFalse(np.array_equal(eps["arr1"], eps["arr2"])) |
| 404 | |
| 405 | def test_modal_volume_in_box(self): |
| 406 | sim = self.init_simple_simulation() |