Changeset c7062fe in sasmodels
- Timestamp:
- Mar 17, 2016 8:37:25 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:
- 246517d
- Parents:
- 228cbd3 (diff), d529d93 (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. - Files:
-
- 1 added
- 39 edited
Legend:
- Unmodified
- Added
- Removed
-
doc/Makefile
r7bb290c r63776d3 131 131 pdf: latex 132 132 $(MAKE) -C _build/latex all-pdf 133 $(COPY) _build/latex/SASModels.pdf _build/html 133 134 134 135 changes: -
doc/genmodel.py
r91c5fdc r70bbb74 1 import sys, os 1 import sys, os, math, re 2 import numpy as np 3 import matplotlib.pyplot as plt 2 4 sys.path.insert(0, os.path.abspath('..')) 3 5 from sasmodels import generate, core 6 from sasmodels.direct_model import DirectModel 7 from sasmodels.data import empty_data1D, empty_data2D 8 4 9 5 10 # Convert ../sasmodels/models/name.py to name … … 8 13 # Load the doc string from the module definition file and store it in rst 9 14 docstr = generate.make_doc(core.load_model_info(model_name)) 15 16 # Generate automatically plot of the model and add it to rst documentation 17 18 info = core.load_model_info(model_name) 19 20 # Calculate 1D curve for default parameters 21 pars = dict((p[0], p[2]) for p in info['parameters']) 22 23 # Plotting ranges and options 24 opts = { 25 'xscale' : 'log', 26 'yscale' : 'log' if not info['structure_factor'] else 'linear', 27 'qmin' : 0.005, 28 'qmax' : 1.0, 29 'nq' : 1000, 30 'nq2d' : 100, 31 } 32 33 qmin, qmax, nq = opts['qmin'], opts['qmax'], opts['nq'] 34 qmin = math.log10(qmin) 35 qmax = math.log10(qmax) 36 q = np.logspace(qmin, qmax, nq) 37 data = empty_data1D(q) 38 model = core.load_model(model_name) 39 calculator = DirectModel(data, model) 40 Iq1D = calculator() 41 42 # TO DO: Generation of 2D plots 43 # Problem in sasmodels.direct_model._calc_theory 44 # There self._kernel.q_input.nq gets a value of 0 in the 2D case 45 # and returns a 0 numpy array (it does not call the C code) 46 47 # If 2D model, compute 2D image 48 #if info['has_2d'] != []: 49 # qmax, nq2d = opts['qmax'], opts['nq2d'] 50 # data2d = empty_data2D(np.linspace(-qmax, qmax, nq2d), resolution=0.0) 51 # #model = core.load_model(model_name) 52 # calculator = DirectModel(data2d, model) 53 # Iq2D = calculator() 54 55 # Generate image (comment IF for 1D/2D for the moment) and generate only 1D 56 #if info['has_2d'] == []: 57 # fig = plt.figure() 58 # ax = fig.add_subplot(1,1,1) 59 # ax.plot(q, Iq1D, color='blue', lw=2, label=model_name) 60 # ax.set_xlabel(r'$Q \/(\AA^{-1})$') 61 # ax.set_xscale(opts['xscale']) 62 # ax.set_ylabel(r'$I(Q) \/(\mathrm{cm}^{-1})$') 63 # ax.set_yscale(opts['yscale']) 64 # ax.legend() 65 #else: 66 # # need figure with 1D + 2D 67 # pass 68 fig = plt.figure() 69 ax = fig.add_subplot(1,1,1) 70 ax.plot(q, Iq1D, color='blue', lw=2, label=model_name) 71 ax.set_xlabel(r'$Q \/(\AA^{-1})$') 72 ax.set_xscale(opts['xscale']) 73 ax.set_ylabel(r'$I(Q) \/(\mathrm{cm}^{-1})$') 74 ax.set_yscale(opts['yscale']) 75 ax.legend() 76 77 78 # Save image in model/img 79 figname = model_name + '_autogenfig.png' 80 filename = os.path.join('model', 'img', figname) 81 plt.savefig(filename) 82 83 # Auto caption for figure 84 captionstr = '\n' 85 captionstr += '.. figure:: img/' + model_name + '_autogenfig.png\n' 86 captionstr += '\n' 87 #if info['has_2d'] == []: 88 # captionstr += ' 1D plot corresponding to the default parameters of the model.\n' 89 #else: 90 # captionstr += ' 1D and 2D plots corresponding to the default parameters of the model.\n' 91 captionstr += ' 1D plot corresponding to the default parameters of the model.\n' 92 captionstr += '\n' 93 94 # Add figure reference and caption to documentation (at end, before References) 95 pattern = '\*\*REFERENCE' 96 m = re.search(pattern, docstr.upper()) 97 98 if m: 99 docstr1 = docstr[:m.start()] 100 docstr2 = docstr[m.start():] 101 docstr = docstr1 + captionstr + docstr2 102 else: 103 print 'References NOT FOUND for model: ', model_name 104 docstr = docstr + captionstr 105 10 106 open(sys.argv[2],'w').write(docstr) -
sasmodels/bumps_model.py
r190fc2b rc5dadbb 83 83 pars = {} 84 84 for p in model_info['parameters']: 85 name, default, limits = p[0], p[2], p[3] 86 value = kwargs.pop(name, default) 87 pars[name] = Parameter.default(value, name=name, limits=limits) 85 value = kwargs.pop(p.name, p.default) 86 pars[p.name] = Parameter.default(value, name=p.name, limits=p.limits) 88 87 for name in model_info['partype']['pd-2d']: 89 88 for xpart, xdefault, xlimits in [ 90 ('_pd', 0., limits),89 ('_pd', 0., pars[name].limits), 91 90 ('_pd_n', 35., (0, 1000)), 92 91 ('_pd_nsigma', 3., (0, 10)), -
sasmodels/compare.py
r91c5fdc rfcd7bbd 681 681 """ 682 682 # Get the default values for the parameters 683 pars = dict((p [0], p[2]) for p in model_info['parameters'])683 pars = dict((p.name, p.default) for p in model_info['parameters']) 684 684 685 685 # Fill in default values for the polydispersity parameters 686 686 for p in model_info['parameters']: 687 if p [4]in ('volume', 'orientation'):688 pars[p [0]+'_pd'] = 0.0689 pars[p [0]+'_pd_n'] = 0690 pars[p [0]+'_pd_nsigma'] = 3.0691 pars[p [0]+'_pd_type'] = "gaussian"687 if p.type in ('volume', 'orientation'): 688 pars[p.name+'_pd'] = 0.0 689 pars[p.name+'_pd_n'] = 0 690 pars[p.name+'_pd_nsigma'] = 3.0 691 pars[p.name+'_pd_type'] = "gaussian" 692 692 693 693 # Plug in values given in demo … … 833 833 pars = suppress_pd(pars) 834 834 pars.update(presets) # set value after random to control value 835 #import pprint; pprint.pprint(model_info) 835 836 constrain_pars(model_info, pars) 836 837 constrain_new_to_old(model_info, pars) -
sasmodels/generate.py
r2f0c07d rfcd7bbd 80 80 is selected, or when an initial value is not otherwise specified. 81 81 82 [*lb*, *ub*] are the hard limits on the parameter value, used to limit83 the polydispersity density function. In the fit, the parameter limits82 *limits = [lb, ub]* are the hard limits on the parameter value, used to 83 limit the polydispersity density function. In the fit, the parameter limits 84 84 given to the fit are the limits on the central value of the parameter. 85 85 If there is polydispersity, it will evaluate parameter values outside … … 216 216 import re 217 217 import string 218 from collections import namedtuple 218 219 219 220 import numpy as np 221 222 PARAMETER_FIELDS = ['name', 'units', 'default', 'limits', 'type', 'description'] 223 Parameter = namedtuple('Parameter', PARAMETER_FIELDS) 220 224 221 225 #TODO: determine which functions are useful outside of generate … … 293 297 """ 294 298 column_widths = [ 295 max(len(p [0]) for p in pars),296 max(len(p [-1]) for p in pars),297 max(len(format_units(p [1])) for p in pars),299 max(len(p.name) for p in pars), 300 max(len(p.description) for p in pars), 301 max(len(format_units(p.units)) for p in pars), 298 302 PARTABLE_VALUE_WIDTH, 299 303 ] … … 310 314 for p in pars: 311 315 lines.append(" ".join([ 312 "%-*s" % (column_widths[0], p [0]),313 "%-*s" % (column_widths[1], p [-1]),314 "%-*s" % (column_widths[2], format_units(p [1])),315 "%*g" % (column_widths[3], p [2]),316 "%-*s" % (column_widths[0], p.name), 317 "%-*s" % (column_widths[1], p.description), 318 "%-*s" % (column_widths[2], format_units(p.units)), 319 "%*g" % (column_widths[3], p.default), 316 320 ])) 317 321 lines.append(sep) … … 469 473 fixed_2d = partype['fixed-1d'] 470 474 471 iq_parameters = [p [0]475 iq_parameters = [p.name 472 476 for p in model_info['parameters'][2:] # skip scale, background 473 if p [0]in set(fixed_1d + pd_1d)]474 iqxy_parameters = [p [0]477 if p.name in set(fixed_1d + pd_1d)] 478 iqxy_parameters = [p.name 475 479 for p in model_info['parameters'][2:] # skip scale, background 476 if p [0]in set(fixed_2d + pd_2d)]477 volume_parameters = [p [0]480 if p.name in set(fixed_2d + pd_2d)] 481 volume_parameters = [p.name 478 482 for p in model_info['parameters'] 479 if p [4]== 'volume']483 if p.type == 'volume'] 480 484 481 485 # Fill in defintions for volume parameters … … 606 610 607 611 for p in pars: 608 name, ptype = p[0], p[4] 609 if ptype == 'volume': 610 partype['pd-1d'].append(name) 611 partype['pd-2d'].append(name) 612 partype['pd-rel'].add(name) 613 elif ptype == 'magnetic': 614 partype['fixed-2d'].append(name) 615 elif ptype == 'orientation': 616 partype['pd-2d'].append(name) 617 elif ptype == '': 618 partype['fixed-1d'].append(name) 619 partype['fixed-2d'].append(name) 612 if p.type == 'volume': 613 partype['pd-1d'].append(p.name) 614 partype['pd-2d'].append(p.name) 615 partype['pd-rel'].add(p.name) 616 elif p.type == 'magnetic': 617 partype['fixed-2d'].append(p.name) 618 elif p.type == 'orientation': 619 partype['pd-2d'].append(p.name) 620 elif p.type == '': 621 partype['fixed-1d'].append(p.name) 622 partype['fixed-2d'].append(p.name) 620 623 else: 621 raise ValueError("unknown parameter type %r" % p type)622 partype[p type].append(name)624 raise ValueError("unknown parameter type %r" % p.type) 625 partype[p.type].append(p.name) 623 626 624 627 return partype … … 628 631 Process parameter block, precalculating parameter details. 629 632 """ 633 # convert parameters into named tuples 634 pars = [Parameter(*p) for p in model_info['parameters']] 630 635 # Fill in the derived attributes 631 partype = categorize_parameters(model_info['parameters']) 632 model_info['limits'] = dict((p[0], p[3]) for p in model_info['parameters']) 636 model_info['parameters'] = pars 637 partype = categorize_parameters(pars) 638 model_info['limits'] = dict((p.name, p.limits) for p in pars) 633 639 model_info['partype'] = partype 634 model_info['defaults'] = dict((p [0], p[2]) for p in model_info['parameters'])640 model_info['defaults'] = dict((p.name, p.default) for p in pars) 635 641 if model_info.get('demo', None) is None: 636 642 model_info['demo'] = model_info['defaults'] … … 649 655 * *id* is the id of the kernel 650 656 * *name* is the display name of the kernel 657 * *filename* is the full path to the module defining the file (if any) 651 658 * *title* is a short description of the kernel 652 659 * *description* is a long description of the kernel (this doesn't seem -
sasmodels/kernelpy.py
r17bbadd rfcd7bbd 111 111 112 112 # First two fixed pars are scale and background 113 pars = [p [0]for p in model_info['parameters'][2:]]113 pars = [p.name for p in model_info['parameters'][2:]] 114 114 offset = len(self.q_input.q_vectors) 115 115 self.args = self.q_input.q_vectors + [None] * len(pars) -
sasmodels/list_pars.py
r17bbadd rfcd7bbd 26 26 model_info = load_model_info(name) 27 27 for p in model_info['parameters']: 28 pname = p[0] 29 partable.setdefault(pname, []) 30 partable[pname].append(name) 28 partable.setdefault(p.name, []) 29 partable[p.name].append(name) 31 30 return partable 32 31 -
sasmodels/model_test.py
r17bbadd rfcd7bbd 251 251 python -m sasmodels.model_test [-v] [opencl|dll] model1 model2 ... 252 252 253 If -v is included on the 253 If -v is included on the command line, then use verboe output. 254 254 255 If neither opencl nor dll is specified, then models will be tested with 255 256 both opencl and dll; the compute target is ignored for pure python models. -
sasmodels/models/be_polyelectrolyte.py
r2f0c07d r6dd90c1 170 170 'ionization_degree': 2.0, 171 171 'polymer_concentration': 10.0, 172 'background': 0.0, 172 173 }, 0.1, -3.75693800588], 173 174 … … 189 190 'ionization_degree': 0.5, 190 191 'polymer_concentration': 0.1, 192 'background': 0.0, 191 193 }, 200., 1.80664667511e-06], 192 194 ] -
sasmodels/models/core_shell_parallelepiped.py
r2f0c07d r6dd90c1 186 186 187 187 qx, qy = 0.2 * np.cos(2.5), 0.2 * np.sin(2.5) 188 tests = [[{}, 0.2, 0.53 2149288477],189 [{}, [0.2], [0.53 2149288477]],190 [{'theta':10.0, 'phi':10.0}, (qx, qy), 0.03 1102135569],191 [{'theta':10.0, 'phi':10.0}, [(qx, qy)], [0.03 1102135569]],188 tests = [[{}, 0.2, 0.533149288477], 189 [{}, [0.2], [0.533149288477]], 190 [{'theta':10.0, 'phi':10.0}, (qx, qy), 0.032102135569], 191 [{'theta':10.0, 'phi':10.0}, [(qx, qy)], [0.032102135569]], 192 192 ] 193 193 del qx, qy # not necessary to delete, but cleaner -
sasmodels/models/correlation_length.py
r3e6c5c1 r6dd90c1 84 84 85 85 tests = [[{}, 0.001, 1009.98], 86 [{}, 0.150141, 0.17 4645],87 [{}, 0.442528, 0.02 03957]]86 [{}, 0.150141, 0.175645], 87 [{}, 0.442528, 0.0213957]] -
sasmodels/models/cylinder.py
r2f0c07d r6dd90c1 167 167 168 168 qx, qy = 0.2 * np.cos(2.5), 0.2 * np.sin(2.5) 169 tests = [[{}, 0.2, 0.04 1761386790780453],170 [{}, [0.2], [0.04 1761386790780453]],171 [{'theta':10.0, 'phi':10.0}, (qx, qy), 0.03 414647218513852],172 [{'theta':10.0, 'phi':10.0}, [(qx, qy)], [0.03 414647218513852]],169 tests = [[{}, 0.2, 0.042761386790780453], 170 [{}, [0.2], [0.042761386790780453]], 171 [{'theta':10.0, 'phi':10.0}, (qx, qy), 0.03514647218513852], 172 [{'theta':10.0, 'phi':10.0}, [(qx, qy)], [0.03514647218513852]], 173 173 ] 174 174 del qx, qy # not necessary to delete, but cleaner -
sasmodels/models/gauss_lorentz_gel.py
r168052c r6dd90c1 132 132 'lorentz_scale_factor': 50.0, 133 133 'dynamic_cor_length': 20.0, 134 }, 0.001, 149.48 1],134 }, 0.001, 149.482], 135 135 136 136 [{'gauss_scale_factor': 100.0, … … 138 138 'lorentz_scale_factor': 50.0, 139 139 'dynamic_cor_length': 20.0, 140 }, 0.105363, 9.19 03],140 }, 0.105363, 9.1913], 141 141 142 142 [{'gauss_scale_factor': 100.0, … … 144 144 'lorentz_scale_factor': 50.0, 145 145 'dynamic_cor_length': 20.0, 146 }, 0.441623, 0.63 2811],146 }, 0.441623, 0.633811], 147 147 148 148 # Additional tests with larger range of parameters … … 151 151 'lorentz_scale_factor': 3.0, 152 152 'dynamic_cor_length': 1.0, 153 }, 0.1, 2.97 02970297],153 }, 0.1, 2.9712970297], 154 154 155 155 [{'gauss_scale_factor': 10.0, … … 158 158 'dynamic_cor_length': 1.0, 159 159 'background': 100.0 160 }, 5.0, 100.11 5384615],160 }, 5.0, 100.116384615], 161 161 162 162 [{'gauss_scale_factor': 10.0, … … 164 164 'lorentz_scale_factor': 3.0, 165 165 'dynamic_cor_length': 1.0, 166 'background': 0.0, 166 167 }, 200., 7.49981250469e-05], 167 168 ] -
sasmodels/models/gel_fit.py
r5111921 r6dd90c1 92 92 'gyration_radius': 10.0, 93 93 'fractal_exp': 10.0, 94 'cor_length': 20.0 94 'cor_length': 20.0, 95 'background': 0.0, 95 96 }, 0.1, 0.716532], 96 97 -
sasmodels/models/guinier.py
r723cebe r6dd90c1 57 57 58 58 # parameters for unit tests 59 tests = [[{'rg' : 31.5}, 0.005, 0.99 1756]]59 tests = [[{'rg' : 31.5}, 0.005, 0.992756]] -
sasmodels/models/hardsphere.py
r8e45182 rd529d93 3 3 spherical particles interacting through hard sphere (excluded volume) 4 4 interactions. 5 May be a reasonable approximation for other shapes of particles that 6 freely rotate, and for moderately polydisperse systems. Though strictly 7 the maths needs to be modified (no \Beta(Q) correction yet in sasview). 5 8 6 The calculation uses the Percus-Yevick closure where the interparticle 9 radius_effective is the effective hard sphere radius. 10 volfraction is the volume fraction occupied by the spheres. 11 12 In sasview the effective radius may be calculated from the parameters 13 used in the form factor $P(q)$ that this $S(q)$ is combined with. 14 15 For numerical stability the computation uses a Taylor series expansion 16 at very small $qR$, there may be a very minor glitch at the transition point 17 in some circumstances. 18 19 The S(Q) uses the Percus-Yevick closure where the interparticle 7 20 potential is 8 21 … … 44 57 systems. Though strictly the maths needs to be modified - 45 58 which sasview does not do yet. 46 effect_radiusis the hard sphere radius59 radius_effective is the hard sphere radius 47 60 volfraction is the volume fraction occupied by the spheres. 48 61 """ … … 51 64 52 65 # ["name", "units", default, [lower, upper], "type","description"], 53 parameters = [[" effect_radius", "Ang", 50.0, [0, inf], "volume",66 parameters = [["radius_effective", "Ang", 50.0, [0, inf], "volume", 54 67 "effective radius of hard sphere"], 55 68 ["volfraction", "", 0.2, [0, 0.74], "", … … 66 79 double D,A,B,G,X,X2,X4,S,C,FF,HARDSPH; 67 80 68 if(fabs( effect_radius) < 1.E-12) {81 if(fabs(radius_effective) < 1.E-12) { 69 82 HARDSPH=1.0; 70 83 return(HARDSPH); … … 75 88 A= (1.+2.*volfraction)*D; 76 89 A *=A; 77 X=fabs(q* effect_radius*2.0);90 X=fabs(q*radius_effective*2.0); 78 91 79 92 if(X < 5.E-06) { … … 138 151 # VR defaults to 1.0 139 152 140 demo = dict( effect_radius=200, volfraction=0.2, effect_radius_pd=0.1, effect_radius_pd_n=40)153 demo = dict(radius_effective=200, volfraction=0.2, radius_effective_pd=0.1, radius_effective_pd_n=40) 141 154 oldname = 'HardsphereStructure' 142 oldpars = dict( )155 oldpars = dict(radius_effective="effect_radius",radius_effective_pd="effect_radius_pd",radius_effective_pd_n="effect_radius_pd_n") 143 156 # Q=0.001 is in the Taylor series, low Q part, so add Q=0.1, assuming double precision sasview is correct 144 157 tests = [ 145 [ {'scale': 1.0, 'background' : 0.0, ' effect_radius' : 50.0, 'volfraction' : 0.2,146 ' effect_radius_pd' : 0}, [0.001,0.1], [0.209128,0.930587]]158 [ {'scale': 1.0, 'background' : 0.0, 'radius_effective' : 50.0, 'volfraction' : 0.2, 159 'radius_effective_pd' : 0}, [0.001,0.1], [0.209128,0.930587]] 147 160 ] 148 161 # ADDED by: RKH ON: 16Mar2016 using equations from FISH as better than orig sasview, see notes above. Added Taylor expansions at small Q, -
sasmodels/models/hayter_msa.py
r348557a rd529d93 9 9 10 10 **This routine only works for charged particles**. If the charge is set to 11 zero the routine willself-destruct! For non-charged particles use a hard11 zero the routine may self-destruct! For non-charged particles use a hard 12 12 sphere potential. 13 13 … … 15 15 which in turn is used to compute the Debye screening length. At present 16 16 there is no provision for entering the ionic strength directly nor for use 17 of any multivalent salts. The counterions are also assumed to be monovalent. 17 of any multivalent salts, though it should be possible to simulate the effect 18 of this by increasing the salt concentration. The counterions are also assumed to 19 be monovalent. 20 21 In sasview the effective radius may be calculated from the parameters 22 used in the form factor $P(q)$ that this $S(q)$ is combined with. 23 24 The computation uses a Taylor series expansion at very small rescaled $qR$, to 25 avoid some serious rounding error issues, this may result in a minor artefact 26 in the transition region under some circumstances. 18 27 19 28 For 2D data, the scattering intensity is calculated in the same way as 1D, … … 24 33 q = \sqrt{q_x^2 + q_y^2} 25 34 26 .. figure:: img/HayterMSAsq_227.jpg27 28 1D plot using the default values (in linear scale).29 35 30 36 References … … 35 41 J P Hansen and J B Hayter, *Molecular Physics*, 46 (1982) 651-656 36 42 """ 43 from numpy import inf 37 44 38 # dp[0] = 2.0*effect_radius(); 45 category = "structure-factor" 46 structure_factor = True 47 single = False # double precision only! 48 49 # dp[0] = 2.0*radius_effective(); 39 50 # dp[1] = fabs(charge()); 40 51 # dp[2] = volfraction(); … … 43 54 # dp[5] = dielectconst(); 44 55 45 from numpy import inf46 56 47 source = ["hayter_msa_kernel.c"] 57 48 58 49 59 name = "hayter_msa" 50 title = "Hayter-Penfold MSA charged sphereinterparticle S(Q) structure factor"60 title = "Hayter-Penfold rescaled MSA, charged sphere, interparticle S(Q) structure factor" 51 61 description = """\ 52 [Hayter-Penfold MSA charged sphere interparticle S(Q) structure factor]62 [Hayter-Penfold RMSA charged sphere interparticle S(Q) structure factor] 53 63 Interparticle structure factor S(Q)for a charged hard spheres. 54 64 Routine takes absolute value of charge, use HardSphere if charge 55 65 goes to zero. 56 In sasview the effective radius will be calculated from the57 parameters used in P(Q).66 In sasview the effective radius and volume fraction may be calculated 67 from the parameters used in P(Q). 58 68 """ 59 single = False # double precision only! 69 60 70 61 71 # pylint: disable=bad-whitespace, line-too-long 62 72 # [ "name", "units", default, [lower, upper], "type", "description" ], 63 73 parameters = [ 64 [" effect_radius", "Ang", 20.75, [0, inf], "volume", "effective radius of hard sphere"],74 ["radius_effective", "Ang", 20.75, [0, inf], "volume", "effective radius of charged sphere"], 65 75 ["charge", "e", 19.0, [0, inf], "", "charge on sphere (in electrons)"], 66 ["volfraction", " ", 0.0192, [0, 0.74], "", "volume fraction of spheres"],76 ["volfraction", "None", 0.0192, [0, 0.74], "", "volume fraction of spheres"], 67 77 ["temperature", "K", 318.16, [0, inf], "", "temperature, in Kelvin, for Debye length calculation"], 68 ["saltconc", "M", 0.0, [-inf, inf], "", "conc of salt, 1:1 electolyte, for Debye length"],69 ["dielectconst", " ", 71.08, [-inf, inf], "", "dielectric constant of solvent (default water), for Debye length"],78 ["saltconc", "M", 0.0, [-inf, inf], "", "conc of salt, moles/litre, 1:1 electolyte, for Debye length"], 79 ["dielectconst", "None", 71.08, [-inf, inf], "", "dielectric constant (relative permittivity) of solvent, default water, for Debye length"] 70 80 ] 71 81 # pylint: enable=bad-whitespace, line-too-long 72 category = "structure-factor"73 82 83 source = ["hayter_msa_kernel.c"] 74 84 # No volume normalization despite having a volume parameter 75 85 # This should perhaps be volume normalized? … … 85 95 86 96 oldname = 'HayterMSAStructure' 87 oldpars = dict() 97 #oldpars = dict(effect_radius="radius_effective",effect_radius_pd="radius_effective_pd",effect_radius_pd_n="radius_effective_pd_n") 98 oldpars = dict(radius_effective="effect_radius",radius_effective_pd="effect_radius_pd",radius_effective_pd_n="effect_radius_pd_n") 99 #oldpars = dict( ) 88 100 # default parameter set, use compare.sh -midQ -linear 89 101 # note the calculation varies in different limiting cases so a wide range of 90 102 # parameters will be required for a thorough test! 91 103 # odd that the default st has saltconc zero 92 demo = dict( effect_radius=20.75,104 demo = dict(radius_effective=20.75, 93 105 charge=19.0, 94 106 volfraction=0.0192, … … 96 108 saltconc=0.05, 97 109 dielectconst=71.08, 98 effect_radius_pd=0.1,99 effect_radius_pd_n=40)110 radius_effective_pd=0.1, 111 radius_effective_pd_n=40) 100 112 # 101 113 # attempt to use same values as old sasview unit test at Q=.001 was 0.0712928, … … 104 116 [{'scale': 1.0, 105 117 'background': 0.0, 106 ' effect_radius': 20.75,118 'radius_effective': 20.75, 107 119 'charge': 19.0, 108 120 'volfraction': 0.0192, … … 110 122 'saltconc': 0, 111 123 'dielectconst': 78.0, 112 ' effect_radius_pd': 0},124 'radius_effective_pd': 0}, 113 125 [0.00001,0.0010,0.01,0.075], [0.0711646,0.0712928,0.0847006,1.07150]], 114 126 [{'scale': 1.0, 115 127 'background': 0.0, 116 ' effect_radius': 20.75,128 'radius_effective': 20.75, 117 129 'charge': 19.0, 118 130 'volfraction': 0.0192, … … 120 132 'saltconc': 0.05, 121 133 'dielectconst': 78.0, 122 ' effect_radius_pd': 0.1,123 ' effect_radius_pd_n': 40},134 'radius_effective_pd': 0.1, 135 'radius_effective_pd_n': 40}, 124 136 [0.00001,0.0010,0.01,0.075], [0.450272,0.450420,0.465116,1.039625]] 125 137 ] 126 138 # ADDED by: RKH ON: 16Mar2016 converted from sasview, new Taylor expansion at smallest rescaled Q -
sasmodels/models/hayter_msa_kernel.c
r348557a rd529d93 3 3 // C99 needs declarations of routines here 4 4 double Iq(double QQ, 5 double effect_radius, double zz, double VolFrac, double Temp, double csalt, double dialec);5 double radius_effective, double zz, double VolFrac, double Temp, double csalt, double dialec); 6 6 int 7 7 sqcoef(int ir, double gMSAWave[]); … … 14 14 15 15 double Iq(double QQ, 16 double effect_radius, double zz, double VolFrac, double Temp, double csalt, double dialec)16 double radius_effective, double zz, double VolFrac, double Temp, double csalt, double dialec) 17 17 { 18 18 double gMSAWave[17]={1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17}; … … 28 28 pi = M_PI; 29 29 30 diam=2* effect_radius; //in A30 diam=2*radius_effective; //in A 31 31 32 32 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -
sasmodels/models/hollow_rectangular_prism.py
r5111921 r6dd90c1 158 158 thickness='thickness', sld='sldPipe', solvent_sld='sldSolv') 159 159 160 tests = [[{}, 0.2, 0.76 587283098],161 [{}, [0.2], [0.76 587283098]],160 tests = [[{}, 0.2, 0.76687283098], 161 [{}, [0.2], [0.76687283098]], 162 162 ] 163 163 -
sasmodels/models/hollow_rectangular_prism_infinitely_thin_walls.py
rdeb7ee0 r6dd90c1 137 137 sld='sldPipe', solvent_sld='sldSolv') 138 138 139 tests = [[{}, 0.2, 0.83 6719188592],140 [{}, [0.2], [0.83 6719188592]],139 tests = [[{}, 0.2, 0.837719188592], 140 [{}, [0.2], [0.837719188592]], 141 141 ] 142 142 -
sasmodels/models/line.py
r4b0e1f3 r6dd90c1 80 80 [{'intercept': 1.0, 81 81 'slope': 1.0, 82 }, 1.0, 2.0 ],82 }, 1.0, 2.001], 83 83 84 84 [{'intercept': 1.0, 85 85 'slope': 1.0, 86 }, 0.0, 1.0 ],86 }, 0.0, 1.001], 87 87 88 88 [{'intercept': 1.0, 89 89 'slope': 1.0, 90 }, 0.4, 1.4 ],90 }, 0.4, 1.401], 91 91 92 92 [{'intercept': 1.0, 93 93 'slope': 1.0, 94 }, 1.3, 2.3 ],94 }, 1.3, 2.301], 95 95 96 96 [{'intercept': 1.0, 97 97 'slope': 1.0, 98 }, 0.5, 1.5 ],98 }, 0.5, 1.501], 99 99 100 100 [{'intercept': 1.0, 101 101 'slope': 1.0, 102 }, [0.4, 0.5], [1.4 , 1.5]],102 }, [0.4, 0.5], [1.401, 1.501]], 103 103 104 104 [{'intercept': 1.0, 105 105 'slope': 1.0, 106 'background': 0.0, 106 107 }, (1.3, 1.57), 5.911], 107 108 ] -
sasmodels/models/lorentz.py
reb5901b r6dd90c1 64 64 65 65 # parameters for unit tests 66 tests = [[{'cor_length': 250}, 0.01, 0.13 7931]]66 tests = [[{'cor_length': 250}, 0.01, 0.138931]] -
sasmodels/models/mass_fractal.py
r168052c r6dd90c1 106 106 'mass_dim': 1.9, 107 107 'cutoff_length': 100.0, 108 }, 0.05, 279.59 322],108 }, 0.05, 279.59422], 109 109 110 110 # Additional tests with larger range of parameters … … 112 112 'mass_dim': 3.3, 113 113 'cutoff_length': 1.0, 114 }, 0.5, 1.29 016774904],114 }, 0.5, 1.29116774904], 115 115 116 116 [{'radius': 1.0, … … 124 124 'cutoff_length': 1.0, 125 125 'scale': 10.0, 126 }, 0.051, 11.62 27966145],126 }, 0.051, 11.6237966145], 127 127 ] -
sasmodels/models/mass_surface_fractal.py
r168052c r6dd90c1 115 115 'cluster_rg': 86.7, 116 116 'primary_rg': 4000.0, 117 'background': 0.0, 117 118 }, 0.05, 1.77537e-05], 118 119 … … 122 123 'cluster_rg': 90.0, 123 124 'primary_rg': 4000.0, 124 }, 0.001, 0.18 462699016],125 }, 0.001, 0.18562699016], 125 126 126 127 [{'mass_dim': 1.3, … … 136 137 'primary_rg': 1000.0, 137 138 'scale': 10.0, 139 'background': 0.0, 138 140 }, 0.051, 0.000169548800377], 139 141 ] -
sasmodels/models/mono_gauss_coil.py
r4c05f49 r6dd90c1 61 61 62 62 # NB: Scale and Background are implicit parameters on every model 63 def Iq(q, radius_gyration):63 def Iq(q, i_zero, radius_gyration): 64 64 # pylint: disable = missing-docstring 65 z = ( x * radius_gyration) * (x * radius_gyration)66 if x== 0:65 z = (q * radius_gyration) ** 2 66 if q == 0: 67 67 inten = 1.0 68 68 else: 69 69 inten = i_zero * 2.0 * (exp(-z) + z - 1.0 ) / (z * z) 70 70 return inten 71 Iq.vectorized = True# Iq accepts an array of q values71 #Iq.vectorized = True # Iq accepts an array of q values 72 72 73 73 def Iqxy(qx, qy, *args): 74 74 # pylint: disable = missing-docstring 75 75 return Iq(sqrt(qx ** 2 + qy ** 2), *args) 76 Iqxy.vectorized =True # Iqxy accepts an array of qx, qy values76 #Iqxy.vectorized = True # Iqxy accepts an array of qx, qy values 77 77 78 78 demo = dict(scale = 1.0, -
sasmodels/models/parallelepiped.py
r5111921 r6dd90c1 233 233 234 234 qx, qy = 0.2 * np.cos(2.5), 0.2 * np.sin(2.5) 235 tests = [[{}, 0.2, 0.17 658004974],236 [{}, [0.2], [0.17 658004974]],237 [{'theta':10.0, 'phi':10.0}, (qx, qy), 0.00 460296014],238 [{'theta':10.0, 'phi':10.0}, [(qx, qy)], [0.00 460296014]],235 tests = [[{}, 0.2, 0.17758004974], 236 [{}, [0.2], [0.17758004974]], 237 [{'theta':10.0, 'phi':10.0}, (qx, qy), 0.00560296014], 238 [{'theta':10.0, 'phi':10.0}, [(qx, qy)], [0.00560296014]], 239 239 ] 240 240 del qx, qy # not necessary to delete, but cleaner -
sasmodels/models/poly_gauss_coil.py
r4c05f49 r6dd90c1 67 67 68 68 # NB: Scale and Background are implicit parameters on every model 69 def Iq(q, radius_gyration, polydispersity):69 def Iq(q, i_zero, radius_gyration, polydispersity): 70 70 # pylint: disable = missing-docstring 71 71 u = polydispersity - 1.0 72 72 # TO DO 73 74 75 z = ((x * radius_gyration) * (x * radius_gyration))/ (1.0 + 2.0 * u)76 if x== 0:77 78 79 80 81 Iq.vectorized = True# Iq accepts an array of q values73 # 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 78 else: 79 inten = i_zero * 2.0 * (power((1.0 + u * z),minusoneonu) + z - 1.0 ) / ((1.0 + u) * (z * z)) 80 return inten 81 #Iq.vectorized = True # Iq accepts an array of q values 82 82 83 83 def Iqxy(qx, qy, *args): 84 84 # pylint: disable = missing-docstring 85 85 return Iq(sqrt(qx ** 2 + qy ** 2), *args) 86 Iqxy.vectorized =True # Iqxy accepts an array of qx, qy values86 #Iqxy.vectorized = True # Iqxy accepts an array of qx, qy values 87 87 88 88 demo = dict(scale = 1.0, -
sasmodels/models/polymer_excl_volume.py
r168052c r6dd90c1 168 168 tests = [ 169 169 # Accuracy tests based on content in test/polyexclvol_default_igor.txt 170 [{'rg': 60, 'porod_exp': 3.0}, 0.001, 0.99 8801],171 [{'rg': 60, 'porod_exp': 3.0}, 0.105363, 0.01 62751],172 [{'rg': 60, 'porod_exp': 3.0 }, 0.665075, 6.56261e-05],170 [{'rg': 60, 'porod_exp': 3.0}, 0.001, 0.999801], 171 [{'rg': 60, 'porod_exp': 3.0}, 0.105363, 0.0172751], 172 [{'rg': 60, 'porod_exp': 3.0, 'background': 0.0}, 0.665075, 6.56261e-05], 173 173 174 174 # Additional tests with larger range of parameters 175 [{'rg': 10, 'porod_exp': 4.0}, 0.1, 0.72 3436675809],175 [{'rg': 10, 'porod_exp': 4.0}, 0.1, 0.724436675809], 176 176 [{'rg': 2.2, 'porod_exp': 22.0, 'background': 100.0}, 5.0, 100.0], 177 177 [{'rg': 1.1, 'porod_exp': 1, 'background': 10.0, 'scale': 1.25}, -
sasmodels/models/rectangular_prism.py
rdeb7ee0 r6dd90c1 135 135 sld='sldPipe', solvent_sld='sldSolv') 136 136 137 tests = [[{}, 0.2, 0.37 4248406825],138 [{}, [0.2], [0.37 4248406825]],137 tests = [[{}, 0.2, 0.375248406825], 138 [{}, [0.2], [0.375248406825]], 139 139 ] -
sasmodels/models/sc_crystal.py
r5111921 r6dd90c1 152 152 tests = [ 153 153 # Accuracy tests based on content in test/utest_extra_models.py 154 [{}, 0.001, 10.30 38],155 [{}, 0.215268, 0.00 714889],156 [{}, (0.414467), 0.00 0313289]154 [{}, 0.001, 10.3048], 155 [{}, 0.215268, 0.00814889], 156 [{}, (0.414467), 0.001313289] 157 157 ] 158 158 -
sasmodels/models/squarewell.py
r5111921 rd529d93 8 8 Positive well depths correspond to an attractive potential well. Negative well depths correspond to a potential 9 9 "shoulder", which may or may not be physically reasonable. The stickyhardsphere model may be a better choice in 10 some circumstances. Computed values may behave badly at extremely small Q.10 some circumstances. Computed values may behave badly at extremely small $qR$. 11 11 12 The well width ( *l*\) is defined as multiples of the particle diameter (2\*\ *R*\ )12 The well width (|lambda| ) is defined as multiples of the particle diameter (2\*\ *R*\ ) 13 13 14 14 The interaction potential is: … … 22 22 U(r) = \begin{cases} 23 23 \infty & r < 2R \\ 24 -\epsilon , 2R \leq < 2R\lambda25 0 & r \geq 2R 24 -\epsilon & 2R \leq r < 2R\lambda \\ 25 0 & r \geq 2R\lambda 26 26 \end{cases} 27 27 28 28 where $r$ is the distance from the center of the sphere of a radius $R$. 29 29 30 In sasview the effective radius may be calculated from the parameters 31 used in the form factor $P(q)$ that this $S(q)$ is combined with. 30 32 31 33 For 2D data: The 2D scattering intensity is calculated in the same way as 1D, where the *q* vector is defined as … … 35 37 q = \sqrt{q_x^2 + q_y^2} 36 38 37 .. comment::38 39 .. figure:: img/squarewell_226.jpg40 41 1D plot using the default values (in linear scale).*42 39 43 40 REFERENCE … … 59 56 """ 60 57 category = "structure-factor" 58 structure_factor = True 61 59 62 60 #single = False … … 65 63 # [ "name", "units", default, [lower, upper], "type", 66 64 # "description" ], 67 [" effect_radius", "Ang", 50.0, [0, inf], "volume",65 ["radius_effective", "Ang", 50.0, [0, inf], "volume", 68 66 "effective radius of hard sphere"], 69 67 ["volfraction", "", 0.04, [0, 0.08], "", … … 71 69 ["welldepth", "kT", 1.5, [0.0, 1.5], "", 72 70 "depth of well, epsilon"], 73 ["wellwidth", "diameters", 1.2, [ 0, inf], "",74 "width of well in diameters (=2R) units "],71 ["wellwidth", "diameters", 1.2, [1.0, inf], "", 72 "width of well in diameters (=2R) units, must be > 1"], 75 73 ] 76 74 … … 89 87 x= q; 90 88 91 req = effect_radius;89 req = radius_effective; 92 90 phis = volfraction; 93 91 edibkb = welldepth; … … 134 132 135 133 oldname = 'SquareWellStructure' 136 oldpars = dict( )137 demo = dict( effect_radius=50, volfraction=0.04, welldepth=1.5,138 wellwidth=1.2, effect_radius_pd=0, effect_radius_pd_n=0)134 oldpars = dict(radius_effective="effect_radius",radius_effective_pd="effect_radius_pd",radius_effective_pd_n="effect_radius_pd_n") 135 demo = dict(radius_effective=50, volfraction=0.04, welldepth=1.5, 136 wellwidth=1.2, radius_effective_pd=0, radius_effective_pd_n=0) 139 137 # 140 138 tests = [ 141 [ {'scale': 1.0, 'background' : 0.0, ' effect_radius' : 50.0, 'volfraction' : 0.04,'welldepth' : 1.5, 'wellwidth' : 1.2,142 ' effect_radius_pd' : 0}, [0.001], [0.97665742]]139 [ {'scale': 1.0, 'background' : 0.0, 'radius_effective' : 50.0, 'volfraction' : 0.04,'welldepth' : 1.5, 'wellwidth' : 1.2, 140 'radius_effective_pd' : 0}, [0.001], [0.97665742]] 143 141 ] 144 # ADDED by: converting from sasview RKH ON: 16Mar2016 - in progress142 # ADDED by: converting from sasview RKH ON: 16Mar2016 145 143 -
sasmodels/models/star_polymer.py
r13ed84c r6dd90c1 76 76 tests = [[{'radius2': 2.0, 77 77 'arms': 3.3, 78 }, 0.5, 0.85 0646091108],78 }, 0.5, 0.851646091108], 79 79 80 80 [{'radius2': 1.0, -
sasmodels/models/stickyhardsphere.py
r8e45182 rd529d93 49 49 the optimization does not hit the constraints. 50 50 51 In sasview the effective radius willbe calculated from the parameters51 In sasview the effective radius may be calculated from the parameters 52 52 used in the form factor $P(q)$ that this $S(q)$ is combined with. 53 53 -
sasmodels/models/surface_fractal.py
r168052c r6dd90c1 106 106 'surface_dim': 2.0, 107 107 'cutoff_length': 500.0, 108 }, 0.05, 301428.6 5916],108 }, 0.05, 301428.66016], 109 109 110 110 # Additional tests with larger range of parameters … … 112 112 'surface_dim': 1.0, 113 113 'cutoff_length': 10.0, 114 }, 0.332070182643, 1125.00 321004],114 }, 0.332070182643, 1125.00421004], 115 115 116 116 [{'radius': 3.5, … … 124 124 'cutoff_length': 33.0, 125 125 'scale': 0.1, 126 }, 0.51, 2.50 020147004],126 }, 0.51, 2.50120147004], 127 127 ] -
sasmodels/models/teubner_strey.py
reb69cce r6dd90c1 91 91 oldpars = dict(a2='scale') 92 92 93 tests = [[{}, 0.2, 0.14 4927536232]]93 tests = [[{}, 0.2, 0.145927536232]] -
sasmodels/models/vesicle.py
rfa8011eb r6dd90c1 130 130 131 131 132 # NOTE: test results taken from values returned by SasView 3.1.2 133 tests = [[{}, 0.0010005303255, 17139.8268799], 134 [{}, 0.200027832249, 0.130387268704], 132 # NOTE: test results taken from values returned by SasView 3.1.2, with 133 # 0.001 added for a non-zero default background. 134 tests = [[{}, 0.0010005303255, 17139.8278799], 135 [{}, 0.200027832249, 0.131387268704], 135 136 [{}, 'ER', 130.], 136 137 [{}, 'VR', 0.54483386436], -
sasmodels/product.py
r35b4c47 rfcd7bbd 28 28 s_id, s_name, s_pars = s_info['id'], s_info['name'], s_info['parameters'] 29 29 # We require models to start with scale and background 30 assert s_pars[SCALE] [0]== 'scale'31 assert s_pars[BACKGROUND] [0]== 'background'30 assert s_pars[SCALE].name == 'scale' 31 assert s_pars[BACKGROUND].name == 'background' 32 32 # We require structure factors to start with effect radius and volfraction 33 assert s_pars[EFFECT_RADIUS] [0]== 'effect_radius'34 assert s_pars[VOLFRACTION] [0]== 'volfraction'33 assert s_pars[EFFECT_RADIUS].name == 'effect_radius' 34 assert s_pars[VOLFRACTION].name == 'volfraction' 35 35 # Combine the parameter sets. We are skipping the first three 36 36 # parameters of S since scale, background are defined in P and … … 38 38 pars = p_pars + s_pars[3:] 39 39 # check for duplicates; can't use assertion since they may never be checked 40 if len(set(p [0]for p in pars)) != len(pars):40 if len(set(p.name for p in pars)) != len(pars): 41 41 raise ValueError("Duplicate parameters in %s and %s"%(p_id)) 42 42 # For comparison with sasview, determine the old parameters. … … 52 52 model_info['title'] = 'Product of %s and structure factor %s'%(p_name, s_name) 53 53 model_info['description'] = model_info['title'] 54 model_info['docs'] = model_info['title'] 54 55 model_info['category'] = "custom" 55 56 model_info['parameters'] = pars 56 # Remember the component info blocks so we can build the product model 57 model_info['composition'] = ('product', [p_info, s_info]) 57 #model_info['single'] = p_info['single'] and s_info['single'] 58 model_info['structure_factor'] = False 59 model_info['variant_info'] = None 60 #model_info['tests'] = [] 61 #model_info['source'] = [] 62 # Iq, Iqxy, form_volume, ER, VR and sesans 58 63 model_info['oldname'] = oldname 59 64 model_info['oldpars'] = oldpars 65 model_info['composition'] = ('product', [p_info, s_info]) 60 66 process_parameters(model_info) 61 67 return model_info -
sasmodels/sasview_model.py
r28da77d rfcd7bbd 60 60 self.dispersion = dict() 61 61 partype = model.info['partype'] 62 for name, units, default, limits, _, _in model.info['parameters']:63 self.params[ name] =default64 self.details[ name] = [units] +limits62 for p in model.info['parameters']: 63 self.params[p.name] = p.default 64 self.details[p.name] = [p.units] + p.limits 65 65 66 66 for name in partype['pd-2d']: -
sasmodels/convert.py
r310ddcb r228cbd3 129 129 warnings.warn("parameter background not used in sasview %s"%name) 130 130 131 131 132 # If it is a product model P*S, then check the individual forms for special 132 133 # cases. Note: despite the structure factor alone not having scale or … … 146 147 for p in "La", "Lb", "Lc", "Ld": 147 148 if p in oldpars: oldpars[p] *= 1e-13 149 elif name == 'core_shell_parallelepiped': 150 _remove_pd(oldpars, 'rimA', name) 151 elif name in ['mono_gauss_coil','poly_gauss_coil']: 152 del oldpars['i_zero'] 148 153 149 154 return oldpars … … 177 182 elif name == 'rpa': 178 183 pars['case_num'] = int(pars['case_num']) 184 elif name == 'mono_gauss_coil': 185 pars['i_zero'] = 1 186 elif name == 'poly_gauss_coil': 187 pars['i_zero'] = 1 188
Note: See TracChangeset
for help on using the changeset viewer.