Changeset 6831fa0 in sasmodels
- Timestamp:
- Oct 14, 2016 5:18:34 PM (8 years ago)
- Branches:
- master, core_shell_microgels, costrafo411, magnetic_model, ticket-1257-vesicle-product, ticket_1156, ticket_1265_superball, ticket_822_more_unit_tests
- Children:
- b716cc6
- Parents:
- 87bc707
- Location:
- sasmodels
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
sasmodels/compare.py
r9068f4c r6831fa0 38 38 from . import core 39 39 from . import kerneldll 40 from . import weights40 from . import exception 41 41 from .data import plot_theory, empty_data1D, empty_data2D 42 42 from .direct_model import DirectModel … … 45 45 try: 46 46 from typing import Optional, Dict, Any, Callable, Tuple 47 except :47 except Exception: 48 48 pass 49 49 else: … … 466 466 if k.endswith('.type'): 467 467 par = k[:-5] 468 if v == 'gaussian': continue 468 469 cls = dispersers[v if v != 'rectangle' else 'rectangula'] 469 470 handle = cls() 470 471 model[0].disperser_handles[par] = handle 471 model[0].set_dispersion(par, handle) 472 try: 473 model[0].set_dispersion(par, handle) 474 except Exception: 475 exception.annotate_exception("while setting %s to %r" 476 %(par, v)) 477 raise 478 472 479 473 480 #print("sasview pars",oldpars) -
sasmodels/conversion_table.py
r5f1acda r6831fa0 729 729 "theta": "axis_theta", 730 730 "sld_solvent": "solvent_sld", 731 "n_stacking": "n_stacking" 731 "n_stacking": "n_stacking", 732 "thick_layer": "layer_thick", 733 "thick_core": "core_thick", 732 734 } 733 735 ], -
sasmodels/models/stacked_disks.c
r0d6e865 r6831fa0 14 14 double solvent_sld); 15 15 16 double Iqxy(double qx, double qy, 17 double thick_core, 18 double thick_layer, 19 double radius, 20 double n_stacking, 21 double sigma_dnn, 22 double core_sld, 23 double layer_sld, 24 double solvent_sld, 25 double theta, 26 double phi); 27 16 28 static 17 29 double _kernel(double qq, … … 22 34 double halfheight, 23 35 double thick_layer, 24 double zi, 36 double sin_alpha, 37 double cos_alpha, 25 38 double sigma_dnn, 26 39 double d, … … 34 47 // zi is the dummy variable for the integration (x in Feigin's notation) 35 48 36 const double besarg1 = qq*radius*sin (zi);37 const double besarg2 = qq*radius*sin(zi);49 const double besarg1 = qq*radius*sin_alpha; 50 //const double besarg2 = qq*radius*sin_alpha; 38 51 39 const double sinarg1 = qq*halfheight*cos (zi);40 const double sinarg2 = qq*(halfheight+thick_layer)*cos (zi);52 const double sinarg1 = qq*halfheight*cos_alpha; 53 const double sinarg2 = qq*(halfheight+thick_layer)*cos_alpha; 41 54 42 55 const double be1 = sas_J1c(besarg1); 43 const double be2 = sas_J1c(besarg2); 44 const double si1 = sin(sinarg1)/sinarg1; 45 const double si2 = sin(sinarg2)/sinarg2; 56 //const double be2 = sas_J1c(besarg2); 57 const double be2 = be1; 58 const double si1 = sinc(sinarg1); 59 const double si2 = sinc(sinarg2); 46 60 47 61 const double dr1 = (core_sld-solvent_sld); 48 62 const double dr2 = (layer_sld-solvent_sld); 49 63 const double area = M_PI*radius*radius; 50 const double totald =2.0*(thick_layer+halfheight);64 const double totald = 2.0*(thick_layer+halfheight); 51 65 52 66 const double t1 = area*(2.0*halfheight)*dr1*(si1)*(be1); … … 54 68 55 69 56 double retval =((t1+t2)*(t1+t2)) *sin(zi);70 double retval =((t1+t2)*(t1+t2)); 57 71 58 72 // loop for the structure facture S(q) 59 73 double sqq=0.0; 60 74 for(int kk=1;kk<n_stacking;kk+=1) { 61 double dexpt=qq*cos(zi)*qq*cos(zi)*d*d*sigma_dnn*sigma_dnn*kk/2.0; 62 sqq=sqq+(n_stacking-kk)*cos(qq*cos(zi)*d*kk)*exp(-1.*dexpt); 75 double qd_cos_alpha = qq*d*cos_alpha; 76 double dexpt=square(qd_cos_alpha*sigma_dnn)*kk/2.0; 77 sqq += (n_stacking-kk)*cos(qd_cos_alpha*kk)*exp(-1.*dexpt); 63 78 } 64 65 79 // end of loop for S(q) 66 80 sqq=1.0+2.0*sqq/n_stacking; 67 81 68 retval *= sqq; 69 70 return(retval); 82 return retval * sqq; 71 83 } 72 84 … … 88 100 double summ = 0.0; //initialize integral 89 101 90 double d =2.0*thick_layer+thick_core;91 double halfheight = thick_core/2.0;102 double d = 2.0*thick_layer+thick_core; 103 double halfheight = 0.5*thick_core; 92 104 93 for(int i=0;i<N_POINTS_76;i++) { 94 double zi = (Gauss76Z[i] + 1.0)*M_PI/4.0; 95 double yyy = Gauss76Wt[i] * 96 _kernel(q, 105 for(int i=0; i<N_POINTS_76; i++) { 106 double zi = (Gauss76Z[i] + 1.0)*M_PI_4; 107 double sin_alpha, cos_alpha; // slots to hold sincos function output 108 SINCOS(zi, sin_alpha, cos_alpha); 109 double yyy = _kernel(q, 97 110 radius, 98 111 core_sld, … … 101 114 halfheight, 102 115 thick_layer, 103 zi, 116 sin_alpha, 117 cos_alpha, 104 118 sigma_dnn, 105 119 d, 106 120 n_stacking); 107 summ += yyy;121 summ += Gauss76Wt[i] * yyy * sin_alpha; 108 122 } 109 123 110 double answer = M_PI /4.0*summ;124 double answer = M_PI_4*summ; 111 125 112 126 //Convert to [cm-1] … … 116 130 } 117 131 118 static double stacked_disks_kernel_2d(double q, double q_x, double q_y,119 double thick_core,120 double thick_layer,121 double radius,122 double n_stacking,123 double sigma_dnn,124 double core_sld,125 double layer_sld,126 double solvent_sld,127 double theta,128 double phi)129 {130 131 double ct, st, cp, sp;132 133 //convert angle degree to radian134 theta = theta * M_PI/180.0;135 phi = phi * M_PI/180.0;136 137 SINCOS(theta, st, ct);138 SINCOS(phi, sp, cp);139 140 // silence compiler warnings about unused variable141 (void) sp;142 143 // parallelepiped orientation144 const double cyl_x = st * cp;145 const double cyl_y = st * sp;146 147 // Compute the angle btw vector q and the148 // axis of the parallelepiped149 const double cos_val = cyl_x*q_x + cyl_y*q_y;150 151 // Note: cos(alpha) = 0 and 1 will get an152 // undefined value from Stackdisc_kern153 double alpha = acos( cos_val );154 155 // Call the IGOR library function to get the kernel156 double d = 2 * thick_layer + thick_core;157 double halfheight = thick_core/2.0;158 double answer = _kernel(q,159 radius,160 core_sld,161 layer_sld,162 solvent_sld,163 halfheight,164 thick_layer,165 alpha,166 sigma_dnn,167 d,168 n_stacking);169 170 answer /= sin(alpha);171 //convert to [cm-1]172 answer *= 1.0e-4;173 174 return answer;175 }176 177 132 double form_volume(double thick_core, 178 133 double thick_layer, 179 134 double radius, 180 135 double n_stacking){ 181 double d = 2 * thick_layer + thick_core;182 return acos(-1.0)* radius * radius * d * n_stacking;136 double d = 2.0 * thick_layer + thick_core; 137 return M_PI * radius * radius * d * n_stacking; 183 138 } 184 139 … … 203 158 solvent_sld); 204 159 } 160 161 162 double 163 Iqxy(double qx, double qy, 164 double thick_core, 165 double thick_layer, 166 double radius, 167 double n_stacking, 168 double sigma_dnn, 169 double core_sld, 170 double layer_sld, 171 double solvent_sld, 172 double theta, 173 double phi) 174 { 175 double q, sin_alpha, cos_alpha; 176 ORIENT_SYMMETRIC(qx, qy, theta, phi, q, sin_alpha, cos_alpha); 177 178 double d = 2.0 * thick_layer + thick_core; 179 double halfheight = 0.5*thick_core; 180 double answer = _kernel(q, 181 radius, 182 core_sld, 183 layer_sld, 184 solvent_sld, 185 halfheight, 186 thick_layer, 187 sin_alpha, 188 cos_alpha, 189 sigma_dnn, 190 d, 191 n_stacking); 192 193 //convert to [cm-1] 194 answer *= 1.0e-4; 195 196 return answer; 197 } 198
Note: See TracChangeset
for help on using the changeset viewer.