Changeset 34d6cab in sasmodels
- Timestamp:
- Feb 10, 2016 10:11:15 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:
- 3eb3312
- Parents:
- 8115d82
- Location:
- sasmodels
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
sasmodels/convert.py
r0a4628d r34d6cab 10 10 'broad_peak', 11 11 'two_lorentzian', 12 "two_power_law", 12 13 'gel_fit', 13 14 'gauss_lorentz_gel', -
sasmodels/models/line.py
r0a4628d r34d6cab 8 8 .. math:: 9 9 10 I(q) = A + B*q 10 I(q) = A + B \cdot q 11 12 .. note:: 13 For 2D plots intensity has different definition than other shape independent models 14 .. math:: 15 I(q) = I(qx) \cdot I(qy) 11 16 12 17 .. figure:: None -
sasmodels/models/two_power_law.py
r8115d82 r34d6cab 11 11 12 12 I(q) = \begin{cases} 13 A \pow(qval,-m1)& q <= qc \\14 C \pow(qval,-m2)& q > qc13 A q^{-m1} + \text{background} & q <= qc \\ 14 C q^{-m2} + \text{background} & q > qc 15 15 \end{cases} 16 16 17 17 where $qc$ = the location of the crossover from one slope to the other, 18 18 $A$ = the scaling coefficent that sets the overall intensity of the lower Q power law region, 19 $m1$ = power law exponent at low Q 19 $m1$ = power law exponent at low Q, 20 20 $m2$ = power law exponent at high Q 21 21 … … 24 24 25 25 .. math:: 26 C = frac{A}{\pow(qc/-m1)\pow(qc/-m2)}26 C = \frac{A}{qc^{-m1} qc^{-m2}} 27 27 28 .. .note28 .. note:: 29 29 Be sure to enter the power law exponents as positive values! 30 30 … … 50 50 from numpy import power 51 51 from numpy import sqrt 52 from numpy import inf 52 53 53 54 name = "two_power_law" … … 68 69 # pylint: disable=bad-whitespace, line-too-long 69 70 # ["name", "units", default, [lower, upper], "type", "description"], 70 parameters = [["coef _A", "", 1.0, [-inf, inf], "", "scaling coefficentin low Q region"],71 [" qc", "1/Ang", 0.04,[0, inf], "", "crossover location"],72 ["power_1", "",1.0, [0, inf], "", "power law exponent at low Q"],73 ["power_2", "",4.0, [0, inf], "", "power law exponent at high Q"],71 parameters = [["coefficent_1", "", 1.0, [-inf, inf], "", "coefficent A in low Q region"], 72 ["crossover", "1/Ang", 0.04,[0, inf], "", "crossover location"], 73 ["power_1", "", 1.0, [0, inf], "", "power law exponent at low Q"], 74 ["power_2", "", 4.0, [0, inf], "", "power law exponent at high Q"], 74 75 ] 75 76 # pylint: enable=bad-whitespace, line-too-long 76 77 77 78 def Iq(q, 78 coef _A=1.0,79 qc=0.04,79 coefficent_1=1.0, 80 crossover=0.04, 80 81 power_1=1.0, 81 82 power_2=4.0, … … 84 85 """ 85 86 :param q: Input q-value (float or [float, float]) 86 :param coef _A:Scaling coefficent at low Q87 :param qc:Crossover location87 :param coefA: Scaling coefficent at low Q 88 :param crossover: Crossover location 88 89 :param power_1: Exponent of power law function at low Q 89 90 :param power_2: Exponent of power law function at high Q 90 91 :return: Calculated intensity 91 92 """ 93 # pylint: disable=bad-whitespace 92 94 93 # pylint: disable=bad-whitespace 94 if(g<=qc): 95 intensity = coef_A*power(q,-1.0*power_1) 95 if q<=crossover: 96 intensity = coefficent_1*power(q,-1.0*power_1) 96 97 else: 97 coef _C = coef_A*power(qc,-1.0*power_1)/power(qc,-1.0*power_2)98 intensity = coef _C*power(q,-1.0*power_2)98 coefficent_2 = coefficent_1*power(crossover,-1.0*power_1)/power(crossover,-1.0*power_2) 99 intensity = coefficent_2*power(q,-1.0*power_2) 99 100 100 101 return intensity 101 102 102 Iq.vectorized = True # Iq accepts an array of q values 103 103 Iq.vectorized = False # Iq accepts an array of q values 104 104 105 105 def Iqxy(qx, qy, *args): … … 113 113 return Iq(sqrt(qx**2 + qy**2), *args) 114 114 115 Iqxy.vectorized = True # Iqxy accepts an array of qx, qy values115 Iqxy.vectorized = False # Iqxy accepts an array of qx, qy values 116 116 117 117 demo = dict(scale=1, background=0.1, 118 coef _A=1,119 qc=0.04,118 coefficent_1=1.0, 119 crossover=0.04, 120 120 power_1=1.0, 121 121 power_2=4.0) 122 122 123 123 oldname = "TwoPowerLawModel" 124 oldpars = dict(background='background', 125 coef_A='coef_A', 126 qc='qc', 124 oldpars = dict(coefficent_1='coef_A', 125 crossover='qc', 127 126 power_1='power1', 128 power_2='power2') 127 power_2='power2', 128 background='background') 129 129 130 130 tests = [ 131 131 132 132 # Accuracy tests based on content in test/utest_extra_models.py 133 [{'coeff _A':1.0,134 ' qc':0.04,133 [{'coefficent_1': 1.0, 134 'crossover': 0.04, 135 135 'power_1': 1.0, 136 136 'power_2': 4.0, 137 'background': 0. 1,137 'background': 0.0, 138 138 }, 0.001, 1000], 139 139 140 [{'coeff _A':1.0,141 ' qc':0.04,140 [{'coefficent_1': 1.0, 141 'crossover': 0.04, 142 142 'power_1': 1.0, 143 143 'power_2': 4.0, 144 'background': 0. 1,144 'background': 0.0, 145 145 }, 0.150141, 0.125945], 146 146 147 [{'coeff _A': 1.0,148 ' qc':0.04,147 [{'coeffcent_1': 1.0, 148 'crossover': 0.04, 149 149 'power_1': 1.0, 150 150 'power_2': 4.0, 151 'background': 0. 1,152 }, [0.442528,0.0], 0.00166884],151 'background': 0.0, 152 }, 0.442528, 0.00166884], 153 153 ]
Note: See TracChangeset
for help on using the changeset viewer.