core_shell_microgelscostrafo411magnetic_modelrelease_v0.94release_v0.95ticket-1257-vesicle-productticket_1156ticket_1265_superballticket_822_more_unit_tests
Last change
on this file since 19b6d28 was
19b6d28,
checked in by Doucet, Mathieu <doucetm@…>, 8 years ago
|
Add porod model
|
-
Property mode set to
100644
|
File size:
1.2 KB
|
Rev | Line | |
---|
[19b6d28] | 1 | r""" |
---|
| 2 | This model fits the Porod function |
---|
| 3 | |
---|
| 4 | .. math:: |
---|
| 5 | |
---|
| 6 | I(q) = C/q^4 |
---|
| 7 | \\ |
---|
| 8 | C = 2\pi (\Delta\rho)^2 S_v |
---|
| 9 | |
---|
| 10 | to the data directly without any need for linearisation (cf. Log I(q) vs Log q). |
---|
| 11 | |
---|
| 12 | Here $C$ is the scale factor and $S_v$ is the specific surface area (ie, surface area / volume) |
---|
| 13 | of the sample, and $\Delta\rho$ is the contrast factor. |
---|
| 14 | |
---|
| 15 | For 2D data: The 2D scattering intensity is calculated in the same way as 1D, where the q vector is defined as |
---|
| 16 | |
---|
| 17 | .. math:: |
---|
| 18 | q = \sqrt{q_x^2+q_y^2} |
---|
| 19 | |
---|
| 20 | """ |
---|
| 21 | |
---|
| 22 | from numpy import sqrt, power |
---|
| 23 | |
---|
| 24 | name = "porod" |
---|
| 25 | title = "Porod function" |
---|
| 26 | description = """\ |
---|
| 27 | I(q) = scale/q^4 + background |
---|
| 28 | """ |
---|
| 29 | |
---|
| 30 | category = "shape-independent" |
---|
| 31 | |
---|
| 32 | parameters = [] |
---|
| 33 | |
---|
| 34 | def Iq(q): |
---|
| 35 | """ |
---|
| 36 | @param q: Input q-value |
---|
| 37 | """ |
---|
| 38 | return 1.0/power(q,4) |
---|
| 39 | |
---|
| 40 | Iq.vectorized = True # Iq accepts an array of q values |
---|
| 41 | |
---|
| 42 | def Iqxy(qx, qy, *args): |
---|
| 43 | """ |
---|
| 44 | @param qx: Input q_x-value |
---|
| 45 | @param qy: Input q_y-value |
---|
| 46 | @param args: Remaining arguments |
---|
| 47 | """ |
---|
| 48 | return Iq(sqrt(qx ** 2 + qy ** 2), *args) |
---|
| 49 | |
---|
| 50 | Iqxy.vectorized = True # Iqxy accepts an array of qx, qy values |
---|
| 51 | |
---|
| 52 | demo = dict(scale=1.5, background=0.5) |
---|
| 53 | |
---|
| 54 | oldname = "PorodModel" |
---|
| 55 | oldpars = dict(scale='scale', background='background') |
---|
| 56 | |
---|
| 57 | tests = [[{'scale': 0.00001, 'background':0.01}, 0.04, 3.916250]] |
---|
Note: See
TracBrowser
for help on using the repository browser.