1 | r""" |
---|

2 | Definition |
---|

3 | ---------- |
---|

4 | |
---|

5 | This model fits the Guinier function |
---|

6 | |
---|

7 | .. math:: |
---|

8 | |
---|

9 | I(q) = \text{scale} \cdot \exp{\left[ \frac{-Q^2R_g^2}{3} \right]} |
---|

10 | + \text{background} |
---|

11 | |
---|

12 | to the data directly without any need for linearisation (*cf*. the usual |
---|

13 | plot of $\ln I(q)$ vs $q^2$\ ). Note that you may have to restrict the data |
---|

14 | range to include small q only, where the Guinier approximation actually |
---|

15 | applies. See also the guinier_porod model. |
---|

16 | |
---|

17 | For 2D data the scattering intensity is calculated in the same way as 1D, |
---|

18 | where the $q$ vector is defined as |
---|

19 | |
---|

20 | .. math:: q = \sqrt{q_x^2 + q_y^2} |
---|

21 | |
---|

22 | References |
---|

23 | ---------- |
---|

24 | |
---|

25 | A Guinier and G Fournet, *Small-Angle Scattering of X-Rays*, |
---|

26 | John Wiley & Sons, New York (1955) |
---|

27 | """ |
---|

28 | |
---|

29 | import numpy as np |
---|

30 | from numpy import inf |
---|

31 | |
---|

32 | name = "guinier" |
---|

33 | title = "" |
---|

34 | description = """ |
---|

35 | I(q) = scale.exp ( - rg^2 q^2 / 3.0 ) |
---|

36 | |
---|

37 | List of default parameters: |
---|

38 | scale = scale |
---|

39 | rg = Radius of gyration |
---|

40 | """ |
---|

41 | category = "shape-independent" |
---|

42 | |
---|

43 | # ["name", "units", default, [lower, upper], "type","description"], |
---|

44 | parameters = [["rg", "Ang", 60.0, [0, inf], "", "Radius of Gyration"]] |
---|

45 | |
---|

46 | Iq = """ |
---|

47 | double exponent = rg*rg*q*q/3.0; |
---|

48 | double value = exp(-exponent); |
---|

49 | return value; |
---|

50 | """ |
---|

51 | |
---|

52 | def random(): |
---|

53 | scale = 10**np.random.uniform(1, 4) |
---|

54 | # Note: compare.py has Rg cutoff of 1e-30 at q=1 for guinier, so use that |
---|

55 | # log_10 Ae^(-(q Rg)^2/3) = log_10(A) - (q Rg)^2/ (3 ln 10) > -30 |
---|

56 | # => log_10(A) > Rg^2/(3 ln 10) - 30 |
---|

57 | q_max = 1.0 |
---|

58 | rg_max = np.sqrt(90*np.log(10) + 3*np.log(scale))/q_max |
---|

59 | rg = 10**np.random.uniform(0, np.log10(rg_max)) |
---|

60 | pars = dict( |
---|

61 | #background=0, |
---|

62 | scale=scale, |
---|

63 | rg=rg, |
---|

64 | ) |
---|

65 | return pars |
---|

66 | |
---|

67 | # parameters for demo |
---|

68 | demo = dict(scale=1.0, rg=60.0) |
---|

69 | |
---|

70 | # parameters for unit tests |
---|

71 | tests = [[{'rg' : 31.5}, 0.005, 0.992756]] |
---|