def get_simulation_2(params): simulation = ba.SpecularSimulation() footprint = ba.FootprintFactorSquare(0.001) simulation.setBeamParameters(1.798 * angstrom, data_2[:, 0] * deg, footprint) simulation.setBeamIntensity(5.0e+8) sample = get_sample(params) simulation.setSample(sample) return simulation
def get_simulation(): """ Returns a depth-probe simulation. """ alpha_distr = ba.DistributionGaussian(0.0, d_ang) footprint = ba.FootprintFactorSquare(beam_sample_ratio) simulation = ba.DepthProbeSimulation() simulation.setBeamParameters(wl, n_ai_bins, ai_min, ai_max, footprint) simulation.setZSpan(n_z_bins, z_min, z_max) simulation.addParameterDistribution("*/Beam/InclinationAngle", alpha_distr, n_points, n_sig) return simulation
def get_simulation(scan_size=500): """ Returns a specular simulation with beam and detector defined. """ footprint = ba.FootprintFactorSquare(beam_sample_ratio) alpha_distr = ba.RangedDistributionGaussian(n_points, n_sig) scan = ba.AngularSpecScan(wavelength, scan_size, alpha_i_min, alpha_i_max) scan.setFootprintFactor(footprint) scan.setAbsoluteAngularResolution(alpha_distr, d_ang) simulation = ba.SpecularSimulation() simulation.setScan(scan) return simulation
def get_simulation(): """ Returns a depth-probe simulation. """ footprint = ba.FootprintFactorSquare(beam_sample_ratio) simulation = ba.DepthProbeSimulation() simulation.setBeamParameters(wl, n_ai_bins, ai_min, ai_max, footprint) simulation.setZSpan(n_z_bins, z_min, z_max) fwhm2sigma = 2 * np.sqrt(2 * np.log(2)) # add angular beam divergence # put your code here (2 lines) # add wavelength divergence # put your code here (2 lines) return simulation
def get_simulation(): """ Returns a depth-probe simulation. """ footprint = ba.FootprintFactorSquare(beam_sample_ratio) simulation = ba.DepthProbeSimulation() simulation.setBeamParameters(wl, n_ai_bins, ai_min, ai_max, footprint) simulation.setZSpan(n_z_bins, z_min, z_max) fwhm2sigma = 2 * np.sqrt(2 * np.log(2)) # add angular beam divergence alpha_distr = ba.DistributionGaussian(0.0, d_ang / fwhm2sigma) simulation.addParameterDistribution("*/Beam/InclinationAngle", alpha_distr, n_points, n_sig) # add wavelength divergence wl_distr = ba.DistributionGaussian(wl, d_wl / fwhm2sigma) simulation.addParameterDistribution("*/Beam/Wavelength", wl_distr, n_points_wl, n_sig_wl) return simulation
simulation.setSample(get_sample()) simulation.runSimulation() return simulation.result() def get_plot_data(sim_result): return sim_result.axis(), sim_result.array() def plot(sim_result_1, sim_result_2): """ Plots results from two different simulations """ plt.semilogy(*get_plot_data(sim_result_1), *get_plot_data(sim_result_2)) plt.xlabel(r'$\alpha_i \; (deg)$', fontsize=16) plt.ylabel(r'Intensity', fontsize=16) plt.legend(['With footprint', 'Without footprint'], loc='upper right') plt.show() if __name__ == '__main__': beam_sample_ratio = 0.01 # beam-to-sample size ratio result_with_fp = run_simulation( get_simulation(footprint=ba.FootprintFactorSquare(beam_sample_ratio))) result_without_fp = run_simulation(get_simulation(footprint=None)) plot(result_with_fp, result_without_fp)
def plot(sim_result_1, sim_result_2): """ Plots results from two different simulations """ x1, y1 = get_plot_data(sim_result_1) x2, y2 = get_plot_data(sim_result_2) plt.semilogy(x1, y1, x2, y2) plt.xlabel(r'$\alpha_i \; (deg)$', fontsize=16) plt.ylabel(r'Intensity', fontsize=16) plt.legend(['With footprint', 'Without footprint'], loc='upper right') plt.show() if __name__ == '__main__': beam_sample_ratio = 0.01 # beam-to-sample size ratio result_with_fp = run_simulation( get_simulation( footprint=ba.FootprintFactorSquare(beam_sample_ratio) ) ) result_without_fp = run_simulation(get_simulation(footprint=None)) plot(result_with_fp, result_without_fp)