#!/usr/bin/env python3
"""
Same as CylindersAndSpecular.py, but with beam and detector
both rotated by phi = 1.34 deg.

This example tests that indexOfSpecular correctly handles non-zero phi.
The simulation result should be identical to CylindersAndSpecular.py.
"""
import bornagain as ba
from bornagain import ba_plot as bp, deg, nm

phi = 1.34*deg


def get_sample():
    """
    Standard sample model: dilute random assembly of cylinders on a substrate.
    """
    from bornagain import std_samples
    return std_samples.cylinders()


def get_simulation(sample):
    # Beam with non-zero phi
    wavelength = 0.1*nm
    alpha_i = 0.2*deg
    beam = ba.Beam(1e9, wavelength, alpha_i, phi)

    # Detector rotated by phi, otherwise same as in CylindersAndSpecular
    n = <%= test_mode ? 11 : 200 %>
    detector = ba.SphericalDetector(n, -2*deg + phi, 2*deg + phi, n, 0., 3*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)") -%>
