Changeset af0e70c in sasmodels
- Timestamp:
- Apr 19, 2016 6:48:40 AM (9 years ago)
- Branches:
- master, core_shell_microgels, costrafo411, magnetic_model, release_v0.94, release_v0.95, ticket-1257-vesicle-product, ticket_1156, ticket_1265_superball, ticket_822_more_unit_tests
- Children:
- 7c20ba0
- Parents:
- 25b82a1
- Location:
- sasmodels/models
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
sasmodels/models/spherical_sld.c
r1bf66d9 raf0e70c 2 2 int n_shells, 3 3 double radius_core, 4 double thick_inter0, 4 5 double thick_flat[], 5 6 double thick_inter[]) … … 7 8 int i; 8 9 double r = radius_core; 10 r += thick_inter0; 9 11 for (i=0; i < n_shells; i++) { 10 12 r += thick_inter[i]; … … 15 17 16 18 17 static double sphere_sld_kernel(double dp[], double q) { 18 int n = dp[0]; 19 int i,j,k; 20 21 double scale = dp[1]; 22 double thick_inter_core = dp[2]; 23 double sld_core = dp[4]; 24 double sld_solv = dp[5]; 25 double background = dp[6]; 26 double npts = dp[57]; //number of sub_layers in each interface 27 double nsl=npts;//21.0; //nsl = Num_sub_layer: must be ODD double number 28 int n_s; 29 30 double sld_i,sld_f,dz,bes,fun,f,vol,qr,r,contr,f2; 31 double sign,slope=0.0; 32 double pi; 33 34 double total_thick=0.0; 35 36 int fun_type[12]; 37 double sld[12]; 38 double thick_inter[12]; 39 double thick[12]; 40 double fun_coef[12]; 41 42 fun_type[0] = dp[3]; 43 fun_coef[0] = fabs(dp[58]); 44 for (i =1; i<=n; i++){ 45 sld[i] = dp[i+6]; 46 thick_inter[i]= dp[i+16]; 47 thick[i] = dp[i+26]; 48 fun_type[i] = dp[i+36]; 49 fun_coef[i] = fabs(dp[i+46]); 50 total_thick += thick[i]; 51 total_thick += thick_inter[i]; 52 } 53 sld[0] = sld_core; 54 sld[n+1] = sld_solv; 55 thick[0] = dp[59]; 56 thick[n+1] = total_thick/5.0; 57 thick_inter[0] = thick_inter_core; 58 thick_inter[n+1] = 0.0; 59 fun_coef[n+1] = 0.0; 60 pi = 4.0*atan(1.0); 61 f = 0.0; 62 r = 0.0; 63 vol = 0.0; 64 //vol_pre = 0.0; 65 //vol_sub = 0.0; 66 sld_f = sld_core; 67 68 //floor_nsl = floor(nsl/2.0); 69 70 dz = 0.0; 71 // iteration for # of shells + core + solvent 72 for (i=0;i<=n+1; i++){ 73 //iteration for N sub-layers 74 //if (fabs(thick[i]) <= 1e-24){ 75 // continue; 76 //} 77 // iteration for flat and interface 78 for (j=0;j<2;j++){ 79 // iteration for sub_shells in the interface 80 // starts from #1 sub-layer 81 for (n_s=1;n_s<=nsl; n_s++){ 82 // for solvent, it doesn't have an interface 83 if (i==n+1 && j==1) 84 break; 85 // for flat layers 86 if (j==0){ 87 dz = thick[i]; 88 sld_i = sld[i]; 89 slope = 0.0; 19 static double sphere_sld_kernel( 20 double q, 21 int n_shells, 22 int npts_inter, 23 double radius_core, 24 double sld_core, 25 double sld_solvent, 26 double func_inter_core, 27 double thick_inter_core, 28 double nu_inter_core, 29 double sld_flat[], 30 double thick_flat[], 31 double func_inter[], 32 double thick_inter[], 33 double nu_inter[] ) { 34 35 int i,j,k; 36 int n_s; 37 38 double sld_i,sld_f,dz,bes,fun,f,vol,qr,r,contr,f2; 39 double sign,slope=0.0; 40 double pi; 41 42 double total_thick=0.0; 43 44 //TODO: This part can be further simplified 45 int fun_type[12]; 46 double sld[12]; 47 double thick_internal[12]; 48 double thick[12]; 49 double fun_coef[12]; 50 51 fun_type[0] = func_inter_core; 52 fun_coef[0] = fabs(nu_inter_core); 53 sld[0] = sld_core; 54 thick[0] = radius_core; 55 thick_internal[0] = thick_inter_core; 56 57 for (i =1; i<=n_shells; i++){ 58 sld[i] = sld_flat[i-1]; 59 thick_internal[i]= thick_inter[i-1]; 60 thick[i] = thick_flat[i-1]; 61 fun_type[i] = func_inter[i-1]; 62 fun_coef[i] = fabs(nu_inter[i-1]); 63 total_thick += thick[i]; 64 total_thick += thick_internal[i]; //doesn't account for core layer 65 } 66 67 sld[n_shells+1] = sld_solvent; 68 thick[n_shells+1] = total_thick/5.0; 69 thick_internal[n_shells+1] = 0.0; 70 fun_coef[n_shells+1] = 0.0; 71 fun_type[n_shells+1] = 0; 72 73 pi = 4.0*atan(1.0); 74 f = 0.0; 75 r = 0.0; 76 vol = 0.0; 77 sld_f = sld_core; 78 79 dz = 0.0; 80 // iteration for # of shells + core + solvent 81 for (i=0;i<=n_shells+1; i++){ 82 // iteration for flat and interface 83 for (j=0;j<2;j++){ 84 // iteration for sub_shells in the interface 85 // starts from #1 sub-layer 86 for (n_s=1;n_s<=npts_inter; n_s++){ 87 // for solvent, it doesn't have an interface 88 if (i==n_shells+1 && j==1) 89 break; 90 // for flat layers 91 if (j==0){ 92 dz = thick[i]; 93 sld_i = sld[i]; 94 slope = 0.0; 95 } 96 // for interfacial sub_shells 97 else{ 98 dz = thick_internal[i]/npts_inter; 99 // find sld_i at the outer boundary of sub-layer #n_s 100 sld_i = intersldfunc(fun_type[i], npts_inter, n_s, 101 fun_coef[i], sld[i], sld[i+1]); 102 // calculate slope 103 slope= (sld_i -sld_f)/dz; 104 } 105 contr = sld_f-slope*r; 106 // iteration for the left and right boundary of the shells 107 for (k=0; k<2; k++){ 108 // At r=0, the contribution to I is zero, so skip it. 109 if ( i == 0 && j == 0 && k == 0){ 110 continue; 111 } 112 // On the top of slovent there is no interface; skip it. 113 if (i == n_shells+1 && k == 1){ 114 continue; 115 } 116 // At the right side (outer) boundary 117 if ( k == 1){ 118 sign = 1.0; 119 r += dz; 120 } 121 // At the left side (inner) boundary 122 else{ 123 sign = -1.0; 124 } 125 126 qr = q * r; 127 fun = 0.0; 128 129 if(qr == 0.0){ 130 bes = sign * 1.0; 131 } 132 else{ 133 // for flat sub-layer 134 //TODO: Single precision calculation fails here 135 bes = sign * sph_j1c(qr); 136 if (fabs(slope) > 0.0 ){ 137 const double qrsq = qr*qr; 138 double sinqr, cosqr; 139 SINCOS(qr, sinqr, cosqr); 140 fun = sign * 3.0 * r * 141 (2.0*qr*sinqr - (qrsq-2.0)*cosqr)/(qrsq * qrsq); 142 // In the onioon model Jae-He's formula is rederived 143 // and gives following: 144 //fun = 3.0 * sign * r * 145 //(2.0*cosqr + qr*sinqr)/(qrsq*qrsq); 146 //But this seems not to be working in this case... 147 } 148 } 149 150 // update total volume 151 vol = M_4PI_3 * cube(r); 152 f += vol * (bes * contr + fun * slope); 153 } 154 sld_f = sld_i; 155 // no sub-layer iteration (n_s loop) for the flat layer 156 if (j==0) 157 break; 158 } 90 159 } 91 // for interfacial sub_shells 92 else{ 93 dz = thick_inter[i]/nsl; 94 // find sld_i at the outer boundary of sub-layer #n_s 95 sld_i = intersldfunc(fun_type[i],nsl, n_s, fun_coef[i], sld[i], sld[i+1]); 96 // calculate slope 97 slope= (sld_i -sld_f)/dz; 98 } 99 contr = sld_f-slope*r; 100 // iteration for the left and right boundary of the shells(or sub_shells) 101 for (k=0; k<2; k++){ 102 // At r=0, the contribution to I is zero, so skip it. 103 if ( i == 0 && j == 0 && k == 0){ 104 continue; 105 } 106 // On the top of slovent there is no interface; skip it. 107 if (i == n+1 && k == 1){ 108 continue; 109 } 110 // At the right side (outer) boundary 111 if ( k == 1){ 112 sign = 1.0; 113 r += dz; 114 } 115 // At the left side (inner) boundary 116 else{ 117 sign = -1.0; 118 } 119 qr = q * r; 120 fun = 0.0; 121 122 if(qr == 0.0){ 123 // sigular point 124 bes = sign * 1.0; 125 } 126 else{ 127 // for flat sub-layer 128 //TODO: Single precision calculation most likely fails here 129 //bes = sign * 3.0 * (sin(qr) - qr * cos(qr)) / (qr * qr * qr); 130 bes = sign * sph_j1c(qr); 131 if (fabs(slope) > 0.0 ){ 132 //fun = sign * 3.0 * r * (2.0*qr*sin(qr)-((qr*qr)-2.0)*cos(qr))/(qr * qr * qr * qr); 133 fun = sign * r * sph_j1c(qr) + sign * 3.0 * sin(qr)/(qr * qr * q ) 134 + sign * 6.0 * cos(qr)/(qr * qr * qr * q); 135 } 136 } 137 138 //Some initial optimization tries 139 /*bes = (qr == 0.0 ? sign * 1.0 : sign * 3.0 * (sin(qr) - qr * cos(qr)) / (qr * qr * qr)); 140 //TODO: Will have to chnage this function 141 if (qr!= 0.0 && fabs(slope) > 0.0 ){ 142 fun = sign * 3.0 * r * (2.0*qr*sin(qr)-((qr*qr)-2.0)*cos(qr))/(qr * qr * qr * qr); 143 }*/ 144 145 // update total volume 146 vol = 4.0 * pi / 3.0 * r * r * r; 147 // we won't do the following volume correction for now. 148 // substrate empty area of volume 149 //if (k == 1 && fabs(sld_in[i]-sld_solv) < 1e-04*fabs(sld_solv) && fun_type[i]==0){ 150 // vol_sub += (vol_pre - vol); 151 //} 152 f += vol * (bes * contr + fun * slope); 153 } 154 // remember this sld as sld_f 155 sld_f = sld_i; 156 // no sub-layer iteration (n_s loop) for the flat layer 157 if (j==0) 158 break; 159 } 160 } 161 } 162 f2 = f * f / vol; 163 164 return (f2); 160 } 161 f2 = f * f / vol; 162 return (f2); 165 163 } 166 164 … … 177 175 double sld_core, 178 176 double sld_solvent, 177 double func_inter0, 178 double thick_inter0, 179 double nu_inter0, 179 180 double sld_flat[], 180 181 double thick_flat[], … … 186 187 double intensity; 187 188 //TODO: Remove this container at later stage. 188 double dp[60];189 /*double dp[60]; 189 190 dp[0] = n_shells; 190 191 //This is scale will also have to be removed at some stage 191 192 dp[1] = 1.0; 192 dp[2] = thick_inter [0];193 dp[3] = func_inter [0];193 dp[2] = thick_inter0; 194 dp[3] = func_inter0; 194 195 dp[4] = sld_core; 195 196 dp[5] = sld_solvent; 196 197 dp[6] = 0.0; 197 dp[7] = sld_flat[0]; 198 //TODO: Something is messed up with this data strcucture! 199 dp[17] = thick_inter[0]; 200 dp[27] = thick_flat[0]; 201 dp[37] = func_inter[0]; 202 dp[47] = nu_inter[0]; 203 204 for (int i=1; i<=n_shells; i++){ 198 199 for (int i=0; i<n_shells; i++){ 205 200 dp[i+7] = sld_flat[i]; 206 201 dp[i+17] = thick_inter[i]; … … 211 206 212 207 dp[57] = npts_inter; 213 dp[58] = nu_inter [0];208 dp[58] = nu_inter0; 214 209 dp[59] = radius_core; 215 216 intensity = 1.0e-4*sphere_sld_kernel(dp,q); 210 */ 211 intensity = sphere_sld_kernel(q, n_shells, npts_inter, radius_core, 212 sld_core, sld_solvent, func_inter0, thick_inter0, nu_inter0, 213 sld_flat, thick_flat, func_inter, thick_inter, nu_inter); 214 intensity *=1.0e-4; 217 215 //printf("%10d\n",intensity); 218 216 return intensity; -
sasmodels/models/spherical_sld.py
r1448db7a raf0e70c 1 1 r""" 2 This model calculates an empirical functional form for SAS data using SpericalSLD profile 3 4 Similarly to the OnionExpShellModel, this model provides the form factor, P(q), for a multi-shell sphere, 5 where the interface between the each neighboring shells can be described by one of a number of functions 6 including error, power-law, and exponential functions. This model is to calculate the scattering intensity 7 by building a continuous custom SLD profile against the radius of the particle. The SLD profile is composed 8 of a flat core, a flat solvent, a number (up to 9 ) flat shells, and the interfacial layers between 9 the adjacent flat shells (or core, and solvent) (see below). 2 This model calculates an empirical functional form for SAS data using 3 SpericalSLD profile 4 5 Similarly to the OnionExpShellModel, this model provides the form factor, 6 P(q), for a multi-shell sphere, where the interface between the each neighboring 7 shells can be described by one of a number of functions including error, 8 power-law, and exponential functions. 9 This model is to calculate the scattering intensity by building a continuous 10 custom SLD profile against the radius of the particle. 11 The SLD profile is composed of a flat core, a flat solvent, a number (up to 9 ) 12 flat shells, and the interfacial layers between the adjacent flat shells 13 (or core, and solvent) (see below). 10 14 11 15 .. figure:: img/spherical_sld_profile.gif … … 13 17 Exemplary SLD profile 14 18 15 Unlike the <onion> model (using an analytical integration), 16 the interfacial layers here are sub-divided and numerically integrated assuming each of the sub-layers are described 17 by a line function. The number of the sub-layer can be given by users by setting the integer values of npts_inter. 18 The form factor is normalized by the total volume of the sphere. 19 Unlike the <onion> model (using an analytical integration), the interfacial 20 layers here are sub-divided and numerically integrated assuming each of the 21 sub-layers are described by a line function. 22 The number of the sub-layer can be given by users by setting the integer values 23 of npts_inter. The form factor is normalized by the total volume of the sphere. 19 24 20 25 Definition … … 29 34 \sum_{\text{flat}_i=0}^N f_{\text{flat}_i} +f_\text{solvent} 30 35 31 For a spherically symmetric particle with a particle density $\rho_x(r)$ the sld function can be defined as: 36 For a spherically symmetric particle with a particle density $\rho_x(r)$ 37 the sld function can be defined as: 32 38 33 39 .. math:: … … 39 45 40 46 .. math:: 41 f_\text{core} = 4 \pi \int_{0}^{r_\text{core}} \rho_\text{core} \frac{\sin(qr)} {qr} r^2 dr = 47 f_\text{core} = 4 \pi \int_{0}^{r_\text{core}} \rho_\text{core} 48 \frac{\sin(qr)} {qr} r^2 dr = 42 49 3 \rho_\text{core} V(r_\text{core}) 43 \Big[ \frac{\sin(qr_\text{core}) - qr_\text{core} \cos(qr_\text{core})} {qr_\text{core}^3} \Big] 44 45 f_{\text{inter}_i} = 4 \pi \int_{\Delta t_{ \text{inter}_i } } \rho_{ \text{inter}_i } \frac{\sin(qr)} {qr} r^2 dr 46 47 f_{\text{shell}_i} = 4 \pi \int_{\Delta t_{ \text{inter}_i } } \rho_{ \text{flat}_i } \frac{\sin(qr)} {qr} r^2 dr = 48 3 \rho_{ \text{flat}_i } V ( r_{ \text{inter}_i } + \Delta t_{ \text{inter}_i } ) 49 \Big[ \frac{\sin(qr_{\text{inter}_i} + \Delta t_{ \text{inter}_i } ) - q (r_{\text{inter}_i} + 50 \Delta t_{ \text{inter}_i }) \cos(q( r_{\text{inter}_i} + \Delta t_{ \text{inter}_i } ) ) } 50 \Big[ \frac{\sin(qr_\text{core}) - qr_\text{core} \cos(qr_\text{core})} 51 {qr_\text{core}^3} \Big] 52 53 f_{\text{inter}_i} = 4 \pi \int_{\Delta t_{ \text{inter}_i } } 54 \rho_{ \text{inter}_i } \frac{\sin(qr)} {qr} r^2 dr 55 56 f_{\text{shell}_i} = 4 \pi \int_{\Delta t_{ \text{inter}_i } } 57 \rho_{ \text{flat}_i } \frac{\sin(qr)} {qr} r^2 dr = 58 3 \rho_{ \text{flat}_i } V ( r_{ \text{inter}_i } + 59 \Delta t_{ \text{inter}_i } ) 60 \Big[ \frac{\sin(qr_{\text{inter}_i} + \Delta t_{ \text{inter}_i } ) 61 - q (r_{\text{inter}_i} + \Delta t_{ \text{inter}_i }) 62 \cos(q( r_{\text{inter}_i} + \Delta t_{ \text{inter}_i } ) ) } 51 63 {q ( r_{\text{inter}_i} + \Delta t_{ \text{inter}_i } )^3 } \Big] 52 64 -3 \rho_{ \text{flat}_i } V(r_{ \text{inter}_i }) 53 \Big[ \frac{\sin(qr_{\text{inter}_i}) - qr_{\text{flat}_i} \cos(qr_{\text{inter}_i}) } {qr_{\text{inter}_i}^3} \Big] 54 55 f_\text{solvent} = 4 \pi \int_{r_N}^{\infty} \rho_\text{solvent} \frac{\sin(qr)} {qr} r^2 dr = 65 \Big[ \frac{\sin(qr_{\text{inter}_i}) - qr_{\text{flat}_i} 66 \cos(qr_{\text{inter}_i}) } {qr_{\text{inter}_i}^3} \Big] 67 68 f_\text{solvent} = 4 \pi \int_{r_N}^{\infty} \rho_\text{solvent} 69 \frac{\sin(qr)} {qr} r^2 dr = 56 70 3 \rho_\text{solvent} V(r_N) 57 71 \Big[ \frac{\sin(qr_N) - qr_N \cos(qr_N)} {qr_N^3} \Big] … … 66 80 .. math:: 67 81 \rho_{{inter}_i} (r) = \begin{cases} 68 B \exp\Big( \frac {\pm A(r - r_{\text{flat}_i})} {\Delta t_{ \text{inter}_i }} \Big) +C & \text{for} A \neq 0 \\ 69 B \Big( \frac {(r - r_{\text{flat}_i})} {\Delta t_{ \text{inter}_i }} \Big) +C & \text{for} A = 0 \\ 82 B \exp\Big( \frac {\pm A(r - r_{\text{flat}_i})} 83 {\Delta t_{ \text{inter}_i }} \Big) +C & \text{for} A \neq 0 \\ 84 B \Big( \frac {(r - r_{\text{flat}_i})} 85 {\Delta t_{ \text{inter}_i }} \Big) +C & \text{for} A = 0 \\ 70 86 \end{cases} 71 87 … … 74 90 .. math:: 75 91 \rho_{{inter}_i} (r) = \begin{cases} 76 \pm B \Big( \frac {(r - r_{\text{flat}_i} )} {\Delta t_{ \text{inter}_i }} \Big) ^A +C & \text{for} A \neq 0 \\ 92 \pm B \Big( \frac {(r - r_{\text{flat}_i} )} {\Delta t_{ \text{inter}_i }} 93 \Big) ^A +C & \text{for} A \neq 0 \\ 77 94 \rho_{\text{flat}_{i+1}} & \text{for} A = 0 \\ 78 95 \end{cases} … … 82 99 .. math:: 83 100 \rho_{{inter}_i} (r) = \begin{cases} 84 B \text{erf} \Big( \frac { A(r - r_{\text{flat}_i})} {\sqrt{2} \Delta t_{ \text{inter}_i }} \Big) +C & \text{for} A \neq 0 \\ 85 B \Big( \frac {(r - r_{\text{flat}_i} )} {\Delta t_{ \text{inter}_i }} \Big) +C & \text{for} A = 0 \\ 101 B \text{erf} \Big( \frac { A(r - r_{\text{flat}_i})} 102 {\sqrt{2} \Delta t_{ \text{inter}_i }} \Big) +C & \text{for} A \neq 0 \\ 103 B \Big( \frac {(r - r_{\text{flat}_i} )} {\Delta t_{ \text{inter}_i }} 104 \Big) +C & \text{for} A = 0 \\ 86 105 \end{cases} 87 106 88 The functions are normalized so that they vary between 0 and 1, and they are constrained such that the SLD 89 is continuous at the boundaries of the interface as well as each sub-layers. Thus B and C are determined. 90 91 Once $\rho_{\text{inter}_i}$ is found at the boundary of the sub-layer of the interface, we can find its contribution 92 to the form factor $P(q)$ 93 94 .. math:: 95 f_{\text{inter}_i} = 4 \pi \int_{\Delta t_{ \text{inter}_i } } \rho_{ \text{inter}_i } \frac{\sin(qr)} {qr} r^2 dr = 107 The functions are normalized so that they vary between 0 and 1, and they are 108 constrained such that the SLD is continuous at the boundaries of the interface 109 as well as each sub-layers. Thus B and C are determined. 110 111 Once $\rho_{\text{inter}_i}$ is found at the boundary of the sub-layer of the 112 interface, we can find its contribution to the form factor $P(q)$ 113 114 .. math:: 115 f_{\text{inter}_i} = 4 \pi \int_{\Delta t_{ \text{inter}_i } } 116 \rho_{ \text{inter}_i } \frac{\sin(qr)} {qr} r^2 dr = 96 117 4 \pi \sum_{j=0}^{npts_{\text{inter}_i} -1 } 97 \int_{r_j}^{r_{j+1}} \rho_{ \text{inter}_i } (r_j) \frac{\sin(qr)} {qr} r^2 dr \approx 118 \int_{r_j}^{r_{j+1}} \rho_{ \text{inter}_i } (r_j) 119 \frac{\sin(qr)} {qr} r^2 dr \approx 98 120 99 121 4 \pi \sum_{j=0}^{npts_{\text{inter}_i} -1 } \Big[ 100 3 ( \rho_{ \text{inter}_i } ( r_{j+1} ) - \rho_{ \text{inter}_i } ( r_{j} ) V ( r_{ \text{sublayer}_j } ) 101 \Big[ \frac {r_j^2 \beta_\text{out}^2 \sin(\beta_\text{out}) - (\beta_\text{out}^2-2) \cos(\beta_\text{out}) } 122 3 ( \rho_{ \text{inter}_i } ( r_{j+1} ) - \rho_{ \text{inter}_i } 123 ( r_{j} ) V ( r_{ \text{sublayer}_j } ) 124 \Big[ \frac {r_j^2 \beta_\text{out}^2 \sin(\beta_\text{out}) 125 - (\beta_\text{out}^2-2) \cos(\beta_\text{out}) } 102 126 {\beta_\text{out}^4 } \Big] 103 127 104 - 3 ( \rho_{ \text{inter}_i } ( r_{j+1} ) - \rho_{ \text{inter}_i } ( r_{j} ) V ( r_{ \text{sublayer}_j-1 } ) 105 \Big[ \frac {r_{j-1}^2 \sin(\beta_\text{in}) - (\beta_\text{in}^2-2) \cos(\beta_\text{in}) } 128 - 3 ( \rho_{ \text{inter}_i } ( r_{j+1} ) - \rho_{ \text{inter}_i } 129 ( r_{j} ) V ( r_{ \text{sublayer}_j-1 } ) 130 \Big[ \frac {r_{j-1}^2 \sin(\beta_\text{in}) 131 - (\beta_\text{in}^2-2) \cos(\beta_\text{in}) } 106 132 {\beta_\text{in}^4 } \Big] 107 133 … … 120 146 V(a) = \frac {4\pi}{3}a^3 121 147 122 a_\text{in} ~ \frac{r_j}{r_{j+1} -r_j} \text{, } a_\text{out} ~ \frac{r_{j+1}}{r_{j+1} -r_j} 148 a_\text{in} ~ \frac{r_j}{r_{j+1} -r_j} \text{, } a_\text{out} 149 ~ \frac{r_{j+1}}{r_{j+1} -r_j} 123 150 124 151 \beta_\text{in} = qr_j \text{, } \beta_\text{out} = qr_{j+1} 125 152 126 153 127 We assume the $\rho_{\text{inter}_i} (r)$ can be approximately linear within a sub-layer $j$ 154 We assume the $\rho_{\text{inter}_i} (r)$ can be approximately linear 155 within a sub-layer $j$ 128 156 129 157 Finally form factor can be calculated by … … 131 159 .. math:: 132 160 133 P(q) = \frac{[f]^2} {V_\text{particle}} \text{where} V_\text{particle} = V(r_{\text{shell}_N}) 161 P(q) = \frac{[f]^2} {V_\text{particle}} \text{where} V_\text{particle} 162 = V(r_{\text{shell}_N}) 134 163 135 164 For 2D data the scattering intensity is calculated in the same way as 1D, … … 150 179 151 180 .. note:: 152 The outer most radius is used as the effective radius for S(Q) when $P(Q) * S(Q)$ is applied. 181 The outer most radius is used as the effective radius for S(Q) 182 when $P(Q) * S(Q)$ is applied. 153 183 154 184 References 155 185 ---------- 156 L A Feigin and D I Svergun, Structure Analysis by Small-Angle X-Ray and Neutron Scattering, Plenum Press, New York, (1987) 186 L A Feigin and D I Svergun, Structure Analysis by Small-Angle X-Ray 187 and Neutron Scattering, Plenum Press, New York, (1987) 157 188 158 189 """ … … 170 201 # pylint: disable=bad-whitespace, line-too-long 171 202 # ["name", "units", default, [lower, upper], "type", "description"], 172 parameters = [["n_shells", "", 1, [0, 9], "", "number of shells"], 173 ["npts_inter", "", 35, [0, 35], "", "number of points in each sublayer Must be odd number"], 174 ["radius_core", "Ang", 50.0, [0, inf], "", "intern layer thickness"], 175 ["sld_core", "1e-6/Ang^2", 2.07, [-inf, inf], "", "sld function flat"], 176 ["sld_solvent", "1e-6/Ang^2", 1.0, [-inf, inf], "", "sld function solvent"], 203 parameters = [["n_shells", "", 1, [0, 9], "volume", "number of shells"], 204 ["npts_inter", "", 35, [0, inf], "", "number of points in each sublayer Must be odd number"], 205 ["radius_core", "Ang", 50.0, [0, inf], "volume", "intern layer thickness"], 206 ["sld_core", "1e-6/Ang^2", 2.07, [-inf, inf], "", "sld function flat"], 207 ["sld_solvent", "1e-6/Ang^2", 1.0, [-inf, inf], "", "sld function solvent"], 208 ["func_inter0", "", 0, [0, 4], "", "Erf:0, RPower:1, LPower:2, RExp:3, LExp:4"], 209 ["thick_inter0", "Ang", 50.0, [0, inf], "volume", "intern layer thickness for core layer"], 210 ["nu_inter0", "", 2.5, [-inf, inf], "", "steepness parameter for core layer"], 177 211 ["sld_flat[n_shells]", "1e-6/Ang^2", 4.06, [-inf, inf], "", "sld function flat"], 178 ["thick_flat[n_shells]", "Ang", 100.0, [0, inf], " ", "flat layer_thickness"],212 ["thick_flat[n_shells]", "Ang", 100.0, [0, inf], "volume", "flat layer_thickness"], 179 213 ["func_inter[n_shells]", "", 0, [0, 4], "", "Erf:0, RPower:1, LPower:2, RExp:3, LExp:4"], 180 ["thick_inter[n_shells]", "Ang", 50.0, [0, inf], " ", "intern layer thickness"],214 ["thick_inter[n_shells]", "Ang", 50.0, [0, inf], "volume", "intern layer thickness"], 181 215 ["nu_inter[n_shells]", "", 2.5, [-inf, inf], "", "steepness parameter"], 182 216 ] … … 184 218 source = ["lib/librefl.c", "lib/sph_j1c.c", "spherical_sld.c"] 185 219 220 profile_axes = ['Radius (A)', 'SLD (1e-6/A^2)'] 186 221 def profile(n_shells, radius_core, sld_core, sld_solvent, sld_flat, 187 222 thick_flat, func_inter, thick_inter, nu_inter, npts_inter): … … 256 291 257 292 demo = { 258 "n_shells": 4,259 "npts_inter": 35.0,260 "radius_core": 50.0,261 "sld_core": 2.07,293 "n_shells": 4, 294 "npts_inter": 35.0, 295 "radius_core": 50.0, 296 "sld_core": 2.07, 262 297 "sld_solvent": 1.0, 263 "sld_flat":[4.0,3.5,4.0,3.5,4.0], 264 "thick_flat":[100.0,100.0,100.0,100.0,100.0], 265 "func_inter":[0,0,0,0,0], 266 "thick_inter":[50.0,50.0,50.0,50.0,50.0], 267 "nu_inter":[2.5,2.5,2.5,2.5,2.5] 298 "thick_inter0": 50.0, 299 "func_inter0": 0, 300 "nu_inter0": 2.5, 301 "sld_flat":[4.0,3.5,4.0,3.5], 302 "thick_flat":[100.0,100.0,100.0,100.0], 303 "func_inter":[0,0,0,0], 304 "thick_inter":[50.0,50.0,50.0,50.0], 305 "nu_inter":[2.5,2.5,2.5,2.5], 268 306 } 269 307 … … 271 309 tests = [ 272 310 # Accuracy tests based on content in test/utest_extra_models.py 273 [{'npts_iter':35, 274 'sld_solv':1, 275 'radius_core':50.0, 276 'sld_core':2.07, 277 'func_inter2':0.0, 278 'thick_inter2':50, 279 'nu_inter2':2.5, 280 'sld_flat2':4, 281 'thick_flat2':100, 282 'func_inter1':0.0, 283 'thick_inter1':50, 284 'nu_inter1':2.5, 285 'background': 0.0, 311 [{"n_shells":4, 312 'npts_inter':35, 313 "radius_core":50.0, 314 "sld_core":2.07, 315 "sld_solvent": 1.0, 316 "sld_flat":[4.0,3.5,4.0,3.5], 317 "thick_flat":[100.0,100.0,100.0,100.0], 318 "func_inter":[0,0,0,0], 319 "thick_inter":[50.0,50.0,50.0,50.0], 320 "nu_inter":[2.5,2.5,2.5,2.5] 286 321 }, 0.001, 0.001], 287 322 ]
Note: See TracChangeset
for help on using the changeset viewer.