Changeset 4605bf10 in sasmodels
- Timestamp:
- Apr 18, 2016 7:47:14 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:
- a7c2cfe
- Parents:
- eb97b11
- Location:
- sasmodels/models
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
sasmodels/models/spherical_sld.c
reb97b11 r4605bf10 1 //Headers 2 static double form_volume(double thick_inter[], 3 double thick_flat_[], 4 double core_radius, 5 int n_shells); 6 7 static double Iq(double q, 1 static double form_volume( 8 2 int n_shells, 9 double thick_inter[], 10 double func_inter[], 11 double sld_core, 12 double sld_solvent, 13 double sld_flat[], 3 double radius_core, 14 4 double thick_flat[], 15 double nu_inter[], 16 int npts_inter, 17 double core_radius); 18 19 static double Iqxy(double qx, double qy, 20 int n_shells, 21 double thick_inter[], 22 double func_inter[], 23 double sld_core, 24 double sld_solvent, 25 double sld_flat[], 26 double thick_flat[], 27 double nu_inter[], 28 int npts_inter, 29 double core_radius); 30 31 //Main code 32 static double form_volume(double thick_inter[], 33 double thick_flat_[], 34 double core_radius, 35 int n) 5 double thick_inter[]) 36 6 { 37 7 double radius = 0.0; 38 8 int i; 39 double r = core_radius;40 for (i=0; i < n ; i++) {9 double r = radius_core; 10 for (i=0; i < n_shells; i++) { 41 11 r += thick_inter[i]; 42 12 r += thick_flat[i]; … … 191 161 } 192 162 } 193 //vol += vol_sub;194 163 f2 = f * f / vol; 195 //f2 *= scale;196 //f2 += background;197 //free(fun_type);198 //free(sld);199 //free(thick_inter);200 //free(thick);201 //free(fun_coef);202 164 203 165 return (f2); … … 210 172 * @return: function value 211 173 */ 212 double Iq(double q,174 static double Iq(double q, 213 175 int n_shells, 214 double thick_inter[],215 double func_inter[],176 int npts_inter, 177 double radius_core, 216 178 double sld_core, 217 179 double sld_solvent, 218 180 double sld_flat[], 219 181 double thick_flat[], 220 double nu_inter[], 221 int npts_inter, 222 double core_radius 223 ) { 182 double func_inter[], 183 double thick_inter[], 184 double nu_inter[] ) { 224 185 225 186 //printf("Number of points %d\n",npts_inter); 226 187 double intensity; 227 //TODO: Remove this container at later stage. It is only kept to minimize stupid errors now188 //TODO: Remove this container at later stage. 228 189 double dp[60]; 229 190 dp[0] = n_shells; 230 191 //This is scale will also have to be removed at some stage 231 192 dp[1] = 1.0; 232 dp[2] = thick_inter _0;233 dp[3] = func_inter _0;193 dp[2] = thick_inter[0]; 194 dp[3] = func_inter[0]; 234 195 dp[4] = sld_core; 235 196 dp[5] = sld_solvent; 236 197 dp[6] = 0.0; 237 198 238 for (i =0; i<n; i++){199 for (int i=1; i<n_shells; i++){ 239 200 dp[i+7] = sld_flat[i]; 240 201 dp[i+17] = thick_inter[i]; … … 245 206 246 207 dp[57] = npts_inter; 247 dp[58] = nu_inter _0;248 dp[59] = rad _core_0;208 dp[58] = nu_inter[0]; 209 dp[59] = radius_core; 249 210 250 211 intensity = 1.0e-4*sphere_sld_kernel(dp,q); … … 259 220 * @return: function value 260 221 */ 261 double Iqxy(double qx, double qy, 222 223 /*static double Iqxy(double qx, double qy, 262 224 int n_shells, 263 double thick_inter[],264 double func_inter[],225 int npts_inter, 226 double radius_core 265 227 double sld_core, 266 228 double sld_solvent, 267 229 double sld_flat[], 268 230 double thick_flat[], 231 double func_inter[], 232 double thick_inter[], 269 233 double nu_inter[], 270 int npts_inter,271 double core_radius272 234 ) { 273 235 274 236 double q = sqrt(qx*qx + qy*qy); 275 return Iq(q, n_shells, thick_inter[], func_inter[], sld_core, sld_solvent, 276 sld_flat[], thick_flat[],nu_inter[], npts_inter, core_radius) 277 278 } 279 237 return Iq(q, n_shells, npts_inter, radius_core, sld_core, sld_solvent, 238 sld_flat[], thick_flat[], func_inter[], thick_inter[], nu_inter[]) 239 }*/ 240 -
sasmodels/models/spherical_sld.py
reb97b11 r4605bf10 171 171 # ["name", "units", default, [lower, upper], "type", "description"], 172 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"], 173 174 ["radius_core", "Ang", 50.0, [0, inf], "", "intern layer thickness"], 174 175 ["sld_core", "1e-6/Ang^2", 2.07, [-inf, inf], "", "sld function flat"], 175 176 ["sld_solvent", "1e-6/Ang^2", 1.0, [-inf, inf], "", "sld function solvent"], 176 ["sld_flat[n]", "1e-6/Ang^2", 4.06, [-inf, inf], "", "sld function flat"], 177 ["thick_flat[n]", "Ang", 100.0, [0, inf], "", "flat layer_thickness"], 178 ["func_inter[n]", "", 0, [0, 4], "", "Erf:0, RPower:1, LPower:2, RExp:3, LExp:4"], 179 ["thick_inter[n]", "Ang", 50.0, [0, inf], "", "intern layer thickness"], 180 ["nu_inter[n]", "", 2.5, [-inf, inf], "", "steepness parameter"], 181 ["npts_inter", "", 35, [0, 35], "", "number of points in each sublayer Must be odd number"], 177 ["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"], 179 ["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"], 181 ["nu_inter[n_shells]", "", 2.5, [-inf, inf], "", "steepness parameter"], 182 182 ] 183 183 # pylint: enable=bad-whitespace, line-too-long … … 195 195 Returns shape profile with x=radius, y=SLD. 196 196 """ 197 198 #total_radius = 1.25*(sum(thickness[:n_shells]) + core_radius + 1)199 #dr = total_radius/400 # 400 points for a smooth plot200 197 201 198 z = [] … … 220 217 # shift half sub thickness for the first point 221 218 z0 -= dz#/2.0 222 z.append(z0) 223 #z0 -= dz/2.0 224 z0 += thick_flat[i] 225 sld_i = sld_flat[i] 226 beta.append(sld_flat[i]) 227 dz = 0 219 z.append(z0) 220 #z0 -= dz/2.0 221 z0 += thick_flat[i] 222 sld_i = sld_flat[i] 223 beta.append(sld_flat[i]) 224 dz = 0 225 else: 226 nu = nu_inter[i-1] 227 # decide which sld is which, sld_r or sld_l 228 if i == 1: 229 sld_l = sld_core 228 230 else: 229 nu = nu_inter[i-1] 230 # decide which sld is which, sld_r or sld_l 231 if i == 1: 232 sld_l = sld_core 233 else: 234 sld_l = sld_flat[i-1] 235 if i == n_shells+1: 236 sld_r = sld_solvent 237 else: 238 sld_r = sld_flat[i] 239 # get function type 240 func_idx = func_inter[i-1] 241 # calculate the sld 242 sld_i = intersldfunc(func_idx, npts_inter, n_s, nu, 231 sld_l = sld_flat[i-1] 232 if i == n_shells+1: 233 sld_r = sld_solvent 234 else: 235 sld_r = sld_flat[i] 236 # get function type 237 func_idx = func_inter[i-1] 238 # calculate the sld 239 sld_i = intersldfunc(func_idx, npts_inter, n_s, nu, 243 240 sld_l, sld_r) 244 # append to the list 245 z.append(z0) 246 beta.append(sld_i) 247 z0 += dz 248 if j == 1: 249 break 250 # put sld of solvent 241 # append to the list 242 z.append(z0) 243 beta.append(sld_i) 244 z0 += dz 245 if j == 1: 246 break 251 247 z.append(z0) 252 248 beta.append(sld_solvent) … … 255 251 beta.append(sld_solvent) 256 252 # return sld profile (r, beta) 257 258 253 return np.asarray(z), np.asarray(beta)*1e-6 259 254 … … 268 263 n=4, 269 264 scale=1.0, 270 s olvent_sld=1.0,265 sld_solvent=1.0, 271 266 background=0.0, 272 267 npts_inter=35.0,
Note: See TracChangeset
for help on using the changeset viewer.