#!/usr/bin/env python3
"""
Plot |F(q)| vs q for sphere.

"""
import bornagain as ba
import cmath
import numpy as np
from bornagain import ba_plot as bp, deg, nm, C3

if __name__ == '__main__':
    R = 1
    ff = ba.Sphere(R)
    qmax = 32

    v = ff.volume()
    n = 1000
    x = [qmax*i/(n - 1) for i in range(n)]
    # Undo the bottom-to-center shift built into Sphere's formfactor
    y = [(ff.formfactorAtBottom(C3(q, 0, 0)) * cmath.exp(-1j*q*R)).real/v for q in x]
    ym = [-f for f in y]

    bp.plt.semilogy(x, y)
    bp.plt.semilogy(x, ym)

    bp.plt.xlim([0, qmax])
    bp.plt.ylim([5e-5, 2])

    label_fontsize = 18
    bp.plt.xlabel("$qR$", fontsize=label_fontsize)
    bp.plt.ylabel("$|F(q)|$", fontsize=label_fontsize)

    bp.plt.tight_layout()
    bp.plt.show()
