- Timestamp:
- Sep 5, 2017 10:08:03 AM (7 years ago)
- Branches:
- master, core_shell_microgels, costrafo411, magnetic_model, ticket-1257-vesicle-product, ticket_1156, ticket_1265_superball, ticket_822_more_unit_tests
- Children:
- 142a8e2
- Parents:
- 573ffab (diff), 133103b (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. - git-author:
- Paul Butler <butlerpd@…> (09/05/17 10:08:03)
- git-committer:
- GitHub <noreply@…> (09/05/17 10:08:03)
- Location:
- sasmodels
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
sasmodels/sesans.py
r94d13f1 r9f91afe 41 41 _H0 = None # type: np.ndarray 42 42 43 def __init__(self, z, SElength, zaccept, Rmax):43 def __init__(self, z, SElength, lam, zaccept, Rmax): 44 44 # type: (np.ndarray, float, float) -> None 45 45 #import logging; logging.info("creating SESANS transform") 46 46 self.q = z 47 self._set_hankel(SElength, zaccept, Rmax)47 self._set_hankel(SElength, lam, zaccept, Rmax) 48 48 49 49 def apply(self, Iq): … … 54 54 return P 55 55 56 def _set_hankel(self, SElength, zaccept, Rmax):56 def _set_hankel(self, SElength, lam, zaccept, Rmax): 57 57 # type: (np.ndarray, float, float) -> None 58 58 # Force float32 arrays, otherwise run into memory problems on some machines … … 71 71 H = np.float32(dq/(2*pi)) * j0(repSE*repq) * repq 72 72 73 replam = np.tile(lam, (q.size, 1)) 74 reptheta = np.arcsin(repq*replam/2*np.pi) 75 mask = reptheta > zaccept 76 H[mask] = 0 77 73 78 self.q_calc = q 74 79 self._H, self._H0 = H, H0 -
sasmodels/alignment.py
r7ae2b7f r870a2f4 42 42 view[:] = x 43 43 return view 44 -
sasmodels/core.py
r650c6d2 r2e66ef5 117 117 Load model info and build model. 118 118 119 *model_name* is the name of the model as used by :func:`load_model_info`. 120 Additional keyword arguments are passed directly to :func:`build_model`. 119 *model_name* is the name of the model, or perhaps a model expression 120 such as sphere*hardsphere or sphere+cylinder. 121 122 *dtype* and *platform* are given by :func:`build_model`. 121 123 """ 122 124 return build_model(load_model_info(model_name), … … 128 130 """ 129 131 Load a model definition given the model name. 132 133 *model_name* is the name of the model, or perhaps a model expression 134 such as sphere*hardsphere or sphere+cylinder. 130 135 131 136 This returns a handle to the module defining the model. This can be … … 227 232 228 233 Possible types include 'half', 'single', 'double' and 'quad'. If the 229 type is 'fast', then this is equivalent to dtype 'single' with the 230 fast flag set to True. 234 type is 'fast', then this is equivalent to dtype 'single' but using 235 fast native functions rather than those with the precision level guaranteed 236 by the OpenCL standard. 237 238 Platform preference can be specfied ("ocl" vs "dll"), with the default 239 being OpenCL if it is availabe. If the dtype name ends with '!' then 240 platform is forced to be DLL rather than OpenCL. 241 242 This routine ignores the preferences within the model definition. This 243 is by design. It allows us to test models in single precision even when 244 we have flagged them as requiring double precision so we can easily check 245 the performance on different platforms without having to change the model 246 definition. 231 247 """ 232 248 # Assign default platform, overriding ocl with dll if OpenCL is unavailable -
sasmodels/generate.py
rbb4b509 r573ffab 210 210 211 211 # Conversion from units defined in the parameter table for each model 212 # to units displayed in the sphinx documentation. 212 # to units displayed in the sphinx documentation. 213 # This section associates the unit with the macro to use to produce the LaTex 214 # code. The macro itself needs to be defined in sasmodels/doc/rst_prolog. 215 # 216 # NOTE: there is an RST_PROLOG at the end of this file which is NOT 217 # used for the bundled documentation. Still as long as we are defining the macros 218 # in two places any new addition should define the macro in both places. 213 219 RST_UNITS = { 214 220 "Ang": "|Ang|", … … 216 222 "1/Ang^2": "|Ang^-2|", 217 223 "Ang^3": "|Ang^3|", 224 "Ang^2": "|Ang^2|", 218 225 "1e15/cm^3": "|1e15cm^3|", 219 226 "Ang^3/mol": "|Ang^3|/mol", -
sasmodels/model_test.py
rbb4b509 rbedb9b0 47 47 import sys 48 48 import unittest 49 50 try: 51 from StringIO import StringIO 52 except ImportError: 53 # StringIO.StringIO renamed to io.StringIO in Python 3 54 # Note: io.StringIO exists in python 2, but using unicode instead of str 55 from io import StringIO 49 56 50 57 import numpy as np # type: ignore … … 337 344 338 345 def run_one(model): 339 # type: (str) -> None346 # type: (str) -> str 340 347 """ 341 348 Run the tests for a single model, printing the results to stdout. … … 350 357 351 358 # Build a object to capture and print the test results 352 stream = _WritelnDecorator( sys.stdout) # Add writeln() method to stream359 stream = _WritelnDecorator(StringIO()) # Add writeln() method to stream 353 360 verbosity = 2 354 361 descriptions = True … … 388 395 else: 389 396 stream.writeln("Note: no test suite created --- this should never happen") 397 398 output = stream.getvalue() 399 stream.close() 400 return output 390 401 391 402 -
sasmodels/models/multilayer_vesicle.py
r5d23de2 r870a2f4 71 71 sufficiently fine grained in certain cases. Please report any such occurences 72 72 to the SasView team. Generally, for the best possible experience: 73 * Start with the best possible guess 74 * Using a priori knowledge, hold as many parameters fixed as possible 75 * if N=1, tw (water thickness) must by definition be zero. Both N and tw should 73 74 - Start with the best possible guess 75 - Using a priori knowledge, hold as many parameters fixed as possible 76 - if N=1, tw (water thickness) must by definition be zero. Both N and tw should 76 77 be fixed during fitting. 77 *If N>1, use constraints to keep N > 178 *Because N only really moves in integer steps, it may get "stuck" if the78 - If N>1, use constraints to keep N > 1 79 - Because N only really moves in integer steps, it may get "stuck" if the 79 80 optimizer step size is too small so care should be taken 80 81 If you experience problems with this please contact the SasView team and let -
sasmodels/models/star_polymer.py
r40a87fa rd439007 1 1 r""" 2 The Benoit model for a simple star polymer, with Gaussian coils arms from3 a common point.4 5 2 Definition 6 3 ---------- 4 5 Calcuates the scattering from a simple star polymer with f equal Gaussian coil 6 arms. A star being defined as a branched polymer with all the branches 7 emanating from a common central (in the case of this model) point. It is 8 derived as a special case of on the Benoit model for general branched 9 polymers\ [#CITBenoit]_ as also used by Richter ''et. al.''\ [#CITRichter]_ 7 10 8 11 For a star with $f$ arms the scattering intensity $I(q)$ is calculated as … … 15 18 where 16 19 17 .. math:: v=\frac{u ^2f}{(3f-2)}20 .. math:: v=\frac{uf}{(3f-2)} 18 21 19 22 and … … 21 24 .. math:: u = \left\langle R_{g}^2\right\rangle q^2 22 25 23 contains the square of the ensemble average radius-of-gyration of an arm. 26 contains the square of the ensemble average radius-of-gyration of the full 27 polymer while v contains the radius of gyration of a single arm $R_{arm}$. 28 The two are related as: 29 30 .. math:: R_{arm}^2 = \frac{f}{3f-2} R_{g}^2 31 24 32 Note that when there is only one arm, $f = 1$, the Debye Gaussian coil 25 equation is recovered. Star polymers in solutions tend to have strong 26 interparticle and osmotic effects, so the Benoit equation may not work well. 27 At small $q$ the Guinier term and hence $I(q=0)$ is the same as for $f$ arms 28 of radius of gyration $R_g$, as described for the :ref:`mono-gauss-coil` model. 33 equation is recovered. 34 35 .. note:: 36 Star polymers in solutions tend to have strong interparticle and osmotic 37 effects. Thus the Benoit equation may not work well for many real cases. 38 At small $q$ the Guinier term and hence $I(q=0)$ is the same as for $f$ arms 39 of radius of gyration $R_g$, as described for the :ref:`mono-gauss-coil` 40 model. A newer model for star polymer incorporating excluded volume has been 41 developed by Li et al in arXiv:1404.6269 [physics.chem-ph]. 29 42 30 43 References 31 44 ---------- 32 45 33 H Benoit *J. Polymer Science*, 11, 596-599 (1953) 46 .. [#CITBenoit] H Benoit *J. Polymer Science*, 11, 507-510 (1953) 47 .. [#CITRichter] D Richter, B. Farago, J. S. Huang, L. J. Fetters, 48 B Ewen *Macromolecules*, 22, 468-472 (1989) 49 50 Authorship and Verification 51 ---------------------------- 52 53 * **Author:** Kieran Campbell **Date:** July 24, 2012 54 * **Last Modified by:** Paul Butler **Date:** Auguts 26, 2017 55 * **Last Reviewed by:** Ziang Li and Richard Heenan **Date:** May 17, 2017 34 56 """ 35 57 … … 45 67 - v = u^2f/(3f-2) 46 68 - u = <R_g^2>q^2, where <R_g^2> is the ensemble average radius of 47 gyration squared of an arm69 gyration squared of the entire polymer 48 70 - f is the number of arms on the star 71 - the radius of gyration of an arm is given b 72 Rg_arm^2 = R_g^2 * f/(3f-2) 49 73 """ 50 74 category = "shape-independent" … … 52 76 # pylint: disable=bad-whitespace, line-too-long 53 77 # ["name", "units", default, [lower, upper], "type","description"], 54 parameters = [["rg_squared", "Ang^2", 100.0, [0.0, inf], "", "Ensemble radius of gyration SQUARED of an arm"],78 parameters = [["rg_squared", "Ang^2", 100.0, [0.0, inf], "", "Ensemble radius of gyration SQUARED of the full polymer"], 55 79 ["arms", "", 3, [1.0, 6.0], "", "Number of arms in the model"], 56 80 ] -
sasmodels/resolution.py
rb32caab r990d8df 437 437 .. math:: 438 438 439 \log \Delta q = (\log q_n - log q_1) / (n - 1)439 \log \Delta q = (\log q_n - \log q_1) / (n - 1) 440 440 441 441 From this we can compute the number of steps required to extend $q$ … … 451 451 452 452 n_\text{extend} = (n-1) (\log q_\text{max} - \log q_n) 453 / (\log q_n - log q_1)453 / (\log q_n - \log q_1) 454 454 """ 455 455 q = np.sort(q) … … 459 459 log_delta_q = log(10.) / points_per_decade 460 460 if q_min < q[0]: 461 if q_min < 0: q_min = q[0]*MINIMUM_ABSOLUTE_Q 461 if q_min < 0: 462 q_min = q[0]*MINIMUM_ABSOLUTE_Q 462 463 n_low = log_delta_q * (log(q[0])-log(q_min)) 463 464 q_low = np.logspace(log10(q_min), log10(q[0]), np.ceil(n_low)+1)[:-1] -
sasmodels/rst2html.py
rf2f5413 r870a2f4 38 38 - mathml 39 39 - mathjax 40 See ` http://docutils.sourceforge.net/docs/user/config.html#math-output`_40 See `<http://docutils.sourceforge.net/docs/user/config.html#math-output>`_ 41 41 for details. 42 42 … … 176 176 from PyQt5.QtCore import QUrl 177 177 except ImportError: 178 from PyQt4.QtWeb kit import QWebView178 from PyQt4.QtWebKit import QWebView 179 179 from PyQt4.QtCore import QUrl 180 180 helpView = QWebView() … … 204 204 from PyQt5.QtCore import QUrl 205 205 except ImportError: 206 from PyQt4.QtWeb kit import QWebView206 from PyQt4.QtWebKit import QWebView 207 207 from PyQt4.QtCore import QUrl 208 208 frame = QWebView() … … 211 211 sys.exit(app.exec_()) 212 212 213 def can_use_qt(): 214 """ 215 Return True if QWebView exists. 216 217 Checks first in PyQt5 then in PyQt4 218 """ 219 try: 220 from PyQt5.QtWebKitWidgets import QWebView 221 return True 222 except ImportError: 223 try: 224 from PyQt4.QtWebKit import QWebView 225 return True 226 except ImportError: 227 return False 228 213 229 def view_help(filename, qt=False): 214 230 import os 215 url="file:///"+os.path.abspath(filename).replace("\\","/") 231 232 if qt: 233 qt = can_use_qt() 234 235 url = "file:///"+os.path.abspath(filename).replace("\\", "/") 216 236 if filename.endswith('.rst'): 217 237 html = load_rst_as_html(filename)
Note: See TracChangeset
for help on using the changeset viewer.