Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # The output confirms that the geometry was changed correctly:
- # Working in 2D dimensions.
- # Computational cell is 10 x 10 x 0 with resolution 16
- # cylinder, center = (0,0,0)
- # radius 3, height 1e+20, axis (0, 0, 1)
- # dielectric constant epsilon diagonal = (12.25,12.25,12.25)
- # ellipsoid, center = (0,0,0)
- # size (1,2,1e+20)
- # axes (1,0,0), (0,1,0), (0,0,1)
- # dielectric constant epsilon diagonal = (1,1,1)
- # time for set_epsilon = 0.098387 s
- # -----------
- # Working in 2D dimensions.
- # Computational cell is 10 x 10 x 0 with resolution 16
- # cylinder, center = (2,2,0)
- # radius 3, height 1e+20, axis (0, 0, 1)
- # dielectric constant epsilon diagonal = (12.25,12.25,12.25)
- # ellipsoid, center = (2,2,0)
- # size (1,2,1e+20)
- # axes (1,0,0), (0,1,0), (0,0,1)
- # dielectric constant epsilon diagonal = (1,1,1)
- # time for set_epsilon = 0.053612 s
- def test_set_materials(self):
- def change_geom(sim):
- t = sim.meep_time()
- fn = t * 0.02
- geom = [mp.Cylinder(radius=3, material=mp.Medium(index=3.5), center=mp.Vector3(fn, fn)),
- mp.Ellipsoid(size=mp.Vector3(1, 2, mp.inf), center=mp.Vector3(fn, fn))]
- sim.set_materials(geometry=geom)
- c = mp.Cylinder(radius=3, material=mp.Medium(index=3.5))
- e = mp.Ellipsoid(size=mp.Vector3(1, 2, mp.inf))
- sources = mp.Source(src=mp.GaussianSource(1, fwidth=0.1), component=mp.Hz, center=mp.Vector3())
- symmetries = [mp.Mirror(mp.X, -1), mp.Mirror(mp.Y, -1)]
- sim = mp.Simulation(cell_size=mp.Vector3(10, 10),
- geometry=[c, e],
- boundary_layers=[mp.PML(1.0)],
- sources=[sources],
- symmetries=symmetries,
- resolution=16)
- eps = {'arr1': None, 'arr2': None}
- def get_arr1(sim):
- eps['arr1'] = sim.get_array(mp.Vector3(), mp.Vector3(10, 10), mp.Dielectric)
- def get_arr2(sim):
- eps['arr2'] = sim.get_array(mp.Vector3(), mp.Vector3(10, 10), mp.Dielectric)
- sim.run(mp.at_time(50, get_arr1), mp.at_time(100, change_geom),
- mp.at_end(get_arr2), until=200)
- self.assertFalse(np.array_equal(eps['arr1'], eps['arr2']))
Add Comment
Please, Sign In to add comment