This can be called in a step function, and is useful for changing the geometry or default material as a function of time.
(
self, geometry: List[GeometricObject] = None, default_material: Medium = None
)
| 2231 | return [self.structure.estimated_cost(i) for i in range(mp.count_processors())] |
| 2232 | |
| 2233 | def set_materials( |
| 2234 | self, geometry: List[GeometricObject] = None, default_material: Medium = None |
| 2235 | ): |
| 2236 | """ |
| 2237 | This can be called in a step function, and is useful for changing the geometry or |
| 2238 | default material as a function of time. |
| 2239 | """ |
| 2240 | if self.fields: |
| 2241 | self.fields.remove_susceptibilities() |
| 2242 | |
| 2243 | absorbers = [bl for bl in self.boundary_layers if type(bl) is Absorber] |
| 2244 | |
| 2245 | # Since we are about to overwrite self.structure, SWIG will garbage |
| 2246 | # collect it. However, that's not what we want because we're just |
| 2247 | # passing self.structure into create_structure_and_set_materials for |
| 2248 | # the "set_materials" half of that function. The return value will be |
| 2249 | # the same structure we passed in. We tell SWIG to disown (and not |
| 2250 | # delete) the current self.structure. SWIG will properly take ownership |
| 2251 | # of the returned self.structure (which is the same structure as |
| 2252 | # before). |
| 2253 | self.structure.this.disown() |
| 2254 | |
| 2255 | self.structure = mp.create_structure( |
| 2256 | self.cell_size, |
| 2257 | self.dft_data_list, |
| 2258 | self.pml_vols1, |
| 2259 | self.pml_vols2, |
| 2260 | self.pml_vols3, |
| 2261 | self.absorber_vols, |
| 2262 | self.gv, |
| 2263 | mp.boundary_region(), |
| 2264 | mp.symmetry(), |
| 2265 | self.num_chunks, |
| 2266 | self.Courant, |
| 2267 | self.eps_averaging, |
| 2268 | self.subpixel_tol, |
| 2269 | self.subpixel_maxeval, |
| 2270 | geometry if geometry is not None else self.geometry, |
| 2271 | self.geometry_center, |
| 2272 | self.ensure_periodicity and not not self.k_point, |
| 2273 | default_material if default_material else self.default_material, |
| 2274 | absorbers, |
| 2275 | self.extra_materials, |
| 2276 | self.split_chunks_evenly, |
| 2277 | True, |
| 2278 | self.structure, |
| 2279 | False, |
| 2280 | None, |
| 2281 | ) |
| 2282 | self.geps = mp._set_materials( |
| 2283 | self.structure, |
| 2284 | self.cell_size, |
| 2285 | self.gv, |
| 2286 | self.eps_averaging, |
| 2287 | self.subpixel_tol, |
| 2288 | self.subpixel_maxeval, |
| 2289 | geometry if geometry is not None else self.geometry, |
| 2290 | self.geometry_center, |