nomulti = wmax - wmin intte = int.simps(fte, wlist, axis=1) / nomulti inttm = int.simps(ftm, wlist, axis=1) / nomulti print("Done") # Dump data to file or stdout comments = ( "# F_TE = |Fy^2|^2\n" + "# F_TM = |Fx * cosA^2 + Fz * sinA^2|^2\n" + "# Integral over wlength of F_TE and F_TM for different\n" + "# angles at a fixed position.\n" + "#angle\tInt (TE)\tInt (TM)\n" ) if args.output: bp.wdfile(args.output, comments, np.array([alist, intte, inttm]).T, "%.6e") else: print(comments) for i in xrange(alist.size): print("%.6e\t%.6e\t%.6e" % (alist[i], intte[i], inttm[i])) # Plot data if requested if args.graph: import matplotlib.pyplot as plt plt.plot(alist, intte, label="TE", color="r") plt.plot(alist, inttm, label="TM", color="b") plt.xlabel("Angle (rad)") plt.ylabel("Integral of the energy ratio") plt.grid() plt.legend(loc=2)
ftm_int = integ.simps(ftm_mplied, zlist, axis=0) spectrum_modte = original_spec * fte_int spectrum_modtm = original_spec * ftm_int print("Done") # Dump data to file or stdout comments = ( "# F_TE = |Fy^2|^2\n" + "# F_TM = |Fx * cosA^2 + Fz * sinA^2|^2\n" + "# Modified spectrum for TE and TM waves for a\n" + "# distributions of the radiative centers.\n" + "# wlength\tF_TE\tF_TM" ) if args.output: bp.wdfile(args.output, comments, np.array([wlist, spectrum_modte, spectrum_modtm]).T, "%.6e") else: print(comments) for i in xrange(wlist.size): print("%.6e\t%.6e\t%.6e" % (wlist[i], spectrum_modte[i], spectrum_modtm[i])) # Plot data if requested if args.graph: import matplotlib.pyplot as plt plt.plot(wlist, spectrum_modte, label="TE", color="r") plt.plot(wlist, spectrum_modtm, label="TM", color="b") plt.xlabel("Wavelength (nm)") plt.ylabel("Energy ratio") plt.grid() plt.legend(loc=2)
fy[index] = multilayer.calculateFy(z, wlength, angle) # We are probably more interesed on the effect of the multilayer on the # energy rather than the electric field. What we want is |Fy(z)|^2 for # TE waves and |Fx(z) cosA^2 + Fz(z) sinA^2|^2 for TM waves. ftm = np.absolute(fx * np.cos(alist) ** 2 + fz * np.sin(alist) ** 2) ** 2 fte = np.absolute(fy) ** 2 print("Done") # Dump data to file or stdout comments = "#angle\tF_TE\tF_TM\n" + \ "# F_TE = |Fy^2|^2\n" + \ "# T_TM = |Fx * cosA^2 + Fz * sinA^2|^2\n" if args.output: bp.wdfile(args.output, comments, np.array([alist, fte, ftm]).T, '%.6e') else: print(comments) for i in xrange(alist.size): print("%.6e\t%.6e\t%.6e" % (alist[i], fte[i], ftm[i])) # Plot data if requested if args.graph: import matplotlib.pyplot as plt plt.plot(alist, fte, label='TE', color = 'r') plt.plot(alist, ftm, label='TM', color = 'b') plt.xlabel('Angle (rad)') plt.ylabel('Energy ratio') plt.grid() plt.legend(loc=2)