Changeset ee60aa7 in sasmodels
- Timestamp:
- Sep 10, 2018 4:16:46 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:
- d299327
- Parents:
- 3f818b2
- Files:
-
- 59 edited
Legend:
- Unmodified
- Added
- Removed
-
explore/precision.py
r2a7e20e ree60aa7 357 357 ) 358 358 add_function( 359 name=" debye",359 name="gauss_coil", 360 360 mp_function=lambda x: 2*(mp.exp(-x**2) + x**2 - 1)/x**4, 361 361 np_function=lambda x: 2*(np.expm1(-x**2) + x**2)/x**4, 362 362 ocl_function=make_ocl(""" 363 363 const double qsq = q*q; 364 if (qsq < 1.0) { // Pade approximation 364 // For double: use O(5) Pade with 0.5 cutoff (10 mad + 1 divide) 365 // For single: use O(7) Taylor with 0.8 cutoff (7 mad) 366 if (qsq < 0.0) { 365 367 const double x = qsq; 366 368 if (0) { // 0.36 single … … 372 374 const double B1=3./8., B2=3./56., B3=1./336.; 373 375 return (((A3*x + A2)*x + A1)*x + 1.)/(((B3*x + B2)*x + B1)*x + 1.); 374 } else if ( 1) { // 1.0 for single, 0.25 for double376 } else if (0) { // 1.0 for single, 0.25 for double 375 377 // PadeApproximant[2*Exp[-x^2] + x^2-1)/x^4, {x, 0, 8}] 376 378 const double A1=1./15., A2=1./60, A3=0., A4=1./75600.; … … 385 387 /(((((B5*x + B4)*x + B3)*x + B2)*x + B1)*x + 1.); 386 388 } 387 } else if (qsq < 1.) { // Taylor series; 0.9 for single, 0.25 for double389 } else if (qsq < 0.8) { 388 390 const double x = qsq; 389 391 const double C0 = +1.; -
sasmodels/core.py
r5399809 ree60aa7 364 364 actual = [p.name for p in model.info.parameters.kernel_parameters] 365 365 target = ("sld sld_solvent radius length theta phi" 366 " radius_effective volfraction structure_factor_mode" 366 " radius_effective volfraction " 367 " structure_factor_mode radius_effective_mode" 367 368 " A_sld A_sld_solvent A_radius").split() 368 369 assert target == actual, "%s != %s"%(target, actual) -
sasmodels/kernel.py
r5399809 ree60aa7 92 92 def _call_kernel(self, call_details, values, cutoff, magnetic, effective_radius_type): 93 93 # type: (CallDetails, np.ndarray, np.ndarray, float, bool, int) -> np.ndarray 94 raise NotImp mentedError()94 raise NotImplementedError() -
sasmodels/models/barbell.c
rd277229 ree60aa7 79 79 effective_radius(int mode, double radius_bell, double radius, double length) 80 80 { 81 if (mode == 1) { 81 switch (mode) { 82 case 1: // equivalent sphere 82 83 return radius_from_volume(radius_bell, radius , length); 83 } else if (mode == 2) {84 case 2: // radius 84 85 return radius; 85 } else if (mode == 3) {86 case 3: // half length 86 87 return 0.5*length; 87 } else {88 case 4: // half total length 88 89 return radius_from_totallength(radius_bell,radius,length); 89 90 } -
sasmodels/models/barbell.py
rd277229 ree60aa7 117 117 source = ["lib/polevl.c", "lib/sas_J1.c", "lib/gauss76.c", "barbell.c"] 118 118 have_Fq = True 119 effective_radius_type = ["equivalent sphere","radius","half length","half total length"] 119 effective_radius_type = [ 120 "equivalent sphere", "radius", "half length", "half total length", 121 ] 120 122 121 123 def random(): -
sasmodels/models/capped_cylinder.c
rd277229 ree60aa7 101 101 effective_radius(int mode, double radius, double radius_cap, double length) 102 102 { 103 if (mode == 1) { 103 switch (mode) { 104 case 1: // equivalent sphere 104 105 return radius_from_volume(radius, radius_cap, length); 105 } else if (mode == 2) {106 case 2: // radius 106 107 return radius; 107 } else if (mode == 3) {108 case 3: // half length 108 109 return 0.5*length; 109 } else {110 case 4: // half total length 110 111 return radius_from_totallength(radius, radius_cap,length); 111 112 } -
sasmodels/models/capped_cylinder.py
rd277229 ree60aa7 137 137 source = ["lib/polevl.c", "lib/sas_J1.c", "lib/gauss76.c", "capped_cylinder.c"] 138 138 have_Fq = True 139 effective_radius_type = ["equivalent sphere","radius","half length","half total length"] 139 effective_radius_type = [ 140 "equivalent sphere", "radius", "half length", "half total length", 141 ] 140 142 141 143 def random(): -
sasmodels/models/core_multi_shell.c
ra94046f ree60aa7 6 6 const double vol = M_4PI_3 * cube(r); 7 7 return sld * vol * bes; 8 }9 10 static double11 form_volume(double core_radius, double fp_n, double thickness[])12 {13 double r = core_radius;14 int n = (int)(fp_n+0.5);15 for (int i=0; i < n; i++) {16 r += thickness[i];17 }18 return M_4PI_3 * cube(r);19 8 } 20 9 … … 31 20 32 21 static double 22 form_volume(double core_radius, double fp_n, double thickness[]) 23 { 24 return M_4PI_3 * cube(outer_radius(core_radius, fp_n, thickness)); 25 } 26 27 static double 33 28 effective_radius(int mode, double core_radius, double fp_n, double thickness[]) 34 // this seems regardless to always give the result for outer radius for n=1 shells; why??35 // printf shows fp_n is always 1, not 0,1,236 29 { 37 // printf("fp_n =%g \n",fp_n); 38 if (mode == 1) { 39 double r = core_radius; 40 int n = (int)(fp_n+0.5); 41 if ( n > 0) { 42 for (int i=0; i < n; i++) { 43 r += thickness[i]; 44 } 45 } 46 return r; 47 //return outer_radius(core_radius,fp_n,thickness); 48 } else { 49 return core_radius; 50 } 30 switch (mode) { 31 case 1: // outer radius 32 return outer_radius(core_radius, fp_n, thickness); 33 case 2: // core radius 34 return core_radius; 35 } 51 36 } 52 37 -
sasmodels/models/core_multi_shell.py
rd277229 ree60aa7 145 145 return np.asarray(z), np.asarray(rho) 146 146 147 #def ER(radius, n, thickness):148 # """Effective radius"""149 # n = int(n[0]+0.5) # n is a control parameter and is not polydisperse150 # return np.sum(thickness[:n], axis=0) + radius151 152 147 demo = dict(sld_core=6.4, 153 148 radius=60, -
sasmodels/models/core_shell_bicelle.c
rd277229 ree60aa7 54 54 effective_radius(int mode, double radius, double thick_rim, double thick_face, double length) 55 55 { 56 if (mode == 1) { 56 switch (mode) { 57 case 1: // equivalent sphere 57 58 return radius_from_volume(radius, thick_rim, thick_face, length); 58 } else if (mode == 2) {59 case 2: // outer rim radius 59 60 return radius + thick_rim; 60 } else if (mode == 3) {61 case 3: // half outer thickness 61 62 return 0.5*length + thick_face; 62 } else {63 case 4: // half diagonal 63 64 return radius_from_diagonal(radius,thick_rim,thick_face,length); 64 65 } -
sasmodels/models/core_shell_bicelle.py
rd277229 ree60aa7 155 155 "core_shell_bicelle.c"] 156 156 have_Fq = True 157 effective_radius_type = ["equivalent sphere","outer rim radius", "half outer thickness","half diagonal"] 157 effective_radius_type = [ 158 "equivalent sphere", "outer rim radius", 159 "half outer thickness", "half diagonal", 160 ] 158 161 159 162 def random(): -
sasmodels/models/core_shell_bicelle_elliptical.c
rd277229 ree60aa7 29 29 effective_radius(int mode, double r_minor, double x_core, double thick_rim, double thick_face, double length) 30 30 { 31 if (mode == 1) { 31 switch (mode) { 32 case 1: // equivalent sphere 32 33 return radius_from_volume(r_minor, x_core, thick_rim, thick_face, length); 33 } else if (mode == 2) {34 case 2: // outer rim average radius 34 35 return 0.5*r_minor*(1.0 + x_core) + thick_rim; 35 } else if (mode == 3) {36 case 3: // outer rim min radius 36 37 return (x_core < 1.0 ? x_core*r_minor+thick_rim : r_minor+thick_rim); 37 } else if (mode == 4) {38 case 4: // outer max radius 38 39 return (x_core > 1.0 ? x_core*r_minor+thick_rim : r_minor+thick_rim); 39 } else if (mode ==5) {40 case 5: // half outer thickness 40 41 return 0.5*length + thick_face; 41 } else {42 case 6: // half diagonal 42 43 return radius_from_diagonal(r_minor,x_core,thick_rim,thick_face,length); 43 44 } -
sasmodels/models/core_shell_bicelle_elliptical.py
rd277229 ree60aa7 147 147 "core_shell_bicelle_elliptical.c"] 148 148 have_Fq = True 149 effective_radius_type = ["equivalent sphere","outer rim average radius","outer rim min radius", 150 "outer max radius", "half outer thickness","half diagonal"] 149 effective_radius_type = [ 150 "equivalent sphere", "outer rim average radius", "outer rim min radius", 151 "outer max radius", "half outer thickness", "half diagonal", 152 ] 151 153 152 154 def random(): -
sasmodels/models/core_shell_bicelle_elliptical_belt_rough.c
rd277229 ree60aa7 30 30 effective_radius(int mode, double r_minor, double x_core, double thick_rim, double thick_face, double length) 31 31 { 32 if (mode == 1) { 32 switch (mode) { 33 case 1: // equivalent sphere 33 34 return radius_from_volume(r_minor, x_core, thick_rim, thick_face, length); 34 } else if (mode == 2) {35 case 2: // outer rim average radius 35 36 return 0.5*r_minor*(1.0 + x_core) + thick_rim; 36 } else if (mode == 3) {37 case 3: // outer rim min radius 37 38 return (x_core < 1.0 ? x_core*r_minor+thick_rim : r_minor+thick_rim); 38 } else if (mode == 4) {39 case 4: // outer max radius 39 40 return (x_core > 1.0 ? x_core*r_minor+thick_rim : r_minor+thick_rim); 40 } else if (mode ==5) {41 case 5: // half outer thickness 41 42 return 0.5*length + thick_face; 42 } else {43 case 6: // half diagonal 43 44 return radius_from_diagonal(r_minor,x_core,thick_rim,thick_face,length); 44 45 } -
sasmodels/models/core_shell_bicelle_elliptical_belt_rough.py
rd277229 ree60aa7 160 160 "core_shell_bicelle_elliptical_belt_rough.c"] 161 161 have_Fq = True 162 effective_radius_type = ["equivalent sphere","outer rim average radius","outer rim min radius", 163 "outer max radius", "half outer thickness","half diagonal"] 162 effective_radius_type = [ 163 "equivalent sphere", "outer rim average radius", "outer rim min radius", 164 "outer max radius", "half outer thickness", "half diagonal", 165 ] 164 166 165 167 demo = dict(scale=1, background=0, -
sasmodels/models/core_shell_cylinder.c
ra94046f ree60aa7 30 30 static double 31 31 effective_radius(int mode, double radius, double thickness, double length) 32 //effective_radius_type = ["equivalent sphere","outer radius","half outer length","half min outer dimension",33 // "half max outer dimension","half outer diagonal"]34 32 { 35 if (mode == 1) { 33 switch (mode) { 34 case 1: // equivalent sphere 36 35 return radius_from_volume(radius, thickness, length); 37 } else if (mode == 2) {36 case 2: // outer radius 38 37 return radius + thickness; 39 } else if (mode == 3) {38 case 3: // half outer length 40 39 return 0.5*length + thickness; 41 } else if (mode == 4) {40 case 4: // half min outer length 42 41 return (radius < 0.5*length ? radius + thickness : 0.5*length + thickness); 43 } else if (mode == 5) {42 case 5: // half max outer length 44 43 return (radius > 0.5*length ? radius + thickness : 0.5*length + thickness); 45 } else {44 case 6: // half outer diagonal 46 45 return radius_from_diagonal(radius,thickness,length); 47 46 } -
sasmodels/models/core_shell_cylinder.py
rc44b611 ree60aa7 132 132 source = ["lib/polevl.c", "lib/sas_J1.c", "lib/gauss76.c", "core_shell_cylinder.c"] 133 133 have_Fq = True 134 effective_radius_type = ["equivalent sphere","outer radius","half outer length","half min outer dimension", 135 "half max outer dimension","half outer diagonal"] 136 137 #def ER(radius, thickness, length): 138 # """ 139 # Returns the effective radius used in the S*P calculation 140 # """ 141 # radius = radius + thickness 142 # length = length + 2 * thickness 143 # ddd = 0.75 * radius * (2 * radius * length + (length + radius) * (length + pi * radius)) 144 # return 0.5 * (ddd) ** (1. / 3.) 134 effective_radius_type = [ 135 "equivalent sphere", "outer radius", "half outer length", 136 "half min outer dimension", "half max outer dimension", 137 "half outer diagonal", 138 ] 145 139 146 140 def random(): -
sasmodels/models/core_shell_ellipsoid.c
r3c60146 ree60aa7 73 73 const double radius_polar_tot = radius_equat_core*x_core + thick_shell*x_polar_shell; 74 74 75 if (mode == 1) { 75 switch (mode) { 76 case 1: // equivalent sphere 76 77 return radius_from_volume(radius_equat_core, x_core, thick_shell, x_polar_shell); 77 } else if (mode == 2) {78 case 2: // average outer curvature 78 79 return radius_from_curvature(radius_equat_core, x_core, thick_shell, x_polar_shell); 79 } else if (mode == 3) {80 case 3: // min outer radius 80 81 return (radius_polar_tot < radius_equat_tot ? radius_polar_tot : radius_equat_tot); 81 } else {82 case 4: // max outer radius 82 83 return (radius_polar_tot > radius_equat_tot ? radius_polar_tot : radius_equat_tot); 83 84 } -
sasmodels/models/core_shell_ellipsoid.py
rd277229 ree60aa7 146 146 source = ["lib/sas_3j1x_x.c", "lib/gauss76.c", "core_shell_ellipsoid.c"] 147 147 have_Fq = True 148 effective_radius_type = ["equivalent sphere","average outer curvature", "min outer radius", "max outer radius"] 149 150 #def ER(radius_equat_core, x_core, thick_shell, x_polar_shell): 151 # """ 152 # Returns the effective radius used in the S*P calculation 153 # """ 154 # from .ellipsoid import ER as ellipsoid_ER 155 # polar_outer = radius_equat_core*x_core + thick_shell*x_polar_shell 156 # equat_outer = radius_equat_core + thick_shell 157 # return ellipsoid_ER(polar_outer, equat_outer) 148 effective_radius_type = [ 149 "equivalent sphere", "average outer curvature", 150 "min outer radius", "max outer radius", 151 ] 158 152 159 153 def random(): -
sasmodels/models/core_shell_parallelepiped.c
ra94046f ree60aa7 31 31 double thick_rim_a, double thick_rim_b, double thick_rim_c) 32 32 { 33 const double volume _paral= form_volume(length_a, length_b, length_c, thick_rim_a, thick_rim_b, thick_rim_c);34 return cbrt( 0.75*volume_paral/M_PI);33 const double volume = form_volume(length_a, length_b, length_c, thick_rim_a, thick_rim_b, thick_rim_c); 34 return cbrt(volume/M_4PI_3); 35 35 } 36 36 … … 45 45 effective_radius(int mode, double length_a, double length_b, double length_c, 46 46 double thick_rim_a, double thick_rim_b, double thick_rim_c) 47 //effective_radius_type = ["equivalent sphere","half outer length_a", "half outer length_b", "half outer length_c",48 // "equivalent circular cross-section","half outer ab diagonal","half outer diagonal"]49 // note the core box is A*B*C with slabs ta, tb & tc on each face but missing the corners, though that fact is ignored here50 // in the equvalent sphere option51 47 { 52 if (mode == 1) { 48 switch (mode) { 49 case 1: // equivalent sphere 53 50 return radius_from_volume(length_a, length_b, length_c, thick_rim_a, thick_rim_b, thick_rim_c); 54 } else if (mode == 2) {51 case 2: // half outer length a 55 52 return 0.5 * length_a + thick_rim_a; 56 } else if (mode == 3) {53 case 3: // half outer length b 57 54 return 0.5 * length_b + thick_rim_b; 58 } else if (mode == 4) {55 case 4: // half outer length c 59 56 return 0.5 * length_c + thick_rim_c; 60 } else if (mode == 5) {57 case 5: // equivalent circular cross-section 61 58 return radius_from_crosssection(length_a, length_b, thick_rim_a, thick_rim_b); 62 } else if (mode == 6) {59 case 6: // half outer ab diagonal 63 60 return 0.5*sqrt(square(length_a+ 2.0*thick_rim_a) + square(length_b+ 2.0*thick_rim_b)); 64 } else {61 case 7: // half outer diagonal 65 62 return 0.5*sqrt(square(length_a+ 2.0*thick_rim_a) + square(length_b+ 2.0*thick_rim_b) + square(length_c+ 2.0*thick_rim_c)); 66 63 } -
sasmodels/models/core_shell_parallelepiped.py
rd277229 ree60aa7 98 98 is the scattering length of the solvent. 99 99 100 .. note:: 100 .. note:: 101 101 102 102 the code actually implements two substitutions: $d(cos\alpha)$ is … … 227 227 source = ["lib/gauss76.c", "core_shell_parallelepiped.c"] 228 228 have_Fq = True 229 effective_radius_type = ["equivalent sphere","half outer length_a", "half outer length_b", "half outer length_c", 230 "equivalent circular cross-section","half outer ab diagonal","half outer diagonal"] 231 232 #def ER(length_a, length_b, length_c, thick_rim_a, thick_rim_b, thick_rim_c): 233 # """ 234 # Return equivalent radius (ER) 235 # """ 236 # from .parallelepiped import ER as ER_p 237 # 238 # a = length_a + 2*thick_rim_a 239 # b = length_b + 2*thick_rim_b 240 # c = length_c + 2*thick_rim_c 241 # return ER_p(a, b, c) 242 243 # VR defaults to 1.0 229 effective_radius_type = [ 230 "equivalent sphere", 231 "half outer length_a", "half outer length_b", "half outer length_c", 232 "equivalent circular cross-section", 233 "half outer ab diagonal", "half outer diagonal", 234 ] 244 235 245 236 def random(): -
sasmodels/models/core_shell_sphere.c
rd277229 ree60aa7 8 8 effective_radius(int mode, double radius, double thickness) 9 9 { 10 if (mode == 1) { 10 switch (mode) { 11 case 1: // outer radius 11 12 return radius + thickness; 12 } else {13 case 2: // core radius 13 14 return radius; 14 15 } -
sasmodels/models/core_shell_sphere.py
r2cc8aa2 ree60aa7 83 83 sld_core=1.0, sld_shell=2.0, sld_solvent=0.0) 84 84 85 #def ER(radius, thickness):86 # """87 # Equivalent radius88 # @param radius: core radius89 # @param thickness: shell thickness90 # """91 # return radius + thickness92 93 85 def random(): 94 86 outer_radius = 10**np.random.uniform(1.3, 4.3) -
sasmodels/models/cylinder.c
rd277229 ree60aa7 28 28 effective_radius(int mode, double radius, double length) 29 29 { 30 if (mode == 1) { 30 switch (mode) { 31 case 1: 31 32 return radius_from_volume(radius, length); 32 } else if (mode == 2) {33 case 2: 33 34 return radius; 34 } else if (mode == 3) {35 case 3: 35 36 return 0.5*length; 36 } else if (mode == 4) {37 case 4: 37 38 return (radius < 0.5*length ? radius : 0.5*length); 38 } else if (mode == 5) {39 case 5: 39 40 return (radius > 0.5*length ? radius : 0.5*length); 40 } else {41 case 6: 41 42 return radius_from_diagonal(radius,length); 42 43 } -
sasmodels/models/cylinder.py
rd277229 ree60aa7 139 139 source = ["lib/polevl.c", "lib/sas_J1.c", "lib/gauss76.c", "cylinder.c"] 140 140 have_Fq = True 141 effective_radius_type = ["equivalent sphere","radius","half length","half min dimension","half max dimension","half diagonal"] 142 143 #def ER(radius, length): 144 # """ 145 # Return equivalent radius (ER) 146 # """ 147 # ddd = 0.75 * radius * (2 * radius * length + (length + radius) * (length + pi * radius)) 148 # return 0.5 * (ddd) ** (1. / 3.) 141 effective_radius_type = [ 142 "equivalent sphere", "radius", 143 "half length", "half min dimension", "half max dimension", "half diagonal", 144 ] 149 145 150 146 def random(): -
sasmodels/models/ellipsoid.c
rd277229 ree60aa7 34 34 effective_radius(int mode, double radius_polar, double radius_equatorial) 35 35 { 36 if (mode == 1) { 36 switch (mode) { 37 case 1: // equivalent sphere 37 38 return radius_from_volume(radius_polar, radius_equatorial); 38 } else if (mode == 2) {39 case 2: // average curvature 39 40 return radius_from_curvature(radius_polar, radius_equatorial); 40 } else if (mode == 3) {41 case 3: // min radius 41 42 return (radius_polar < radius_equatorial ? radius_polar : radius_equatorial); 42 } else {43 case 4: // max radius 43 44 return (radius_polar > radius_equatorial ? radius_polar : radius_equatorial); 44 45 } -
sasmodels/models/ellipsoid.py
r2773c66 ree60aa7 169 169 source = ["lib/sas_3j1x_x.c", "lib/gauss76.c", "ellipsoid.c"] 170 170 have_Fq = True 171 effective_radius_type = ["equivalent sphere","average curvature", "min radius", "max radius"] 171 effective_radius_type = [ 172 "equivalent sphere", "average curvature", "min radius", "max radius", 173 ] 172 174 173 175 def random(): -
sasmodels/models/elliptical_cylinder.c
rfbaef04 ree60aa7 35 35 static double 36 36 effective_radius(int mode, double radius_minor, double r_ratio, double length) 37 //effective_radius_type = ["equivalent sphere","average radius","min radius","max radius",38 // "equivalent circular cross-section","half length","half min dimension","half max dimension","half diagonal"]39 37 { 40 if (mode == 1) { 38 switch (mode) { 39 case 1: // equivalent sphere 41 40 return radius_from_volume(radius_minor, r_ratio, length); 42 } else if (mode == 2) {41 case 2: // average radius 43 42 return 0.5*radius_minor*(1.0 + r_ratio); 44 } else if (mode == 3) {43 case 3: // min radius 45 44 return (r_ratio > 1.0 ? radius_minor : r_ratio*radius_minor); 46 } else if (mode == 4) {45 case 4: // max radius 47 46 return (r_ratio < 1.0 ? radius_minor : r_ratio*radius_minor); 48 } else if (mode == 5) {47 case 5: // equivalent circular cross-section 49 48 return sqrt(radius_minor*radius_minor*r_ratio); 50 } else if (mode == 6) {49 case 6: // half length 51 50 return 0.5*length; 52 } else if (mode == 7) {51 case 7: // half min dimension 53 52 return radius_from_min_dimension(radius_minor,r_ratio,0.5*length); 54 } else if (mode == 8) {53 case 8: // half max dimension 55 54 return radius_from_max_dimension(radius_minor,r_ratio,0.5*length); 56 } else {55 case 9: // half diagonal 57 56 return radius_from_diagonal(radius_minor,r_ratio,length); 58 57 } -
sasmodels/models/elliptical_cylinder.py
r2cc8aa2 ree60aa7 123 123 source = ["lib/polevl.c", "lib/sas_J1.c", "lib/gauss76.c", "elliptical_cylinder.c"] 124 124 have_Fq = True 125 effective_radius_type = ["equivalent sphere","average radius","min radius","max radius", 126 "equivalent circular cross-section","half length","half min dimension","half max dimension","half diagonal"] 125 effective_radius_type = [ 126 "equivalent sphere", "average radius", "min radius", "max radius", 127 "equivalent circular cross-section", 128 "half length", "half min dimension", "half max dimension", "half diagonal", 129 ] 127 130 128 131 demo = dict(scale=1, background=0, radius_minor=100, axis_ratio=1.5, length=400.0, 129 132 sld=4.0, sld_solvent=1.0, theta=10.0, phi=20, psi=30, 130 133 theta_pd=10, phi_pd=2, psi_pd=3) 131 132 #def ER(radius_minor, axis_ratio, length):133 # """134 # Equivalent radius135 # @param radius_minor: Ellipse minor radius136 # @param axis_ratio: Ratio of major radius over minor radius137 # @param length: Length of the cylinder138 # """139 # radius = sqrt(radius_minor * radius_minor * axis_ratio)140 # ddd = 0.75 * radius * (2 * radius * length141 # + (length + radius) * (length + pi * radius))142 # return 0.5 * (ddd) ** (1. / 3.)143 134 144 135 def random(): -
sasmodels/models/fuzzy_sphere.c
rd277229 ree60aa7 7 7 effective_radius(int mode, double radius, double fuzziness) 8 8 { 9 if (mode == 1) { 9 switch (mode) { 10 case 1: // radius 10 11 return radius; 11 } else {12 case 2: // radius + fuzziness 12 13 return radius + fuzziness; 13 14 } -
sasmodels/models/fuzzy_sphere.py
rd277229 ree60aa7 84 84 source = ["lib/sas_3j1x_x.c","fuzzy_sphere.c"] 85 85 have_Fq = True 86 effective_radius_type = ["radius","radius + fuzziness"] 87 88 #def ER(radius): 89 # """ 90 # Return radius 91 # """ 92 # return radius 93 94 # VR defaults to 1.0 86 effective_radius_type = ["radius", "radius + fuzziness"] 95 87 96 88 def random(): -
sasmodels/models/hollow_cylinder.c
rd277229 ree60aa7 15 15 } 16 16 17 // TODO: interface to form_volume/shell_volume not yet settled 18 static double 19 shell_volume(double *total, double radius, double thickness, double length) 20 { 21 *total = M_PI*length*square(radius+thickness); 22 return *total - M_PI*length*radius*radius; 23 } 24 17 25 static double 18 26 form_volume(double radius, double thickness, double length) 19 27 { 20 double v_shell = M_PI*length*(square(radius+thickness) - radius*radius);21 return v_shell;28 double total; 29 return shell_volume(&total, radius, thickness, length); 22 30 } 23 31 … … 38 46 effective_radius(int mode, double radius, double thickness, double length) 39 47 { 40 if (mode == 1) { 48 switch (mode) { 49 case 1: // equivalent sphere 41 50 return radius_from_volume(radius, thickness, length); 42 } else if (mode == 2) {51 case 2: // outer radius 43 52 return radius + thickness; 44 } else if (mode == 3) {53 case 3: // half length 45 54 return 0.5*length; 46 } else if (mode == 4) {55 case 4: // half outer min dimension 47 56 return (radius + thickness < 0.5*length ? radius + thickness : 0.5*length); 48 } else if (mode == 5) {57 case 5: // half outer max dimension 49 58 return (radius + thickness > 0.5*length ? radius + thickness : 0.5*length); 50 } else {59 case 6: // half outer diagonal 51 60 return radius_from_diagonal(radius,thickness,length); 52 61 } -
sasmodels/models/hollow_cylinder.py
r2cc8aa2 ree60aa7 100 100 source = ["lib/polevl.c", "lib/sas_J1.c", "lib/gauss76.c", "hollow_cylinder.c"] 101 101 have_Fq = True 102 effective_radius_type = ["equivalent sphere","outer radius","half length", 103 "half outer min dimension","half outer max dimension","half outer diagonal"] 104 105 # pylint: disable=W0613 106 #def ER(radius, thickness, length): 107 # """ 108 # :param radius: Cylinder core radius 109 # :param thickness: Cylinder wall thickness 110 # :param length: Cylinder length 111 # :return: Effective radius 112 # """ 113 # router = radius + thickness 114 # if router == 0 or length == 0: 115 # return 0.0 116 # len1 = router 117 # len2 = length/2.0 118 # term1 = len1*len1*2.0*len2/2.0 119 # term2 = 1.0 + (len2/len1)*(1.0 + 1/len2/2.0)*(1.0 + pi*len1/len2/2.0) 120 # ddd = 3.0*term1*term2 121 # diam = pow(ddd, (1.0/3.0)) 122 # return diam 123 124 def VR(radius, thickness, length): 125 """ 126 :param radius: Cylinder radius 127 :param thickness: Cylinder wall thickness 128 :param length: Cylinder length 129 :return: Volf ratio for P(q)*S(q) 130 """ 131 router = radius + thickness 132 vol_core = pi*radius*radius*length 133 vol_total = pi*router*router*length 134 vol_shell = vol_total - vol_core 135 return vol_total, vol_shell 102 effective_radius_type = [ 103 "equivalent sphere", "outer radius", "half length", 104 "half outer min dimension", "half outer max dimension", 105 "half outer diagonal", 106 ] 136 107 137 108 def random(): -
sasmodels/models/hollow_rectangular_prism.c
ra94046f ree60aa7 1 // TODO: interface to form_volume/shell_volume not yet settled 1 2 static double 2 form_volume(double length_a, double b2a_ratio, double c2a_ratio, double thickness)3 shell_volume(double *total, double length_a, double b2a_ratio, double c2a_ratio, double thickness) 3 4 { 4 5 double length_b = length_a * b2a_ratio; … … 8 9 double c_core = length_c - 2.0*thickness; 9 10 double vol_core = a_core * b_core * c_core; 10 double vol_total = length_a * length_b * length_c; 11 double vol_shell = vol_total - vol_core; 12 return vol_shell; 11 *total = length_a * length_b * length_c; 12 return *total - vol_core; 13 } 14 15 static double 16 form_volume(double length_a, double b2a_ratio, double c2a_ratio, double thickness) 17 { 18 double total; 19 return shell_volume(&total, length_a, b2a_ratio, c2a_ratio, thickness); 13 20 } 14 21 … … 19 26 // NOTE length_a is external dimension! 20 27 { 21 if (mode == 1) { 28 switch (mode) { 29 case 1: // equivalent sphere 22 30 return cbrt(0.75*cube(length_a)*b2a_ratio*c2a_ratio/M_PI); 23 } else if (mode == 2) {31 case 2: // half length_a 24 32 return 0.5 * length_a; 25 } else if (mode == 3) {33 case 3: // half length_b 26 34 return 0.5 * length_a*b2a_ratio; 27 } else if (mode == 4) {35 case 4: // half length_c 28 36 return 0.5 * length_a*c2a_ratio; 29 } else if (mode == 5) {37 case 5: // equivalent outer circular cross-section 30 38 return length_a*sqrt(b2a_ratio/M_PI); 31 } else if (mode == 6) {39 case 6: // half ab diagonal 32 40 return 0.5*sqrt(square(length_a) * (1.0 + square(b2a_ratio))); 33 } else {41 case 7: // half diagonal 34 42 return 0.5*sqrt(square(length_a) * (1.0 + square(b2a_ratio) + square(c2a_ratio))); 35 43 } -
sasmodels/models/hollow_rectangular_prism.py
rc44b611 ree60aa7 149 149 source = ["lib/gauss76.c", "hollow_rectangular_prism.c"] 150 150 have_Fq = True 151 effective_radius_type = ["equivalent sphere","half length_a", "half length_b", "half length_c", 152 "equivalent outer circular cross-section","half ab diagonal","half diagonal"] 153 154 #def ER(length_a, b2a_ratio, c2a_ratio, thickness): 155 # """ 156 # Return equivalent radius (ER) 157 # thickness parameter not used 158 # """ 159 # b_side = length_a * b2a_ratio 160 # c_side = length_a * c2a_ratio 161 # 162 # # surface average radius (rough approximation) 163 # surf_rad = sqrt(length_a * b_side / pi) 164 # 165 # ddd = 0.75 * surf_rad * (2 * surf_rad * c_side + (c_side + surf_rad) * (c_side + pi * surf_rad)) 166 # return 0.5 * (ddd) ** (1. / 3.) 167 168 def VR(length_a, b2a_ratio, c2a_ratio, thickness): 169 """ 170 Return shell volume and total volume 171 """ 172 b_side = length_a * b2a_ratio 173 c_side = length_a * c2a_ratio 174 a_core = length_a - 2.0*thickness 175 b_core = b_side - 2.0*thickness 176 c_core = c_side - 2.0*thickness 177 vol_core = a_core * b_core * c_core 178 vol_total = length_a * b_side * c_side 179 vol_shell = vol_total - vol_core 180 return vol_total, vol_shell 181 151 effective_radius_type = [ 152 "equivalent sphere", "half length_a", "half length_b", "half length_c", 153 "equivalent outer circular cross-section", 154 "half ab diagonal", "half diagonal", 155 ] 182 156 183 157 def random(): -
sasmodels/models/hollow_rectangular_prism_thin_walls.c
rd277229 ree60aa7 1 // TODO: interface to form_volume/shell_volume not yet settled 1 2 static double 2 form_volume(double length_a, double b2a_ratio, double c2a_ratio)3 shell_volume(double *total, double length_a, double b2a_ratio, double c2a_ratio) 3 4 { 4 5 double length_b = length_a * b2a_ratio; 5 6 double length_c = length_a * c2a_ratio; 6 7 double vol_shell = 2.0 * (length_a*length_b + length_a*length_c + length_b*length_c); 8 *total = length_a * length_b * length_c; 7 9 return vol_shell; 8 10 } 9 11 10 12 static double 13 form_volume(double length_a, double b2a_ratio, double c2a_ratio) 14 { 15 double total; 16 return shell_volume(&total, length_a, b2a_ratio, c2a_ratio); 17 } 18 19 20 static double 11 21 effective_radius(int mode, double length_a, double b2a_ratio, double c2a_ratio) 12 22 { 13 if (mode == 1) { 23 switch (mode) { 24 case 1: // equivalent sphere 14 25 return cbrt(0.75*cube(length_a)*b2a_ratio*c2a_ratio/M_PI); 15 } else if (mode == 2) {26 case 2: // half length_a 16 27 return 0.5 * length_a; 17 } else if (mode == 3) {28 case 3: // half length_b 18 29 return 0.5 * length_a*b2a_ratio; 19 } else if (mode == 4) {30 case 4: // half length_c 20 31 return 0.5 * length_a*c2a_ratio; 21 } else if (mode == 5) {32 case 5: // equivalent outer circular cross-section 22 33 return length_a*sqrt(b2a_ratio/M_PI); 23 } else if (mode == 6) {34 case 6: // half ab diagonal 24 35 return 0.5*sqrt(square(length_a) * (1.0 + square(b2a_ratio))); 25 } else {36 case 7: // half diagonal 26 37 return 0.5*sqrt(square(length_a) * (1.0 + square(b2a_ratio) + square(c2a_ratio))); 27 38 } -
sasmodels/models/hollow_rectangular_prism_thin_walls.py
rc44b611 ree60aa7 109 109 source = ["lib/gauss76.c", "hollow_rectangular_prism_thin_walls.c"] 110 110 have_Fq = True 111 effective_radius_type = ["equivalent sphere","half length_a", "half length_b", "half length_c", 112 "equivalent outer circular cross-section","half ab diagonal","half diagonal"] 113 114 #def ER(length_a, b2a_ratio, c2a_ratio): 115 # """ 116 # Return equivalent radius (ER) 117 # """ 118 # b_side = length_a * b2a_ratio 119 # c_side = length_a * c2a_ratio 120 # 121 # # surface average radius (rough approximation) 122 # surf_rad = sqrt(length_a * b_side / pi) 123 # 124 # ddd = 0.75 * surf_rad * (2 * surf_rad * c_side + (c_side + surf_rad) * (c_side + pi * surf_rad)) 125 # return 0.5 * (ddd) ** (1. / 3.) 126 127 def VR(length_a, b2a_ratio, c2a_ratio): 128 """ 129 Return shell volume and total volume 130 """ 131 b_side = length_a * b2a_ratio 132 c_side = length_a * c2a_ratio 133 vol_total = length_a * b_side * c_side 134 vol_shell = 2.0 * (length_a*b_side + length_a*c_side + b_side*c_side) 135 return vol_shell, vol_total 111 effective_radius_type = [ 112 "equivalent sphere", "half length_a", "half length_b", "half length_c", 113 "equivalent outer circular cross-section", 114 "half ab diagonal", "half diagonal", 115 ] 136 116 137 117 -
sasmodels/models/mono_gauss_coil.c
rd277229 ree60aa7 7 7 effective_radius(int mode, double rg) 8 8 { 9 if (mode == 1) { 9 switch (mode) { 10 case 1: // R_g 10 11 return rg; 11 } else if (mode == 2) {12 case 2: // 2R_g 12 13 return 2.0*rg; 13 } else if (mode == 3) {14 case 3: // 3R_g 14 15 return 3.0*rg; 15 } else {16 case 4: // (5/3)^0.5*R_g 16 17 return sqrt(5.0/3.0)*rg; 17 18 } 18 19 } 19 20 21 static double 22 gauss_coil(double qr) 23 { 24 const double x = qr*qr; 25 26 // Use series expansion at low q for higher accuracy. We could use 27 // smaller polynomials if we sacrifice some digits of precision or 28 // introduce an additional series expansion around x == 1. 29 // See explore/precision.py, gauss_coil function. 30 #if FLOAT_SIZE>4 // DOUBLE_PRECISION 31 // For double precision: use O(5) Pade with 0.5 cutoff (10 mad + 1 divide) 32 if (x < 0.5) { 33 // PadeApproximant[2*Exp[-x^2] + x^2-1)/x^4, {x, 0, 8}] 34 const double A1=1./12., A2=2./99., A3=1./2640., A4=1./23760., A5=-1./1995840.; 35 const double B1=5./12., B2=5./66., B3=1./132., B4=1./2376., B5=1./95040.; 36 return (((((A5*x + A4)*x + A3)*x + A2)*x + A1)*x + 1.) 37 / (((((B5*x + B4)*x + B3)*x + B2)*x + B1)*x + 1.); 38 } 39 #else 40 // For single precision: use O(7) Taylor with 0.8 cutoff (7 mad) 41 if (x < 0.8) { 42 const double C0 = +1.; 43 const double C1 = -1./3.; 44 const double C2 = +1./12.; 45 const double C3 = -1./60.; 46 const double C4 = +1./360.; 47 const double C5 = -1./2520.; 48 const double C6 = +1./20160.; 49 const double C7 = -1./181440.; 50 return ((((((C7*x + C6)*x + C5)*x + C4)*x + C3)*x + C2)*x + C1)*x + C0; 51 } 52 #endif 53 54 return 2.0 * (expm1(-x) + x)/(x*x); 55 } 56 20 57 double Iq(double q, double i_zero, double rg) 21 58 { 22 const double uarg = square(q*rg); 23 const double inten; 24 if (q == 0) { 25 inten = i_zero; 26 } else { 27 inten = 2.0*i_zero * (exp(-uarg) + uarg - 1.0)/square(uarg); 28 } 29 30 return inten; 59 return i_zero * gauss_coil(q*rg); 31 60 } -
sasmodels/models/mono_gauss_coil.py
rd277229 ree60aa7 71 71 ["rg", "Ang", 75.0, [0.0, inf], "volume", "Radius of gyration"], 72 72 ] 73 # pylint: enable=bad-whitespace, line-too-long 73 74 74 75 source = ["mono_gauss_coil.c"] 75 76 have_Fq = False 76 effective_radius_type = ["R_g", "2R_g","3R_g","(5/3)^0.5*R_g"]77 effective_radius_type = ["R_g", "2R_g", "3R_g", "(5/3)^0.5*R_g"] 77 78 78 79 # pylint: enable=bad-whitespace, line-too-long80 81 ## NB: Scale and Background are implicit parameters on every model82 #def Iq(q, i_zero, rg):83 # # pylint: disable = missing-docstring84 # z = (q * rg)**285 #86 # with errstate(invalid='ignore'):87 # inten = (i_zero * 2.0) * (exp(-z) + z - 1.0)/z**288 # inten[q == 0] = i_zero89 # return inten90 #Iq.vectorized = True # Iq accepts an array of q values91 79 92 80 def random(): -
sasmodels/models/multilayer_vesicle.c
rd277229 ree60aa7 50 50 effective_radius(int mode, double radius, double thick_shell, double thick_solvent, double fp_n_shells) 51 51 { 52 // case 1: outer radius 52 53 return radius + fp_n_shells*thick_shell + (fp_n_shells - 1.0)*thick_solvent; 53 54 } -
sasmodels/models/multilayer_vesicle.py
rd277229 ree60aa7 148 148 effective_radius_type = ["outer radius"] 149 149 150 #def ER(radius, thick_shell, thick_solvent, n_shells):151 # n_shells = int(n_shells+0.5)152 # return radius + n_shells * (thick_shell + thick_solvent) - thick_solvent153 154 150 def random(): 155 151 volfraction = 10**np.random.uniform(-3, -0.5) # scale from 0.1% to 30% -
sasmodels/models/onion.c
rd277229 ree60aa7 30 30 31 31 static double 32 form_volume(double radius_core, double n_shells, double thickness[]) 33 { 34 int n = (int)(n_shells+0.5); 35 double r = radius_core; 36 for (int i=0; i < n; i++) { 37 r += thickness[i]; 38 } 39 return M_4PI_3*cube(r); 40 } 41 42 static double 43 effective_radius(int mode, double radius_core, double n_shells, double thickness[]) 32 outer_radius(double radius_core, double n_shells, double thickness[]) 44 33 { 45 34 int n = (int)(n_shells+0.5); … … 49 38 } 50 39 return r; 40 } 41 42 static double 43 form_volume(double radius_core, double n_shells, double thickness[]) 44 { 45 return M_4PI_3*cube(outer_radius(radius_core, n_shells, thickness)); 46 } 47 48 static double 49 effective_radius(int mode, double radius_core, double n_shells, double thickness[]) 50 { 51 // case 1: outer radius 52 return outer_radius(radius_core, n_shells, thickness); 51 53 } 52 54 -
sasmodels/models/onion.py
rd277229 ree60aa7 367 367 return np.asarray(z), np.asarray(rho) 368 368 369 #def ER(radius_core, n_shells, thickness):370 # """Effective radius"""371 # n = int(n_shells[0]+0.5)372 # return np.sum(thickness[:n], axis=0) + radius_core373 374 369 demo = { 375 370 "sld_solvent": 2.2, -
sasmodels/models/parallelepiped.c
rd277229 ree60aa7 8 8 effective_radius(int mode, double length_a, double length_b, double length_c) 9 9 { 10 if (mode == 1) { 10 switch (mode) { 11 case 1: // equivalent sphere 11 12 return cbrt(0.75*length_a*length_b*length_c/M_PI); 12 } else if (mode == 2) {13 case 2: // half length_a 13 14 return 0.5 * length_a; 14 } else if (mode == 3) {15 case 3: // half length_b 15 16 return 0.5 * length_b; 16 } else if (mode == 4) {17 case 4: // half length_c 17 18 return 0.5 * length_c; 18 } else if (mode == 5) {19 case 5: // equivalent circular cross-section 19 20 return sqrt(length_a*length_b/M_PI); 20 } else if (mode == 6) {21 case 6: // half ab diagonal 21 22 return 0.5*sqrt(length_a*length_a + length_b*length_b); 22 } else {23 case 7: // half diagonal 23 24 return 0.5*sqrt(length_a*length_a + length_b*length_b + length_c*length_c); 24 25 } 25 26 } 26 27 27 28 28 static void -
sasmodels/models/parallelepiped.py
rd277229 ree60aa7 140 140 ensuring that the inequality $A < B < C$ is not violated, The calculation 141 141 will not report an error, but the results may be not correct. 142 142 143 143 .. _parallelepiped-orientation: 144 144 … … 231 231 source = ["lib/gauss76.c", "parallelepiped.c"] 232 232 have_Fq = True 233 effective_radius_type = ["equivalent sphere","half length_a", "half length_b", "half length_c", 234 "equivalent circular cross-section","half ab diagonal","half diagonal"] 235 236 #def ER(length_a, length_b, length_c): 237 # """ 238 # Return effective radius (ER) for P(q)*S(q) 239 # """ 240 # # now that axes can be in any size order, need to sort a,b,c 241 # # where a~b and c is either much smaller or much larger 242 # abc = np.vstack((length_a, length_b, length_c)) 243 # abc = np.sort(abc, axis=0) 244 # selector = (abc[1] - abc[0]) > (abc[2] - abc[1]) 245 # length = np.where(selector, abc[0], abc[2]) 246 # # surface average radius (rough approximation) 247 # radius = sqrt(np.where(~selector, abc[0]*abc[1], abc[1]*abc[2]) / pi) 248 # 249 # ddd = 0.75 * radius * (2*radius*length + (length + radius)*(length + pi*radius)) 250 # return 0.5 * (ddd) ** (1. / 3.) 251 252 # VR defaults to 1.0 253 233 effective_radius_type = [ 234 "equivalent sphere", "half length_a", "half length_b", "half length_c", 235 "equivalent circular cross-section", "half ab diagonal", "half diagonal", 236 ] 254 237 255 238 def random(): -
sasmodels/models/pringle.c
rd277229 ree60aa7 107 107 effective_radius(int mode, double radius, double thickness, double alpha, double beta) 108 108 { 109 if (mode == 1) { 109 switch (mode) { 110 case 1: // equivalent sphere 110 111 return cbrt(0.75*radius*radius*thickness); 111 } else {112 case 2: // radius 112 113 return radius; 113 114 } -
sasmodels/models/pringle.py
rd277229 ree60aa7 72 72 73 73 74 source = ["lib/polevl.c", "lib/sas_J0.c", "lib/sas_J1.c", \74 source = ["lib/polevl.c", "lib/sas_J0.c", "lib/sas_J1.c", 75 75 "lib/sas_JN.c", "lib/gauss76.c", "pringle.c"] 76 effective_radius_type = ["equivalent sphere","radius"] 77 78 #def ER(radius, thickness, alpha, beta): 79 # """ 80 # Return equivalent radius (ER) 81 # """ 82 # ddd = 0.75 * radius * (2 * radius * thickness + (thickness + radius) \ 83 # * (thickness + pi * radius)) 84 # return 0.5 * (ddd) ** (1. / 3.) 76 effective_radius_type = ["equivalent sphere", "radius"] 85 77 86 78 def random(): -
sasmodels/models/raspberry.c
rd277229 ree60aa7 17 17 effective_radius(int mode, double radius_lg, double radius_sm, double penetration) 18 18 { 19 if (mode == 1) { 19 switch (mode) { 20 case 1: // radius_large 20 21 return radius_lg; 21 } else {22 case 2: // radius_outer 22 23 return radius_lg + 2.0*radius_sm - penetration; 23 24 } -
sasmodels/models/raspberry.py
rd277229 ree60aa7 152 152 153 153 source = ["lib/sas_3j1x_x.c", "raspberry.c"] 154 effective_radius_type = ["radius_large", "radius_outer"]154 effective_radius_type = ["radius_large", "radius_outer"] 155 155 156 156 def random(): -
sasmodels/models/rectangular_prism.c
rd277229 ree60aa7 8 8 effective_radius(int mode, double length_a, double b2a_ratio, double c2a_ratio) 9 9 { 10 if (mode == 1) { 10 switch (mode) { 11 case 1: // equivalent sphere 11 12 return cbrt(0.75*cube(length_a)*b2a_ratio*c2a_ratio/M_PI); 12 } else if (mode == 2) {13 case 2: // half length_a 13 14 return 0.5 * length_a; 14 } else if (mode == 3) {15 case 3: // half length_b 15 16 return 0.5 * length_a*b2a_ratio; 16 } else if (mode == 4) {17 case 4: // half length_c 17 18 return 0.5 * length_a*c2a_ratio; 18 } else if (mode == 5) {19 case 5: // equivalent circular cross-section 19 20 return length_a*sqrt(b2a_ratio/M_PI); 20 } else if (mode == 6) {21 case 6: // half ab diagonal 21 22 return 0.5*sqrt(square(length_a) * (1.0 + square(b2a_ratio))); 22 } else {23 case 7: // half diagonal 23 24 return 0.5*sqrt(square(length_a) * (1.0 + square(b2a_ratio) + square(c2a_ratio))); 24 25 } -
sasmodels/models/rectangular_prism.py
rd277229 ree60aa7 136 136 source = ["lib/gauss76.c", "rectangular_prism.c"] 137 137 have_Fq = True 138 effective_radius_type = ["equivalent sphere","half length_a", "half length_b", "half length_c", 139 "equivalent circular cross-section","half ab diagonal","half diagonal"] 140 141 #def ER(length_a, b2a_ratio, c2a_ratio): 142 # """ 143 # Return equivalent radius (ER) 144 # """ 145 # b_side = length_a * b2a_ratio 146 # c_side = length_a * c2a_ratio 147 # 148 # # surface average radius (rough approximation) 149 # surf_rad = sqrt(length_a * b_side / pi) 150 # 151 # ddd = 0.75 * surf_rad * (2 * surf_rad * c_side + (c_side + surf_rad) * (c_side + pi * surf_rad)) 152 # return 0.5 * (ddd) ** (1. / 3.) 138 effective_radius_type = [ 139 "equivalent sphere", "half length_a", "half length_b", "half length_c", 140 "equivalent circular cross-section", "half ab diagonal", "half diagonal", 141 ] 153 142 154 143 def random(): -
sasmodels/models/sphere.c
rd277229 ree60aa7 7 7 effective_radius(int mode, double radius) 8 8 { 9 // case 1: radius 9 10 return radius; 10 11 } -
sasmodels/models/sphere.py
r2cc8aa2 ree60aa7 71 71 effective_radius_type = ["radius"] 72 72 73 #def ER(radius):74 # """75 # Return equivalent radius (ER)76 # """77 # return radius78 79 # VR defaults to 1.080 81 73 def random(): 82 74 radius = 10**np.random.uniform(1.3, 4) -
sasmodels/models/spherical_sld.c
rd277229 ree60aa7 1 static double form_volume(2 double fp_n_shells,3 double thickness[],4 double interface[])5 {6 int n_shells= (int)(fp_n_shells + 0.5);7 double r = 0.0;8 for (int i=0; i < n_shells; i++) {9 r += thickness[i] + interface[i];10 }11 return M_4PI_3*cube(r);12 }13 14 1 static double 15 effective_radius(int mode,double fp_n_shells, double thickness[], double interface[])2 outer_radius(double fp_n_shells, double thickness[], double interface[]) 16 3 { 17 4 int n_shells= (int)(fp_n_shells + 0.5); … … 21 8 } 22 9 return r; 10 } 11 12 static double form_volume( 13 double fp_n_shells, 14 double thickness[], 15 double interface[]) 16 { 17 return M_4PI_3*cube(outer_radius(fp_n_shells, thickness, interface)); 18 } 19 20 static double 21 effective_radius(int mode, double fp_n_shells, double thickness[], double interface[]) 22 { 23 // case 1: outer radius 24 return outer_radius(fp_n_shells, thickness, interface); 23 25 } 24 26 -
sasmodels/models/spherical_sld.py
re8eff7b ree60aa7 22 22 23 23 0: erf($\nu z$) 24 24 25 25 1: Rpow($z^\nu$) 26 26 27 27 2: Lpow($z^\nu$) 28 28 29 29 3: Rexp($-\nu z$) 30 30 31 31 4: Lexp($-\nu z$) 32 32 … … 270 270 271 271 272 #def ER(n_shells, thickness, interface):273 # """Effective radius"""274 # n_shells = int(n_shells + 0.5)275 # total = (np.sum(thickness[:n_shells], axis=1)276 # + np.sum(interface[:n_shells], axis=1))277 # return total278 279 280 272 demo = { 281 273 "n_shells": 5, -
sasmodels/models/triaxial_ellipsoid.c
rd277229 ree60aa7 30 30 effective_radius(int mode, double radius_equat_minor, double radius_equat_major, double radius_polar) 31 31 { 32 if (mode == 1) { 32 switch (mode) { 33 case 1: // equivalent sphere 33 34 return radius_from_volume(radius_equat_minor,radius_equat_major, radius_polar); 34 } else if (mode == 2) {35 case 2: // min radius 35 36 return radius_from_min_dimension(radius_equat_minor,radius_equat_major, radius_polar); 36 } else {37 case 3: // max radius 37 38 return radius_from_max_dimension(radius_equat_minor,radius_equat_major, radius_polar); 38 39 } -
sasmodels/models/triaxial_ellipsoid.py
rd277229 ree60aa7 158 158 source = ["lib/sas_3j1x_x.c", "lib/gauss76.c", "triaxial_ellipsoid.c"] 159 159 have_Fq = True 160 effective_radius_type = ["equivalent sphere","min radius", "max radius"] 161 162 def ER(radius_equat_minor, radius_equat_major, radius_polar): 163 """ 164 Returns the effective radius used in the S*P calculation 165 """ 166 from .ellipsoid import ER as ellipsoid_ER 167 168 # now that radii can be in any size order, radii need sorting a,b,c 169 # where a~b and c is either much smaller or much larger 170 radii = np.vstack((radius_equat_major, radius_equat_minor, radius_polar)) 171 radii = np.sort(radii, axis=0) 172 selector = (radii[1] - radii[0]) > (radii[2] - radii[1]) 173 polar = np.where(selector, radii[0], radii[2]) 174 equatorial = np.sqrt(np.where(~selector, radii[0]*radii[1], radii[1]*radii[2])) 175 return ellipsoid_ER(polar, equatorial) 160 effective_radius_type = ["equivalent sphere", "min radius", "max radius"] 176 161 177 162 def random(): -
sasmodels/models/vesicle.c
rd277229 ree60aa7 1 // TODO: interface to form_volume/shell_volume not yet settled 2 static double 3 shell_volume(double *total, double radius, double thickness) 4 { 5 //note that for the vesicle model, the volume is ONLY the shell volume 6 *total = M_4PI_3 * cube(radius+thickness); 7 return *total - M_4PI_3*cube(radius); 8 } 9 1 10 static double 2 11 form_volume(double radius, double thickness) 3 12 { 4 13 //note that for the vesicle model, the volume is ONLY the shell volume 5 return M_4PI_3*(cube(radius+thickness) - cube(radius)); 14 double total; 15 return shell_volume(&total, radius, thickness); 6 16 } 7 17 … … 9 19 effective_radius(int mode, double radius, double thickness) 10 20 { 21 // case 1: outer radius 11 22 return radius + thickness; 12 23 } -
sasmodels/models/vesicle.py
r2cc8aa2 ree60aa7 102 102 effective_radius_type = ["outer radius"] 103 103 104 #def ER(radius, thickness):105 # '''106 # returns the effective radius used in the S*P calculation107 #108 # :param radius: core radius109 # :param thickness: shell thickness110 # '''111 # return radius + thickness112 113 def VR(radius, thickness):114 '''115 returns the volumes of the shell and of the whole sphere including the116 core plus shell - is used to normalize when including polydispersity.117 118 :param radius: core radius119 :param thickness: shell thickness120 :return whole: volume of core and shell121 :return whole-core: volume of the shell122 '''123 124 whole = 4./3. * pi * (radius + thickness)**3125 core = 4./3. * pi * radius**3126 return whole, whole - core127 128 104 def random(): 129 105 total_radius = 10**np.random.uniform(1.3, 5)
Note: See TracChangeset
for help on using the changeset viewer.