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()) else: ## frequency-domain computation f.solve_cw(getattr(model, 'MaxTol',0.001), getattr(model, 'MaxIter', 5000), getattr(model, 'BiCGStab', 8)) for monitor in (monitor1_Ex, monitor1_Hy, monitor2_Ex, monitor2_Hy): monitor.record(field=f) for slice_ in slices: slice_.finalize() meep_utils.notify(model.simulation_name) ## Get the reflection and transmission of the structure if meep.my_rank() == 0: #t = monitor1_Ex.get_time() #Ex1, Hy1, Ex2, Hy2 = [mon.get_field_waveform() for mon in (monitor1_Ex, monitor1_Hy, monitor2_Ex, monitor2_Hy)] freq, s11, s12, columnheaderstring = meep_utils.get_s_parameters(monitor1_Ex, monitor1_Hy, monitor2_Ex, monitor2_Hy, frequency_domain=True if getattr(model, 'frequency', None) else False, frequency=getattr(model, 'frequency', None), ## procedure compatible with both FDTD and FDFD intf=getattr(model, 'interesting_frequencies', [0, model.src_freq+model.src_width]), ## clip the frequency range for plotting pad_zeros=1.0, ## speed-up FFT, and stabilize eff-param retrieval Kx=getattr(model, 'Kx', 0), Ky=getattr(model, 'Ky', 0), ## enable oblique incidence (works only if monitors in vacuum) eps1=getattr(model, 'mon1eps', 1), eps2=getattr(model, 'mon2eps', 1)) ## enable monitors inside dielectrics print "EVERYTHING OK" meep_utils.savetxt(fname=model.simulation_name+".dat", fmt="%.6e", X=zip(freq, np.abs(s11), np.angle(s11), np.abs(s12), np.angle(s12)), ## Save 5 columns: freq, amplitude/phase for reflection/transmission header=model.parameterstring+columnheaderstring) ## Export header with open("./last_simulation_name.dat", "w") as outfile: outfile.write(model.simulation_name) meep.all_wait() # Wait until all file operations are finished
f.step() dt = (f.time() / c) meep_utils.lorentzian_unstable_check_new(model, dt) timer = meep_utils.Timer(simtime=model.simtime) #meep.quiet(True) count = 0 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_maker in slice_makers: slice_maker.poll(f.time() / c) snapshot_maker.poll(f.time() / c) #print f.get_field(meep.Ex, meep.vec(0,0,0)) meep.all_wait() ## FIXME needed? for slice_maker in slice_makers: slice_maker.finalize() meep_utils.notify(model.simulation_name, run_time=timer.get_time()) else: f.step() print sim_param['MaxIter'] f.solve_cw(sim_param['MaxTol'], sim_param['MaxIter'], sim_param['BiCGStab']) for monitor in (monitor1_Ex, monitor1_Hy, monitor2_Ex, monitor2_Hy): monitor.record(field=f) snapshot_maker.take_snapshot(0) meep_utils.notify(model.simulation_name) with open("./last_simulation_name.txt", "w") as outfile: outfile.write(model.simulation_name)
tmptime = time.time() f.step() print 'setup took ', -tmptime + time.time() , 's' dt = (f.time()/c) meep_utils.lorentzian_unstable_check_new(model, dt) timer = meep_utils.Timer(simtime=model.simtime) #meep.quiet(True) count = 0 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_maker in slice_makers: slice_maker.poll(f.time()/c) snapshot_maker.poll(f.time()/c) #print f.get_field(meep.Ex, meep.vec(0,0,0)) meep.all_wait() ## FIXME needed? for slice_maker in slice_makers: slice_maker.finalize() meep_utils.notify(model.simulation_name, run_time=timer.get_time()) else: f.step() print sim_param['MaxIter'] f.solve_cw(sim_param['MaxTol'], sim_param['MaxIter'], sim_param['BiCGStab']) for monitor in (monitor1_Ex, monitor1_Hy, monitor2_Ex, monitor2_Hy): monitor.record(field=f) snapshot_maker.take_snapshot(0) meep_utils.notify(model.simulation_name) with open("./last_simulation_name.txt", "w") as outfile: outfile.write(model.simulation_name) meep.master_printf("=== Processing recorded fields ===\n") ## Get the reflection and transmission of the structure meep.master_printf(" getting s-params\n")