Changeset 168052c in sasmodels for sasmodels/models/gauss_lorentz_gel.py
- Timestamp:
- Jan 29, 2016 6:02:35 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:
- ed82794
- Parents:
- bf6631a
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sasmodels/models/gauss_lorentz_gel.py
r07a6700 r168052c 42 42 ---------- 43 43 44 G Evmenenko, E Theunissen, K Mortensen, H Reynaers, *Polymer*, 42 (2001) 2907-2913 44 G Evmenenko, E Theunissen, K Mortensen, H Reynaers, *Polymer*, 45 42 (2001) 2907-2913 45 46 46 47 """ 47 48 48 from numpy import inf, pi,sqrt, exp49 from numpy import inf, sqrt, exp 49 50 50 51 name = "gauss_lorentz_gel" … … 63 64 """ 64 65 category = "shape-independent" 65 66 # pylint: disable=bad-whitespace, line-too-long 66 67 # ["name", "units", default, [lower, upper], "type", "description"], 67 68 parameters = [["gauss_scale_factor", "", 100.0, [-inf, inf], "", "Gauss scale factor"], … … 69 70 ["lorentz_scale_factor", "", 50.0, [-inf, inf], "", "Lorentzian scale factor"], 70 71 ["dynamic_cor_length", "Ang", 20.0, [0, inf], "", "Dynamic correlation length"], 71 72 72 ] 73 # pylint: enable=bad-whitespace, line-too-long 73 74 74 75 def Iq(q, 75 gauss_scale_factor, 76 static_cor_length, 77 lorentz_scale_factor, 78 dynamic_cor_length): 76 gauss_scale_factor=100.0, 77 static_cor_length=100.0, 78 lorentz_scale_factor=50.0, 79 dynamic_cor_length=20.0): 80 """ 79 81 80 term1 = gauss_scale_factor *\ 81 exp(-1.0*q*q*static_cor_length*static_cor_length/2.0) 82 term2 = lorentz_scale_factor /\ 83 (1.0+(q*dynamic_cor_length)*(q*dynamic_cor_length)) 82 :param q: Input q-value 83 :param gauss_scale_factor: Gauss scale factor 84 :param static_cor_length: Static correlation length 85 :param lorentz_scale_factor: Lorentzian scale factor 86 :param dynamic_cor_length: Dynamic correlation length 87 :return: 1-D intensity 88 """ 84 89 85 return term1 + term2 90 term1 = gauss_scale_factor *\ 91 exp(-1.0*q*q*static_cor_length*static_cor_length/2.0) 92 term2 = lorentz_scale_factor /\ 93 (1.0+(q*dynamic_cor_length)*(q*dynamic_cor_length)) 94 95 return term1 + term2 86 96 87 97 Iq.vectorized = True # Iq accepts an array of q values … … 89 99 90 100 def Iqxy(qx, qy, *args): 91 iq = Iq(sqrt(qx**2 + qy**2), *args) 101 """ 102 :param qx: Input q_x-value 103 :param qy: Input q_y-value 104 :param args: Remaining aruments 105 :return: 2-D intensity 106 """ 92 107 93 return iq108 return Iq(sqrt(qx**2 + qy**2), *args) 94 109 95 110 Iqxy.vectorized = True # Iqxy accepts an array of qx, qy values … … 111 126 112 127 tests = [ 113 # Accuracy tests based on content in test/utest_extra_models.py114 [{'gauss_scale_factor': 100.0,115 'static_cor_length': 100.0,116 'lorentz_scale_factor': 50.0,117 'dynamic_cor_length': 20.0,118 }, 0.001, 149.481],119 128 120 [{'gauss_scale_factor': 100.0, 121 'static_cor_length': 100.0, 122 'lorentz_scale_factor': 50.0, 123 'dynamic_cor_length': 20.0, 124 }, 0.105363, 9.1903], 129 # Accuracy tests based on content in test/utest_extra_models.py 130 [{'gauss_scale_factor': 100.0, 131 'static_cor_length': 100.0, 132 'lorentz_scale_factor': 50.0, 133 'dynamic_cor_length': 20.0, 134 }, 0.001, 149.481], 125 135 126 127 128 129 130 }, 0.441623, 0.632811],136 [{'gauss_scale_factor': 100.0, 137 'static_cor_length': 100.0, 138 'lorentz_scale_factor': 50.0, 139 'dynamic_cor_length': 20.0, 140 }, 0.105363, 9.1903], 131 141 132 # Additional tests with larger range of parameters 133 [{'gauss_scale_factor': 10.0, 134 'static_cor_length': 100.0, 135 'lorentz_scale_factor': 3.0, 136 'dynamic_cor_length': 1.0, 137 }, 0.1, 2.9702970297], 142 [{'gauss_scale_factor': 100.0, 143 'static_cor_length': 100.0, 144 'lorentz_scale_factor': 50.0, 145 'dynamic_cor_length': 20.0, 146 }, 0.441623, 0.632811], 138 147 139 [{'gauss_scale_factor': 10.0,140 'static_cor_length': 100.0,141 'lorentz_scale_factor': 3.0,142 'dynamic_cor_length': 1.0,143 'background': 100.0144 }, 5.0, 100.115384615],148 # Additional tests with larger range of parameters 149 [{'gauss_scale_factor': 10.0, 150 'static_cor_length': 100.0, 151 'lorentz_scale_factor': 3.0, 152 'dynamic_cor_length': 1.0, 153 }, 0.1, 2.9702970297], 145 154 146 [{'gauss_scale_factor': 10.0, 147 'static_cor_length': 100.0, 148 'lorentz_scale_factor': 3.0, 149 'dynamic_cor_length': 1.0, 150 }, 200., 7.49981250469e-05], 151 ] 155 [{'gauss_scale_factor': 10.0, 156 'static_cor_length': 100.0, 157 'lorentz_scale_factor': 3.0, 158 'dynamic_cor_length': 1.0, 159 'background': 100.0 160 }, 5.0, 100.115384615], 161 162 [{'gauss_scale_factor': 10.0, 163 'static_cor_length': 100.0, 164 'lorentz_scale_factor': 3.0, 165 'dynamic_cor_length': 1.0, 166 }, 200., 7.49981250469e-05], 167 ]
Note: See TracChangeset
for help on using the changeset viewer.