Changes in / [0784c18:d634601] in sasmodels
- Location:
- sasmodels
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
sasmodels/convert.py
r310ddcb r228cbd3 129 129 warnings.warn("parameter background not used in sasview %s"%name) 130 130 131 131 132 # If it is a product model P*S, then check the individual forms for special 132 133 # cases. Note: despite the structure factor alone not having scale or … … 146 147 for p in "La", "Lb", "Lc", "Ld": 147 148 if p in oldpars: oldpars[p] *= 1e-13 149 elif name == 'core_shell_parallelepiped': 150 _remove_pd(oldpars, 'rimA', name) 151 elif name in ['mono_gauss_coil','poly_gauss_coil']: 152 del oldpars['i_zero'] 148 153 149 154 return oldpars … … 177 182 elif name == 'rpa': 178 183 pars['case_num'] = int(pars['case_num']) 184 elif name == 'mono_gauss_coil': 185 pars['i_zero'] = 1 186 elif name == 'poly_gauss_coil': 187 pars['i_zero'] = 1 188 -
sasmodels/models/mono_gauss_coil.py
r6dd90c1 r246517d 14 14 15 15 *I(q)* = *scale* |cdot| *I* \ :sub:`0` |cdot| *P(q)* + *background* 16 16 17 17 where 18 18 … … 20 20 21 21 *P(q)* = 2 [exp(-Z) + Z - 1] / Z \ :sup:`2` 22 23 22 23 *Z* = (*q R* \ :sub:`g`)\ :sup:`2` 24 24 25 25 and 26 26 27 28 27 *V* = *M* / (*N*\ :sub:`A` |delta|) 28 29 29 Here, |phi|\ :sub:`poly` is the volume fraction of polymer, *V* is the volume of a polymer coil, *M* is the molecular weight of the polymer, *N*\ :sub:`A` is Avogadro's Number, |delta| is the bulk density of the polymer, |rho|\ :sub:`poly` is the sld of the polymer, |rho|\ :sub:`solv` is the sld of the solvent, and *R*\ :sub:`g` is the radius of gyration of the polymer coil. 30 30 … … 52 52 description = """ 53 53 Evaluates the scattering from 54 54 monodisperse polymer chains. 55 55 """ 56 56 category = "shape-independent" 57 57 58 58 # ["name", "units", default, [lower, upper], "type", "description"], 59 parameters = [["i_zero", "1/cm", 1.0, [-inf, inf], "", "Intensity at q=0"],60 ["radius_gyration", "Ang", 50.0, [0.0, inf], "", "Radius of gyration"]]59 parameters = [["i_zero", "1/cm", 70.0, [0.0, inf], "", "Intensity at q=0"], 60 ["radius_gyration", "Ang", 75.0, [0.0, inf], "", "Radius of gyration"]] 61 61 62 62 # NB: Scale and Background are implicit parameters on every model 63 63 def Iq(q, i_zero, radius_gyration): 64 64 # pylint: disable = missing-docstring 65 z = (q * radius_gyration) * * 266 if q == 0:67 inten = 1.065 z = (q * radius_gyration) * (q * radius_gyration) 66 if (q == 0).any(): 67 inten = i_zero 68 68 else: 69 69 inten = i_zero * 2.0 * (exp(-z) + z - 1.0 ) / (z * z) … … 77 77 78 78 demo = dict(scale = 1.0, 79 i_zero = 1.0,80 radius_gyration = 50.0,79 i_zero = 70.0, 80 radius_gyration = 75.0, 81 81 background = 0.0) 82 82 … … 87 87 88 88 tests = [ 89 [{'scale': 1.0, 'radius_gyration': 50.0, 'background': 0.0},90 [0.0106939, 0.469418], [ 0.911141, 0.00362394]],89 [{'scale': 70.0, 'radius_gyration': 75.0, 'background': 0.0}, 90 [0.0106939, 0.469418], [57.1241, 0.112859]], 91 91 ] -
sasmodels/models/poly_gauss_coil.py
r6dd90c1 r246517d 14 14 15 15 *I(q)* = *scale* |cdot| *I* \ :sub:`0` |cdot| *P(q)* + *background* 16 16 17 17 where 18 18 … … 20 20 21 21 *P(q)* = 2 [(1 + UZ)\ :sup:`-1/U` + Z - 1] / [(1 + U) Z\ :sup:`2`] 22 23 24 25 22 23 *Z* = [(*q R*\ :sub:`g`)\ :sup:`2`] / (1 + 2U) 24 25 *U* = (Mw / Mn) - 1 = (*polydispersity ratio*) - 1 26 26 27 27 and 28 28 29 30 29 *V* = *M* / (*N*\ :sub:`A` |delta|) 30 31 31 Here, |phi|\ :sub:`poly`, is the volume fraction of polymer, *V* is the volume of a polymer coil, *M* is the molecular weight of the polymer, *N*\ :sub:`A` is Avogadro's Number, |delta| is the bulk density of the polymer, |rho|\ :sub:`poly` is the sld of the polymer, |rho|\ :sub:`solv` is the sld of the solvent, and *R*\ :sub:`g` is the radius of gyration of the polymer coil. 32 32 … … 57 57 description = """ 58 58 Evaluates the scattering from 59 59 polydisperse polymer chains. 60 60 """ 61 61 category = "shape-independent" 62 62 63 63 # ["name", "units", default, [lower, upper], "type", "description"], 64 parameters = [["i_zero", "1/cm", 1.0, [-inf, inf], "", "Intensity at q=0"],65 ["radius_gyration", "Ang", 50.0, [0.0, inf], "", "Radius of gyration"],64 parameters = [["i_zero", "1/cm", 70.0, [0.0, inf], "", "Intensity at q=0"], 65 ["radius_gyration", "Ang", 75.0, [0.0, inf], "", "Radius of gyration"], 66 66 ["polydispersity", "None", 2.0, [1.0, inf], "", "Polymer Mw/Mn"]] 67 67 … … 69 69 def Iq(q, i_zero, radius_gyration, polydispersity): 70 70 # pylint: disable = missing-docstring 71 # need to trap the case of the polydispersity being 1 (ie, monodispersity) 71 72 u = polydispersity - 1.0 72 # TO DO 73 # should trap the case of polydispersity = 1 by switching to a taylor expansion 74 minusoneonu = -1.0 / u 75 z = (q * radius_gyration) ** 2 / (1.0 + 2.0 * u) 76 if q == 0: 77 inten = i_zero * 1.0 73 if polydispersity == 1: 74 minusoneonu = -1.0 / u 78 75 else: 79 inten = i_zero * 2.0 * (power((1.0 + u * z),minusoneonu) + z - 1.0 ) / ((1.0 + u) * (z * z)) 76 minusoneonu = -1.0 / u 77 z = ((q * radius_gyration) * (q * radius_gyration)) / (1.0 + 2.0 * u) 78 if (q == 0).any(): 79 inten = i_zero 80 else: 81 inten = i_zero * 2.0 * (power((1.0 + u * z),minusoneonu) + z - 1.0 ) / ((1.0 + u) * (z * z)) 80 82 return inten 81 #Iq.vectorized = True# Iq accepts an array of q values83 Iq.vectorized = True # Iq accepts an array of q values 82 84 83 85 def Iqxy(qx, qy, *args): … … 87 89 88 90 demo = dict(scale = 1.0, 89 i_zero = 1.0,90 radius_gyration = 50.0,91 i_zero = 70.0, 92 radius_gyration = 75.0, 91 93 polydispersity = 2.0, 92 94 background = 0.0) … … 99 101 100 102 tests = [ 101 [{'scale': 1.0, 'radius_gyration': 50.0, 'polydispersity': 2.0, 'background': 0.0},102 [0.0106939, 0.469418], [ 0.912993, 0.0054163]],103 [{'scale': 70.0, 'radius_gyration': 75.0, 'polydispersity': 2.0, 'background': 0.0}, 104 [0.0106939, 0.469418], [57.6405, 0.169016]], 103 105 ]
Note: See TracChangeset
for help on using the changeset viewer.