Changeset 7e923c2 in sasmodels for sasmodels/models
- Timestamp:
- Aug 7, 2018 10:45:52 PM (6 years ago)
- Branches:
- master, core_shell_microgels, magnetic_model, ticket-1257-vesicle-product, ticket_1156, ticket_1265_superball, ticket_822_more_unit_tests
- Children:
- 1a7ddc9
- Parents:
- c036ddb (diff), e9b17b18 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent. - Location:
- sasmodels/models
- Files:
-
- 1 added
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
sasmodels/models/guinier.py
r2d81cfe rc9fc873 7 7 .. math:: 8 8 9 I(q) = \text{scale} \cdot \exp{\left[ \frac{-Q^2 R_g^2}{3} \right]}9 I(q) = \text{scale} \cdot \exp{\left[ \frac{-Q^2 R_g^2 }{3} \right]} 10 10 + \text{background} 11 11 … … 19 19 20 20 .. math:: q = \sqrt{q_x^2 + q_y^2} 21 22 In scattering, the radius of gyration $R_g$ quantifies the objects's 23 distribution of SLD (not mass density, as in mechanics) from the objects's 24 SLD centre of mass. It is defined by 25 26 .. math:: R_g^2 = \frac{\sum_i\rho_i\left(r_i-r_0\right)^2}{\sum_i\rho_i} 27 28 where $r_0$ denotes the object's SLD centre of mass and $\rho_i$ is the SLD at 29 a point $i$. 30 31 Notice that $R_g^2$ may be negative (since SLD can be negative), which happens 32 when a form factor $P(Q)$ is increasing with $Q$ rather than decreasing. This 33 can occur for core/shell particles, hollow particles, or for composite 34 particles with domains of different SLDs in a solvent with an SLD close to the 35 average match point. (Alternatively, this might be regarded as there being an 36 internal inter-domain "structure factor" within a single particle which gives 37 rise to a peak in the scattering). 38 39 To specify a negative value of $R_g^2$ in SasView, simply give $R_g$ a negative 40 value ($R_g^2$ will be evaluated as $R_g |R_g|$). Note that the physical radius 41 of gyration, of the exterior of the particle, will still be large and positive. 42 It is only the apparent size from the small $Q$ data that will give a small or 43 negative value of $R_g^2$. 21 44 22 45 References … … 42 65 43 66 # ["name", "units", default, [lower, upper], "type","description"], 44 parameters = [["rg", "Ang", 60.0, [ 0, inf], "", "Radius of Gyration"]]67 parameters = [["rg", "Ang", 60.0, [-inf, inf], "", "Radius of Gyration"]] 45 68 46 69 Iq = """ 47 double exponent = rg*rg*q*q/3.0;70 double exponent = fabs(rg)*rg*q*q/3.0; 48 71 double value = exp(-exponent); 49 72 return value; … … 66 89 67 90 # parameters for demo 68 demo = dict(scale=1.0, rg=60.0)91 demo = dict(scale=1.0, background=0.001, rg=60.0 ) 69 92 70 93 # parameters for unit tests -
sasmodels/models/core_shell_sphere.py
rdc76240 rc036ddb 58 58 title = "Form factor for a monodisperse spherical particle with particle with a core-shell structure." 59 59 description = """ 60 F ^2(q) = 3/V_s [V_c (sld_core-sld_shell)(sin(q*radius)-q*radius*cos(q*radius))/(q*radius)^361 + V_s (sld_shell-sld_solvent)(sin(q*r_s)-q*r_s*cos(q*r_s))/(q*r_s)^3]60 F(q) = [V_c (sld_core-sld_shell) 3 (sin(q*radius)-q*radius*cos(q*radius))/(q*radius)^3 61 + V_s (sld_shell-sld_solvent) 3 (sin(q*r_s)-q*r_s*cos(q*r_s))/(q*r_s)^3] 62 62 63 63 V_s: Volume of the sphere shell -
sasmodels/models/ellipsoid.c
r108e70e rc036ddb 5 5 } 6 6 7 /* Fq overrides Iq 7 8 static double 8 9 Iq(double q, … … 37 38 return 1.0e-4 * s * s * form; 38 39 } 40 */ 41 42 static void 43 Fq(double q, 44 double *F1, 45 double *F2, 46 double sld, 47 double sld_solvent, 48 double radius_polar, 49 double radius_equatorial) 50 { 51 // Using ratio v = Rp/Re, we can implement the form given in Guinier (1955) 52 // i(h) = int_0^pi/2 Phi^2(h a sqrt(cos^2 + v^2 sin^2) cos dT 53 // = int_0^pi/2 Phi^2(h a sqrt((1-sin^2) + v^2 sin^2) cos dT 54 // = int_0^pi/2 Phi^2(h a sqrt(1 + sin^2(v^2-1)) cos dT 55 // u-substitution of 56 // u = sin, du = cos dT 57 // i(h) = int_0^1 Phi^2(h a sqrt(1 + u^2(v^2-1)) du 58 const double v_square_minus_one = square(radius_polar/radius_equatorial) - 1.0; 59 // translate a point in [-1,1] to a point in [0, 1] 60 // const double u = GAUSS_Z[i]*(upper-lower)/2 + (upper+lower)/2; 61 const double zm = 0.5; 62 const double zb = 0.5; 63 double total_F2 = 0.0; 64 double total_F1 = 0.0; 65 for (int i=0;i<GAUSS_N;i++) { 66 const double u = GAUSS_Z[i]*zm + zb; 67 const double r = radius_equatorial*sqrt(1.0 + u*u*v_square_minus_one); 68 const double f = sas_3j1x_x(q*r); 69 total_F2 += GAUSS_W[i] * f * f; 70 total_F1 += GAUSS_W[i] * f; 71 } 72 // translate dx in [-1,1] to dx in [lower,upper] 73 const double form_squared_avg = total_F2*zm; 74 const double form_avg = total_F1*zm; 75 const double s = (sld - sld_solvent) * form_volume(radius_polar, radius_equatorial); 76 *F1 = 1e-2 * s * form_avg; 77 *F2 = 1e-4 * s * s * form_squared_avg; 78 } 39 79 40 80 static double -
sasmodels/models/ellipsoid.py
r2d81cfe rc036ddb 161 161 ] 162 162 163 163 164 source = ["lib/sas_3j1x_x.c", "lib/gauss76.c", "ellipsoid.c"] 165 166 have_Fq = True 164 167 165 168 def ER(radius_polar, radius_equatorial): -
sasmodels/models/lib/sphere_form.c
r925ad6e r01c8d9e 13 13 return 1.0e-4*square(contrast * fq); 14 14 } 15 -
sasmodels/models/sphere.py
ref07e95 rc036ddb 69 69 source = ["lib/sas_3j1x_x.c", "lib/sphere_form.c"] 70 70 71 # No volume normalization despite having a volume parameter 72 # This should perhaps be volume normalized? 73 form_volume = """ 71 c_code = """ 72 static double form_volume(double radius) 73 { 74 74 return sphere_volume(radius); 75 """ 75 } 76 76 77 Iq = """ 78 return sphere_form(q, radius, sld, sld_solvent); 79 """ 77 static void Fq(double q, double *F1,double *F2, double sld, double solvent_sld, double radius) 78 { 79 const double fq = sas_3j1x_x(q*radius); 80 const double contrast = (sld - solvent_sld); 81 const double form = 1e-2 * contrast * sphere_volume(radius) * fq; 82 *F1 = form; 83 *F2 = form*form; 84 } 85 """ 86 87 # TODO: figure this out by inspection 88 have_Fq = True 80 89 81 90 def ER(radius):
Note: See TracChangeset
for help on using the changeset viewer.