Changeset e187b25 in sasmodels
- Timestamp:
- Aug 5, 2016 10:48:52 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:
- 785cbec
- Parents:
- 50ec515
- Location:
- sasmodels/models
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
sasmodels/models/core_multi_shell.py
r42356c8 re187b25 105 105 def profile(sld_core, radius, sld_solvent, n, sld, thickness): 106 106 """ 107 SLD profile 108 109 :return: (r, beta) where r is a list of radius of the transition points\ 110 and beta is a list of the corresponding SLD values. 111 107 Returns the SLD profile *r* (Ang), and *rho* (1e-6/Ang^2). 112 108 """ 113 total_radius = 1.25*(sum(thickness[:n]) + radius + 1)114 115 109 r = [] 116 beta= []110 rho = [] 117 111 118 112 # add in the core 119 113 r.append(0) 120 beta.append(sld)114 rho.append(sld_core) 121 115 r.append(radius) 122 beta.append(sld)116 rho.append(sld_core) 123 117 124 118 # add in the shells 125 119 for k in range(n): 126 120 # Left side of each shells 127 r0 = r[-1] 128 r.append(r0) 129 beta.append(sld[k]) 130 r.append(r0 + thickness[k]) 131 beta.append(sld[k]) 121 r.append(r[-1]) 122 rho.append(sld[k]) 123 r.append(r[-1] + thickness[k]) 124 rho.append(sld[k]) 132 125 # add in the solvent 133 126 r.append(r[-1]) 134 beta.append(sld_solvent)135 r.append( total_radius)136 beta.append(sld_solvent)127 rho.append(sld_solvent) 128 r.append(r[-1]*1.25) 129 rho.append(sld_solvent) 137 130 138 return np.asarray(r), np.asarray( beta)131 return np.asarray(r), np.asarray(rho) 139 132 140 133 def ER(radius, n, thickness): -
sasmodels/models/onion.py
rd119f34 re187b25 306 306 parameters = [["sld_core", "1e-6/Ang^2", 1.0, [-inf, inf], "sld", 307 307 "Core scattering length density"], 308 [" core_radius", "Ang", 200., [0, inf], "volume",308 ["radius_core", "Ang", 200., [0, inf], "volume", 309 309 "Radius of the core"], 310 310 ["sld_solvent", "1e-6/Ang^2", 6.4, [-inf, inf], "sld", … … 325 325 single = False 326 326 327 #def Iq(q, *args, **kw):328 # return q329 330 327 profile_axes = ['Radius (A)', 'SLD (1e-6/A^2)'] 331 def profile( core_sld, core_radius, solvent_sld, n_shells,332 in_sld, out_sld, thickness, A):328 def profile(sld_core, radius_core, sld_solvent, n_shells, 329 sld_in, sld_out, thickness, A): 333 330 """ 334 331 Returns shape profile with x=radius, y=SLD. 335 332 """ 336 333 337 total_radius = 1.25*(sum(thickness[:n_shells]) + core_radius+ 1)334 total_radius = 1.25*(sum(thickness[:n_shells]) + radius_core + 1) 338 335 dr = total_radius/400 # 400 points for a smooth plot 339 336 340 337 r = [] 341 beta= []338 rho = [] 342 339 343 340 # add in the core 344 341 r.append(0) 345 beta.append(core_sld)346 r.append( core_radius)347 beta.append(core_sld)342 rho.append(sld_core) 343 r.append(radius_core) 344 rho.append(sld_core) 348 345 349 346 # add in the shells … … 352 349 r0 = r[-1] 353 350 r.append(r0) 354 beta.append(in_sld[k])351 rho.append(sld_in[k]) 355 352 356 353 if fabs(A[k]) < 1.0e-16: 357 354 # flat shell 358 355 r.append(r0 + thickness[k]) 359 beta.append(out_sld[k])356 rho.append(sld_out[k]) 360 357 else: 361 358 # exponential shell … … 363 360 # to protect against a thickness0. 364 361 num_steps = np.floor(thickness[k]/dr) + 1 365 slope = ( out_sld[k] - in_sld[k])/expm1(A[k])366 const = ( in_sld[k] - slope)362 slope = (sld_out[k] - sld_in[k]) / expm1(A[k]) 363 const = (sld_in[k] - slope) 367 364 for rk in np.linspace(0, thickness[k], num_steps+1): 368 365 r.append(r0+rk) 369 beta.append(slope*exp(A[k]*rk/thickness[k]) + const)366 rho.append(slope*exp(A[k]*rk/thickness[k]) + const) 370 367 371 368 # add in the solvent 372 369 r.append(r[-1]) 373 beta.append(solvent_sld)370 rho.append(sld_solvent) 374 371 r.append(total_radius) 375 beta.append(solvent_sld)376 377 return np.asarray(r), np.asarray( beta)*1e-6372 rho.append(sld_solvent) 373 374 return np.asarray(r), np.asarray(rho) 378 375 379 376 def ER(core_radius, n, thickness):
Note: See TracChangeset
for help on using the changeset viewer.