Changeset eb97b11 in sasmodels
- Timestamp:
- Apr 18, 2016 8:22:12 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:
- 4605bf10
- Parents:
- f2f67a6
- Location:
- sasmodels/models
- Files:
-
- 1 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
sasmodels/models/spherical_sld.c
r299dcce reb97b11 5 5 int n_shells); 6 6 7 double Iq(double q,7 static double Iq(double q, 8 8 int n_shells, 9 9 double thick_inter[], … … 17 17 double core_radius); 18 18 19 double Iqxy(double qx, double qy,19 static double Iqxy(double qx, double qy, 20 20 int n_shells, 21 21 double thick_inter[], … … 56 56 double background = dp[6]; 57 57 double npts = dp[57]; //number of sub_layers in each interface 58 double nsl=npts;//21.0; //nsl = Num_sub_layer: MUST ODD number in double //no other number works now58 double nsl=npts;//21.0; //nsl = Num_sub_layer: must be ODD double number 59 59 int n_s; 60 60 … … 63 63 double pi; 64 64 65 //int* fun_type;66 //double* sld;67 //double* thick_inter;68 //double* thick;69 //double* fun_coef;70 71 65 double total_thick=0.0; 72 66 73 //fun_type = (int*)malloc((n+2)*sizeof(int));74 //sld = (double*)malloc((n+2)*sizeof(double));75 //thick_inter = (double*)malloc((n+2)*sizeof(double));76 //thick = (double*)malloc((n+2)*sizeof(double));77 //fun_coef = (double*)malloc((n+2)*sizeof(double));78 79 //TODO: Solution to avoid mallocs but probablyu can be done better80 67 int fun_type[12]; 81 68 double sld[12]; … … 175 162 if (fabs(slope) > 0.0 ){ 176 163 //fun = sign * 3.0 * r * (2.0*qr*sin(qr)-((qr*qr)-2.0)*cos(qr))/(qr * qr * qr * qr); 177 fun = sign * r * sph_j1c(qr) + sign * 3.0 * sin(qr)/(qr * qr * q ) + sign * 6.0 * cos(qr)/(qr * qr * qr * q); 164 fun = sign * r * sph_j1c(qr) + sign * 3.0 * sin(qr)/(qr * qr * q ) 165 + sign * 6.0 * cos(qr)/(qr * qr * qr * q); 178 166 } 179 167 } … … 285 273 286 274 double q = sqrt(qx*qx + qy*qy); 287 return Iq(q, n_shells, thick_inter_0, func_inter_0, core0_sld, solvent_sld, 288 flat1_sld, flat2_sld, flat3_sld, flat4_sld, flat5_sld, 289 flat6_sld, flat7_sld, flat8_sld, flat9_sld, flat10_sld, 290 thick_inter_1, thick_inter_2, thick_inter_3, thick_inter_4, thick_inter_5, 291 thick_inter_6, thick_inter_7, thick_inter_8, thick_inter_9, thick_inter_10, 292 thick_flat_1, thick_flat_2, thick_flat_3, thick_flat_4, thick_flat_5, 293 thick_flat_6, thick_flat_7, thick_flat_8, thick_flat_9, thick_flat_10, 294 func_inter_1, func_inter_2, func_inter_3, func_inter_4, func_inter_5, 295 func_inter_6, func_inter_7, func_inter_8, func_inter_9, func_inter_10, 296 nu_inter_1, nu_inter_2, nu_inter_3, nu_inter_4, nu_inter_5, 297 nu_inter_6, nu_inter_7, nu_inter_8, nu_inter_9, nu_inter_10, 298 npts_inter, nu_inter_0, rad_core_0); 299 300 //TODO: Check if evalute rphi is not needed? 301 302 } 303 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 -
sasmodels/models/spherical_sld.py
rd2bb604 reb97b11 170 170 # pylint: disable=bad-whitespace, line-too-long 171 171 # ["name", "units", default, [lower, upper], "type", "description"], 172 parameters = [["n ", "", 1, [0, 9], "", "number of shells"],172 parameters = [["n_shells", "", 1, [0, 9], "", "number of shells"], 173 173 ["radius_core", "Ang", 50.0, [0, inf], "", "intern layer thickness"], 174 174 ["sld_core", "1e-6/Ang^2", 2.07, [-inf, inf], "", "sld function flat"], 175 ["sld_solvent", "1e-6/Ang^2", 1.0, [-inf, inf], "", "sld function solvent"], 175 176 ["sld_flat[n]", "1e-6/Ang^2", 4.06, [-inf, inf], "", "sld function flat"], 176 177 ["thick_flat[n]", "Ang", 100.0, [0, inf], "", "flat layer_thickness"], 177 178 ["func_inter[n]", "", 0, [0, 4], "", "Erf:0, RPower:1, LPower:2, RExp:3, LExp:4"], 178 179 ["thick_inter[n]", "Ang", 50.0, [0, inf], "", "intern layer thickness"], 179 [" inter_nu[n]", "", 2.5, [-inf, inf], "", "steepness parameter"],180 ["nu_inter[n]", "", 2.5, [-inf, inf], "", "steepness parameter"], 180 181 ["npts_inter", "", 35, [0, 35], "", "number of points in each sublayer Must be odd number"], 181 ["sld_solvent", "1e-6/Ang^2", 1.0, [-inf, inf], "", "sld function solvent"],182 182 ] 183 183 # pylint: enable=bad-whitespace, line-too-long 184 #source = ["lib/librefl.c", "lib/sph_j1c.c", "spherical_sld.c"] 185 186 def Iq(q, *args, **kw): 187 return q 188 189 def Iqxy(qx, *args, **kw): 190 return qx 184 source = ["lib/librefl.c", "lib/sph_j1c.c", "spherical_sld.c"] 185 186 #def Iq(q, *args, **kw): 187 # return q 188 189 #def Iqxy(qx, *args, **kw): 190 # return qx 191 192 def profile(n_shells, radius_core, sld_core, sld_solvent, sld_flat, 193 thick_flat, func_inter, thick_inter, nu_inter, npts_inter): 194 """ 195 Returns shape profile with x=radius, y=SLD. 196 """ 197 198 #total_radius = 1.25*(sum(thickness[:n_shells]) + core_radius + 1) 199 #dr = total_radius/400 # 400 points for a smooth plot 200 201 z = [] 202 beta = [] 203 z0 = 0 204 # two sld points for core 205 z.append(0) 206 beta.append(sld_core) 207 z.append(radius_core) 208 beta.append(sld_core) 209 z0 += radius_core 210 211 for i in range(1, n_shells+2): 212 dz = thick_inter[i-1]/npts_inter 213 # j=0 for interface, j=1 for flat layer 214 for j in range(0, 2): 215 # interation for sub-layers 216 for n_s in range(0, npts_inter+1): 217 if j == 1: 218 if i == n_shells+1: 219 break 220 # shift half sub thickness for the first point 221 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 228 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, 243 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 251 z.append(z0) 252 beta.append(sld_solvent) 253 z_ext = z0/5.0 254 z.append(z0+z_ext) 255 beta.append(sld_solvent) 256 # return sld profile (r, beta) 257 258 return np.asarray(z), np.asarray(beta)*1e-6 259 260 def ER(core_radius, n, thickness): 261 return np.sum(thickness[:n[0]], axis=0) + core_radius 262 263 def VR(core_radius, n, thickness): 264 return 1.0, 1.0 191 265 192 266
Note: See TracChangeset
for help on using the changeset viewer.