meep.vec(-model.size_x / 2, -model.size_y / 2, -model.size_z / 2 + model.pml_thickness * 0), meep.vec(model.size_x / 2, model.size_y / 2, model.size_z / 2 - model.pml_thickness * 0)) vol.center_origin() ## Define the Perfectly Matched Layers #perfectly_matched_layers = meep.pml(model.pml_thickness, meep.Z) ## PML on both faces at Z axis perfectly_matched_layers = meep.pml(model.pml_thickness) ## PML on all faces if not sim_param['frequency_domain']: meep.master_printf("== Time domain structure setup ==\n") ## Define each polarizability by redirecting the callback to the corresponding "where_material" function ## Define the frequency-independent epsilon for all materials (needed here, before defining s, or unstable) model.double_vec = model.eps meep.set_EPS_Callback(model.__disown__()) s = meep.structure(vol, meep.EPS, perfectly_matched_layers, meep.identity()) ## Add all the materials model.build_polarizabilities(s) ## Add the source dependence #srctype = meep.band_src_time(model.srcFreq/c, model.srcWidth/c, model.simtime*c/1.1) srctype = meep.gaussian_src_time(model.srcFreq / c, model.srcWidth / c) ## , 0, 1000e-12 ?? else: meep.master_printf( "== Frequency domain structure setup (for frequency of %g Hz) ==\n" % sim_param['frequency'])
## Initialize volume vol = meep.vol3d(model.size_x, model.size_y, model.size_z, 1./model.resolution) volume_except_pml = meep.volume( meep.vec(-model.size_x/2, -model.size_y/2, -model.size_z/2+model.pml_thickness*0), meep.vec(model.size_x/2, model.size_y/2, model.size_z/2-model.pml_thickness*0)) vol.center_origin() ## Define the Perfectly Matched Layers perfectly_matched_layers = meep.pml(model.pml_thickness, meep.Z) ## PML on both faces at Z axis if not sim_param['frequency_domain']: meep.master_printf("== Time domain structure setup ==\n") ## Define each polarizability by redirecting the callback to the corresponding "where_material" function ## Define the frequency-independent epsilon for all materials (needed here, before defining s, or unstable) model.double_vec = model.eps; meep.set_EPS_Callback(model.__disown__()) s = meep.structure(vol, meep.EPS, perfectly_matched_layers, meep.identity()) ## Add all the materials model.build_polarizabilities(s) ## Add the source dependence #srctype = meep.band_src_time(model.srcFreq/c, model.srcWidth/c, model.simtime*c/1.1) srctype = meep.gaussian_src_time(model.srcFreq/c, model.srcWidth/c) ## , 0, 1000e-12 ?? else: meep.master_printf("== Frequency domain structure setup (for frequency of %g Hz) ==\n" % sim_param['frequency']) if (model.Kx!=0 or model.Ky!=0): print "Warning: frequency-domain solver may be broken for nonperpendicular incidence" ## Frequency-domain simulation does not support dispersive materials yet. We must define each material by ## using the nondispersive permittivity and the nondispersive conductivity ## (both calculated from polarizabilities at given frequency)
## Initialize volume vol = meep.vol3d(model.size_x, model.size_y, model.size_z, 1./model.resolution) volume_except_pml = meep.volume( meep.vec(-model.size_x/2, -model.size_y/2, -model.size_z/2+model.pml_thickness*0), meep.vec(model.size_x/2, model.size_y/2, model.size_z/2-model.pml_thickness*0)) vol.center_origin() ## Define the Perfectly Matched Layers perfectly_matched_layers = meep.pml(model.pml_thickness) ## PML on both faces at Z axis if not sim_param['frequency_domain']: meep.master_printf("== Time domain structure setup ==\n") ## Define each polarizability by redirecting the callback to the corresponding "where_material" function ## Define the frequency-independent epsilon for all materials (needed here, before defining s, or unstable) model.double_vec = model.get_static_permittivity; meep.set_EPS_Callback(model.__disown__()) s = meep.structure(vol, meep.EPS, perfectly_matched_layers, meep.identity()) ## Add all the materials model.build_polarizabilities(s) ## Add the source dependence #srctype = meep.band_src_time(model.srcFreq/c, model.srcWidth/c, model.simtime*c/1.1) srctype = meep.gaussian_src_time(model.srcFreq/c, model.srcWidth/c) ## , 0, 1000e-12 ?? else: meep.master_printf("== Frequency domain structure setup (for frequency of %g Hz) ==\n" % sim_param['frequency']) if (model.Kx!=0 or model.Ky!=0): print "Warning: frequency-domain solver may be broken for nonperpendicular incidence" ## Frequency-domain simulation does not support dispersive materials yet. We must define each material by ## using the nondispersive permittivity and the nondispersive conductivity ## (both calculated from polarizabilities at given frequency)
eps_matrix = numpy.absolute( eps_matrix / numpy.amax(eps_matrix))**2 * modulation print(eps_matrix[10, 10]) # grating = numpy.abs(eps_matrix) ** 2 # plt.figure(1) # plt.imshow(_eps_matrix, cmap='hot', extent=[0, gridSizeX, 0, gridSizeY]) # plt.colorbar() # plt.show() meep.master_printf("Setting the material matrix...\n") self.set_matrix_2D(eps_matrix, vol) # self.setMatrix(grating) self.stored_eps_matrix = eps_matrix # to prevent the garbage collector from cleaning up the matrix... meep.master_printf("MeepMaterial object initialized.\n") meep.set_EPS_Callback(epsilon().__disown__()) struct = meep.structure(vol, EPS, no_pml()) fld = meep.fields(struct) fld.add_volume_source(Ex, gaussian_src_time(freq_read / c, 1.5e9 / c), vol) while fld.time() / c < 30e-15: fld.step() meep.print_f.get_field(Ex, meep.vec(0.5e-6, 0.5e-6, 3e-6)) meep.del_EPS_Callback()