Changeset 40a87fa in sasmodels for sasmodels/models/onion.py
- Timestamp:
- Aug 8, 2016 9:24:11 AM (8 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:
- 2472141
- Parents:
- 2d65d51
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sasmodels/models/onion.py
r785cbec r40a87fa 300 300 # TODO: n is a volume parameter that is not polydisperse 301 301 302 # ["name", "units", default, [lower, upper], "type","description"], 303 parameters = [["sld_core", "1e-6/Ang^2", 1.0, [-inf, inf], "sld", 304 "Core scattering length density"], 305 ["radius_core", "Ang", 200., [0, inf], "volume", 306 "Radius of the core"], 307 ["sld_solvent", "1e-6/Ang^2", 6.4, [-inf, inf], "sld", 308 "Solvent scattering length density"], 309 ["n_shells", "", 1, [0, 10], "volume", 310 "number of shells"], 311 ["sld_in[n_shells]", "1e-6/Ang^2", 1.7, [-inf, inf], "sld", 312 "scattering length density at the inner radius of shell k"], 313 ["sld_out[n_shells]", "1e-6/Ang^2", 2.0, [-inf, inf], "sld", 314 "scattering length density at the outer radius of shell k"], 315 ["thickness[n_shells]", "Ang", 40., [0, inf], "volume", 316 "Thickness of shell k"], 317 ["A[n_shells]", "", 1.0, [-inf, inf], "", 318 "Decay rate of shell k"], 319 ] 302 # pylint: disable=bad-whitespace, line-too-long 303 # ["name", "units", default, [lower, upper], "type","description"], 304 parameters = [ 305 ["sld_core", "1e-6/Ang^2", 1.0, [-inf, inf], "sld", "Core scattering length density"], 306 ["radius_core", "Ang", 200., [0, inf], "volume", "Radius of the core"], 307 ["sld_solvent", "1e-6/Ang^2", 6.4, [-inf, inf], "sld", "Solvent scattering length density"], 308 ["n_shells", "", 1, [0, 10], "volume", "number of shells"], 309 ["sld_in[n_shells]", "1e-6/Ang^2", 1.7, [-inf, inf], "sld", "scattering length density at the inner radius of shell k"], 310 ["sld_out[n_shells]", "1e-6/Ang^2", 2.0, [-inf, inf], "sld", "scattering length density at the outer radius of shell k"], 311 ["thickness[n_shells]", "Ang", 40., [0, inf], "volume", "Thickness of shell k"], 312 ["A[n_shells]", "", 1.0, [-inf, inf], "", "Decay rate of shell k"], 313 ] 314 # pylint: enable=bad-whitespace, line-too-long 320 315 321 316 source = ["lib/sph_j1c.c", "onion.c"] … … 330 325 331 326 total_radius = 1.25*(sum(thickness[:n_shells]) + radius_core + 1) 332 d r= total_radius/400 # 400 points for a smooth plot333 334 r= []327 dz = total_radius/400 # 400 points for a smooth plot 328 329 z = [] 335 330 rho = [] 336 331 337 332 # add in the core 338 r.append(0)333 z.append(0) 339 334 rho.append(sld_core) 340 r.append(radius_core)335 z.append(radius_core) 341 336 rho.append(sld_core) 342 337 … … 344 339 for k in range(n_shells): 345 340 # Left side of each shells 346 r0 = r[-1]347 r.append(r0)341 z_current = z[-1] 342 z.append(z_current) 348 343 rho.append(sld_in[k]) 349 344 350 345 if fabs(A[k]) < 1.0e-16: 351 346 # flat shell 352 r.append(r0+ thickness[k])347 z.append(z_current + thickness[k]) 353 348 rho.append(sld_out[k]) 354 349 else: … … 356 351 # num_steps must be at least 1, so use floor()+1 rather than ceil 357 352 # to protect against a thickness0. 358 num_steps = np.floor(thickness[k]/d r) + 1353 num_steps = np.floor(thickness[k]/dz) + 1 359 354 slope = (sld_out[k] - sld_in[k]) / expm1(A[k]) 360 355 const = (sld_in[k] - slope) 361 for rkin np.linspace(0, thickness[k], num_steps+1):362 r.append(r0+rk)363 rho.append(slope*exp(A[k]* rk/thickness[k]) + const)356 for z_shell in np.linspace(0, thickness[k], num_steps+1): 357 z.append(z_current+z_shell) 358 rho.append(slope*exp(A[k]*z_shell/thickness[k]) + const) 364 359 365 360 # add in the solvent 366 r.append(r[-1])361 z.append(z[-1]) 367 362 rho.append(sld_solvent) 368 r.append(total_radius)363 z.append(total_radius) 369 364 rho.append(sld_solvent) 370 365 371 return np.asarray( r), np.asarray(rho)366 return np.asarray(z), np.asarray(rho) 372 367 373 368 def ER(core_radius, n, thickness): 369 """Effective radius""" 374 370 return np.sum(thickness[:n[0]], axis=0) + core_radius 375 376 def VR(core_radius, n, thickness):377 return 1.0, 1.0378 371 379 372 demo = {
Note: See TracChangeset
for help on using the changeset viewer.