Guest User

Untitled

a guest
Mar 5th, 2018
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.17 KB | None | 0 0
  1. # The output confirms that the geometry was changed correctly:
  2.  
  3. # Working in 2D dimensions.
  4. # Computational cell is 10 x 10 x 0 with resolution 16
  5. # cylinder, center = (0,0,0)
  6. # radius 3, height 1e+20, axis (0, 0, 1)
  7. # dielectric constant epsilon diagonal = (12.25,12.25,12.25)
  8. # ellipsoid, center = (0,0,0)
  9. # size (1,2,1e+20)
  10. # axes (1,0,0), (0,1,0), (0,0,1)
  11. # dielectric constant epsilon diagonal = (1,1,1)
  12. # time for set_epsilon = 0.098387 s
  13. # -----------
  14. # Working in 2D dimensions.
  15. # Computational cell is 10 x 10 x 0 with resolution 16
  16. # cylinder, center = (2,2,0)
  17. # radius 3, height 1e+20, axis (0, 0, 1)
  18. # dielectric constant epsilon diagonal = (12.25,12.25,12.25)
  19. # ellipsoid, center = (2,2,0)
  20. # size (1,2,1e+20)
  21. # axes (1,0,0), (0,1,0), (0,0,1)
  22. # dielectric constant epsilon diagonal = (1,1,1)
  23. # time for set_epsilon = 0.053612 s
  24.  
  25. def test_set_materials(self):
  26.  
  27. def change_geom(sim):
  28. t = sim.meep_time()
  29. fn = t * 0.02
  30. geom = [mp.Cylinder(radius=3, material=mp.Medium(index=3.5), center=mp.Vector3(fn, fn)),
  31. mp.Ellipsoid(size=mp.Vector3(1, 2, mp.inf), center=mp.Vector3(fn, fn))]
  32. sim.set_materials(geometry=geom)
  33.  
  34. c = mp.Cylinder(radius=3, material=mp.Medium(index=3.5))
  35. e = mp.Ellipsoid(size=mp.Vector3(1, 2, mp.inf))
  36.  
  37. sources = mp.Source(src=mp.GaussianSource(1, fwidth=0.1), component=mp.Hz, center=mp.Vector3())
  38. symmetries = [mp.Mirror(mp.X, -1), mp.Mirror(mp.Y, -1)]
  39. sim = mp.Simulation(cell_size=mp.Vector3(10, 10),
  40. geometry=[c, e],
  41. boundary_layers=[mp.PML(1.0)],
  42. sources=[sources],
  43. symmetries=symmetries,
  44. resolution=16)
  45.  
  46. eps = {'arr1': None, 'arr2': None}
  47.  
  48. def get_arr1(sim):
  49. eps['arr1'] = sim.get_array(mp.Vector3(), mp.Vector3(10, 10), mp.Dielectric)
  50.  
  51. def get_arr2(sim):
  52. eps['arr2'] = sim.get_array(mp.Vector3(), mp.Vector3(10, 10), mp.Dielectric)
  53.  
  54. sim.run(mp.at_time(50, get_arr1), mp.at_time(100, change_geom),
  55. mp.at_end(get_arr2), until=200)
  56.  
  57. self.assertFalse(np.array_equal(eps['arr1'], eps['arr2']))
Add Comment
Please, Sign In to add comment