source: sasmodels/sasmodels/models/lamellar_stack_paracrystal.c @ 5467cd8

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

use sas_sinx_x rather than sinc

  • Property mode set to 100644
File size: 2.0 KB
Line 
1/*      Lamellar_ParaCrystal - Pedersen's model
2
3*/
4double paraCryst_sn(double ww, double qval, double davg, int Nlayers, double an);
5double paraCryst_an(double ww, double qval, double davg, int Nlayers);
6
7static double
8Iq(double qval,
9   double th,
10   double fp_Nlayers,
11   double davg,
12   double pd,
13   double sld,
14   double solvent_sld)
15{
16        //get the fractional part of Nlayers, to determine the "mixing" of N's
17        int n1 = (int)(fp_Nlayers);             //truncate towards zero
18        int n2 = n1 + 1;
19        const double xn = (double)n2 - fp_Nlayers;      //fractional contribution of n1
20       
21        const double ww = exp(-0.5*square(qval*pd*davg));
22
23        //calculate the n1 contribution
24        double Znq,Snq,an;
25        an = paraCryst_an(ww,qval,davg,n1);
26        Snq = paraCryst_sn(ww,qval,davg,n1,an);
27
28        Znq = xn*Snq;
29       
30        //calculate the n2 contribution
31        an = paraCryst_an(ww,qval,davg,n2);
32        Snq = paraCryst_sn(ww,qval,davg,n2,an);
33
34        Znq += (1.0-xn)*Snq;
35       
36        //and the independent contribution
37        Znq += (1.0-ww*ww)/(1.0+ww*ww-2.0*ww*cos(qval*davg));
38       
39        //the limit when Nlayers approaches infinity
40//      Zq = (1-ww^2)/(1+ww^2-2*ww*cos(qval*davg))
41       
42        const double xi = th/2.0;               //use 1/2 the bilayer thickness
43        const double Pbil = square(sas_sinx_x(qval*xi));
44       
45        const double contr = sld - solvent_sld;
46        const double inten = 2.0*M_PI*contr*contr*Pbil*Znq/(qval*qval);
47//printf("q=%.7e wwm1=%g ww=%.5e an=% 12.5e Snq=% 12.5e Znq=% 12.5e Pbil=% 12.5e\n",qval,wwm1,ww,an,Snq,Znq,Pbil);
48        return 1.0e-4*inten;
49}
50
51// functions for the lamellar paracrystal model
52double
53paraCryst_sn(double ww, double qval, double davg, int Nlayers, double an) {
54       
55        double Snq;
56
57        Snq = an/( (double)Nlayers*square(1.0+ww*ww-2.0*ww*cos(qval*davg)) );
58       
59        return Snq;
60}
61
62double
63paraCryst_an(double ww, double qval, double davg, int Nlayers) {
64        double an;
65       
66        an = 4.0*ww*ww - 2.0*(ww*ww*ww+ww)*cos(qval*davg);
67        an -= 4.0*pow(ww,(Nlayers+2))*cos((double)Nlayers*qval*davg);
68        an += 2.0*pow(ww,(Nlayers+3))*cos((double)(Nlayers-1)*qval*davg);
69        an += 2.0*pow(ww,(Nlayers+1))*cos((double)(Nlayers+1)*qval*davg);
70       
71        return an;
72}
73
Note: See TracBrowser for help on using the repository browser.