Changeset 76d78c2 in sasmodels
- Timestamp:
- Mar 18, 2016 5:33:19 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:
- 29172aa, 74f7238, a06430c
- Parents:
- 251b40b (diff), c079f50 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent. - Location:
- sasmodels
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
sasmodels/models/adsorbed_layer.py
rf10bc52 rc079f50 6 6 7 7 r""" 8 This model describes the scattering from a layer of surfactant or polymer adsorbed on spherical particles under the conditions that (i) the particles (cores) are contrast-matched to the dispersion medium, (ii) *S(Q)* ~ 1 (ie, the particle volume fraction is dilute), (iii) the particle radius is >> layer thickness (ie, the interface is locally flat), and (iv) scattering from excess unadsorbed adsorbate in the bulk medium is absent or has been corrected for.8 This model describes the scattering from a layer of surfactant or polymer adsorbed on large, smooth, notionally spherical particles under the conditions that (i) the particles (cores) are contrast-matched to the dispersion medium, (ii) *S(Q)* ~ 1 (ie, the particle volume fraction is dilute), (iii) the particle radius is >> layer thickness (ie, the interface is locally flat), and (iv) scattering from excess unadsorbed adsorbate in the bulk medium is absent or has been corrected for. 9 9 10 10 Unlike many other core-shell models, this model does not assume any form for the density distribution of the adsorbed species normal to the interface (cf, a core-shell model normally assumes the density distribution to be a homogeneous step-function). For comparison, if the thickness of a (traditional core-shell like) step function distribution is *t*, the second moment about the mean of the density distribution (ie, the distance of the centre-of-mass of the distribution from the interface), |sigma| = sqrt((*t* :sup:`2` )/12). … … 34 34 35 35 description = """ 36 Evaluates the scattering from particles36 Evaluates the scattering from large particles 37 37 with an adsorbed layer of surfactant or 38 38 polymer, independent of the form of the … … 42 42 43 43 # ["name", "units", default, [lower, upper], "type", "description"], 44 parameters = [["second_moment", "Ang", 23.0, [0.0, inf], "", "Second moment "],45 ["adsorbed_amount", "mg/m2", 1.9, [0.0, inf], "", "Adsorbed amount "],46 ["density_ poly", "g/cm3", 0.7, [0.0, inf], "", "Polymer density"],47 ["radius", "Ang", 500.0, [0.0, inf], "", " Particle radius"],48 ["volfraction", "None", 0.14, [0.0, inf], "", " Particle volfraction"],49 [" polymer_sld", "1/Ang^2", 1.5e-06, [-inf, inf], "", "PolymerSLD"],50 ["s olvent_sld", "1/Ang^2", 6.3e-06, [-inf, inf], "", "Solvent SLD"]]44 parameters = [["second_moment", "Ang", 23.0, [0.0, inf], "", "Second moment of polymer distribution"], 45 ["adsorbed_amount", "mg/m2", 1.9, [0.0, inf], "", "Adsorbed amount of polymer"], 46 ["density_shell", "g/cm3", 0.7, [0.0, inf], "", "Bulk density of polymer in the shell"], 47 ["radius", "Ang", 500.0, [0.0, inf], "", "Core particle radius"], 48 ["volfraction", "None", 0.14, [0.0, inf], "", "Core particle volume fraction"], 49 ["sld_shell", "1e-6/Ang^2", 1.5, [-inf, inf], "sld", "Polymer shell SLD"], 50 ["sld_solvent", "1e-6/Ang^2", 6.3, [-inf, inf], "sld", "Solvent SLD"]] 51 51 52 52 # NB: Scale and Background are implicit parameters on every model 53 def Iq(q, second_moment, adsorbed_amount, density_ poly, radius,54 volfraction, polymer_sld, solvent_sld):53 def Iq(q, second_moment, adsorbed_amount, density_shell, radius, 54 volfraction, sld_shell, sld_solvent): 55 55 # pylint: disable = missing-docstring 56 deltarhosqrd = (polymer_sld - solvent_sld) * (polymer_sld - solvent_sld) 57 numerator = 6.0 * pi * volfraction * (adsorbed_amount * adsorbed_amount) 58 denominator = (q * q) * (density_poly * density_poly) * radius 59 eterm = exp(-1.0 * (q * q) * (second_moment * second_moment)) 60 #scale by 10^10 for units conversion to cm^-1 61 inten = 1.0e+10 * deltarhosqrd * ((numerator / denominator) * eterm) 56 # deltarhosqrd = (sld_shell - sld_solvent) * (sld_shell - sld_solvent) 57 # numerator = 6.0 * pi * volfraction * (adsorbed_amount * adsorbed_amount) 58 # denominator = (q * q) * (density_shell * density_shell) * radius 59 # eterm = exp(-1.0 * (q * q) * (second_moment * second_moment)) 60 # #scale by 10^-2 for units conversion to cm^-1 61 # inten = 1.0e-02 * deltarhosqrd * ((numerator / denominator) * eterm) 62 aa = (sld_shell - sld_solvent) * adsorbed_amount / q / density_shell 63 bb = q * second_moment 64 #scale by 10^-2 for units conversion to cm^-1 65 inten = 6.0e-02 * pi * volfraction * aa * aa * exp(-bb * bb) / radius 62 66 return inten 63 67 Iq.vectorized = True # Iq accepts an array of q values … … 71 75 second_moment = 23.0, 72 76 adsorbed_amount = 1.9, 73 density_ poly= 0.7,77 density_shell = 0.7, 74 78 radius = 500.0, 75 79 volfraction = 0.14, 76 polymer_sld = 1.5e-06,77 s olvent_sld = 6.3e-06,80 sld_shell = 1.5, 81 sld_solvent = 6.3, 78 82 background = 0.0) 79 83 … … 82 86 second_moment = 'second_moment', 83 87 adsorbed_amount = 'ads_amount', 84 density_ poly= 'density_poly',88 density_shell = 'density_poly', 85 89 radius = 'radius_core', 86 90 volfraction = 'volf_cores', 87 polymer_sld= 'sld_poly',88 s olvent_sld= 'sld_solv',91 sld_shell = 'sld_poly', 92 sld_solvent = 'sld_solv', 89 93 background = 'background') 90 94 … … 92 96 tests = [ 93 97 [{'scale': 1.0, 'second_moment': 23.0, 'adsorbed_amount': 1.9, 94 'density_ poly': 0.7, 'radius': 500.0, 'volfraction': 0.14,95 ' polymer_sld': 1.5e-06, 'solvent_sld': 6.3e-06, 'background': 0.0},98 'density_shell': 0.7, 'radius': 500.0, 'volfraction': 0.14, 99 'sld_shell': 1.5, 'sld_solvent': 6.3, 'background': 0.0}, 96 100 [0.0106939, 0.469418], [73.741, 9.65391e-53]], 97 101 ] 102 # ADDED by: SMK ON: 16Mar2016 convert from sasview, check vs SANDRA, 18Mar2016 RKH some edits & renaming -
sasmodels/sesans.py
r02e70ff r251b40b 63 63 64 64 def Cosine2D(data, q_calc, Iq_calc, qx, qy, Iq_mono): 65 return hankel(data.x, data.y data.lam * 1e-9,65 return hankel(data.x, data.y, data.lam * 1e-9, 66 66 data.sample.thickness / 10, 67 67 q_calc, Iq_calc) … … 70 70 # Calls a model with existing model parameters already in place, then integrate the product of q and I(q) from 0 to (4*pi/lambda) 71 71 allq = np.linspace(0,4*pi/wavelength,1000) 72 allIq = 72 allIq = 1 73 73 integral = allq*allIq 74 74 … … 86 86 Gprime = np.zeros_like(wavelength, 'd') 87 87 f = np.zeros_like(wavelength, 'd') 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 P[i] = (1-sd[i]/f[i])+1/f[i]*Gprime[i]88 for i, wavelength_i in enumerate(wavelength): 89 z = magfield*wavelength_i 90 allq=np.linspace() #for calculating the Q-range of the scattering power integral 91 allIq=np.linspace() # This is the model applied to the allq q-space. Needs to refference the model somehow 92 alldq = (allq[1]-allq[0])*1e10 93 sigma[i]=wavelength[i]^2*thickness/2/pi*np.sum(allIq*allq*alldq) 94 s[i]=1-exp(-sigma) 95 for j, Iqy_j, qy_j in enumerate(qy): 96 for k, Iqz_k, qz_k in enumerate(qz): 97 Iq = np.sqrt(Iqy_j^2+Iqz_k^2) 98 q = np.sqrt(qy_j^2 + qz_k^2) 99 Gintegral = Iq*cos(z*Qz_k) 100 Gprime[i] += Gintegral 101 # sigma = wavelength^2*thickness/2/pi* allq[i]*allIq[i] 102 # s[i] += 1-exp(Totalscatter(modelname)*thickness) 103 # For now, work with standard 2-phase scatter 104 105 106 sd[i] += Iq 107 f[i] = 1-s[i]+sd[i] 108 P[i] = (1-sd[i]/f[i])+1/f[i]*Gprime[i] 109 109 110 110 … … 119 119 G = np.zeros_like(SElength, 'd') 120 120 threshold=2*pi*theta/wavelength 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 121 for i, SElength_i in enumerate(SElength): 122 allq=np.linspace() #for calculating the Q-range of the scattering power integral 123 allIq=np.linspace() # This is the model applied to the allq q-space. Needs to refference the model somehow 124 alldq = (allq[1]-allq[0])*1e10 125 sigma[i]=wavelength[i]^2*thickness/2/pi*np.sum(allIq*allq*alldq) 126 s[i]=1-exp(-sigma) 127 128 dq = (q[1]-q[0])*1e10 129 a = (x<threshold) 130 acceptq = a*q 131 acceptIq = a*Iq 132 133 G[i] = np.sum(besselj(0, acceptq*SElength_i)*acceptIq*acceptq*dq) 134 135 # G[i]=np.sum(integral) 136 137 G *= dq*1e10*2*pi 138 139 P = exp(thickness*wavelength**2/(4*pi**2)*(G-G[0])) 140 140 141 141 def hankel(SElength, wavelength, thickness, q, Iq):
Note: See TracChangeset
for help on using the changeset viewer.