#!/usr/bin/env python3
"""
"""
import numpy as np
import bornagain as ba
from bornagain import ba_plot as bp, nm


def get_sample():
    # Materials
    a_color = (0.05, 0.62, 0.55)
    a_mat = ba.SLDMaterial("A", a_color, 5e-06, 0)
    substrate_color = (0.28, 0.57, 0.82)
    substrate_mat = ba.SLDMaterial("Substrate", substrate_color, 2e-06, 0)

    # Layers
    ambient_layer = ba.Layer(ba.Vacuum())
    film = ba.Layer(a_mat, 30*nm)
    substrate_layer = ba.Layer(substrate_mat)

    # Sample
    sample = ba.Sample()
    sample.addLayer(ambient_layer)
    sample.addLayer(film)
    sample.addLayer(substrate_layer)

    return sample

def get_simulation(sample):
    "Specular simulation with a qz-defined beam"
    n = 500
    qzs = np.linspace(0.01, 1, n)  # qz-values
    scan = ba.QzScan(qzs)
    return ba.SpecularSimulation(scan, sample)


if __name__ == '__main__':
    sample = get_sample()
    ba.showSample3D(sample, sample_size=80*nm, seed=0)
    simulation = get_simulation(sample)
    result = simulation.simulate()
    bp.plot_datafield(result)
    bp.plt.show()
