#!/usr/bin/env python3
"""
GISAS of a thick, highly absorptive Au layer on Si, at extra-long wavelength.

Au (SLD: 3.484e-5, 1.791e-5) on a 10 nm vacuum gap on Si (SLD: 3.842e-7,
6.282e-7) with ErfTransient roughness. Beam wavelength 12 nm tests
the numerics under strong absorption.
"""
import bornagain as ba
from bornagain import ba_plot as bp, deg, nm


def get_sample():
    au_color = (0.93, 0.72, 0.25)
    au_mat = ba.SLDMaterial("Au", au_color, 3.48388057043e-05, 1.79057609656e-05)
    si_color = (0.30, 0.62, 0.86)
    si_mat = ba.SLDMaterial("Si", si_color, 3.84197565094e-07, 6.28211531498e-07)

    autocorr = ba.SelfAffineFractalModel(5*nm, 0.5, 10*nm)
    transient = ba.ErfTransient()
    roughness = ba.Roughness(autocorr, transient)

    vacuum_layer = ba.Layer(ba.Vacuum())
    au_layer = ba.Layer(au_mat, 200*nm)
    vacuum_layer_2 = ba.Layer(ba.Vacuum(), 10*nm)
    substrate_layer = ba.Layer(si_mat, roughness)

    sample = ba.Sample()
    sample.addLayer(vacuum_layer)
    sample.addLayer(au_layer)
    sample.addLayer(vacuum_layer_2)
    sample.addLayer(substrate_layer)
    return sample


def get_simulation(sample):
    beam = ba.Beam(1e8, 12*nm, 0.2*deg)
    n = <%= test_mode ? 25 : 100 %>
    detector = ba.SphericalDetector(n, -2*deg, 2*deg, n, 0, 2*deg)
    simulation = ba.ScatteringSimulation(beam, sample, detector)
    simulation.options().setIncludeSpecular(True)
    return simulation


<%= include_partial("template/main/runsim_unitaspect.py",
    "ba.showSample3D(sample, sample_size=120*nm, seed=0)") -%>
