source: sasmodels/sasmodels/models/polymer_micelle.c @ c3ebc71

core_shell_microgelscostrafo411magnetic_modelticket-1257-vesicle-productticket_1156ticket_1265_superballticket_822_more_unit_tests
Last change on this file since c3ebc71 was c3ebc71, checked in by Paul Kienzle <pkienzle@…>, 6 years ago

polymer_micelle: minor code cleanup

  • Property mode set to 100644
File size: 2.6 KB
Line 
1double Iq(double q,
2        double ndensity,
3        double v_core,
4        double v_corona,
5        double solvent_sld,
6        double core_sld,
7        double corona_sld,
8        double radius_core,
9        double rg,
10        double d_penetration,
11        double n_aggreg);
12
13static double micelle_spherical_kernel(double q,
14        double ndensity,
15        double v_core,
16        double v_corona,
17        double solvent_sld,
18        double core_sld,
19        double corona_sld,
20        double radius_core,
21        double rg,
22        double d_penetration,
23        double n_aggreg)
24{
25    const double rho_solv = solvent_sld;     // sld of solvent [1/A^2]
26    const double rho_core = core_sld;        // sld of core [1/A^2]
27    const double rho_corona = corona_sld;    // sld of corona [1/A^2]
28
29    const double beta_core = v_core * (rho_core - rho_solv);
30    const double beta_corona = v_corona * (rho_corona - rho_solv);
31
32    // Self-correlation term of the core
33    const double bes_core = sph_j1c(q*radius_core);
34    const double term1 = square(n_aggreg*beta_core*bes_core);
35
36    // Self-correlation term of the chains
37    const double qrg2 = square(q*rg);
38    const double debye_chain = (qrg2 == 0.0) ? 1.0 : 2.0*(expm1(-qrg2)+qrg2)/(qrg2*qrg2);
39    const double term2 = n_aggreg * beta_corona * beta_corona * debye_chain;
40
41    // Interference cross-term between core and chains
42    const double chain_ampl = (qrg2 == 0.0) ? 1.0 : -expm1(-qrg2)/qrg2;
43    const double bes_corona = sinc(q*(radius_core + d_penetration * rg));
44    const double term3 = 2.0 * n_aggreg * n_aggreg * beta_core * beta_corona *
45                 bes_core * chain_ampl * bes_corona;
46
47    // Interference cross-term between chains
48    const double term4 = n_aggreg * (n_aggreg - 1.0)
49                 * square(beta_corona * chain_ampl * bes_corona);
50
51    // I(q)_micelle : Sum of 4 terms computed above
52    double i_micelle = term1 + term2 + term3 + term4;
53
54    // rescale from [A^2] to [cm^2]
55    i_micelle *= 1.0e-13;
56
57    // "normalize" by number density --> intensity in [cm-1]
58    i_micelle *= ndensity;
59
60    return(i_micelle);
61
62}
63
64double Iq(double q,
65        double ndensity,
66        double v_core,
67        double v_corona,
68        double solvent_sld,
69        double core_sld,
70        double corona_sld,
71        double radius_core,
72        double rg,
73        double d_penetration,
74        double n_aggreg)
75{
76    return micelle_spherical_kernel(q,
77            ndensity,
78            v_core,
79            v_corona,
80            solvent_sld,
81            core_sld,
82            corona_sld,
83            radius_core,
84            rg,
85            d_penetration,
86            n_aggreg);
87}
Note: See TracBrowser for help on using the repository browser.