#!/usr/bin/env python3 """ Specular reflectometry with sliced cylinders (refractive-index variant). A layer of cylinders defined with RefractiveMaterial is subdivided into N horizontal slabs. Results must agree with SpecularWithSlicing2.py (SLD-material variant), demonstrating the numerical equivalence of both material representations. """ import bornagain as ba from bornagain import angstrom, ba_plot as bp, deg, nm HEIGHT = 5 * nm RADIUS = 5 * nm SURF_DENSITY = 0.01 # nm^-2 N_SLICES = 3 WAVELENGTH = 1.54 * angstrom def get_sample(): vacuum = ba.Vacuum() substrate_color = (0.28, 0.57, 0.82) substrate_mat = ba.RefractiveMaterial("Substrate", substrate_color, 6e-6, 2e-8) particle_color = (0.86, 0.24, 0.18) particle_mat = ba.RefractiveMaterial("Particle", particle_color, 6e-4, 2e-8) cylinder = ba.Cylinder(RADIUS, HEIGHT) particle = ba.Particle(particle_mat, cylinder) top_layer = ba.Layer(vacuum) top_layer.deposit2D(ba.Dilute2D(SURF_DENSITY, particle)) top_layer.setNumberOfSlices(N_SLICES) sample = ba.Sample() sample.addLayer(top_layer) sample.addLayer(ba.Layer(substrate_mat)) return sample def get_simulation(sample): n = <%= test_mode ? 50 : 500 %> scan = ba.AlphaScan(n, 5*deg/n, 5*deg) scan.setWavelength(WAVELENGTH) return ba.SpecularSimulation(scan, sample) <%= include_partial("template/main/runsim.py", "ba.showSample3D(sample, sample_size=120*nm, seed=0)") -%>