Sphere

Result

Sphere result

Python script

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#!/usr/bin/env python3
# /// script
# requires-python = ">=3.10"
# dependencies = ["bornagain>=25,<26"]
# ///
"""
Plot |F(q)| vs q for sphere.

"""
import bornagain as ba
ba.require_versions("bornagain>=25,<26")
import cmath
import numpy as np
from bornagain import deg, nm, C3

if __name__ == '__main__':
    R = 10*nm
    ff = ba.Sphere(R)
    qR_max = 32

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

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

    ba.plt.xlim([0, qR_max])
    ba.plt.ylim([5e-5, 2])

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

    ba.plt.tight_layout()
    ba.plt.show()
auto/Examples/formfactor/Sphere.py