Changeset 15bd6e7 in sasmodels


Ignore:
Timestamp:
Mar 17, 2016 9:38:20 AM (9 years ago)
Author:
ajj
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:
54954e1
Parents:
4373d62
Message:

reverting to @smk98 updates to gaussian coil models from #246517d47

Files:
3 edited

Legend:

Unmodified
Added
Removed
  • example/sesansfit.sh

    • Property mode changed from 100644 to 100755
    r5be92e8 r15bd6e7  
    88set -x 
    99 
    10 python -m bumps.cli $* 
     10pythonw -m bumps.cli $* 
  • sasmodels/models/mono_gauss_coil.py

    raa2edb2 r15bd6e7  
    1414 
    1515     *I(q)* = *scale* |cdot| *I* \ :sub:`0` |cdot| *P(q)* + *background* 
    16           
     16 
    1717where 
    1818 
     
    2020 
    2121     *P(q)* = 2 [exp(-Z) + Z - 1] / Z \ :sup:`2` 
    22           
    23         *Z* = (*q R* \ :sub:`g`)\ :sup:`2` 
     22 
     23    *Z* = (*q R* \ :sub:`g`)\ :sup:`2` 
    2424 
    2525and 
    2626 
    27         *V* = *M* / (*N*\ :sub:`A` |delta|) 
    28           
     27    *V* = *M* / (*N*\ :sub:`A` |delta|) 
     28 
    2929Here, |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. 
    3030 
     
    5252description =  """ 
    5353    Evaluates the scattering from  
    54         monodisperse polymer chains. 
     54    monodisperse polymer chains. 
    5555    """ 
    5656category =  "shape-independent" 
    5757 
    5858#             ["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"]] 
     59parameters =  [["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"]] 
    6161 
    6262# NB: Scale and Background are implicit parameters on every model 
    6363def Iq(q, i_zero, radius_gyration): 
    6464    # pylint: disable = missing-docstring 
    65     z = (q * radius_gyration) ** 2 
    66     if q == 0: 
    67        inten = 1.0 
     65    z = (q * radius_gyration) * (q * radius_gyration) 
     66    if (q == 0).any(): 
     67       inten = i_zero 
    6868    else: 
    6969       inten = i_zero * 2.0 * (exp(-z) + z - 1.0 ) / (z * z) 
     
    7777 
    7878demo =  dict(scale = 1.0, 
    79             i_zero = 1.0, 
    80             radius_gyration = 50.0, 
     79            i_zero = 70.0, 
     80            radius_gyration = 75.0, 
    8181            background = 0.0) 
    8282 
     
    8787 
    8888tests =  [ 
    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]], 
    9191    ] 
  • sasmodels/models/poly_gauss_coil.py

    raa2edb2 r15bd6e7  
    1414 
    1515     *I(q)* = *scale* |cdot| *I* \ :sub:`0` |cdot| *P(q)* + *background* 
    16           
     16 
    1717where 
    1818 
     
    2020 
    2121     *P(q)* = 2 [(1 + UZ)\ :sup:`-1/U` + Z - 1] / [(1 + U) Z\ :sup:`2`] 
    22           
    23         *Z* = [(*q R*\ :sub:`g`)\ :sup:`2`] / (1 + 2U) 
    24           
    25         *U* = (Mw / Mn) - 1 = (*polydispersity ratio*) - 1 
     22 
     23    *Z* = [(*q R*\ :sub:`g`)\ :sup:`2`] / (1 + 2U) 
     24 
     25    *U* = (Mw / Mn) - 1 = (*polydispersity ratio*) - 1 
    2626 
    2727and 
    2828 
    29         *V* = *M* / (*N*\ :sub:`A` |delta|) 
    30           
     29    *V* = *M* / (*N*\ :sub:`A` |delta|) 
     30 
    3131Here, |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. 
    3232 
     
    5757description =  """ 
    5858    Evaluates the scattering from  
    59         polydisperse polymer chains. 
     59    polydisperse polymer chains. 
    6060    """ 
    6161category =  "shape-independent" 
    6262 
    6363#             ["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"], 
     64parameters =  [["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"], 
    6666               ["polydispersity", "None", 2.0, [1.0, inf], "", "Polymer Mw/Mn"]] 
    6767 
     
    6969def Iq(q, i_zero, radius_gyration, polydispersity): 
    7070    # pylint: disable = missing-docstring 
     71    # need to trap the case of the polydispersity being 1 (ie, monodispersity) 
    7172    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 
    7875    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)) 
    8082    return inten 
    81 #Iq.vectorized = True # Iq accepts an array of q values 
     83Iq.vectorized =  True # Iq accepts an array of q values 
    8284 
    8385def Iqxy(qx, qy, *args): 
     
    8789 
    8890demo =  dict(scale = 1.0, 
    89             i_zero = 1.0, 
    90             radius_gyration = 50.0, 
     91            i_zero = 70.0, 
     92            radius_gyration = 75.0, 
    9193            polydispersity = 2.0, 
    9294            background = 0.0) 
     
    99101 
    100102tests =  [ 
    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]], 
    103105    ] 
Note: See TracChangeset for help on using the changeset viewer.