Changeset 2d65d51 in sasmodels
- Timestamp:
- Aug 7, 2016 6:30:01 PM (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:
- 40a87fa
- Parents:
- 906cadf
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sasmodels/models/spherical_sld.py
r785cbec r2d65d51 212 212 ["nu[n_shells]", "", 2.5, [0, inf], "", "interface shape exponent"], 213 213 ["n_steps", "", 35, [0, inf], "", "number of steps in each interface (must be an odd integer)"], 214 214 ] 215 215 # pylint: enable=bad-whitespace, line-too-long 216 216 source = ["lib/polevl.c", "lib/sas_erf.c", "lib/sph_j1c.c", "spherical_sld.c"] … … 235 235 z = [] 236 236 rho = [] 237 z 0= 0237 z_next = 0 238 238 # two sld points for core 239 z.append( 0)239 z.append(z_next) 240 240 rho.append(sld[0]) 241 241 242 242 for i in range(0, int(n_shells)): 243 z 0+= thickness[i]244 z.append(z 0)243 z_next += thickness[i] 244 z.append(z_next) 245 245 rho.append(sld[i]) 246 246 dz = interface[i]/n_steps 247 247 sld_l = sld[i] 248 248 sld_r = sld[i+1] if i < n_shells-1 else sld_solvent 249 f n = SHAPE_FUNCTIONS[int(np.clip(shape[i], 0, len(SHAPE_FUNCTIONS)-1))]249 fun = SHAPE_FUNCTIONS[int(np.clip(shape[i], 0, len(SHAPE_FUNCTIONS)-1))] 250 250 for step in range(1, n_steps+1): 251 portion = f n(float(step)/n_steps, max(abs(nu[i]), 1e-14))252 z 0+= dz253 z.append(z 0)251 portion = fun(float(step)/n_steps, max(abs(nu[i]), 1e-14)) 252 z_next += dz 253 z.append(z_next) 254 254 rho.append((sld_r - sld_l)*portion + sld_l) 255 z.append(z 0*1.2)255 z.append(z_next*1.2) 256 256 rho.append(sld_solvent) 257 257 # return sld profile (r, beta) … … 260 260 261 261 def ER(n_shells, thickness, interface): 262 """Effective radius""" 262 263 n_shells = int(n_shells) 263 264 total = (np.sum(thickness[:n_shells], axis=1) … … 270 271 "n_steps": 35.0, 271 272 "sld_solvent": 1.0, 272 "sld": [2.07,4.0,3.5,4.0,3.5],273 "thickness": [50.0,100.0,100.0,100.0,100.0],274 "interface": [50.0,50.0,50.0,50.0],275 "shape": [0 ,0,0,0,0],276 "nu": [2.5,2.5,2.5,2.5,2.5],273 "sld": [2.07, 4.0, 3.5, 4.0, 3.5], 274 "thickness": [50.0, 100.0, 100.0, 100.0, 100.0], 275 "interface": [50.0]*5, 276 "shape": [0]*5, 277 "nu": [2.5]*5, 277 278 } 278 279 279 #TODO: Not working yet280 """281 280 tests = [ 282 # Accuracy tests based on content in test/utest_extra_models.py281 # Results checked against sasview 3.1 283 282 [{"n_shells": 5, 284 285 286 287 288 289 290 291 }, 0.001, 0.001],283 "n_steps": 35, 284 "sld_solvent": 1.0, 285 "sld": [2.07, 4.0, 3.5, 4.0, 3.5], 286 "thickness": [50.0, 100.0, 100.0, 100.0, 100.0], 287 "interface": [50]*5, 288 "shape": [0]*5, 289 "nu": [2.5]*5, 290 }, 0.001, 750697.238], 292 291 ] 293 """
Note: See TracChangeset
for help on using the changeset viewer.