z_position=model.monitor_z2, Kx=model.Kx, Ky=model.Ky) monitor2_Hy = meep_utils.AmplitudeMonitorPlane(f, comp=meep.Hy, size_x=model.size_x, size_y=model.size_y, resolution=20e-8, z_position=model.monitor_z2, Kx=model.Kx, Ky=model.Ky) slices = [ meep_utils.Slice(model=model, field=f, components=(meep.Dielectric), at_t=0, outputhdf=True, name='EPS') ] slices += [ meep_utils.Slice(model=model, field=f, components=meep.Ex, at_y=0, at_x=[-0.35e-6, 0.35e-6], min_timestep=0.5e-15, outputhdf=True, outputgif=True, name='ParallelCut') ] slices += [
#f.add_volume_source(meep.Ex, src_time_type, srcvolume, meep.AMPL) f.add_volume_source(meep.Ez, src_time_type, srcvolume, meep.AMPL) ## Define monitor planes, and the field output for visualisation (controlled by keywords in the 'comment' parameter) monitor_options = {'size_x':model.size_x, 'size_y':model.size_y, 'resolution':model.resolution, 'Kx':getattr(model, 'Kx', 0), 'Ky':getattr(model, 'Ky', 0)} monitor1_Ex = meep_utils.AmplitudeMonitorPlane(f, comp=meep.Ex, z_position=model.monitor_z1, **monitor_options) monitor1_Hy = meep_utils.AmplitudeMonitorPlane(f, comp=meep.Hy, z_position=model.monitor_z1, **monitor_options) monitor2_Ex = meep_utils.AmplitudeMonitorPlane(f, comp=meep.Ex, z_position=model.monitor_z2, **monitor_options) monitor2_Hy = meep_utils.AmplitudeMonitorPlane(f, comp=meep.Hy, z_position=model.monitor_z2, **monitor_options) slices = [] if not "noepssnapshot" in model.comment: slices += [meep_utils.Slice(model=model, field=f, components=(meep.Dielectric), at_t=0, name='EPS')] if "narrowfreq-snapshots" in model.comment: slices += [meep_utils.Slice(model=model, field=f, components=meep.Ex, at_y=0, at_t=np.inf, name=('At%.3eHz'%getattr(model, 'frequency', None)) if getattr(model, 'frequency', None) else '', outputpng=True, outputvtk=False)] if "fieldevolution" in model.comment: slices += [meep_utils.Slice(model=model, field=f, components=(meep.Ex), at_x=0, name='FieldEvolution', min_timestep=.1/model.src_freq, outputgif=True, outputhdf=True, outputvtk=True)] if "snapshote" in model.comment: slices += [meep_utils.Slice(model=model, field=f, components=(meep.Ex, meep.Ey, meep.Ez), at_t=np.inf, name='SnapshotE')] ## Run the FDTD simulation or the frequency-domain solver if not getattr(model, 'frequency', None): ## time-domain computation f.step(); timer = meep_utils.Timer(simtime=model.simtime); meep.quiet(True) # use custom progress messages while (f.time()/c < model.simtime): # timestepping cycle f.step()
## Secondary (pump) source src_time_type = meep.continuous_src_time(model.srcFreq / c) f.add_volume_source(meep.Ez, src_time_type2, srcvolume) ## Define monitors planes and visualisation output #monitor_options = {'size_x':model.size_x, 'size_y':model.size_y, 'Kx':model.Kx, 'Ky':model.Ky} #monitor1_Ex = meep_utils.AmplitudeMonitorPlane(comp=meep.Ex, z_position=model.monitor_z1, **monitor_options) #monitor1_Hy = meep_utils.AmplitudeMonitorPlane(comp=meep.Hy, z_position=model.monitor_z1, **monitor_options) #monitor2_Ex = meep_utils.AmplitudeMonitorPlane(comp=meep.Ex, z_position=model.monitor_z2, **monitor_options) #monitor2_Hy = meep_utils.AmplitudeMonitorPlane(comp=meep.Hy, z_position=model.monitor_z2, **monitor_options) #XXX TODO slice_makers = [ meep_utils.Slice(model=model, field=f, components=(meep.Dielectric), at_t=0, name='EPS') ] slice_makers += [ meep_utils.Slice(model=model, field=f, components=meep.Ez, at_t=[0e-12, 100e-12], min_timestep=.025e-12, outputgif=True) ] slice_makers += [ meep_utils.Slice(model=model, field=f, components=meep.Ez, at_t=2.5e-12) ]
else: src_time_type = meep.continuous_src_time(getattr(model, 'frequency', None)/c) srcvolume = meep.volume( ## (spatial source shape) meep.vec(-model.size_x/2, -model.size_y/2, -model.size_z/2+model.pml_thickness), meep.vec( model.size_x/2, model.size_y/2, -model.size_z/2+model.pml_thickness)) f.add_volume_source(meep.Ex, src_time_type, srcvolume) ## Define monitors planes and visualisation output monitor_options = {'size_x':model.size_x, 'size_y':model.size_y, 'resolution':model.resolution, 'Kx':getattr(model, 'Kx', 0), 'Ky':getattr(model, 'Ky', 0)} monitor1_Ex = meep_utils.AmplitudeMonitorPlane(f, comp=meep.Ex, z_position=model.monitor_z1, **monitor_options) monitor1_Hy = meep_utils.AmplitudeMonitorPlane(f, comp=meep.Hy, z_position=model.monitor_z1, **monitor_options) monitor2_Ex = meep_utils.AmplitudeMonitorPlane(f, comp=meep.Ex, z_position=model.monitor_z2, **monitor_options) monitor2_Hy = meep_utils.AmplitudeMonitorPlane(f, comp=meep.Hy, z_position=model.monitor_z2, **monitor_options) slices = [] slices += [meep_utils.Slice(model=model, field=f, components=(meep.Dielectric), at_t=0, name='EPS')] #slices += [meep_utils.Slice(model=model, field=f, components=meep.Ex, at_x=0, at_t=np.inf, #name=('At%.3eHz'%getattr(model, 'frequency', None)) if getattr(model, 'frequency_domain') else '', outputpng=True, outputvtk=False)] #slices += [meep_utils.Slice(model=model, field=f, components=(meep.Ex), at_x=0, name='FieldEvolution', min_timestep=.1/model.src_freq, outputgif=True)] #slices += [meep_utils.Slice(model=model, field=f, components=(meep.Ex, meep.Ey, meep.Ez), at_t=np.inf, name='SnapshotE')] ## Run the FDTD simulation or the frequency-domain solver if not getattr(model, 'frequency', None): ## time-domain computation f.step(); timer = meep_utils.Timer(simtime=model.simtime); meep.quiet(True) # use custom progress messages while (f.time()/c < model.simtime): # timestepping cycle f.step() timer.print_progress(f.time()/c) for monitor in (monitor1_Ex, monitor1_Hy, monitor2_Ex, monitor2_Hy): monitor.record(field=f) for slice_ in slices: slice_.poll(f.time()/c) for slice_ in slices: slice_.finalize() meep_utils.notify(model.simulation_name, run_time=timer.get_time())
f = meep.fields(s) # Add the field source (see meep_utils for an example of how an arbitrary source waveform is defined) src_time_type = meep.continuous_src_time(model.src_freq / c) srcvolume = meep.volume( meep.vec(-model.size_x / 2, -model.size_y / 2, -model.size_z / 2 + model.pml_thickness), meep.vec(+model.size_x / 2, +model.size_y / 2, -model.size_z / 2 + model.pml_thickness)) f.add_volume_source(meep.Ex, src_time_type, srcvolume) ## Define visualisation output slices = [ meep_utils.Slice(model=model, field=f, components=(meep.Dielectric), at_t=0, name='EPS') ] slices += [ meep_utils.Slice(model=model, field=f, components=meep.Ez, at_y=0, min_timestep=.3e-15, outputgif=True, name='ParallelCut') ] slices += [ meep_utils.Slice(model=model, field=f,
**monitor_options) monitor2_Ex = meep_utils.AmplitudeMonitorPlane(f, comp=meep.Ex, z_position=model.monitor_z2, **monitor_options) monitor2_Hy = meep_utils.AmplitudeMonitorPlane(f, comp=meep.Hy, z_position=model.monitor_z2, **monitor_options) slices = [] if not "noepssnapshot" in model.comment: slices += [ meep_utils.Slice(model=model, field=f, components=(meep.Dielectric), at_t=0, name='EPS') ] if "narrowfreq-snapshots" in model.comment: slices += [ meep_utils.Slice(model=model, field=f, components=meep.Ex, at_y=0, at_t=np.inf, name=('At%.3eHz' % getattr(model, 'frequency', None)) if getattr(model, 'frequency', None) else '', outputpng=True, outputvtk=False) ]
'size_y': model.apertured, 'Kx': 0, 'Ky': 0 } ## (specific for the apertured microscope) monitor2_Ex = meep_utils.AmplitudeMonitorPlane(comp=meep.Ex, z_position=model.monitor_z2, **monitor_options) monitor2_Hy = meep_utils.AmplitudeMonitorPlane(comp=meep.Hy, z_position=model.monitor_z2, **monitor_options) slices = [] slices += [ meep_utils.Slice(model=model, field=f, components=(meep.Dielectric), at_t=0, name='EPS') ] #slices += [meep_utils.Slice(model=model, field=f, components=(meep.Ex), at_x=0, name='FieldEvolution', min_timestep=1e-12)] slices += [ meep_utils.Slice(model=model, field=f, components=(meep.Ex, meep.Ey, meep.Ez), at_t=np.inf, name='SnapshotE') ] slices += [ meep_utils.Slice( model=model, field=f,