Changes in / [c7062fe:228cbd3] in sasmodels
- Files:
-
- 1 deleted
- 38 edited
Legend:
- Unmodified
- Added
- Removed
-
doc/Makefile
r63776d3 r7bb290c 131 131 pdf: latex 132 132 $(MAKE) -C _build/latex all-pdf 133 $(COPY) _build/latex/SASModels.pdf _build/html134 133 135 134 changes: -
doc/genmodel.py
r70bbb74 r91c5fdc 1 import sys, os, math, re 2 import numpy as np 3 import matplotlib.pyplot as plt 1 import sys, os 4 2 sys.path.insert(0, os.path.abspath('..')) 5 3 from sasmodels import generate, core 6 from sasmodels.direct_model import DirectModel7 from sasmodels.data import empty_data1D, empty_data2D8 9 4 10 5 # Convert ../sasmodels/models/name.py to name … … 13 8 # Load the doc string from the module definition file and store it in rst 14 9 docstr = generate.make_doc(core.load_model_info(model_name)) 15 16 # Generate automatically plot of the model and add it to rst documentation17 18 info = core.load_model_info(model_name)19 20 # Calculate 1D curve for default parameters21 pars = dict((p[0], p[2]) for p in info['parameters'])22 23 # Plotting ranges and options24 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 plots43 # Problem in sasmodels.direct_model._calc_theory44 # There self._kernel.q_input.nq gets a value of 0 in the 2D case45 # and returns a 0 numpy array (it does not call the C code)46 47 # If 2D model, compute 2D image48 #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 1D56 #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 + 2D67 # pass68 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/img79 figname = model_name + '_autogenfig.png'80 filename = os.path.join('model', 'img', figname)81 plt.savefig(filename)82 83 # Auto caption for figure84 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 + docstr2102 else:103 print 'References NOT FOUND for model: ', model_name104 docstr = docstr + captionstr105 106 10 open(sys.argv[2],'w').write(docstr) -
sasmodels/bumps_model.py
rc5dadbb r190fc2b 83 83 pars = {} 84 84 for p in model_info['parameters']: 85 value = kwargs.pop(p.name, p.default) 86 pars[p.name] = Parameter.default(value, name=p.name, limits=p.limits) 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) 87 88 for name in model_info['partype']['pd-2d']: 88 89 for xpart, xdefault, xlimits in [ 89 ('_pd', 0., pars[name].limits),90 ('_pd', 0., limits), 90 91 ('_pd_n', 35., (0, 1000)), 91 92 ('_pd_nsigma', 3., (0, 10)), -
sasmodels/compare.py
rfcd7bbd r91c5fdc 681 681 """ 682 682 # Get the default values for the parameters 683 pars = dict((p .name, p.default) for p in model_info['parameters'])683 pars = dict((p[0], p[2]) 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 .typein ('volume', 'orientation'):688 pars[p .name+'_pd'] = 0.0689 pars[p .name+'_pd_n'] = 0690 pars[p .name+'_pd_nsigma'] = 3.0691 pars[p .name+'_pd_type'] = "gaussian"687 if p[4] in ('volume', 'orientation'): 688 pars[p[0]+'_pd'] = 0.0 689 pars[p[0]+'_pd_n'] = 0 690 pars[p[0]+'_pd_nsigma'] = 3.0 691 pars[p[0]+'_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)836 835 constrain_pars(model_info, pars) 837 836 constrain_new_to_old(model_info, pars) -
sasmodels/generate.py
rfcd7bbd r2f0c07d 80 80 is selected, or when an initial value is not otherwise specified. 81 81 82 *limits = [lb, ub]* are the hard limits on the parameter value, used to83 limitthe polydispersity density function. In the fit, the parameter limits82 [*lb*, *ub*] are the hard limits on the parameter value, used to limit 83 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 namedtuple219 218 220 219 import numpy as np 221 222 PARAMETER_FIELDS = ['name', 'units', 'default', 'limits', 'type', 'description']223 Parameter = namedtuple('Parameter', PARAMETER_FIELDS)224 220 225 221 #TODO: determine which functions are useful outside of generate … … 297 293 """ 298 294 column_widths = [ 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),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), 302 298 PARTABLE_VALUE_WIDTH, 303 299 ] … … 314 310 for p in pars: 315 311 lines.append(" ".join([ 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),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]), 320 316 ])) 321 317 lines.append(sep) … … 473 469 fixed_2d = partype['fixed-1d'] 474 470 475 iq_parameters = [p .name471 iq_parameters = [p[0] 476 472 for p in model_info['parameters'][2:] # skip scale, background 477 if p .namein set(fixed_1d + pd_1d)]478 iqxy_parameters = [p .name473 if p[0] in set(fixed_1d + pd_1d)] 474 iqxy_parameters = [p[0] 479 475 for p in model_info['parameters'][2:] # skip scale, background 480 if p .namein set(fixed_2d + pd_2d)]481 volume_parameters = [p .name476 if p[0] in set(fixed_2d + pd_2d)] 477 volume_parameters = [p[0] 482 478 for p in model_info['parameters'] 483 if p .type== 'volume']479 if p[4] == 'volume'] 484 480 485 481 # Fill in defintions for volume parameters … … 610 606 611 607 for p in pars: 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) 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) 623 620 else: 624 raise ValueError("unknown parameter type %r" % p .type)625 partype[p .type].append(p.name)621 raise ValueError("unknown parameter type %r" % ptype) 622 partype[ptype].append(name) 626 623 627 624 return partype … … 631 628 Process parameter block, precalculating parameter details. 632 629 """ 633 # convert parameters into named tuples634 pars = [Parameter(*p) for p in model_info['parameters']]635 630 # Fill in the derived attributes 636 model_info['parameters'] = pars 637 partype = categorize_parameters(pars) 638 model_info['limits'] = dict((p.name, p.limits) for p in pars) 631 partype = categorize_parameters(model_info['parameters']) 632 model_info['limits'] = dict((p[0], p[3]) for p in model_info['parameters']) 639 633 model_info['partype'] = partype 640 model_info['defaults'] = dict((p .name, p.default) for p in pars)634 model_info['defaults'] = dict((p[0], p[2]) for p in model_info['parameters']) 641 635 if model_info.get('demo', None) is None: 642 636 model_info['demo'] = model_info['defaults'] … … 655 649 * *id* is the id of the kernel 656 650 * *name* is the display name of the kernel 657 * *filename* is the full path to the module defining the file (if any)658 651 * *title* is a short description of the kernel 659 652 * *description* is a long description of the kernel (this doesn't seem -
sasmodels/kernelpy.py
rfcd7bbd r17bbadd 111 111 112 112 # First two fixed pars are scale and background 113 pars = [p .namefor p in model_info['parameters'][2:]]113 pars = [p[0] 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
rfcd7bbd r17bbadd 26 26 model_info = load_model_info(name) 27 27 for p in model_info['parameters']: 28 partable.setdefault(p.name, []) 29 partable[p.name].append(name) 28 pname = p[0] 29 partable.setdefault(pname, []) 30 partable[pname].append(name) 30 31 return partable 31 32 -
sasmodels/model_test.py
rfcd7bbd r17bbadd 251 251 python -m sasmodels.model_test [-v] [opencl|dll] model1 model2 ... 252 252 253 If -v is included on the command line, then use verboe output. 254 253 If -v is included on the 255 254 If neither opencl nor dll is specified, then models will be tested with 256 255 both opencl and dll; the compute target is ignored for pure python models. -
sasmodels/models/be_polyelectrolyte.py
r6dd90c1 r2f0c07d 170 170 'ionization_degree': 2.0, 171 171 'polymer_concentration': 10.0, 172 'background': 0.0,173 172 }, 0.1, -3.75693800588], 174 173 … … 190 189 'ionization_degree': 0.5, 191 190 'polymer_concentration': 0.1, 192 'background': 0.0,193 191 }, 200., 1.80664667511e-06], 194 192 ] -
sasmodels/models/core_shell_parallelepiped.py
r6dd90c1 r2f0c07d 186 186 187 187 qx, qy = 0.2 * np.cos(2.5), 0.2 * np.sin(2.5) 188 tests = [[{}, 0.2, 0.53 3149288477],189 [{}, [0.2], [0.53 3149288477]],190 [{'theta':10.0, 'phi':10.0}, (qx, qy), 0.03 2102135569],191 [{'theta':10.0, 'phi':10.0}, [(qx, qy)], [0.03 2102135569]],188 tests = [[{}, 0.2, 0.532149288477], 189 [{}, [0.2], [0.532149288477]], 190 [{'theta':10.0, 'phi':10.0}, (qx, qy), 0.031102135569], 191 [{'theta':10.0, 'phi':10.0}, [(qx, qy)], [0.031102135569]], 192 192 ] 193 193 del qx, qy # not necessary to delete, but cleaner -
sasmodels/models/correlation_length.py
r6dd90c1 r3e6c5c1 84 84 85 85 tests = [[{}, 0.001, 1009.98], 86 [{}, 0.150141, 0.17 5645],87 [{}, 0.442528, 0.02 13957]]86 [{}, 0.150141, 0.174645], 87 [{}, 0.442528, 0.0203957]] -
sasmodels/models/cylinder.py
r6dd90c1 r2f0c07d 167 167 168 168 qx, qy = 0.2 * np.cos(2.5), 0.2 * np.sin(2.5) 169 tests = [[{}, 0.2, 0.04 2761386790780453],170 [{}, [0.2], [0.04 2761386790780453]],171 [{'theta':10.0, 'phi':10.0}, (qx, qy), 0.03 514647218513852],172 [{'theta':10.0, 'phi':10.0}, [(qx, qy)], [0.03 514647218513852]],169 tests = [[{}, 0.2, 0.041761386790780453], 170 [{}, [0.2], [0.041761386790780453]], 171 [{'theta':10.0, 'phi':10.0}, (qx, qy), 0.03414647218513852], 172 [{'theta':10.0, 'phi':10.0}, [(qx, qy)], [0.03414647218513852]], 173 173 ] 174 174 del qx, qy # not necessary to delete, but cleaner -
sasmodels/models/gauss_lorentz_gel.py
r6dd90c1 r168052c 132 132 'lorentz_scale_factor': 50.0, 133 133 'dynamic_cor_length': 20.0, 134 }, 0.001, 149.48 2],134 }, 0.001, 149.481], 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 13],140 }, 0.105363, 9.1903], 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 3811],146 }, 0.441623, 0.632811], 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 12970297],153 }, 0.1, 2.9702970297], 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 6384615],160 }, 5.0, 100.115384615], 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,167 166 }, 200., 7.49981250469e-05], 168 167 ] -
sasmodels/models/gel_fit.py
r6dd90c1 r5111921 92 92 'gyration_radius': 10.0, 93 93 'fractal_exp': 10.0, 94 'cor_length': 20.0, 95 'background': 0.0, 94 'cor_length': 20.0 96 95 }, 0.1, 0.716532], 97 96 -
sasmodels/models/guinier.py
r6dd90c1 r723cebe 57 57 58 58 # parameters for unit tests 59 tests = [[{'rg' : 31.5}, 0.005, 0.99 2756]]59 tests = [[{'rg' : 31.5}, 0.005, 0.991756]] -
sasmodels/models/hardsphere.py
rd529d93 r8e45182 3 3 spherical particles interacting through hard sphere (excluded volume) 4 4 interactions. 5 May be a reasonable approximation for other shapes of particles that6 freely rotate, and for moderately polydisperse systems. Though strictly7 the maths needs to be modified (no \Beta(Q) correction yet in sasview).8 5 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 6 The calculation uses the Percus-Yevick closure where the interparticle 20 7 potential is 21 8 … … 57 44 systems. Though strictly the maths needs to be modified - 58 45 which sasview does not do yet. 59 radius_effectiveis the hard sphere radius46 effect_radius is the hard sphere radius 60 47 volfraction is the volume fraction occupied by the spheres. 61 48 """ … … 64 51 65 52 # ["name", "units", default, [lower, upper], "type","description"], 66 parameters = [[" radius_effective", "Ang", 50.0, [0, inf], "volume",53 parameters = [["effect_radius", "Ang", 50.0, [0, inf], "volume", 67 54 "effective radius of hard sphere"], 68 55 ["volfraction", "", 0.2, [0, 0.74], "", … … 79 66 double D,A,B,G,X,X2,X4,S,C,FF,HARDSPH; 80 67 81 if(fabs( radius_effective) < 1.E-12) {68 if(fabs(effect_radius) < 1.E-12) { 82 69 HARDSPH=1.0; 83 70 return(HARDSPH); … … 88 75 A= (1.+2.*volfraction)*D; 89 76 A *=A; 90 X=fabs(q* radius_effective*2.0);77 X=fabs(q*effect_radius*2.0); 91 78 92 79 if(X < 5.E-06) { … … 151 138 # VR defaults to 1.0 152 139 153 demo = dict( radius_effective=200, volfraction=0.2, radius_effective_pd=0.1, radius_effective_pd_n=40)140 demo = dict(effect_radius=200, volfraction=0.2, effect_radius_pd=0.1, effect_radius_pd_n=40) 154 141 oldname = 'HardsphereStructure' 155 oldpars = dict( radius_effective="effect_radius",radius_effective_pd="effect_radius_pd",radius_effective_pd_n="effect_radius_pd_n")142 oldpars = dict() 156 143 # Q=0.001 is in the Taylor series, low Q part, so add Q=0.1, assuming double precision sasview is correct 157 144 tests = [ 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]]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]] 160 147 ] 161 # ADDED by: RKH ON: 16Mar2016 using equations from FISH as better than orig sasview, see notes above. Added Taylor expansions at small Q, 148 -
sasmodels/models/hayter_msa.py
rd529d93 r348557a 9 9 10 10 **This routine only works for charged particles**. If the charge is set to 11 zero the routine mayself-destruct! For non-charged particles use a hard11 zero the routine will 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, 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. 17 of any multivalent salts. The counterions are also assumed to be monovalent. 27 18 28 19 For 2D data, the scattering intensity is calculated in the same way as 1D, … … 33 24 q = \sqrt{q_x^2 + q_y^2} 34 25 26 .. figure:: img/HayterMSAsq_227.jpg 27 28 1D plot using the default values (in linear scale). 35 29 36 30 References … … 41 35 J P Hansen and J B Hayter, *Molecular Physics*, 46 (1982) 651-656 42 36 """ 43 from numpy import inf44 37 45 category = "structure-factor" 46 structure_factor = True 47 single = False # double precision only! 48 49 # dp[0] = 2.0*radius_effective(); 38 # dp[0] = 2.0*effect_radius(); 50 39 # dp[1] = fabs(charge()); 51 40 # dp[2] = volfraction(); … … 54 43 # dp[5] = dielectconst(); 55 44 45 from numpy import inf 56 46 57 47 source = ["hayter_msa_kernel.c"] 58 48 59 49 name = "hayter_msa" 60 title = "Hayter-Penfold rescaled MSA, charged sphere,interparticle S(Q) structure factor"50 title = "Hayter-Penfold MSA charged sphere interparticle S(Q) structure factor" 61 51 description = """\ 62 [Hayter-Penfold RMSA charged sphere interparticle S(Q) structure factor]52 [Hayter-Penfold MSA charged sphere interparticle S(Q) structure factor] 63 53 Interparticle structure factor S(Q)for a charged hard spheres. 64 54 Routine takes absolute value of charge, use HardSphere if charge 65 55 goes to zero. 66 In sasview the effective radius and volume fraction may be calculated67 from theparameters used in P(Q).56 In sasview the effective radius will be calculated from the 57 parameters used in P(Q). 68 58 """ 69 59 single = False # double precision only! 70 60 71 61 # pylint: disable=bad-whitespace, line-too-long 72 62 # [ "name", "units", default, [lower, upper], "type", "description" ], 73 63 parameters = [ 74 [" radius_effective", "Ang", 20.75, [0, inf], "volume", "effective radius of charged sphere"],64 ["effect_radius", "Ang", 20.75, [0, inf], "volume", "effective radius of hard sphere"], 75 65 ["charge", "e", 19.0, [0, inf], "", "charge on sphere (in electrons)"], 76 ["volfraction", " None", 0.0192, [0, 0.74], "", "volume fraction of spheres"],66 ["volfraction", "", 0.0192, [0, 0.74], "", "volume fraction of spheres"], 77 67 ["temperature", "K", 318.16, [0, inf], "", "temperature, in Kelvin, for Debye length calculation"], 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"]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"], 80 70 ] 81 71 # pylint: enable=bad-whitespace, line-too-long 72 category = "structure-factor" 82 73 83 source = ["hayter_msa_kernel.c"]84 74 # No volume normalization despite having a volume parameter 85 75 # This should perhaps be volume normalized? … … 95 85 96 86 oldname = 'HayterMSAStructure' 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( ) 87 oldpars = dict() 100 88 # default parameter set, use compare.sh -midQ -linear 101 89 # note the calculation varies in different limiting cases so a wide range of 102 90 # parameters will be required for a thorough test! 103 91 # odd that the default st has saltconc zero 104 demo = dict( radius_effective=20.75,92 demo = dict(effect_radius=20.75, 105 93 charge=19.0, 106 94 volfraction=0.0192, … … 108 96 saltconc=0.05, 109 97 dielectconst=71.08, 110 radius_effective_pd=0.1,111 radius_effective_pd_n=40)98 effect_radius_pd=0.1, 99 effect_radius_pd_n=40) 112 100 # 113 101 # attempt to use same values as old sasview unit test at Q=.001 was 0.0712928, … … 116 104 [{'scale': 1.0, 117 105 'background': 0.0, 118 ' radius_effective': 20.75,106 'effect_radius': 20.75, 119 107 'charge': 19.0, 120 108 'volfraction': 0.0192, … … 122 110 'saltconc': 0, 123 111 'dielectconst': 78.0, 124 ' radius_effective_pd': 0},112 'effect_radius_pd': 0}, 125 113 [0.00001,0.0010,0.01,0.075], [0.0711646,0.0712928,0.0847006,1.07150]], 126 114 [{'scale': 1.0, 127 115 'background': 0.0, 128 ' radius_effective': 20.75,116 'effect_radius': 20.75, 129 117 'charge': 19.0, 130 118 'volfraction': 0.0192, … … 132 120 'saltconc': 0.05, 133 121 'dielectconst': 78.0, 134 ' radius_effective_pd': 0.1,135 ' radius_effective_pd_n': 40},122 'effect_radius_pd': 0.1, 123 'effect_radius_pd_n': 40}, 136 124 [0.00001,0.0010,0.01,0.075], [0.450272,0.450420,0.465116,1.039625]] 137 125 ] 138 # ADDED by: RKH ON: 16Mar2016 converted from sasview, new Taylor expansion at smallest rescaled Q 126 -
sasmodels/models/hayter_msa_kernel.c
rd529d93 r348557a 3 3 // C99 needs declarations of routines here 4 4 double Iq(double QQ, 5 double radius_effective, double zz, double VolFrac, double Temp, double csalt, double dialec);5 double effect_radius, 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 radius_effective, double zz, double VolFrac, double Temp, double csalt, double dialec)16 double effect_radius, 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* radius_effective; //in A30 diam=2*effect_radius; //in A 31 31 32 32 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -
sasmodels/models/hollow_rectangular_prism.py
r6dd90c1 r5111921 158 158 thickness='thickness', sld='sldPipe', solvent_sld='sldSolv') 159 159 160 tests = [[{}, 0.2, 0.76 687283098],161 [{}, [0.2], [0.76 687283098]],160 tests = [[{}, 0.2, 0.76587283098], 161 [{}, [0.2], [0.76587283098]], 162 162 ] 163 163 -
sasmodels/models/hollow_rectangular_prism_infinitely_thin_walls.py
r6dd90c1 rdeb7ee0 137 137 sld='sldPipe', solvent_sld='sldSolv') 138 138 139 tests = [[{}, 0.2, 0.83 7719188592],140 [{}, [0.2], [0.83 7719188592]],139 tests = [[{}, 0.2, 0.836719188592], 140 [{}, [0.2], [0.836719188592]], 141 141 ] 142 142 -
sasmodels/models/line.py
r6dd90c1 rfa8011eb 80 80 [{'intercept': 1.0, 81 81 'slope': 1.0, 82 }, 1.0, 2.0 01],82 }, 1.0, 2.0], 83 83 84 84 [{'intercept': 1.0, 85 85 'slope': 1.0, 86 }, 0.0, 1.0 01],86 }, 0.0, 1.0], 87 87 88 88 [{'intercept': 1.0, 89 89 'slope': 1.0, 90 }, 0.4, 1.4 01],90 }, 0.4, 1.4], 91 91 92 92 [{'intercept': 1.0, 93 93 'slope': 1.0, 94 }, 1.3, 2.3 01],94 }, 1.3, 2.3], 95 95 96 96 [{'intercept': 1.0, 97 97 'slope': 1.0, 98 }, 0.5, 1.5 01],98 }, 0.5, 1.5], 99 99 100 100 [{'intercept': 1.0, 101 101 'slope': 1.0, 102 }, [0.4, 0.5], [1.4 01, 1.501]],102 }, [0.4, 0.5], [1.4, 1.5]], 103 103 104 104 [{'intercept': 1.0, 105 105 'slope': 1.0, 106 'background': 0.0,107 106 }, (1.3, 1.57), 5.911], 108 107 ] -
sasmodels/models/lorentz.py
r6dd90c1 reb5901b 64 64 65 65 # parameters for unit tests 66 tests = [[{'cor_length': 250}, 0.01, 0.13 8931]]66 tests = [[{'cor_length': 250}, 0.01, 0.137931]] -
sasmodels/models/mass_fractal.py
r6dd90c1 r168052c 106 106 'mass_dim': 1.9, 107 107 'cutoff_length': 100.0, 108 }, 0.05, 279.59 422],108 }, 0.05, 279.59322], 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 116774904],114 }, 0.5, 1.29016774904], 115 115 116 116 [{'radius': 1.0, … … 124 124 'cutoff_length': 1.0, 125 125 'scale': 10.0, 126 }, 0.051, 11.62 37966145],126 }, 0.051, 11.6227966145], 127 127 ] -
sasmodels/models/mass_surface_fractal.py
r6dd90c1 r168052c 115 115 'cluster_rg': 86.7, 116 116 'primary_rg': 4000.0, 117 'background': 0.0,118 117 }, 0.05, 1.77537e-05], 119 118 … … 123 122 'cluster_rg': 90.0, 124 123 'primary_rg': 4000.0, 125 }, 0.001, 0.18 562699016],124 }, 0.001, 0.18462699016], 126 125 127 126 [{'mass_dim': 1.3, … … 137 136 'primary_rg': 1000.0, 138 137 'scale': 10.0, 139 'background': 0.0,140 138 }, 0.051, 0.000169548800377], 141 139 ] -
sasmodels/models/mono_gauss_coil.py
r6dd90c1 r4c05f49 61 61 62 62 # NB: Scale and Background are implicit parameters on every model 63 def Iq(q, i_zero,radius_gyration):63 def Iq(q, radius_gyration): 64 64 # pylint: disable = missing-docstring 65 z = ( q * radius_gyration) ** 266 if q== 0:65 z = (x * radius_gyration) * (x * radius_gyration) 66 if x == 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
r6dd90c1 r5111921 233 233 234 234 qx, qy = 0.2 * np.cos(2.5), 0.2 * np.sin(2.5) 235 tests = [[{}, 0.2, 0.17 758004974],236 [{}, [0.2], [0.17 758004974]],237 [{'theta':10.0, 'phi':10.0}, (qx, qy), 0.00 560296014],238 [{'theta':10.0, 'phi':10.0}, [(qx, qy)], [0.00 560296014]],235 tests = [[{}, 0.2, 0.17658004974], 236 [{}, [0.2], [0.17658004974]], 237 [{'theta':10.0, 'phi':10.0}, (qx, qy), 0.00460296014], 238 [{'theta':10.0, 'phi':10.0}, [(qx, qy)], [0.00460296014]], 239 239 ] 240 240 del qx, qy # not necessary to delete, but cleaner -
sasmodels/models/poly_gauss_coil.py
r6dd90c1 r4c05f49 67 67 68 68 # NB: Scale and Background are implicit parameters on every model 69 def Iq(q, i_zero,radius_gyration, polydispersity):69 def Iq(q, radius_gyration, polydispersity): 70 70 # pylint: disable = missing-docstring 71 71 u = polydispersity - 1.0 72 72 # TO DO 73 74 75 z = (q * radius_gyration) ** 2/ (1.0 + 2.0 * u)76 if q== 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 = ((x * radius_gyration) * (x * radius_gyration)) / (1.0 + 2.0 * u) 76 if x == 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
r6dd90c1 r168052c 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 9801],171 [{'rg': 60, 'porod_exp': 3.0}, 0.105363, 0.01 72751],172 [{'rg': 60, 'porod_exp': 3.0 , 'background': 0.0}, 0.665075, 6.56261e-05],170 [{'rg': 60, 'porod_exp': 3.0}, 0.001, 0.998801], 171 [{'rg': 60, 'porod_exp': 3.0}, 0.105363, 0.0162751], 172 [{'rg': 60, 'porod_exp': 3.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 4436675809],175 [{'rg': 10, 'porod_exp': 4.0}, 0.1, 0.723436675809], 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
r6dd90c1 rdeb7ee0 135 135 sld='sldPipe', solvent_sld='sldSolv') 136 136 137 tests = [[{}, 0.2, 0.37 5248406825],138 [{}, [0.2], [0.37 5248406825]],137 tests = [[{}, 0.2, 0.374248406825], 138 [{}, [0.2], [0.374248406825]], 139 139 ] -
sasmodels/models/sc_crystal.py
r6dd90c1 r5111921 152 152 tests = [ 153 153 # Accuracy tests based on content in test/utest_extra_models.py 154 [{}, 0.001, 10.30 48],155 [{}, 0.215268, 0.00 814889],156 [{}, (0.414467), 0.00 1313289]154 [{}, 0.001, 10.3038], 155 [{}, 0.215268, 0.00714889], 156 [{}, (0.414467), 0.000313289] 157 157 ] 158 158 -
sasmodels/models/squarewell.py
rd529d93 r5111921 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 $qR$.10 some circumstances. Computed values may behave badly at extremely small Q. 11 11 12 The well width ( |lambda|) is defined as multiples of the particle diameter (2\*\ *R*\ )12 The well width (*l*\ ) 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 r < 2R\lambda \\25 0 & r \geq 2R \lambda24 -\epsilon , 2R \leq < 2R\lambda 25 0 & r \geq 2R 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 parameters31 used in the form factor $P(q)$ that this $S(q)$ is combined with.32 30 33 31 For 2D data: The 2D scattering intensity is calculated in the same way as 1D, where the *q* vector is defined as … … 37 35 q = \sqrt{q_x^2 + q_y^2} 38 36 37 .. comment:: 38 39 .. figure:: img/squarewell_226.jpg 40 41 1D plot using the default values (in linear scale).* 39 42 40 43 REFERENCE … … 56 59 """ 57 60 category = "structure-factor" 58 structure_factor = True59 61 60 62 #single = False … … 63 65 # [ "name", "units", default, [lower, upper], "type", 64 66 # "description" ], 65 [" radius_effective", "Ang", 50.0, [0, inf], "volume",67 ["effect_radius", "Ang", 50.0, [0, inf], "volume", 66 68 "effective radius of hard sphere"], 67 69 ["volfraction", "", 0.04, [0, 0.08], "", … … 69 71 ["welldepth", "kT", 1.5, [0.0, 1.5], "", 70 72 "depth of well, epsilon"], 71 ["wellwidth", "diameters", 1.2, [ 1.0, inf], "",72 "width of well in diameters (=2R) units , must be > 1"],73 ["wellwidth", "diameters", 1.2, [0, inf], "", 74 "width of well in diameters (=2R) units"], 73 75 ] 74 76 … … 87 89 x= q; 88 90 89 req = radius_effective;91 req = effect_radius; 90 92 phis = volfraction; 91 93 edibkb = welldepth; … … 132 134 133 135 oldname = 'SquareWellStructure' 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)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) 137 139 # 138 140 tests = [ 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]]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]] 141 143 ] 142 # ADDED by: converting from sasview RKH ON: 16Mar2016 144 # ADDED by: converting from sasview RKH ON: 16Mar2016 - in progress 143 145 -
sasmodels/models/star_polymer.py
r6dd90c1 r13ed84c 76 76 tests = [[{'radius2': 2.0, 77 77 'arms': 3.3, 78 }, 0.5, 0.85 1646091108],78 }, 0.5, 0.850646091108], 79 79 80 80 [{'radius2': 1.0, -
sasmodels/models/stickyhardsphere.py
rd529d93 r8e45182 49 49 the optimization does not hit the constraints. 50 50 51 In sasview the effective radius maybe calculated from the parameters51 In sasview the effective radius will 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
r6dd90c1 r168052c 106 106 'surface_dim': 2.0, 107 107 'cutoff_length': 500.0, 108 }, 0.05, 301428.6 6016],108 }, 0.05, 301428.65916], 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 421004],114 }, 0.332070182643, 1125.00321004], 115 115 116 116 [{'radius': 3.5, … … 124 124 'cutoff_length': 33.0, 125 125 'scale': 0.1, 126 }, 0.51, 2.50 120147004],126 }, 0.51, 2.50020147004], 127 127 ] -
sasmodels/models/teubner_strey.py
r6dd90c1 reb69cce 91 91 oldpars = dict(a2='scale') 92 92 93 tests = [[{}, 0.2, 0.14 5927536232]]93 tests = [[{}, 0.2, 0.144927536232]] -
sasmodels/models/vesicle.py
r6dd90c1 rfa8011eb 130 130 131 131 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], 132 # NOTE: test results taken from values returned by SasView 3.1.2 133 tests = [[{}, 0.0010005303255, 17139.8268799], 134 [{}, 0.200027832249, 0.130387268704], 136 135 [{}, 'ER', 130.], 137 136 [{}, 'VR', 0.54483386436], -
sasmodels/product.py
rfcd7bbd r35b4c47 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] .name== 'scale'31 assert s_pars[BACKGROUND] .name== 'background'30 assert s_pars[SCALE][0] == 'scale' 31 assert s_pars[BACKGROUND][0] == 'background' 32 32 # We require structure factors to start with effect radius and volfraction 33 assert s_pars[EFFECT_RADIUS] .name== 'effect_radius'34 assert s_pars[VOLFRACTION] .name== 'volfraction'33 assert s_pars[EFFECT_RADIUS][0] == 'effect_radius' 34 assert s_pars[VOLFRACTION][0] == '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 .namefor p in pars)) != len(pars):40 if len(set(p[0] 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']55 54 model_info['category'] = "custom" 56 55 model_info['parameters'] = pars 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 56 # Remember the component info blocks so we can build the product model 57 model_info['composition'] = ('product', [p_info, s_info]) 63 58 model_info['oldname'] = oldname 64 59 model_info['oldpars'] = oldpars 65 model_info['composition'] = ('product', [p_info, s_info])66 60 process_parameters(model_info) 67 61 return model_info -
sasmodels/sasview_model.py
rfcd7bbd r28da77d 60 60 self.dispersion = dict() 61 61 partype = model.info['partype'] 62 for pin model.info['parameters']:63 self.params[ p.name] = p.default64 self.details[ p.name] = [p.units] + p.limits62 for name, units, default, limits, _, _ in model.info['parameters']: 63 self.params[name] = default 64 self.details[name] = [units] + limits 65 65 66 66 for name in partype['pd-2d']:
Note: See TracChangeset
for help on using the changeset viewer.