Changeset d8b4c5a in sasmodels
- Timestamp:
- Sep 26, 2018 3:45:11 PM (6 years ago)
- Branches:
- master, core_shell_microgels, magnetic_model, ticket-1257-vesicle-product, ticket_1156, ticket_1265_superball, ticket_822_more_unit_tests
- Children:
- 9235fc3
- Parents:
- 2effdf6
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sasmodels/models/be_polyelectrolyte.py
r2effdf6 rd8b4c5a 61 61 history of this code goes back to a 1998 implementation. It was recently noted 62 62 that in that implementation, while both the polymer concentration and salt 63 concentration were converted to units of 1/|Ang|, only the converted polymer 64 concentration was used in the calculation while the unconverted salt 65 concentration was used. This was carried through to sasmodles today (except 66 that the conversion equation for the salt concentration was dropped somewhere 67 along the line). Simple dimensional analysis of the calculation shows that the 63 concentration were converted from experimental units of mol/L to more 64 dimensionally useful units of 1/|Ang|^3, only the converted version of the 65 polymer concentration was actually being used in the calculation while the 66 unconverted salt concentration (still in units of mol/L) was being used. This 67 was carried through to sasmodels today (except that the line of code converting 68 the salt concentration to the new units was dropped somewhere along the line). 69 Simple dimensional analysis of the calculation shows that it is in fact the 68 70 converted salt concentration must be used and the original code suggests that 69 71 was the intention. We therefore believe this is now correct. Once better … … 119 121 120 122 def Iq(q, 121 contrast_factor =10.0,122 bjerrum_length =7.1,123 virial_param =12.0,124 monomer_length =10.0,125 salt_concentration =0.0,126 ionization_degree =0.05,127 polymer_concentration =0.7):123 contrast_factor, 124 bjerrum_length, 125 virial_param, 126 monomer_length, 127 salt_concentration, 128 ionization_degree, 129 polymer_concentration): 128 130 """ 129 :param q: Input q-value 130 :param contrast_factor: Contrast factor of the polymer 131 :param bjerrum_length: Bjerrum length 132 :param virial_param: Virial parameter 133 :param monomer_length: Monomer length 134 :param salt_concentration: Concentration of monovalent salt 135 :param ionization_degree: Degree of ionization 136 :param polymer_concentration: Polymer molar concentration 137 :return: 1-D intensity 131 :params: see parameter table 132 :return: 1-D form factor for polyelectrolytes in low salt 133 134 parameter names, units, default values, and behavior (volume, sld etc) are 135 defined in the parameter table. The concentrations are converted from 136 experimental mol/L to dimensionaly useful 1/A3 in first two lines 138 137 """ 139 138 … … 192 191 193 192 # Accuracy tests based on content in test/utest_other_models.py 193 # Note that these should some day be validated beyond this self validation 194 # (circular reasoning). -- i.e. the "good value," at least for those with 195 # non zero salt concentrations, were obtained by running the current 196 # model in SasView and copying the appropriate result here. 197 # PDB -- Sep 26, 2018 194 198 [{'contrast_factor': 10.0, 195 199 'bjerrum_length': 7.1, … … 202 206 }, 0.001, 0.0948379], 203 207 204 #Comment out rest of tests as they use non zero salt concentrations. With 205 #the new code the results will change. We can just take the answer the code 206 #gives and call it correct but not sure that is appropriate. May however 207 #be the best we can do? How were these generated in the first place? 208 #In the meantime comment them out. 209 #Additional tests with larger range of parameters 210 # [{'contrast_factor': 10.0, 211 # 'bjerrum_length': 100.0, 212 # 'virial_param': 3.0, 213 # 'monomer_length': 1.0, 214 # 'salt_concentration': 10.0, 215 # 'ionization_degree': 2.0, 216 # 'polymer_concentration': 10.0, 217 # 'background': 0.0, 218 # }, 0.1, -3.75693800588], 219 220 # [{'contrast_factor': 10.0, 221 # 'bjerrum_length': 100.0, 222 # 'virial_param': 3.0, 223 # 'monomer_length': 1.0, 224 # 'salt_concentration': 10.0, 225 # 'ionization_degree': 2.0, 226 # 'polymer_concentration': 10.0, 227 # 'background': 100.0 228 # }, 5.0, 100.029142149], 229 # 230 # [{'contrast_factor': 100.0, 231 # 'bjerrum_length': 10.0, 232 # 'virial_param': 180.0, 233 # 'monomer_length': 1.0, 234 # 'salt_concentration': 0.1, 235 # 'ionization_degree': 0.5, 236 # 'polymer_concentration': 0.1, 237 # 'background': 0.0, 238 # }, 200., 1.80664667511e-06], 208 [{'contrast_factor': 10.0, 209 'bjerrum_length': 100.0, 210 'virial_param': 3.0, 211 'monomer_length': 5.0, 212 'salt_concentration': 1.0, 213 'ionization_degree': 0.1, 214 'polymer_concentration': 1.0, 215 'background': 0.0, 216 }, 0.1, 0.253469484], 217 218 [{'contrast_factor': 10.0, 219 'bjerrum_length': 100.0, 220 'virial_param': 3.0, 221 'monomer_length': 5.0, 222 'salt_concentration': 1.0, 223 'ionization_degree': 0.1, 224 'polymer_concentration': 1.0, 225 'background': 1.0, 226 }, 0.05, 1.738358122], 227 228 [{'contrast_factor': 100.0, 229 'bjerrum_length': 10.0, 230 'virial_param': 12.0, 231 'monomer_length': 10.0, 232 'salt_concentration': 0.1, 233 'ionization_degree': 0.5, 234 'polymer_concentration': 0.1, 235 'background': 0.01, 236 }, 0.5, 0.012881893], 239 237 ]
Note: See TracChangeset
for help on using the changeset viewer.