MCPcopy Create free account
hub / github.com/NanoComp/meep / forward_simulation

Function forward_simulation

python/tests/test_adjoint_cyl.py:73–115  ·  view source on GitHub ↗
(design_params, m, far_x)

Source from the content-addressed store, hash-verified

71
72
73def forward_simulation(design_params, m, far_x):
74 matgrid = mp.MaterialGrid(
75 mp.Vector3(Nr, 0, Nz),
76 SiO2,
77 Si,
78 weights=design_params.reshape(Nr, 1, Nz),
79 do_averaging=True,
80 )
81
82 geometry = [
83 mp.Block(
84 center=mp.Vector3(design_r / 2, 0, 0),
85 size=mp.Vector3(design_r, 0, design_z),
86 material=matgrid,
87 )
88 ]
89
90 sim = mp.Simulation(
91 resolution=resolution,
92 cell_size=cell_size,
93 boundary_layers=boundary_layers,
94 sources=get_source(m),
95 geometry=geometry,
96 dimensions=dimensions,
97 m=m,
98 )
99
100 frequencies = [fcen]
101
102 mode = sim.add_near2far(
103 frequencies,
104 mp.Near2FarRegion(
105 center=mp.Vector3(design_r / 2, 0, (sz / 2 - dpml + design_z / 2) / 2),
106 size=mp.Vector3(design_r, 0, 0),
107 weight=+1,
108 ),
109 )
110
111 sim.run(until_after_sources=1200)
112 Er = sim.get_farfield(mode, far_x[0])
113 sim.reset_meep()
114
115 return abs(Er[0]) ** 2
116
117
118def adjoint_solver(design_params, m, far_x):

Callers 1

Calls 6

add_near2farMethod · 0.95
runMethod · 0.95
get_farfieldMethod · 0.95
reset_meepMethod · 0.95
get_sourceFunction · 0.85
absFunction · 0.85

Tested by

no test coverage detected