- Timestamp:
- Sep 2, 2014 1:15:40 PM (10 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:
- 87985ca
- Parents:
- 5d4777d
- Location:
- sasmodels
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
sasmodels/convert.py
r5d4777d rf4cf580 37 37 name='sphere', 38 38 sldSph='sld', sldSolv='solvent_sld', 39 #radius='radius', # DO NOT LIST IDENTICAL PARAMETERS!39 radius='radius', # listing identical parameters is optional 40 40 ), 41 41 } … … 59 59 newpars = pars.copy() 60 60 for old,new in mapping.items(): 61 if old == new: continue 61 62 # Bumps style parameter names 62 63 for variant in ("", "_pd", "_pd_n", "_pd_nsigma", "_pd_type"): -
sasmodels/gen.py
r5d4777d rf4cf580 352 352 const real I = %(fn)s(%(qcall)s, %(pcall)s); 353 353 if (I>=REAL(0.0)) { // scattering cannot be negative 354 ret += weight*I ;354 ret += weight*I%(sasview_spherical)s; 355 355 norm += weight; 356 356 %(volume_norm)s … … 364 364 SPHERICAL_CORRECTION="""\ 365 365 // Correction factor for spherical integration p(theta) I(q) sin(theta) dtheta 366 real spherical_correction = (Ntheta>1 ? fabs(cos(M_PI_180*phi)) : REAL(1.0));\ 366 real spherical_correction = (Ntheta>1 ? fabs(sin(M_PI_180*theta)) : REAL(1.0));\ 367 """ 368 # Use this to reproduce sasview behaviour 369 SASVIEW_SPHERICAL_CORRECTION="""\ 370 // Correction factor for spherical integration p(theta) I(q) sin(theta) dtheta 371 real spherical_correction = (Ntheta>1 ? fabs(cos(M_PI_180*theta))*M_PI_2 : REAL(1.0));\ 367 372 """ 368 373 … … 472 477 fq_pars = [p[0] for p in info['parameters'][len(COMMON_PARAMETERS):] 473 478 if p[0] in set(fixed_pars+pd_pars)] 474 if False and " phi" in pd_pars:479 if False and "theta" in pd_pars: 475 480 spherical_correction = [indent(SPHERICAL_CORRECTION, depth)] 476 481 weights = [p+"_w" for p in pd_pars]+['spherical_correction'] 482 sasview_spherical = "" 483 elif "theta" in pd_pars: 484 spherical_correction = [indent(SASVIEW_SPHERICAL_CORRECTION,depth)] 485 weights = [p+"_w" for p in pd_pars] 486 sasview_spherical = "*spherical_correction" 477 487 else: 478 488 spherical_correction = [] 479 489 weights = [p+"_w" for p in pd_pars] 490 sasview_spherical = "" 480 491 subst = { 481 492 'weight_product': "*".join(weights), … … 484 495 'qcall': q_pars['qcall'], 485 496 'pcall': ", ".join(fq_pars), # skip scale and background 497 'sasview_spherical': sasview_spherical, 486 498 } 487 499 loop_body = [indent(LOOP_BODY%subst, depth)] -
sasmodels/gpu.py
r5d4777d rf4cf580 22 22 devices, where it can be combined with other structure factors and form 23 23 factors and have instrumental resolution effects applied. 24 25 26 24 """ 27 25 import numpy as np … … 59 57 source, info = gen.make(kernel_module) 60 58 ## for debugging, save source to a .cl file, edit it, and reload as model 61 open(info['name']+'.cl','w').write(source)59 #open(info['name']+'.cl','w').write(source) 62 60 #source = open(info['name']+'.cl','r').read() 63 61 return GpuModel(source, info, dtype) -
sasmodels/models/capped_cylinder.c
r5d4777d rf4cf580 22 22 const real upper = REAL(1.0); 23 23 const real lower = h/cap_radius; // integral lower bound 24 const real m = q*cos_alpha*cap_radius; // cos argument slope 25 const real b = q*cos_alpha*(REAL(0.5)*length-h); // cos argument intercept 26 const real qrst = q*sin_alpha*cap_radius; // Q*R*sin(theta) 24 // cos term in integral is: 25 // cos (q (R t - h + L/2) cos(alpha)) 26 // so turn it into: 27 // cos (m t + b) 28 // where: 29 // m = q R cos(alpha) 30 // b = q(L/2-h) cos(alpha) 31 const real m = q*cap_radius*cos_alpha; // cos argument slope 32 const real b = q*(REAL(0.5)*length-h)*cos_alpha; // cos argument intercept 33 const real qrst = q*cap_radius*sin_alpha; // Q*R*sin(theta) 27 34 real total = REAL(0.0); 28 35 for (int i=0; i<76 ;i++) { … … 31 38 const real t = REAL(0.5)*(Gauss76Z[i]*(upper-lower)+upper+lower); 32 39 const real radical = REAL(1.0) - t*t; 33 const real caparg = qrst*sqrt(radical); // cap bessel function arg34 const real be = ( caparg == REAL(0.0) ? REAL(0.5) : J1(caparg)/caparg);40 const real arg = qrst*sqrt(radical); // cap bessel function arg 41 const real be = (arg == REAL(0.0) ? REAL(0.5) : J1(arg)/arg); 35 42 const real Fq = cos(m*t + b) * radical * be; 36 43 total += Gauss76Wt[i] * Fq; … … 84 91 // faster since we don't multiply and divide sin(alpha). 85 92 const real besarg = q*radius*sn; 86 const real siarg = REAL(0.5)*q*length*cn;93 const real siarg = q*REAL(0.5)*length*cn; 87 94 // lim_{x->0} J1(x)/x = 1/2, lim_{x->0} sin(x)/x = 1 88 95 const real bj = (besarg == REAL(0.0) ? REAL(0.5) : J1(besarg)/besarg); … … 131 138 const real cap_Fq = _cap_kernel(q, h, cap_radius, length, sn, cn); 132 139 133 // The following is CylKernel() / sin(alpha), but we are doing it in place134 // to avoid sin(alpha)/sin(alpha) for alpha = 0. It is also a teensy bit135 // faster since we don't multiply and divide sin(alpha).136 140 const real besarg = q*radius*sn; 137 const real siarg = REAL(0.5)*q*length*cn;141 const real siarg = q*REAL(0.5)*length*cn; 138 142 // lim_{x->0} J1(x)/x = 1/2, lim_{x->0} sin(x)/x = 1 139 143 const real bj = (besarg == REAL(0.0) ? REAL(0.5) : J1(besarg)/besarg); -
sasmodels/models/capped_cylinder.py
r5d4777d rf4cf580 1 1 r""" 2 2 Calculates the scattering from a cylinder with spherical section end-caps. 3 This model simply becomes the `convex_lens`_when the length of the cylinder3 This model simply becomes the a convex lens when the length of the cylinder 4 4 $L=0$, that is, a sphereocylinder with end caps that have a radius larger 5 5 than that of the cylinder and the center of the end cap radius lies within … … 128 128 [ "radius", "Ang", 20, [0, inf], "volume", 129 129 "Cylinder radius" ], 130 # TODO: use an expression for cap radius with fixed bounds. 131 # The current form requires cap radius R bigger than cylinder radius r. 132 # Could instead use R/r in [1,inf], r/R in [0,1], or the angle between 133 # cylinder and cap in [0,90]. The problem is similar for the barbell 134 # model. Propose r/R in [0,1] in both cases, with the model specifying 135 # cylinder radius in the capped cylinder model and sphere radius in the 136 # barbell model. This leads to the natural value of zero for no cap 137 # in the capped cylinder, and zero for no bar in the barbell model. In 138 # both models, one would be a pill. 130 139 [ "cap_radius", "Ang", 20, [0, inf], "volume", 131 140 "Cap radius" ], -
sasmodels/models/sphere.py
r5d4777d rf4cf580 30 30 31 31 Iq = """ 32 const real qr = q*radius; 32 33 real sn, cn; 33 const real qr = q*radius;34 34 SINCOS(qr, sn, cn); 35 const real bes = (qr==REAL(0.0) ? REAL(1.0) : (REAL(3.0)*(sn-qr*cn))/(qr*qr*qr));36 const real f = bes * (sld - solvent_sld) * form_volume(radius);37 return REAL(1.0e-4)*f *f;35 const real bes = qr==REAL(0.0) ? REAL(1.0) : REAL(3.0)*(sn-qr*cn)/(qr*qr*qr); 36 const real fq = bes * (sld - solvent_sld) * form_volume(radius); 37 return REAL(1.0e-4)*fq*fq; 38 38 """ 39 39
Note: See TracChangeset
for help on using the changeset viewer.