Changes in / [de032da:663d2a8] in sasmodels
- Files:
-
- 1 added
- 1 deleted
- 86 edited
Legend:
- Unmodified
- Added
- Removed
-
doc/guide/plugin.rst
rdb1d9d5 rc94ab04 303 303 **Note: The order of the parameters in the definition will be the order of the 304 304 parameters in the user interface and the order of the parameters in Fq(), Iq(), 305 Iqac(), Iqabc(), radius_effective(),form_volume() and shell_volume().305 Iqac(), Iqabc(), form_volume() and shell_volume(). 306 306 And** *scale* **and** *background* **parameters are implicit to all models, 307 307 so they do not need to be included in the parameter table.** … … 387 387 can take arbitrary values, even for integer parameters, so your model should 388 388 round the incoming parameter value to the nearest integer inside your model 389 you should round to the nearest integer. In C code, you can do this using: 390 391 .. code-block:: c 389 you should round to the nearest integer. In C code, you can do this using:: 392 390 393 391 static double … … 501 499 Models should define *form_volume(par1, par2, ...)* where the parameter 502 500 list includes the *volume* parameters in order. This is used for a weighted 503 volume normalization so that scattering is on an absolute scale. For 504 solid shapes, the *I(q)* function should use *form_volume* squared 505 as its scale factor. If *form_volume* is not defined, then the default 506 *form_volume = 1.0* will be used. 501 volume normalization so that scattering is on an absolute scale. If 502 *form_volume* is not defined, then the default *form_volume = 1.0* will be 503 used. 507 504 508 505 Hollow shapes, where the volume fraction of particle corresponds to the 509 506 material in the shell rather than the volume enclosed by the shape, must 510 507 also define a *shell_volume(par1, par2, ...)* function. The parameters 511 are the same as for *form_volume*. Here the *I(q)* function should use 512 *shell_volume* squared instead of *form_volume* squared so that the scale 513 parameter corresponds to the volume fraction of material in the sample. 514 The structure factor calculation needs the volume fraction of the filled 515 shapes for its calculation, so the volume fraction parameter in the model 516 is automatically scaled by *form_volume/shell_volume* prior to calling the 517 structure factor. 508 are the same as for *form_volume*. The *I(q)* calculation should use 509 *shell_volume* squared as its scale factor for the volume normalization. 510 The structure factor calculation needs *form_volume* in order to properly 511 scale the volume fraction parameter, so both functions are required for 512 hollow shapes. 518 513 519 514 **Note: Pure python models do not yet support direct computation of the** … … 530 525 """ 531 526 532 This expands into the equivalent C code: 533 534 .. code-block:: c 527 This expands into the equivalent C code:: 535 528 536 529 double Iq(double q, double par1, double par2, ...); … … 543 536 includes only the volume parameters. 544 537 545 * shell_volume* defines the volume of the shell for hollow shapes. As in538 *form_volume* defines the volume of the shell for hollow shapes. As in 546 539 python models, it includes only the volume parameters. 547 540 … … 575 568 Rather than returning NAN from Iq, you must define the *INVALID(v)*. The 576 569 *v* parameter lets you access all the parameters in the model using 577 *v.par1*, *v.par2*, etc. For example: 578 579 .. code-block:: c 570 *v.par1*, *v.par2*, etc. For example:: 580 571 581 572 #define INVALID(v) (v.bell_radius < v.radius) … … 592 583 593 584 Instead of defining the *Iq* function, models can define *Fq* as 594 something like: 595 596 .. code-block:: c 585 something like:: 597 586 598 587 double Fq(double q, double *F1, double *F2, double par1, double par2, ...); … … 626 615 laboratory frame and beam travelling along $-z$. 627 616 628 The oriented C model (oriented pure Python models are not supported) 617 The oriented C model (oriented pure Python models are not supported) 629 618 is called using *Iqabc(qa, qb, qc, par1, par2, ...)* where 630 619 *par1*, etc. are the parameters to the model. If the shape is rotationally … … 655 644 656 645 Using the $z, w$ values for Gauss-Legendre integration in "lib/gauss76.c", the 657 numerical integration is then: 658 659 .. code-block:: c 646 numerical integration is then:: 660 647 661 648 double outer_sum = 0.0; … … 1000 987 memory, and wrong answers computed. The conclusion from a very long and 1001 988 strange debugging session was that any arrays that you declare in your 1002 model should be a multiple of four. For example: 1003 1004 .. code-block:: c 989 model should be a multiple of four. For example:: 1005 990 1006 991 double Iq(q, p1, p2, ...) … … 1034 1019 structure factor is the *hardsphere* interaction, which 1035 1020 uses the effective radius of the form factor as an input to the structure 1036 factor model. The effective radius is the weighted average over all 1037 values of the shape in polydisperse systems. 1038 1039 There can be many notions of effective radius, depending on the shape. For 1040 a sphere it is clearly just the radius, but for an ellipsoid of revolution 1041 we provide average curvature, equivalent sphere radius, minimum radius and 1042 maximum radius. These options are listed as *radius_effective_modes* in 1043 the python model defintion, and must be computed by the *radius_effective* 1044 function which takes the *radius_effective_mode* parameter as an integer, 1045 along with the various model parameters. Unlike normal C/Python arrays, 1046 the first mode is 1, the second is 2, etc. Mode 0 indicates that the 1047 effective radius from the shape is to be ignored in favour of the the 1048 effective radius parameter in the structure factor model. 1049 1050 1051 Consider the core-shell sphere, which defines the following effective radius 1052 modes in the python model:: 1053 1054 radius_effective_modes = [ 1055 "outer radius", 1056 "core radius", 1057 ] 1058 1059 and the following function in the C-file for the model: 1060 1061 .. code-block:: c 1062 1063 static double 1064 radius_effective(int mode, double radius, double thickness) 1065 { 1066 switch (mode) { 1067 case 0: return radius + thickness; 1068 case 1: return radius; 1069 default: return 0.; 1070 } 1071 } 1072 1073 static double 1074 form_volume(double radius, double thickness) 1075 { 1076 return M_4PI_3 * cube(radius + thickness); 1077 } 1078 1079 Given polydispersity over *(r1, r2, ..., rm)* in radius and *(t1, t2, ..., tn)* 1080 in thickness, *radius_effective* is called over a mesh grid covering all 1081 possible combinations of radius and thickness, with a single *(ri, tj)* pair 1082 in each call. The weights each of these results according to the 1083 polydispersity distributions and calls the structure factor with the average 1084 effective radius. Similarly, for *form_volume*. 1085 1086 Hollow models have an additional volume ratio which is needed to scale the 1087 structure factor. The structure factor uses the volume fraction of the filled 1088 particles as part of its density estimate, but the scale factor for the 1089 scattering intensity (as non-solvent volume fraction / volume) is determined 1090 by the shell volume only. Therefore the *shell_volume* function is 1091 needed to compute the form:shell volume ratio, which then scales the 1092 *volfraction* parameter prior to calling the structure factor calculator. 1093 In the case of a hollow sphere, this would be: 1094 1095 .. code-block:: c 1096 1097 static double 1098 shell_volume(double radius, double thickness) 1099 { 1100 double whole = M_4PI_3 * cube(radius + thickness); 1101 double core = M_4PI_3 * cube(radius); 1102 return whole - core; 1103 } 1104 1105 If *shell_volume* is not present, then *form_volume* and *shell_volume* are 1106 assumed to be equal, and the shape is considered solid. 1021 factor model. The effective radius is the average radius of the 1022 form averaged over all the polydispersity values. 1023 1024 :: 1025 1026 def ER(radius, thickness): 1027 """Effective radius of a core-shell sphere.""" 1028 return radius + thickness 1029 1030 Now consider the *core_shell_sphere*, which has a simple effective radius 1031 equal to the radius of the core plus the thickness of the shell, as 1032 shown above. Given polydispersity over *(r1, r2, ..., rm)* in radius and 1033 *(t1, t2, ..., tn)* in thickness, *ER* is called with a mesh 1034 grid covering all possible combinations of radius and thickness. 1035 That is, *radius* is *(r1, r2, ..., rm, r1, r2, ..., rm, ...)* 1036 and *thickness* is *(t1, t1, ... t1, t2, t2, ..., t2, ...)*. 1037 The *ER* function returns one effective radius for each combination. 1038 The effective radius calculator weights each of these according to 1039 the polydispersity distributions and calls the structure factor 1040 with the average *ER*. 1041 1042 :: 1043 1044 def VR(radius, thickness): 1045 """Sphere and shell volumes for a core-shell sphere.""" 1046 whole = 4.0/3.0 * pi * (radius + thickness)**3 1047 core = 4.0/3.0 * pi * radius**3 1048 return whole, whole - core 1049 1050 Core-shell type models have an additional volume ratio which scales 1051 the structure factor. The *VR* function returns the volume of 1052 the whole sphere and the volume of the shell. Like *ER*, there is 1053 one return value for each point in the mesh grid. 1054 1055 *NOTE: we may be removing or modifying this feature soon. As of the 1056 time of writing, core-shell sphere returns (1., 1.) for VR, giving a volume 1057 ratio of 1.0.* 1107 1058 1108 1059 Unit Tests … … 1164 1115 ................... 1165 1116 1166 **NB: For now, this more detailed testing is only possible if you have a 1117 **NB: For now, this more detailed testing is only possible if you have a 1167 1118 SasView build environment available!** 1168 1119 … … 1302 1253 | 2016-10-25 Steve King 1303 1254 | 2017-05-07 Paul Kienzle - Moved from sasview to sasmodels docs 1304 | 2019-03-28 Paul Kienzle - Update docs for radius_effective and shell_volume -
doc/guide/resolution.rst
rdb1d9d5 r8d2df05 1 1 .. resolution.rst 2 2 3 .. This is a port of the original SasView html help file sm_help to ReSTructured 3 .. This is a port of the original SasView html help file sm_help to ReSTructured 4 4 .. text by S King, ISIS, during SasView CodeCamp-III in Feb 2015. 5 5 … … 17 17 resolution contribution into a model calculation/simulation (which by definition 18 18 will be exact) to make it more representative of what has been measured 19 experimentally - a process called *smearing*. The Sasmodels component of SasView 19 experimentally - a process called *smearing*. The Sasmodels component of SasView 20 20 does the latter. 21 21 … … 32 32 33 33 .. note:: 34 Problems may be encountered if the data set loaded by SasView is a 35 concatenation of SANS data from several detector distances where, of 36 course, the worst Q resolution is next to the beam stop at each detector 37 distance. (This will also be noticeable in the residuals plot where 38 there will be poor overlap). SasView sensibly orders all the input 39 data points by increasing Q for nicer-looking plots, however, the dQ 40 data can then vary considerably from point to point. If 'Use dQ data' 41 smearing is selected then spikes may appear in the model fits, whereas 34 Problems may be encountered if the data set loaded by SasView is a 35 concatenation of SANS data from several detector distances where, of 36 course, the worst Q resolution is next to the beam stop at each detector 37 distance. (This will also be noticeable in the residuals plot where 38 there will be poor overlap). SasView sensibly orders all the input 39 data points by increasing Q for nicer-looking plots, however, the dQ 40 data can then vary considerably from point to point. If 'Use dQ data' 41 smearing is selected then spikes may appear in the model fits, whereas 42 42 if 'None' or 'Custom Pinhole Smear' are selected the fits look normal. 43 44 In such instances, possible solutions are to simply remove the data 45 with poor Q resolution from the shorter detector distances, or to fit 43 44 In such instances, possible solutions are to simply remove the data 45 with poor Q resolution from the shorter detector distances, or to fit 46 46 the data from different detector distances simultaneously. 47 47 -
explore/beta/sasfit_compare.py
ra34b811 r119073a 408 408 #radius_effective=12.59921049894873, 409 409 ) 410 target = sasmodels_theory(q, model, radius_effective_mode=0, structure_factor_mode=1, **pars)410 target = sasmodels_theory(q, model, effective_radius_mode=0, structure_factor_mode=1, **pars) 411 411 actual = ellipsoid_pe(q, norm='sasview', **pars) 412 412 title = " ".join(("sasmodels", model, pd_type)) -
explore/beta/sasfit_compare_new.py
ra34b811 rb6422c7 360 360 #polydispersity for hollow_cylinder 361 361 def hollow_cylinder_pe(q,radius=20, thickness=10, length=80, sld=4, sld_solvent=1, volfraction=0.15, 362 radius_pd=0.1, thickness_pd=0.2, length_pd=0.05, radius_pd_type="gaussian", length_pd_type="gaussian", 362 radius_pd=0.1, thickness_pd=0.2, length_pd=0.05, radius_pd_type="gaussian", length_pd_type="gaussian", 363 363 thickness_pd_type="gaussian", radius_effective=None, background=0, scale=1, 364 364 norm='sasview'): … … 595 595 # this one is only used locally for "actual" 596 596 ) 597 target = sasmodels_theory(q, model, radius_effective_mode=0, structure_factor_mode=1, **pars)597 target = sasmodels_theory(q, model, effective_radius_mode=0, structure_factor_mode=1, **pars) 598 598 actual = sphere_r(q, norm='sasview', **pars) 599 599 title = " ".join(("sasmodels", model, pd_type)) … … 612 612 background=0, 613 613 radius_pd=0.01, thickness_pd=0.01, radius_pd_type=pd_type, thickness_pd_type=pd_type, 614 radius_effective=30. ) 614 radius_effective=30. ) 615 615 # equivalent average sphere radius for local "actual" to match what sasview uses, use None to compute average outer radius here, 616 616 617 target = sasmodels_theory(q, model, radius_effective_mode=0, structure_factor_mode=1, **pars)617 target = sasmodels_theory(q, model, effective_radius_mode=0, structure_factor_mode=1, **pars) 618 618 actual = vesicle_pe(q, norm='sasview', **pars) 619 619 title = " ".join(("sasmodels", model, pd_type)) … … 633 633 background=0, 634 634 radius_pd=0.1, thickness_pd=0.0, length_pd=0.0, radius_pd_type=pd_type, thickness_pd_type=pd_type, length_pd_type=pd_type, 635 radius_effective=40.687) 635 radius_effective=40.687) 636 636 # equivalent average sphere radius for local "actual" to match what sasview uses 637 target = sasmodels_theory(q, model, radius_effective_mode=0, structure_factor_mode=1, **pars)637 target = sasmodels_theory(q, model, effective_radius_mode=0, structure_factor_mode=1, **pars) 638 638 actual = hollow_cylinder_pe(q, norm='sasview', **pars) 639 639 # RKH monodisp was OK, actual = hollow_cylinder_theta(q,radius=20, thickness=10, length=80, sld=4, sld_solvent=1 ) … … 656 656 # if change radius_effective to some other value, the S(Q) from sasview does not agree 657 657 ) 658 target = sasmodels_theory(q, model, radius_effective_mode=0, structure_factor_mode=1, **pars)658 target = sasmodels_theory(q, model, effective_radius_mode=0, structure_factor_mode=1, **pars) 659 659 actual = ellipsoid_pe(q, norm='sasview', **pars) 660 660 # RKH test actual = ellipsoid_theta(q, radius_polar=20, radius_equatorial=400, sld=4, sld_solvent=1, volfraction=0.15, radius_effective=270.) -
sasmodels/conversion_table.py
ref476e6 rfa8e6dc 854 854 "TwoPowerLawModel", 855 855 ], 856 "unified_power_ Rg": [856 "unified_power_rg": [ 857 857 "UnifiedPowerRg", 858 858 dict(((field_new+str(index), field_old+str(index)) -
sasmodels/convert.py
ref476e6 rfa8e6dc 606 606 if pars['volfraction_a'] > 0.5: 607 607 pars['volfraction_a'] = 1.0 - pars['volfraction_a'] 608 elif name == 'unified_power_ Rg':608 elif name == 'unified_power_rg': 609 609 pars['level'] = int(pars['level']) 610 610 -
sasmodels/core.py
r9562dd2 rb297ba9 376 376 # type: () -> None 377 377 """Check that model load works""" 378 from .product import RADIUS_ID, VOLFRAC_ID, STRUCTURE_MODE_ID, RADIUS_MODE_ID379 378 #Test the the model produces the parameters that we would expect 380 379 model = load_model("cylinder@hardsphere*sphere") 381 380 actual = [p.name for p in model.info.parameters.kernel_parameters] 382 target = ["sld", "sld_solvent", "radius", "length", "theta", "phi", 383 RADIUS_ID, VOLFRAC_ID, STRUCTURE_MODE_ID, RADIUS_MODE_ID, 384 "A_sld", "A_sld_solvent", "A_radius"] 381 target = ("sld sld_solvent radius length theta phi" 382 " radius_effective volfraction " 383 " structure_factor_mode radius_effective_mode" 384 " A_sld A_sld_solvent A_radius").split() 385 385 assert target == actual, "%s != %s"%(target, actual) 386 386 -
sasmodels/direct_model.py
re220acc rb297ba9 59 59 """ 60 60 mesh = get_mesh(calculator.info, pars, dim=calculator.dim, mono=mono) 61 #print(" in call_kernel: pars:", list(zip(*mesh))[0])61 #print("pars", list(zip(*mesh))[0]) 62 62 call_details, values, is_magnetic = make_kernel_args(calculator, mesh) 63 #print(" in call_kernel:values:", values)63 #print("values:", values) 64 64 return calculator(call_details, values, cutoff, is_magnetic) 65 65 … … 72 72 73 73 Use parameter *radius_effective_mode* to select the effective radius 74 calculation to use amongst the *radius_effective_modes* list given in the 75 model. 74 calculation. 76 75 """ 77 76 R_eff_type = int(pars.pop(RADIUS_MODE_ID, 1.0)) 78 77 mesh = get_mesh(calculator.info, pars, dim=calculator.dim, mono=mono) 79 #print(" in call_Fq:pars", list(zip(*mesh))[0])78 #print("pars", list(zip(*mesh))[0]) 80 79 call_details, values, is_magnetic = make_kernel_args(calculator, mesh) 81 #print(" in call_Fq:values:", values)80 #print("values:", values) 82 81 return calculator.Fq(call_details, values, cutoff, is_magnetic, R_eff_type) 83 82 … … 119 118 active = lambda name: True 120 119 121 #print(" in get_mesh: pars:",[p.id for p in parameters.call_parameters])120 #print("pars",[p.id for p in parameters.call_parameters]) 122 121 mesh = [_get_par_weights(p, values, active(p.name)) 123 122 for p in parameters.call_parameters] -
sasmodels/generate.py
ra34b811 rb297ba9 27 27 which are hollow. 28 28 29 * radius_effective(mode, p1, p2, ...)* returns the effective radius of29 *effective_radius(mode, p1, p2, ...)* returns the effective radius of 30 30 the form with particular dimensions. Mode determines the type of 31 31 effective radius returned, with mode=1 for equivalent volume. … … 820 820 for p in partable.kernel_parameters)) 821 821 # Define the function calls 822 call_ radius_effective = "#define CALL_RADIUS_EFFECTIVE(_mode, _v) 0.0"822 call_effective_radius = "#define CALL_EFFECTIVE_RADIUS(_mode, _v) 0.0" 823 823 if partable.form_volume_parameters: 824 824 refs = _call_pars("_v.", partable.form_volume_parameters) … … 833 833 "do { _form = _shell = form_volume(%s); } " 834 834 "while (0)") % (",".join(refs)) 835 if model_info. radius_effective_modes:836 call_ radius_effective= (837 "#define CALL_ RADIUS_EFFECTIVE(_mode, _v) "838 " radius_effective(_mode, %s)") % (",".join(refs))835 if model_info.effective_radius_type: 836 call_effective_radius = ( 837 "#define CALL_EFFECTIVE_RADIUS(_mode, _v) " 838 "effective_radius(_mode, %s)") % (",".join(refs)) 839 839 else: 840 840 # Model doesn't have volume. We could make the kernel run a little … … 845 845 "do { _form = _shell = 1.0; } while (0)") 846 846 source.append(call_volume) 847 source.append(call_ radius_effective)847 source.append(call_effective_radius) 848 848 model_refs = _call_pars("_v.", partable.iq_parameters) 849 849 -
sasmodels/kernel.py
ra34b811 rb297ba9 78 78 """ 79 79 _, F2, _, shell_volume, _ = self.Fq(call_details, values, cutoff, 80 magnetic, radius_effective_mode=0)80 magnetic, effective_radius_type=0) 81 81 combined_scale = values[0]/shell_volume 82 82 background = values[1] … … 85 85 86 86 def Fq(self, call_details, values, cutoff, magnetic, 87 radius_effective_mode=0):87 effective_radius_type=0): 88 88 # type: (CallDetails, np.ndarray, np.ndarray, float, bool, int) -> np.ndarray 89 89 r""" … … 143 143 volume fraction of the particles. The model can have several 144 144 different ways to compute effective radius, with the 145 * radius_effective_mode* parameter used to select amongst them. The145 *effective_radius_type* parameter used to select amongst them. The 146 146 volume fraction of particles should be determined from the total 147 147 volume fraction of the form, not just the shell volume fraction. … … 153 153 """ 154 154 self._call_kernel(call_details, values, cutoff, magnetic, 155 radius_effective_mode)155 effective_radius_type) 156 156 #print("returned",self.q_input.q, self.result) 157 157 nout = 2 if self.info.have_Fq and self.dim == '1d' else 1 … … 165 165 form_volume = self.result[nout*self.q_input.nq + 1]/total_weight 166 166 shell_volume = self.result[nout*self.q_input.nq + 2]/total_weight 167 radius_effective= self.result[nout*self.q_input.nq + 3]/total_weight167 effective_radius = self.result[nout*self.q_input.nq + 3]/total_weight 168 168 if shell_volume == 0.: 169 169 shell_volume = 1. … … 171 171 if nout == 2 else None) 172 172 F2 = self.result[0:nout*self.q_input.nq:nout]/total_weight 173 return F1, F2, radius_effective, shell_volume, form_volume/shell_volume173 return F1, F2, effective_radius, shell_volume, form_volume/shell_volume 174 174 175 175 def release(self): … … 181 181 182 182 def _call_kernel(self, call_details, values, cutoff, magnetic, 183 radius_effective_mode):183 effective_radius_type): 184 184 # type: (CallDetails, np.ndarray, np.ndarray, float, bool, int) -> np.ndarray 185 185 """ -
sasmodels/kernel_iq.c
r8973e0d r8973e0d 27 27 // parameters in the parameter table. 28 28 // CALL_VOLUME(form, shell, table) : assign form and shell values 29 // CALL_ RADIUS_EFFECTIVE(mode, table) : call the R_eff function29 // CALL_EFFECTIVE_RADIUS(type, table) : call the R_eff function 30 30 // CALL_IQ(q, table) : call the Iq function for 1D calcs. 31 31 // CALL_IQ_A(q, table) : call the Iq function with |q| for 2D data. … … 304 304 pglobal double *result, // nq+1 return values, again with padding 305 305 const double cutoff, // cutoff in the dispersity weight product 306 int32_t radius_effective_mode // which effective radius to compute306 int32_t effective_radius_type // which effective radius to compute 307 307 ) 308 308 { … … 722 722 weighted_form += weight * form; 723 723 weighted_shell += weight * shell; 724 if ( radius_effective_mode != 0) {725 weighted_radius += weight * CALL_ RADIUS_EFFECTIVE(radius_effective_mode, local_values.table);724 if (effective_radius_type != 0) { 725 weighted_radius += weight * CALL_EFFECTIVE_RADIUS(effective_radius_type, local_values.table); 726 726 } 727 727 BUILD_ROTATION(); -
sasmodels/kernelcl.py
ra34b811 r069743a 577 577 578 578 def _call_kernel(self, call_details, values, cutoff, magnetic, 579 radius_effective_mode):579 effective_radius_type): 580 580 # type: (CallDetails, np.ndarray, float, bool, int) -> np.ndarray 581 581 env = environment() … … 601 601 self._result_b, # Result storage. 602 602 self._as_dtype(cutoff), # Probability cutoff. 603 np.uint32( radius_effective_mode), # R_eff mode.603 np.uint32(effective_radius_type), # R_eff mode. 604 604 ] 605 605 -
sasmodels/kernelcuda.py
ra34b811 rb297ba9 473 473 474 474 def _call_kernel(self, call_details, values, cutoff, magnetic, 475 radius_effective_mode):475 effective_radius_type): 476 476 # type: (CallDetails, np.ndarray, float, bool, int) -> np.ndarray 477 477 … … 492 492 self._result_b, # Result storage. 493 493 self._as_dtype(cutoff), # Probability cutoff. 494 np.uint32( radius_effective_mode), # R_eff mode.494 np.uint32(effective_radius_type), # R_eff mode. 495 495 ] 496 496 grid = partition(self.q_input.nq) -
sasmodels/kerneldll.py
ra34b811 rb297ba9 403 403 404 404 def _call_kernel(self, call_details, values, cutoff, magnetic, 405 radius_effective_mode):405 effective_radius_type): 406 406 # type: (CallDetails, np.ndarray, float, bool, int) -> np.ndarray 407 407 … … 417 417 self.result.ctypes.data, # Result storage. 418 418 self._as_dtype(cutoff), # Probability cutoff. 419 radius_effective_mode, # R_eff mode.419 effective_radius_type, # R_eff mode. 420 420 ] 421 421 -
sasmodels/kernelpy.py
ra34b811 rb297ba9 172 172 volume = model_info.form_volume 173 173 shell = model_info.shell_volume 174 radius = model_info. radius_effective174 radius = model_info.effective_radius 175 175 self._volume = ((lambda: (shell(*volume_args), volume(*volume_args))) if shell and volume 176 176 else (lambda: [volume(*volume_args)]*2) if volume … … 180 180 else (lambda mode: 1.0)) 181 181 182 def _call_kernel(self, call_details, values, cutoff, magnetic, radius_effective_mode):182 def _call_kernel(self, call_details, values, cutoff, magnetic, effective_radius_type): 183 183 # type: (CallDetails, np.ndarray, np.ndarray, float, bool) -> np.ndarray 184 184 if magnetic: … … 186 186 #print("Calling python kernel") 187 187 #call_details.show(values) 188 radius = ((lambda: 0.0) if radius_effective_mode == 0189 else (lambda: self._radius( radius_effective_mode)))188 radius = ((lambda: 0.0) if effective_radius_type == 0 189 else (lambda: self._radius(effective_radius_type))) 190 190 self.result = _loops( 191 191 self._parameter_vector, self._form, self._volume, radius, -
sasmodels/model_test.py
r8795b6f rb297ba9 240 240 s_name = pars.pop('@S') 241 241 ps_test = [pars] + list(test[1:]) 242 #print("PS TEST PARAMS!!!",ps_test)243 242 # build the P@S model 244 243 s_info = load_model_info(s_name) … … 247 246 platform=self.platform) 248 247 # run the tests 249 #self.info = ps_model.info250 #print("SELF.INFO PARAMS!!!",[p.id for p in self.info.parameters.call_parameters])251 #print("PS MODEL PARAMETERS:",[p.id for p in ps_model.info.parameters.call_parameters])252 248 results.append(self.run_one(ps_model, ps_test)) 253 249 … … 307 303 """Run a single test case.""" 308 304 user_pars, x, y = test[:3] 309 #print("PS MODEL PARAMETERS:",[p.id for p in model.info.parameters.call_parameters]) 310 pars = expand_pars(model.info.parameters, user_pars) 311 invalid = invalid_pars(model.info.parameters, pars) 305 pars = expand_pars(self.info.parameters, user_pars) 306 invalid = invalid_pars(self.info.parameters, pars) 312 307 if invalid: 313 308 raise ValueError("Unknown parameters in test: " + ", ".join(invalid)) … … 333 328 else: 334 329 y1 = y 335 y2 = test[3] if isinstance(test[3], list) else [test[3]]336 F , Fsq, R_eff, volume, volume_ratio = call_Fq(kernel, pars)337 if F is not None: # Fis none for models with Iq instead of Fq338 self._check_vectors(x, y1, F , 'F')339 self._check_vectors(x, y2, F sq, 'F^2')330 y2 = test[3] if not isinstance(test[3], list) else [test[3]] 331 F1, F2, R_eff, volume, volume_ratio = call_Fq(kernel, pars) 332 if F1 is not None: # F1 is none for models with Iq instead of Fq 333 self._check_vectors(x, y1, F1, 'F') 334 self._check_vectors(x, y2, F2, 'F^2') 340 335 self._check_scalar(test[4], R_eff, 'R_eff') 341 336 self._check_scalar(test[5], volume, 'volume') 342 337 self._check_scalar(test[6], volume_ratio, 'form:shell ratio') 343 return F sq338 return F2 344 339 345 340 def _check_scalar(self, target, actual, name): 346 self.assertTrue(is_near(target, actual, 5), 347 '%s: expected:%s; actual:%s' 348 % (name, target, actual)) 341 if target is None: 342 # smoke test --- make sure it runs and produces a value 343 self.assertTrue(not np.isnan(actual), 344 'invalid %s: %s' % (name, actual)) 345 elif np.isnan(target): 346 # make sure nans match 347 self.assertTrue(np.isnan(actual), 348 '%s: expected:%s; actual:%s' 349 % (name, target, actual)) 350 else: 351 # is_near does not work for infinite values, so also test 352 # for exact values. 353 self.assertTrue(target == actual or is_near(target, actual, 5), 354 '%s: expected:%s; actual:%s' 355 % (name, target, actual)) 349 356 350 357 def _check_vectors(self, x, target, actual, name='I'): … … 356 363 '%s(...) returned wrong length'%name) 357 364 for xi, yi, actual_yi in zip(x, target, actual): 358 self.assertTrue(is_near(yi, actual_yi, 5), 359 '%s(%s): expected:%s; actual:%s' 360 % (name, xi, target, actual)) 365 if yi is None: 366 # smoke test --- make sure it runs and produces a value 367 self.assertTrue(not np.isnan(actual_yi), 368 'invalid %s(%s): %s' % (name, xi, actual_yi)) 369 elif np.isnan(yi): 370 # make sure nans match 371 self.assertTrue(np.isnan(actual_yi), 372 '%s(%s): expected:%s; actual:%s' 373 % (name, xi, yi, actual_yi)) 374 else: 375 # is_near does not work for infinite values, so also test 376 # for exact values. 377 self.assertTrue(yi == actual_yi or is_near(yi, actual_yi, 5), 378 '%s(%s); expected:%s; actual:%s' 379 % (name, xi, yi, actual_yi)) 361 380 362 381 return ModelTestCase … … 370 389 invalid = [] 371 390 for par in sorted(pars.keys()): 372 # Ignore the R_eff mode parameter when checking for valid parameters. 373 # It is an allowed parameter for a model even though it does not exist 374 # in the parameter table. The call_Fq() function pops it from the 375 # parameter list and sends it directly to kernel.Fq(). 391 # special handling of R_eff mode, which is not a usual parameter 376 392 if par == product.RADIUS_MODE_ID: 377 393 continue … … 389 405 """ 390 406 Returns true if *actual* is within *digits* significant digits of *target*. 391 392 *taget* zero and inf should match *actual* zero and inf. If you want to 393 accept eps for zero, choose a value such as 1e-10, which must match up to 394 +/- 1e-15 when *digits* is the default value of 5. 395 396 If *target* is None, then just make sure that *actual* is not NaN. 397 398 If *target* is NaN, make sure *actual* is NaN. 399 """ 400 if target is None: 401 # target is None => actual cannot be NaN 402 return not np.isnan(actual) 403 elif target == 0.: 404 # target is 0. => actual must be 0. 405 # Note: if small values are allowed, then use maybe test zero against eps instead? 406 return actual == 0. 407 elif np.isfinite(target): 408 shift = np.ceil(np.log10(abs(target))) 409 return abs(target-actual) < 1.5*10**(shift-digits) 410 elif target == actual: 411 # target is inf => actual must be inf of same sign 412 return True 413 else: 414 # target is NaN => actual must be NaN 415 return np.isnan(target) == np.isnan(actual) 407 """ 408 import math 409 shift = 10**math.ceil(math.log10(abs(target))) 410 return abs(target-actual)/shift < 1.5*10**-digits 416 411 417 412 # CRUFT: old interface; should be deprecated and removed -
sasmodels/modelinfo.py
ra34b811 rb297ba9 265 265 other sld parameters. The volume parameters are used for calls 266 266 to form_volume within the kernel (required for volume normalization), 267 to shell_volume (for hollow shapes), and to radius_effective(for267 to shell_volume (for hollow shapes), and to effective_radius (for 268 268 structure factor interactions) respectively. 269 269 … … 841 841 info.structure_factor = getattr(kernel_module, 'structure_factor', False) 842 842 # TODO: find Fq by inspection 843 info. radius_effective_modes = getattr(kernel_module, 'radius_effective_modes', None)843 info.effective_radius_type = getattr(kernel_module, 'effective_radius_type', None) 844 844 info.have_Fq = getattr(kernel_module, 'have_Fq', False) 845 845 info.profile_axes = getattr(kernel_module, 'profile_axes', ['x', 'y']) … … 848 848 info.source = getattr(kernel_module, 'source', []) 849 849 info.c_code = getattr(kernel_module, 'c_code', None) 850 info. radius_effective = getattr(kernel_module, 'radius_effective', None)850 info.effective_radius = getattr(kernel_module, 'effective_radius', None) 851 851 # TODO: check the structure of the tests 852 852 info.tests = getattr(kernel_module, 'tests', []) … … 961 961 #: List of options for computing the effective radius of the shape, 962 962 #: or None if the model is not usable as a form factor model. 963 radius_effective_modes= None # type: List[str]963 effective_radius_type = None # type: List[str] 964 964 #: List of C source files used to define the model. The source files 965 965 #: should define the *Iq* function, and possibly *Iqac* or *Iqabc* if the … … 989 989 #: monodisperse approximation for non-dilute solutions, P@S. The first 990 990 #: argument is the integer effective radius mode, with default 0. 991 radius_effective= None # type: Union[None, Callable[[int, np.ndarray], float]]991 effective_radius = None # type: Union[None, Callable[[int, np.ndarray], float]] 992 992 #: Returns *I(q, a, b, ...)* for parameters *a*, *b*, etc. defined 993 993 #: by the parameter table. *Iq* can be defined as a python function, or -
sasmodels/models/_spherepy.py
ra34b811 r0507e09 48 48 ---------------------------- 49 49 50 * **Author: P Kienzle** 51 * **Last Modified by:** 50 * **Author: P Kienzle** 51 * **Last Modified by:** 52 52 * **Last Reviewed by:** S King and P Parker **Date:** 2013/09/09 and 2014/01/06 53 53 * **Source added by :** Steve King **Date:** March 25, 2019 … … 83 83 return 1.333333333333333 * pi * radius ** 3 84 84 85 def radius_effective(mode, radius):85 def effective_radius(mode, radius): 86 86 """Calculate R_eff for sphere""" 87 return radius if mode else 0.87 return radius 88 88 89 89 def Iq(q, sld, sld_solvent, radius): -
sasmodels/models/barbell.c
ra34b811 r99658f6 85 85 86 86 static double 87 radius_effective(int mode, double radius_bell, double radius, double length)87 effective_radius(int mode, double radius_bell, double radius, double length) 88 88 { 89 89 switch (mode) { -
sasmodels/models/barbell.py
ra34b811 r0507e09 126 126 source = ["lib/polevl.c", "lib/sas_J1.c", "lib/gauss76.c", "barbell.c"] 127 127 have_Fq = True 128 radius_effective_modes= [128 effective_radius_type = [ 129 129 "equivalent cylinder excluded volume", "equivalent volume sphere", 130 130 "radius", "half length", "half total length", -
sasmodels/models/capped_cylinder.c
ra34b811 r99658f6 107 107 108 108 static double 109 radius_effective(int mode, double radius, double radius_cap, double length)109 effective_radius(int mode, double radius, double radius_cap, double length) 110 110 { 111 111 switch (mode) { -
sasmodels/models/capped_cylinder.py
ra34b811 r0507e09 146 146 source = ["lib/polevl.c", "lib/sas_J1.c", "lib/gauss76.c", "capped_cylinder.c"] 147 147 have_Fq = True 148 radius_effective_modes= [148 effective_radius_type = [ 149 149 "equivalent cylinder excluded volume", "equivalent volume sphere", 150 150 "radius", "half length", "half total length", -
sasmodels/models/core_multi_shell.c
ra34b811 rd42dd4a 26 26 27 27 static double 28 radius_effective(int mode, double core_radius, double fp_n, double thickness[])28 effective_radius(int mode, double core_radius, double fp_n, double thickness[]) 29 29 { 30 30 switch (mode) { -
sasmodels/models/core_multi_shell.py
ra34b811 r0507e09 108 108 source = ["lib/sas_3j1x_x.c", "core_multi_shell.c"] 109 109 have_Fq = True 110 radius_effective_modes= ["outer radius", "core radius"]110 effective_radius_type = ["outer radius", "core radius"] 111 111 112 112 def random(): -
sasmodels/models/core_shell_bicelle.c
ra34b811 r99658f6 60 60 61 61 static double 62 radius_effective(int mode, double radius, double thick_rim, double thick_face, double length)62 effective_radius(int mode, double radius, double thick_rim, double thick_face, double length) 63 63 { 64 64 switch (mode) { -
sasmodels/models/core_shell_bicelle.py
ra34b811 r0507e09 165 165 "core_shell_bicelle.c"] 166 166 have_Fq = True 167 radius_effective_modes= [167 effective_radius_type = [ 168 168 "excluded volume", "equivalent volume sphere", "outer rim radius", 169 169 "half outer thickness", "half diagonal", -
sasmodels/models/core_shell_bicelle_elliptical.c
ra34b811 r99658f6 35 35 36 36 static double 37 radius_effective(int mode, double r_minor, double x_core, double thick_rim, double thick_face, double length)37 effective_radius(int mode, double r_minor, double x_core, double thick_rim, double thick_face, double length) 38 38 { 39 39 switch (mode) { -
sasmodels/models/core_shell_bicelle_elliptical.py
ra34b811 r0507e09 155 155 "core_shell_bicelle_elliptical.c"] 156 156 have_Fq = True 157 radius_effective_modes= [157 effective_radius_type = [ 158 158 "equivalent cylinder excluded volume", "equivalent volume sphere", 159 159 "outer rim average radius", "outer rim min radius", -
sasmodels/models/core_shell_bicelle_elliptical_belt_rough.c
ra34b811 r99658f6 36 36 37 37 static double 38 radius_effective(int mode, double r_minor, double x_core, double thick_rim, double thick_face, double length)38 effective_radius(int mode, double r_minor, double x_core, double thick_rim, double thick_face, double length) 39 39 { 40 40 switch (mode) { -
sasmodels/models/core_shell_bicelle_elliptical_belt_rough.py
ra34b811 r0507e09 168 168 "core_shell_bicelle_elliptical_belt_rough.c"] 169 169 have_Fq = True 170 radius_effective_modes= [170 effective_radius_type = [ 171 171 "equivalent cylinder excluded volume", "equivalent volume sphere", 172 172 "outer rim average radius", "outer rim min radius", -
sasmodels/models/core_shell_cylinder.c
ra34b811 r99658f6 37 37 38 38 static double 39 radius_effective(int mode, double radius, double thickness, double length)39 effective_radius(int mode, double radius, double thickness, double length) 40 40 { 41 41 switch (mode) { -
sasmodels/models/core_shell_cylinder.py
rdb1d9d5 r81d0b9b 141 141 source = ["lib/polevl.c", "lib/sas_J1.c", "lib/gauss76.c", "core_shell_cylinder.c"] 142 142 have_Fq = True 143 radius_effective_modes= [143 effective_radius_type = [ 144 144 "excluded volume", "equivalent volume sphere", "outer radius", "half outer length", 145 145 "half min outer dimension", "half max outer dimension", "half outer diagonal", -
sasmodels/models/core_shell_ellipsoid.c
ra34b811 r99658f6 68 68 69 69 static double 70 radius_effective(int mode, double radius_equat_core, double x_core, double thick_shell, double x_polar_shell)70 effective_radius(int mode, double radius_equat_core, double x_core, double thick_shell, double x_polar_shell) 71 71 { 72 72 const double radius_equat_tot = radius_equat_core + thick_shell; -
sasmodels/models/core_shell_ellipsoid.py
rdb1d9d5 re5a8f33 3 3 ---------- 4 4 5 Parameters for this model are the core axial ratio $X_{core}$ and a shell 6 thickness $t_{shell}$, which are more often what we would like to determine 7 and make the model better behaved, particularly when polydispersity is 8 applied, than the four independent radii used in the original parameterization 5 Parameters for this model are the core axial ratio $X_{core}$ and a shell 6 thickness $t_{shell}$, which are more often what we would like to determine 7 and make the model better behaved, particularly when polydispersity is 8 applied, than the four independent radii used in the original parameterization 9 9 of this model. 10 10 … … 19 19 $X_{core}$ = 1 is a spherical core. 20 20 21 For a fixed shell thickness $X_{polar shell}$ = 1, to scale $t_{shell}$ 21 For a fixed shell thickness $X_{polar shell}$ = 1, to scale $t_{shell}$ 22 22 pro-rata with the radius set or constrain $X_{polar shell}$ = $X_{core}$. 23 23 … … 47 47 48 48 .. In following equation SK changed radius\_equat\_core to R_e 49 49 50 .. math:: 50 51 :nowrap: … … 75 76 $V = (4/3)\pi R_pR_e^2$ is the volume of the ellipsoid , $R_p$ is the 76 77 polar radius along the rotational axis of the ellipsoid, $R_e$ is the 77 equatorial radius perpendicular to the rotational axis of the ellipsoid, 78 $t_{shell}$ is the thickness of the shell at the equator, 78 equatorial radius perpendicular to the rotational axis of the ellipsoid, 79 $t_{shell}$ is the thickness of the shell at the equator, 79 80 and $\Delta \rho$ (the contrast) is the scattering length density difference, 80 81 either $(\rho_{core} - \rho_{shell})$ or $(\rho_{shell} - \rho_{solvent})$. … … 160 161 source = ["lib/sas_3j1x_x.c", "lib/gauss76.c", "core_shell_ellipsoid.c"] 161 162 have_Fq = True 162 radius_effective_modes= [163 effective_radius_type = [ 163 164 "average outer curvature", "equivalent volume sphere", 164 165 "min outer radius", "max outer radius", -
sasmodels/models/core_shell_parallelepiped.c
ra34b811 r99658f6 75 75 76 76 static double 77 radius_effective(int mode, double length_a, double length_b, double length_c,77 effective_radius(int mode, double length_a, double length_b, double length_c, 78 78 double thick_rim_a, double thick_rim_b, double thick_rim_c) 79 79 { -
sasmodels/models/core_shell_parallelepiped.py
ra34b811 r0507e09 236 236 source = ["lib/gauss76.c", "core_shell_parallelepiped.c"] 237 237 have_Fq = True 238 radius_effective_modes= [238 effective_radius_type = [ 239 239 "equivalent cylinder excluded volume", 240 240 "equivalent volume sphere", -
sasmodels/models/core_shell_sphere.c
ra34b811 rd42dd4a 6 6 7 7 static double 8 radius_effective(int mode, double radius, double thickness)8 effective_radius(int mode, double radius, double thickness) 9 9 { 10 10 switch (mode) { -
sasmodels/models/core_shell_sphere.py
ra34b811 r0507e09 60 60 ---------------------------- 61 61 62 * **Author:** 63 * **Last Modified by:** 64 * **Last Reviewed by:** 62 * **Author:** 63 * **Last Modified by:** 64 * **Last Reviewed by:** 65 65 * **Source added by :** Steve King **Date:** March 25, 2019 66 66 """ … … 92 92 source = ["lib/sas_3j1x_x.c", "lib/core_shell.c", "core_shell_sphere.c"] 93 93 have_Fq = True 94 radius_effective_modes= ["outer radius", "core radius"]94 effective_radius_type = ["outer radius", "core radius"] 95 95 96 96 demo = dict(scale=1, background=0, radius=60, thickness=10, -
sasmodels/models/cylinder.c
ra34b811 r99658f6 32 32 33 33 static double 34 radius_effective(int mode, double radius, double length)34 effective_radius(int mode, double radius, double length) 35 35 { 36 36 switch (mode) { -
sasmodels/models/cylinder.py
ra34b811 r0507e09 110 110 ---------------------------- 111 111 112 * **Author:** 113 * **Last Modified by:** 114 * **Last Reviewed by:** 112 * **Author:** 113 * **Last Modified by:** 114 * **Last Reviewed by:** 115 115 * **Source added by :** Steve King **Date:** March 25, 2019 116 116 """ … … 155 155 source = ["lib/polevl.c", "lib/sas_J1.c", "lib/gauss76.c", "cylinder.c"] 156 156 have_Fq = True 157 radius_effective_modes= [157 effective_radius_type = [ 158 158 "excluded volume", "equivalent volume sphere", "radius", 159 159 "half length", "half min dimension", "half max dimension", "half diagonal", … … 184 184 phi_pd=10, phi_pd_n=5) 185 185 186 # Test 1-D and 2-D models186 # pylint: disable=bad-whitespace, line-too-long 187 187 qx, qy = 0.2 * np.cos(2.5), 0.2 * np.sin(2.5) 188 theta, phi = 80.1534480601659, 10.1510817110481 # (10, 10) in sasview 3.x 188 # After redefinition of angles, find new tests values. Was 10 10 in old coords 189 189 tests = [ 190 190 [{}, 0.2, 0.042761386790780453], 191 191 [{}, [0.2], [0.042761386790780453]], 192 [{'theta': theta, 'phi': phi}, (qx, qy), 0.03514647218513852], 193 [{'theta': theta, 'phi': phi}, [(qx, qy)], [0.03514647218513852]], 192 # new coords 193 [{'theta':80.1534480601659, 'phi':10.1510817110481}, (qx, qy), 0.03514647218513852], 194 [{'theta':80.1534480601659, 'phi':10.1510817110481}, [(qx, qy)], [0.03514647218513852]], 195 # old coords 196 #[{'theta':10.0, 'phi':10.0}, (qx, qy), 0.03514647218513852], 197 #[{'theta':10.0, 'phi':10.0}, [(qx, qy)], [0.03514647218513852]], 194 198 ] 195 del qx, qy, theta, phi # not necessary to delete, but cleaner 196 197 def _extend_with_reff_tests(radius, length): 198 """Test R_eff and form volume calculations""" 199 # V and Vr are the same for each R_eff mode 200 V = pi*radius**2*length # shell volume = form volume for solid objects 201 Vr = 1.0 # form:shell volume ratio 202 # Use test value for I(0.2) from above to check Fsq value. Need to 203 # remove scale and background before testing. 204 q = 0.2 205 scale, background = V, 0.001 206 Fsq = (0.042761386790780453 - background)*scale 207 F = None # Need target value for <F> 208 # Various values for R_eff, depending on mode 209 r_effs = [ 199 del qx, qy # not necessary to delete, but cleaner 200 201 # Default radius and length 202 def calc_volume(radius, length): 203 """Return form volume for cylinder.""" 204 return pi*radius**2*length 205 def calc_r_effs(radius, length): 206 """Return effective radii for modes 0-7 of cylinder.""" 207 return [ 210 208 0., 211 209 0.5*(0.75*radius*(2.0*radius*length … … 218 216 np.sqrt(4*radius**2 + length**2)/2., 219 217 ] 220 tests.extend([ 221 ({'radius_effective_mode': 0}, q, F, Fsq, r_effs[0], V, Vr), 222 ({'radius_effective_mode': 1}, q, F, Fsq, r_effs[1], V, Vr), 223 ({'radius_effective_mode': 2}, q, F, Fsq, r_effs[2], V, Vr),224 ({'radius_effective_mode': 3}, q, F, Fsq, r_effs[3], V, Vr),225 ({'radius_effective_mode': 4}, q, F, Fsq, r_effs[4], V, Vr),226 ({'radius_effective_mode': 5}, q, F, Fsq, r_effs[5], V, Vr),227 ({'radius_effective_mode': 6}, q, F, Fsq, r_effs[6], V, Vr),228 ({'radius_effective_mode': 7}, q, F, Fsq, r_effs[7], V, Vr),229 ])230 231 # Test Reff and volume with default model parameters 232 _extend_with_reff_tests(parameters[2][2], parameters[3][2]) 233 del _extend_with_reff_tests 218 r_effs = calc_r_effs(parameters[2][2], parameters[3][2]) 219 cyl_vol = calc_volume(parameters[2][2], parameters[3][2]) 220 tests.extend([ 221 ({'radius_effective_mode': 0}, 0.1, None, None, r_effs[0], cyl_vol, 1.0), 222 ({'radius_effective_mode': 1}, 0.1, None, None, r_effs[1], None, None), 223 ({'radius_effective_mode': 2}, 0.1, None, None, r_effs[2], None, None), 224 ({'radius_effective_mode': 3}, 0.1, None, None, r_effs[3], None, None), 225 ({'radius_effective_mode': 4}, 0.1, None, None, r_effs[4], None, None), 226 ({'radius_effective_mode': 5}, 0.1, None, None, r_effs[5], None, None), 227 ({'radius_effective_mode': 6}, 0.1, None, None, r_effs[6], None, None), 228 ({'radius_effective_mode': 7}, 0.1, None, None, r_effs[7], None, None), 229 ]) 230 del r_effs, cyl_vol 231 # pylint: enable=bad-whitespace, line-too-long 234 232 235 233 # ADDED by: RKH ON: 18Mar2016 renamed sld's etc -
sasmodels/models/ellipsoid.c
ra34b811 r99658f6 32 32 33 33 static double 34 radius_effective(int mode, double radius_polar, double radius_equatorial)34 effective_radius(int mode, double radius_polar, double radius_equatorial) 35 35 { 36 36 switch (mode) { -
sasmodels/models/ellipsoid.py
ra34b811 r0507e09 167 167 source = ["lib/sas_3j1x_x.c", "lib/gauss76.c", "ellipsoid.c"] 168 168 have_Fq = True 169 radius_effective_modes= [169 effective_radius_type = [ 170 170 "average curvature", "equivalent volume sphere", "min radius", "max radius", 171 171 ] -
sasmodels/models/elliptical_cylinder.c
ra34b811 r99658f6 41 41 42 42 static double 43 radius_effective(int mode, double radius_minor, double r_ratio, double length)43 effective_radius(int mode, double radius_minor, double r_ratio, double length) 44 44 { 45 45 switch (mode) { -
sasmodels/models/elliptical_cylinder.py
ra34b811 r0507e09 131 131 source = ["lib/polevl.c", "lib/sas_J1.c", "lib/gauss76.c", "elliptical_cylinder.c"] 132 132 have_Fq = True 133 radius_effective_modes= [133 effective_radius_type = [ 134 134 "equivalent cylinder excluded volume", 135 135 "equivalent volume sphere", "average radius", "min radius", "max radius", -
sasmodels/models/flexible_cylinder.py
rdb1d9d5 r40c9825 33 33 and solvent respectively. 34 34 35 Our model uses the form factor calculations in reference [1] as implemented in a 35 Our model uses the form factor calculations in reference [1] as implemented in a 36 36 c-library provided by the NIST Center for Neutron Research (Kline, 2006). This states: 37 37 … … 41 41 pseudocontinuous limit. 42 42 See equations (13,26-27) in the original reference for the details. 43 43 44 44 .. note:: 45 45 … … 61 61 62 62 63 **This is a model with complex behaviour depending on the ratio of** $L/b$ **and the 64 reader is strongly encouraged to read reference [1] before use.** 65 66 .. note:: 67 68 There are several typos in the original reference that have been corrected 69 by WRC [2]. Details of the corrections are in the reference below. Most notably 70 71 - Equation (13): the term $(1 - w(QR))$ should swap position with $w(QR)$ 72 73 - Equations (23) and (24) are incorrect; WRC has entered these into 74 Mathematica and solved analytically. The results were then converted to 75 code. 76 77 - Equation (27) should be $q0 = max(a3/(Rg^2)^{1/2},3)$ instead of 78 $max(a3*b(Rg^2)^{1/2},3)$ 79 80 - The scattering function is negative for a range of parameter values and 81 q-values that are experimentally accessible. A correction function has been 82 added to give the proper behavior. 83 84 85 **This is a model with complex behaviour depending on the ratio of** $L/b$ **and the 63 **This is a model with complex behaviour depending on the ratio of** $L/b$ **and the 86 64 reader is strongly encouraged to read reference [1] before use.** 87 65 … … 107 85 ---------------------------- 108 86 109 * **Author:** 110 * **Last Modified by:** 87 * **Author:** 88 * **Last Modified by:** 111 89 * **Last Reviewed by:** Steve King **Date:** March 26, 2019 112 90 * **Source added by :** Steve King **Date:** March 25, 2019 -
sasmodels/models/flexible_cylinder_elliptical.py
rdb1d9d5 r40c9825 26 26 ----------- 27 27 28 The function is calculated in a similar way to that for the 29 :ref:`flexible-cylinder` model in reference [1] below using the author's 28 The function is calculated in a similar way to that for the 29 :ref:`flexible-cylinder` model in reference [1] below using the author's 30 30 "Method 3 With Excluded Volume". 31 31 … … 71 71 these parameters must be held fixed during model fitting. 72 72 73 **This is a model with complex behaviour depending on the ratio of** $L/b$ **and the 73 **This is a model with complex behaviour depending on the ratio of** $L/b$ **and the 74 74 reader is strongly encouraged to read reference [1] before use.** 75 75 … … 95 95 ---------------------------- 96 96 97 * **Author:** 97 * **Author:** 98 98 * **Last Modified by:** Richard Heenan **Date:** December, 2016 99 99 * **Last Reviewed by:** Steve King **Date:** March 26, 2019 -
sasmodels/models/fuzzy_sphere.c
ra34b811 rd42dd4a 5 5 6 6 static double 7 radius_effective(int mode, double radius, double fuzziness)7 effective_radius(int mode, double radius, double fuzziness) 8 8 { 9 9 switch (mode) { -
sasmodels/models/fuzzy_sphere.py
ra34b811 r0507e09 63 63 ---------------------------- 64 64 65 * **Author:** 66 * **Last Modified by:** 67 * **Last Reviewed by:** 65 * **Author:** 66 * **Last Modified by:** 67 * **Last Reviewed by:** 68 68 * **Source added by :** Steve King **Date:** March 25, 2019 69 69 """ … … 98 98 source = ["lib/sas_3j1x_x.c", "fuzzy_sphere.c"] 99 99 have_Fq = True 100 radius_effective_modes= ["radius", "radius + fuzziness"]100 effective_radius_type = ["radius", "radius + fuzziness"] 101 101 102 102 def random(): -
sasmodels/models/hardsphere.py
rdb1d9d5 r5f3c534 3 3 Calculates the interparticle structure factor for monodisperse 4 4 spherical particles interacting through hard sphere (excluded volume) 5 interactions. This $S(q)$ may also be a reasonable approximation for 6 other particle shapes that freely rotate (but see the note below), 5 interactions. This $S(q)$ may also be a reasonable approximation for 6 other particle shapes that freely rotate (but see the note below), 7 7 and for moderately polydisperse systems. 8 8 9 9 .. note:: 10 10 11 This routine is intended for uncharged particles! For charged 11 This routine is intended for uncharged particles! For charged 12 12 particles try using the :ref:`hayter-msa` $S(q)$ instead. 13 13 14 14 .. note:: 15 15 16 Earlier versions of SasView did not incorporate the so-called 17 $\beta(q)$ ("beta") correction [1] for polydispersity and non-sphericity. 16 Earlier versions of SasView did not incorporate the so-called 17 $\beta(q)$ ("beta") correction [1] for polydispersity and non-sphericity. 18 18 This is only available in SasView versions 4.2.2 and higher. 19 19 … … 25 25 26 26 For numerical stability the computation uses a Taylor series expansion 27 at very small $qR$, but there may be a very minor glitch at the 27 at very small $qR$, but there may be a very minor glitch at the 28 28 transition point in some circumstances. 29 29 30 This S(q) uses the Percus-Yevick closure relationship [2] where the 30 This S(q) uses the Percus-Yevick closure relationship [2] where the 31 31 interparticle potential $U(r)$ is 32 32 … … 62 62 ---------------------------- 63 63 64 * **Author:** 65 * **Last Modified by:** 66 * **Last Reviewed by:** 64 * **Author:** 65 * **Last Modified by:** 66 * **Last Reviewed by:** 67 67 * **Source added by :** Steve King **Date:** March 25, 2019 68 68 """ -
sasmodels/models/hayter_msa.py
rdb1d9d5 r9947865 1 1 # Note: model title and parameter table are inserted automatically 2 2 r""" 3 Calculates the interparticle structure factor for a system of charged, 4 spheroidal, objects in a dielectric medium [1,2]. When combined with an 5 appropriate form factor $P(q)$, this allows for inclusion of the 6 interparticle interference effects due to screened Coulombic 3 Calculates the interparticle structure factor for a system of charged, 4 spheroidal, objects in a dielectric medium [1,2]. When combined with an 5 appropriate form factor $P(q)$, this allows for inclusion of the 6 interparticle interference effects due to screened Coulombic 7 7 repulsion between the charged particles. 8 8 9 9 .. note:: 10 10 11 This routine only works for charged particles! If the charge is set 12 to zero the routine may self-destruct! For uncharged particles use 11 This routine only works for charged particles! If the charge is set 12 to zero the routine may self-destruct! For uncharged particles use 13 13 the :ref:`hardsphere` $S(q)$ instead. The upper limit for the charge 14 14 is limited to 200e to avoid numerical instabilities. 15 15 16 16 .. note:: 17 17 18 Earlier versions of SasView did not incorporate the so-called 19 $\beta(q)$ ("beta") correction [3] for polydispersity and non-sphericity. 18 Earlier versions of SasView did not incorporate the so-called 19 $\beta(q)$ ("beta") correction [3] for polydispersity and non-sphericity. 20 20 This is only available in SasView versions 4.2.2 and higher. 21 21 22 22 The salt concentration is used to compute the ionic strength of the solution 23 which in turn is used to compute the Debye screening length. There is no 24 provision for entering the ionic strength directly. **At present the 25 counterions are assumed to be monovalent**, though it should be possible 26 to simulate the effect of multivalent counterions by increasing the salt 23 which in turn is used to compute the Debye screening length. There is no 24 provision for entering the ionic strength directly. **At present the 25 counterions are assumed to be monovalent**, though it should be possible 26 to simulate the effect of multivalent counterions by increasing the salt 27 27 concentration. 28 28 29 Over the range 0 - 100 C the dielectric constant $\kappa$ of water may be 30 approximated with a maximum deviation of 0.01 units by the empirical 29 Over the range 0 - 100 C the dielectric constant $\kappa$ of water may be 30 approximated with a maximum deviation of 0.01 units by the empirical 31 31 formula [4] 32 32 … … 34 34 35 35 \kappa = 87.740 - 0.40008 T + 9.398x10^{-4} T^2 - 1.410x10^{-6} T^3 36 36 37 37 where $T$ is the temperature in celsius. 38 38 … … 73 73 ---------------------------- 74 74 75 * **Author:** 76 * **Last Modified by:** 75 * **Author:** 76 * **Last Modified by:** 77 77 * **Last Reviewed by:** Steve King **Date:** March 28, 2019 78 78 * **Source added by :** Steve King **Date:** March 25, 2019 … … 101 101 [Hayter-Penfold RMSA charged sphere interparticle S(Q) structure factor] 102 102 Interparticle structure factor S(Q) for charged hard spheres. 103 This routine only works for charged particles! For uncharged particles 104 use the hardsphere S(q) instead. The "beta(q)" correction is available 103 This routine only works for charged particles! For uncharged particles 104 use the hardsphere S(q) instead. The "beta(q)" correction is available 105 105 in versions 4.2.2 and higher. 106 106 """ … … 110 110 # [ "name", "units", default, [lower, upper], "type", "description" ], 111 111 # 112 # NOTE: SMK, 28Mar19 The upper limit for charge is set to 200 to avoid instabilities noted by PK in 113 # Ticket #1152. Also see the thread in Ticket 859. The docs above also note that charge=0 will 112 # NOTE: SMK, 28Mar19 The upper limit for charge is set to 200 to avoid instabilities noted by PK in 113 # Ticket #1152. Also see the thread in Ticket 859. The docs above also note that charge=0 will 114 114 # cause problems, yet the default parameters allowed it! After discussions with PK I have 115 # changed it to (an arbitarily) small but non-zero value. But I haven't changed the low limit 115 # changed it to (an arbitarily) small but non-zero value. But I haven't changed the low limit 116 116 # in function random() below. 117 117 # -
sasmodels/models/hollow_cylinder.c
ra34b811 r99658f6 34 34 35 35 static double 36 radius_effective(int mode, double radius, double thickness, double length)36 effective_radius(int mode, double radius, double thickness, double length) 37 37 { 38 38 switch (mode) { -
sasmodels/models/hollow_cylinder.py
ra34b811 r0507e09 110 110 source = ["lib/polevl.c", "lib/sas_J1.c", "lib/gauss76.c", "hollow_cylinder.c"] 111 111 have_Fq = True 112 radius_effective_modes= [112 effective_radius_type = [ 113 113 "excluded volume", "equivalent outer volume sphere", 114 114 "outer radius", "half length", -
sasmodels/models/hollow_rectangular_prism.c
ra34b811 r99658f6 30 30 31 31 static double 32 radius_effective(int mode, double length_a, double b2a_ratio, double c2a_ratio, double thickness)32 effective_radius(int mode, double length_a, double b2a_ratio, double c2a_ratio, double thickness) 33 33 // NOTE length_a is external dimension! 34 34 { -
sasmodels/models/hollow_rectangular_prism.py
ra34b811 r0507e09 157 157 source = ["lib/gauss76.c", "hollow_rectangular_prism.c"] 158 158 have_Fq = True 159 radius_effective_modes= [159 effective_radius_type = [ 160 160 "equivalent cylinder excluded volume", "equivalent outer volume sphere", 161 161 "half length_a", "half length_b", "half length_c", -
sasmodels/models/hollow_rectangular_prism_thin_walls.c
ra34b811 r99658f6 26 26 27 27 static double 28 radius_effective(int mode, double length_a, double b2a_ratio, double c2a_ratio)28 effective_radius(int mode, double length_a, double b2a_ratio, double c2a_ratio) 29 29 { 30 30 switch (mode) { -
sasmodels/models/hollow_rectangular_prism_thin_walls.py
ra34b811 r0507e09 117 117 source = ["lib/gauss76.c", "hollow_rectangular_prism_thin_walls.c"] 118 118 have_Fq = True 119 radius_effective_modes= [119 effective_radius_type = [ 120 120 "equivalent cylinder excluded volume", "equivalent outer volume sphere", 121 121 "half length_a", "half length_b", "half length_c", -
sasmodels/models/mono_gauss_coil.c
ra34b811 r153f8f6 6 6 7 7 static double 8 radius_effective(int mode, double rg)8 effective_radius(int mode, double rg) 9 9 { 10 10 switch (mode) { -
sasmodels/models/mono_gauss_coil.py
ra34b811 r0507e09 59 59 ---------------------------- 60 60 61 * **Author:** 62 * **Last Modified by:** 63 * **Last Reviewed by:** 61 * **Author:** 62 * **Last Modified by:** 63 * **Last Reviewed by:** 64 64 * **Source added by :** Steve King **Date:** March 25, 2019""" 65 65 … … 86 86 source = ["mono_gauss_coil.c"] 87 87 have_Fq = False 88 radius_effective_modes= ["R_g", "2R_g", "3R_g", "sqrt(5/3)*R_g"]88 effective_radius_type = ["R_g", "2R_g", "3R_g", "sqrt(5/3)*R_g"] 89 89 90 90 -
sasmodels/models/multilayer_vesicle.c
ra34b811 ree60aa7 48 48 49 49 static double 50 radius_effective(int mode, double radius, double thick_shell, double thick_solvent, double fp_n_shells)50 effective_radius(int mode, double radius, double thick_shell, double thick_solvent, double fp_n_shells) 51 51 { 52 52 // case 1: outer radius -
sasmodels/models/multilayer_vesicle.py
rdb1d9d5 r6607260 154 154 source = ["lib/sas_3j1x_x.c", "multilayer_vesicle.c"] 155 155 have_Fq = True 156 radius_effective_modes= ["outer radius"]156 effective_radius_type = ["outer radius"] 157 157 158 158 def random(): -
sasmodels/models/onion.c
ra34b811 ree60aa7 47 47 48 48 static double 49 radius_effective(int mode, double radius_core, double n_shells, double thickness[])49 effective_radius(int mode, double radius_core, double n_shells, double thickness[]) 50 50 { 51 51 // case 1: outer radius -
sasmodels/models/onion.py
rdb1d9d5 r62dc889 8 8 .. note:: 9 9 10 *radius* represents the core radius $r_0$ and *thickness[k]* represents 10 *radius* represents the core radius $r_0$ and *thickness[k]* represents 11 11 the thickness of the shell, $r_{k+1} - r_k$. 12 12 … … 60 60 and the volume is $V(r) = \frac{4\pi}{3}r^3$. 61 61 62 The volume of the particle is determined by the radius of the outer 62 The volume of the particle is determined by the radius of the outer 63 63 shell, so $V_\text{particle} = V(r_N)$. 64 64 … … 104 104 B&=\frac{\rho_\text{out} - \rho_\text{in}}{e^A-1} 105 105 & C &= \frac{\rho_\text{in}e^A - \rho_\text{out}}{e^A-1} \\ 106 106 107 107 \alpha_\text{in} &= A\frac{r_{\text{shell}-1}}{\Delta t_\text{shell}} 108 108 & \alpha_\text{out} &= A\frac{r_\text{shell}}{\Delta t_\text{shell}} \\ 109 109 110 110 \beta_\text{in} &= qr_{\text{shell}-1} 111 111 & \beta_\text{out} &= qr_\text{shell} \\ … … 123 123 **Linear SLD profile** ($A \sim 0$): 124 124 125 For small $A$, say, $A = -0.0001$, the function converges to that of of a linear 125 For small $A$, say, $A = -0.0001$, the function converges to that of of a linear 126 126 SLD profile with 127 127 … … 159 159 **Constant SLD** ($A = 0$): 160 160 161 When $A = 0$ the exponential function has no dependence on the radius (meaning 161 When $A = 0$ the exponential function has no dependence on the radius (meaning 162 162 $\rho_\text{out}$ is ignored in this case) and becomes flat. We set the constant 163 163 to $\rho_\text{in}$ for convenience, and thus the form factor contributed by … … 197 197 ---------------------------- 198 198 199 * **Author:** 200 * **Last Modified by:** 199 * **Author:** 200 * **Last Modified by:** 201 201 * **Last Reviewed by:** Steve King **Date:** March 28, 2019 202 202 * **Source added by :** Steve King **Date:** March 25, 2019 … … 347 347 single = False 348 348 have_Fq = True 349 radius_effective_modes= ["outer radius"]349 effective_radius_type = ["outer radius"] 350 350 351 351 profile_axes = ['Radius (A)', 'SLD (1e-6/A^2)'] -
sasmodels/models/parallelepiped.c
ra34b811 r99658f6 37 37 38 38 static double 39 radius_effective(int mode, double length_a, double length_b, double length_c)39 effective_radius(int mode, double length_a, double length_b, double length_c) 40 40 { 41 41 switch (mode) { -
sasmodels/models/parallelepiped.py
ra34b811 r0507e09 240 240 source = ["lib/gauss76.c", "parallelepiped.c"] 241 241 have_Fq = True 242 radius_effective_modes= [242 effective_radius_type = [ 243 243 "equivalent cylinder excluded volume", "equivalent volume sphere", 244 244 "half length_a", "half length_b", "half length_c", -
sasmodels/models/pearl_necklace.c
ra34b811 r4453136 86 86 87 87 static double 88 radius_effective(int mode, double radius, double edge_sep, double thick_string, double fp_num_pearls)88 effective_radius(int mode, double radius, double edge_sep, double thick_string, double fp_num_pearls) 89 89 { 90 90 switch (mode) { -
sasmodels/models/pearl_necklace.py
rdb1d9d5 rc0136c72 111 111 source = ["lib/sas_Si.c", "lib/sas_3j1x_x.c", "pearl_necklace.c"] 112 112 single = False # use double precision unless told otherwise 113 radius_effective_modes= ["equivalent volume sphere"]113 effective_radius_type = ["equivalent volume sphere"] 114 114 115 115 def random(): -
sasmodels/models/poly_gauss_coil.py
ra34b811 r0507e09 58 58 ---------------------------- 59 59 60 * **Author:** 61 * **Last Modified by:** 62 * **Last Reviewed by:** 60 * **Author:** 61 * **Last Modified by:** 62 * **Last Reviewed by:** 63 63 * **Source added by :** Steve King **Date:** March 25, 2019 64 64 """ -
sasmodels/models/pringle.c
ra34b811 r99658f6 111 111 112 112 static double 113 radius_effective(int mode, double radius, double thickness, double alpha, double beta)113 effective_radius(int mode, double radius, double thickness, double alpha, double beta) 114 114 { 115 115 switch (mode) { -
sasmodels/models/pringle.py
ra34b811 r0507e09 85 85 source = ["lib/polevl.c", "lib/sas_J0.c", "lib/sas_J1.c", 86 86 "lib/sas_JN.c", "lib/gauss76.c", "pringle.c"] 87 radius_effective_modes= [87 effective_radius_type = [ 88 88 "equivalent cylinder excluded volume", 89 89 "equivalent volume sphere", -
sasmodels/models/raspberry.c
ra34b811 rd42dd4a 15 15 16 16 static double 17 radius_effective(int mode, double radius_lg, double radius_sm, double penetration)17 effective_radius(int mode, double radius_lg, double radius_sm, double penetration) 18 18 { 19 19 switch (mode) { -
sasmodels/models/raspberry.py
ra34b811 r0507e09 161 161 162 162 source = ["lib/sas_3j1x_x.c", "raspberry.c"] 163 radius_effective_modes= ["radius_large", "radius_outer"]163 effective_radius_type = ["radius_large", "radius_outer"] 164 164 165 165 def random(): -
sasmodels/models/rectangular_prism.c
ra34b811 r99658f6 14 14 15 15 static double 16 radius_effective(int mode, double length_a, double b2a_ratio, double c2a_ratio)16 effective_radius(int mode, double length_a, double b2a_ratio, double c2a_ratio) 17 17 { 18 18 switch (mode) { -
sasmodels/models/rectangular_prism.py
ra34b811 r0507e09 110 110 ---------------------------- 111 111 112 * **Author:** 113 * **Last Modified by:** 114 * **Last Reviewed by:** 112 * **Author:** 113 * **Last Modified by:** 114 * **Last Reviewed by:** 115 115 * **Source added by :** Steve King **Date:** March 25, 2019 116 116 """ … … 151 151 source = ["lib/gauss76.c", "rectangular_prism.c"] 152 152 have_Fq = True 153 radius_effective_modes= [153 effective_radius_type = [ 154 154 "equivalent cylinder excluded volume", "equivalent volume sphere", 155 155 "half length_a", "half length_b", "half length_c", -
sasmodels/models/rpa.py
rdb1d9d5 r055ec4f 34 34 that $R_g^2 = n b^2/6$ where $b$ is the statistical segment length and $n$ is 35 35 the number of statistical segment lengths. A nice tutorial on how these are 36 constructed and implemented can be found in chapters 28, 31 and 34, and Part H, 36 constructed and implemented can be found in chapters 28, 31 and 34, and Part H, 37 37 of Hammouda's 'SANS Toolbox' [3]. 38 38 -
sasmodels/models/sphere.c
ra34b811 ree60aa7 5 5 6 6 static double 7 radius_effective(int mode, double radius)7 effective_radius(int mode, double radius) 8 8 { 9 9 // case 1: radius -
sasmodels/models/sphere.py
ra34b811 r0507e09 49 49 ---------------------------- 50 50 51 * **Author:** 52 * **Last Modified by:** 51 * **Author:** 52 * **Last Modified by:** 53 53 * **Last Reviewed by:** S King and P Parker **Date:** 2013/09/09 and 2014/01/06 54 54 * **Source added by :** Steve King **Date:** March 25, 2019 … … 81 81 source = ["lib/sas_3j1x_x.c", "sphere.c"] 82 82 have_Fq = True 83 radius_effective_modes= ["radius"]83 effective_radius_type = ["radius"] 84 84 85 85 def random(): … … 92 92 93 93 tests = [ 94 [{}, 0.2, 0.726362], # each test starts with default parameter values inside { }, unless modified. Then Q and expected value of I(Q) 95 [{"scale": 1., "background": 0., "sld": 6., "sld_solvent": 1., 96 "radius": 120., "radius_pd": 0.2, "radius_pd_n":45}, 97 0.2, 0.2288431], 98 [{"radius": 120., "radius_pd": 0.02, "radius_pd_n":45}, 99 0.2, 792.0646662454202, 1166737.0473152, 120.0, 7246723.820358589, 1.0], # the longer list here checks F1, F2, R_eff, volume, volume_ratio = call_Fq(kernel, pars) 100 # But note P(Q) = F2/volume 101 # F and F^2 are "unscaled", with for n <F F*>S(q) or for beta approx I(q) = n [<F F*> + <F><F*> (S(q) - 1)] 102 # for n the number density and <.> the orientation average, and F = integral rho(r) exp(i q . r) dr. 103 # The number density is volume fraction divided by particle volume. 104 # Effectively, this leaves F = V drho form, where form is the usual 3 j1(qr)/(qr) or whatever depending on the shape. 105 # [{"@S": "hardsphere"}, 106 # 0.01, 55.881884232102124], # this is current value, not verified elsewhere yet 107 # [{"radius": 120., "radius_pd": 0.2, "radius_pd_n":45}, 108 # 0.2, 1.233304061, [1850806.119736], 120.0, 8087664.1226, 1.0], # the longer list here checks F1, F2, R_eff, volume, volume_ratio = call_Fq(kernel, pars) 109 # [{"@S": "hardsphere"}, 110 # 0.2, 0.14730859242492958], # this is current value, not verified elsewhere yet 111 # [{"@S": "hardsphere"}, 112 # 0.1, 0.7940350343811906], # this is current value, not verified elsewhere yet 113 [{"@S": "hardsphere", 114 "radius": 120., "radius_pd": 0.2, "radius_pd_n":45, 115 "volfraction":0.2, 116 "radius_effective":45.0, # uses this (check) 117 "structure_factor_mode": 1, # 0 = normal decoupling approximation, 1 = beta(Q) approx 118 "radius_effective_mode": 0 # equivalent sphere, there is only one valid mode for sphere. says -this used r_eff =0 or default 50? 119 }, 0.01, 1316.2990966463444 ], 120 [{"@S": "hardsphere", 121 "radius": 120., "radius_pd": 0.2, "radius_pd_n":45, 122 "volfraction":0.2, 123 "radius_effective":50.0, # hard sphere structure factor 124 "structure_factor_mode": 1, # 0 = normal decoupling approximation, 1 = beta(Q) approx 125 "radius_effective_mode": 0 # this used r_eff =0 or default 50? 126 }, 0.01, 1324.7375636587356 ], 127 [{"@S": "hardsphere", 128 "radius": 120., "radius_pd": 0.2, "radius_pd_n":45, 129 "volfraction":0.2, 130 "radius_effective":50.0, # hard sphere structure factor 131 "structure_factor_mode": 1, # 0 = normal decoupling approximation, 1 = beta(Q) approx 132 "radius_effective_mode": 1 # this used 120 ??? 133 }, 0.01, 1579.2858949296565 ] 94 [{}, 0.2, 0.726362], 95 [{"scale": 1., "background": 0., "sld": 6., "sld_solvent": 1., 96 "radius": 120., "radius_pd": 0.2, "radius_pd_n":45}, 97 0.2, 0.228843], 98 [{"radius": 120., "radius_pd": 0.2, "radius_pd_n":45}, 99 0.1, None, None, 120., None, 1.0], 100 [{"@S": "hardsphere"}, 0.1, None], 134 101 ] 135 # putting None for expected result will pass the test if there are no errors from the routine, but without any check on the value of the result -
sasmodels/models/spherical_sld.c
ra34b811 ree60aa7 19 19 20 20 static double 21 radius_effective(int mode, double fp_n_shells, double thickness[], double interface[])21 effective_radius(int mode, double fp_n_shells, double thickness[], double interface[]) 22 22 { 23 23 // case 1: outer radius -
sasmodels/models/spherical_sld.py
r627b68b r0507e09 18 18 sub-shell is described by a line function, with *n_steps* sub-shells per 19 19 interface. The form factor is normalized by the total volume of the sphere. 20 21 .. note::22 23 *n_shells* must be an integer. *n_steps* must be an ODD integer.24 20 25 21 Interface shapes are as follows: … … 77 73 3 \rho_\text{solvent} V(r_N) 78 74 \Big[ \frac{\sin(qr_N) - qr_N \cos(qr_N)} {qr_N^3} \Big] 75 79 76 80 77 Here we assumed that the SLDs of the core and solvent are constant in $r$. … … 159 156 \end{align*} 160 157 158 161 159 We assume $\rho_{\text{inter}_j} (r)$ is approximately linear 162 160 within the sub-shell $j$. … … 181 179 when $P(Q) * S(Q)$ is applied. 182 180 181 183 182 References 184 183 ---------- … … 195 194 196 195 Authorship and Verification 197 --------------------------- 196 ---------------------------- 198 197 199 198 * **Author:** Jae-Hie Cho **Date:** Nov 1, 2010 200 199 * **Last Modified by:** Paul Kienzle **Date:** Dec 20, 2016 201 * **Last Reviewed by:** Steve King **Date:** March 29, 2019200 * **Last Reviewed by:** Paul Butler **Date:** September 8, 2018 202 201 * **Source added by :** Steve King **Date:** March 25, 2019 203 202 """ … … 208 207 209 208 name = "spherical_sld" 210 title = "Sp herical SLD intensity calculation"209 title = "Sperical SLD intensity calculation" 211 210 description = """ 212 211 I(q) = … … 220 219 # pylint: disable=bad-whitespace, line-too-long 221 220 # ["name", "units", default, [lower, upper], "type", "description"], 222 parameters = [["n_shells", "", 1, [1, 10], "volume", "number of shells (must be integer)"],221 parameters = [["n_shells", "", 1, [1, 10], "volume", "number of shells"], 223 222 ["sld_solvent", "1e-6/Ang^2", 1.0, [-inf, inf], "sld", "solvent sld"], 224 223 ["sld[n_shells]", "1e-6/Ang^2", 4.06, [-inf, inf], "sld", "sld of the shell"], … … 233 232 single = False # TODO: fix low q behaviour 234 233 have_Fq = True 235 radius_effective_modes= ["outer radius"]234 effective_radius_type = ["outer radius"] 236 235 237 236 profile_axes = ['Radius (A)', 'SLD (1e-6/A^2)'] -
sasmodels/models/squarewell.py
rdb1d9d5 r5f3c534 1 1 # Note: model title and parameter table are inserted automatically 2 2 r""" 3 Calculates the interparticle structure factor for a hard sphere fluid 4 with a narrow, attractive, square well potential. **The Mean Spherical 5 Approximation (MSA) closure relationship is used, but it is not the most 6 appropriate closure for an attractive interparticle potential.** However, 7 the solution has been compared to Monte Carlo simulations for a square 8 well fluid and these show the MSA calculation to be limited to well 3 Calculates the interparticle structure factor for a hard sphere fluid 4 with a narrow, attractive, square well potential. **The Mean Spherical 5 Approximation (MSA) closure relationship is used, but it is not the most 6 appropriate closure for an attractive interparticle potential.** However, 7 the solution has been compared to Monte Carlo simulations for a square 8 well fluid and these show the MSA calculation to be limited to well 9 9 depths $\epsilon < 1.5$ kT and volume fractions $\phi < 0.08$. 10 10 11 11 Positive well depths correspond to an attractive potential well. Negative 12 12 well depths correspond to a potential "shoulder", which may or may not be 13 physically reasonable. The :ref:`stickyhardsphere` model may be a better 13 physically reasonable. The :ref:`stickyhardsphere` model may be a better 14 14 choice in some circumstances. 15 15 … … 18 18 .. note:: 19 19 20 Earlier versions of SasView did not incorporate the so-called 21 $\beta(q)$ ("beta") correction [2] for polydispersity and non-sphericity. 20 Earlier versions of SasView did not incorporate the so-called 21 $\beta(q)$ ("beta") correction [2] for polydispersity and non-sphericity. 22 22 This is only available in SasView versions 4.2.2 and higher. 23 23 … … 62 62 ---------------------------- 63 63 64 * **Author:** 65 * **Last Modified by:** 64 * **Author:** 65 * **Last Modified by:** 66 66 * **Last Reviewed by:** Steve King **Date:** March 27, 2019 67 67 * **Source added by :** Steve King **Date:** March 25, 2019 … … 75 75 description = """\ 76 76 [Square well structure factor, with MSA closure] 77 Interparticle structure factor S(Q) for a hard sphere fluid 77 Interparticle structure factor S(Q) for a hard sphere fluid 78 78 with a narrow attractive well. Fits are prone to deliver non- 79 physical parameters; use with care and read the references in 80 the model documentation.The "beta(q)" correction is available 79 physical parameters; use with care and read the references in 80 the model documentation.The "beta(q)" correction is available 81 81 in versions 4.2.2 and higher. 82 82 """ -
sasmodels/models/stickyhardsphere.py
rdb1d9d5 r5f3c534 1 1 # Note: model title and parameter table are inserted automatically 2 2 r""" 3 Calculates the interparticle structure factor for a hard sphere fluid 4 with a narrow, attractive, potential well. Unlike the :ref:`squarewell` 5 model, here a perturbative solution of the Percus-Yevick closure 6 relationship is used. The strength of the attractive well is described 3 Calculates the interparticle structure factor for a hard sphere fluid 4 with a narrow, attractive, potential well. Unlike the :ref:`squarewell` 5 model, here a perturbative solution of the Percus-Yevick closure 6 relationship is used. The strength of the attractive well is described 7 7 in terms of "stickiness" as defined below. 8 8 9 9 The perturbation parameter (perturb), $\tau$, should be fixed between 0.01 10 and 0.1 and the "stickiness", $\epsilon$, allowed to vary to adjust the 11 interaction strength. The "stickiness" is defined in the equation below and is 12 a function of both the perturbation parameter and the interaction strength. 13 $\epsilon$ and $\tau$ are defined in terms of the hard sphere diameter $(\sigma = 2 R)$, 14 the width of the square well, $\Delta$ (having the same units as $R$\ ), 15 and the depth of the well, $U_o$, in units of $kT$. From the definition, it 10 and 0.1 and the "stickiness", $\epsilon$, allowed to vary to adjust the 11 interaction strength. The "stickiness" is defined in the equation below and is 12 a function of both the perturbation parameter and the interaction strength. 13 $\epsilon$ and $\tau$ are defined in terms of the hard sphere diameter $(\sigma = 2 R)$, 14 the width of the square well, $\Delta$ (having the same units as $R$\ ), 15 and the depth of the well, $U_o$, in units of $kT$. From the definition, it 16 16 is clear that smaller $\epsilon$ means a stronger attraction. 17 17 … … 37 37 38 38 The true particle volume fraction, $\phi$, is not equal to $h$ which appears 39 in most of reference [1]. The two are related in equation (24). Reference 40 [1] also describes the relationship between this perturbative solution and 39 in most of reference [1]. The two are related in equation (24). Reference 40 [1] also describes the relationship between this perturbative solution and 41 41 the original sticky hard sphere (or "adhesive sphere") model of Baxter [2]. 42 42 … … 47 47 reported to the command window and $S(q)$ is set to -1 (so it will 48 48 disappear on a log-log plot!). 49 50 Use tight bounds to keep the parameters to values that you know are 51 physical (test them), and keep nudging them until the optimization 49 50 Use tight bounds to keep the parameters to values that you know are 51 physical (test them), and keep nudging them until the optimization 52 52 does not hit the constraints. 53 53 54 54 .. note:: 55 55 56 Earlier versions of SasView did not incorporate the so-called 57 $\beta(q)$ ("beta") correction [3] for polydispersity and non-sphericity. 56 Earlier versions of SasView did not incorporate the so-called 57 $\beta(q)$ ("beta") correction [3] for polydispersity and non-sphericity. 58 58 This is only available in SasView versions 4.2.2 and higher. 59 59 60 60 In SasView the effective radius may be calculated from the parameters 61 61 used in the form factor $P(q)$ that this $S(q)$ is combined with. … … 86 86 ---------------------------- 87 87 88 * **Author:** 89 * **Last Modified by:** 88 * **Author:** 89 * **Last Modified by:** 90 90 * **Last Reviewed by:** Steve King **Date:** March 27, 2019 91 91 * **Source added by :** Steve King **Date:** March 25, 2019 … … 101 101 description = """\ 102 102 [Sticky hard sphere structure factor, with Percus-Yevick closure] 103 Interparticle structure factor S(Q) for a hard sphere fluid 103 Interparticle structure factor S(Q) for a hard sphere fluid 104 104 with a narrow attractive well. Fits are prone to deliver non- 105 physical parameters; use with care and read the references in 106 the model documentation.The "beta(q)" correction is available 105 physical parameters; use with care and read the references in 106 the model documentation.The "beta(q)" correction is available 107 107 in versions 4.2.2 and higher. 108 108 """ -
sasmodels/models/triaxial_ellipsoid.c
ra34b811 r99658f6 76 76 77 77 static double 78 radius_effective(int mode, double radius_equat_minor, double radius_equat_major, double radius_polar)78 effective_radius(int mode, double radius_equat_minor, double radius_equat_major, double radius_polar) 79 79 { 80 80 switch (mode) { -
sasmodels/models/triaxial_ellipsoid.py
ra34b811 r0507e09 164 164 source = ["lib/sas_3j1x_x.c", "lib/gauss76.c", "triaxial_ellipsoid.c"] 165 165 have_Fq = True 166 radius_effective_modes= [166 effective_radius_type = [ 167 167 "equivalent biaxial ellipsoid average curvature", 168 168 "equivalent volume sphere", "min radius", "max radius", -
sasmodels/models/vesicle.c
ra34b811 r12f4c19 13 13 14 14 static double 15 radius_effective(int mode, double radius, double thickness)15 effective_radius(int mode, double radius, double thickness) 16 16 { 17 17 // case 1: outer radius -
sasmodels/models/vesicle.py
ra34b811 r0507e09 107 107 source = ["lib/sas_3j1x_x.c", "vesicle.c"] 108 108 have_Fq = True 109 radius_effective_modes= ["outer radius"]109 effective_radius_type = ["outer radius"] 110 110 111 111 def random(): -
sasmodels/product.py
r8795b6f rb297ba9 31 31 # pylint: enable=unused-import 32 32 33 # TODO: make shape averages available to constraints33 # TODO: make estimates available to constraints 34 34 #ESTIMATED_PARAMETERS = [ 35 # ["mean_radius_effective", "A", 0.0, [0, np.inf], "", "mean effective radius"], 36 # ["mean_volume", "A", 0.0, [0, np.inf], "", "mean volume"], 37 # ["mean_volume_ratio", "", 1.0, [0, np.inf], "", "mean form: mean shell volume ratio"], 35 # ["est_radius_effective", "A", 0.0, [0, np.inf], "", "Estimated effective radius"], 36 # ["est_volume_ratio", "", 1.0, [0, np.inf], "", "Estimated volume ratio"], 38 37 #] 38 39 39 STRUCTURE_MODE_ID = "structure_factor_mode" 40 40 RADIUS_MODE_ID = "radius_effective_mode" … … 44 44 # type: (ModelInfo) -> List[Parameter] 45 45 """ 46 Create parameters for structure factor and effective radius modes.46 Create parameters for structure_factor_mode and radius_effective_mode. 47 47 """ 48 48 pars = [] … … 56 56 "Structure factor calculation") 57 57 pars.append(par) 58 if p_info. radius_effective_modesis not None:58 if p_info.effective_radius_type is not None: 59 59 par = parse_parameter( 60 60 RADIUS_MODE_ID, 61 61 "", 62 62 1, 63 [["unconstrained"] + p_info. radius_effective_modes],63 [["unconstrained"] + p_info.effective_radius_type], 64 64 "", 65 65 "Effective radius calculation") … … 177 177 S, # type: np.ndarray 178 178 scale, # type: float 179 radius_effective, # type: float179 effective_radius, # type: float 180 180 beta_mode, # type: bool 181 181 ): … … 193 193 ("beta(Q)", F1**2 / F2), 194 194 ("S_eff(Q)", 1 + (F1**2 / F2)*(S-1)), 195 ("effective_radius", radius_effective),195 ("effective_radius", effective_radius), 196 196 # ("I(Q)", scale*(F2 + (F1**2)*(S-1)) + bg), 197 197 )) … … 200 200 ("P(Q)", scale*F2), 201 201 ("S(Q)", S), 202 ("effective_radius", radius_effective),202 ("effective_radius", effective_radius), 203 203 )) 204 204 return parts … … 281 281 # R_eff type parameter is the second parameter after P and S parameters 282 282 # unless the model doesn't support beta mode, in which case it is first 283 have_radius_type = p_info.radius_effective_modes is not None 284 #print(p_npars,s_npars) 283 have_radius_type = p_info.effective_radius_type is not None 285 284 radius_type_offset = 2+p_npars+s_npars + (1 if have_beta_mode else 0) 286 #print(values[radius_type_offset])287 285 radius_type = int(values[radius_type_offset]) if have_radius_type else 0 288 286 … … 333 331 # Call the form factor kernel to compute <F> and <F^2>. 334 332 # If the model doesn't support Fq the returned <F> will be None. 335 F1, F2, radius_effective, shell_volume, volume_ratio = self.p_kernel.Fq(333 F1, F2, effective_radius, shell_volume, volume_ratio = self.p_kernel.Fq( 336 334 p_details, p_values, cutoff, magnetic, radius_type) 337 335 … … 343 341 # implementation details in kernel_iq.c. 344 342 #print("R_eff=%d:%g, volfrac=%g, volume ratio=%g" 345 # % (radius_type, radius_effective, volfrac, volume_ratio))343 # % (radius_type, effective_radius, volfrac, volume_ratio)) 346 344 if radius_type > 0: 347 345 # set the value to the model R_eff and set the weight to 1 348 s_values[2] = s_values[2+s_npars+s_offset[0]] = radius_effective346 s_values[2] = s_values[2+s_npars+s_offset[0]] = effective_radius 349 347 s_values[2+s_npars+s_offset[0]+nweights] = 1.0 350 348 s_values[3] = s_values[2+s_npars+s_offset[1]] = volfrac*volume_ratio … … 372 370 # the results directly rather than through a lazy evaluator. 373 371 self.results = lambda: _intermediates( 374 F1, F2, S, combined_scale, radius_effective, beta_mode)372 F1, F2, S, combined_scale, effective_radius, beta_mode) 375 373 376 374 return final_result -
sasmodels/sasview_model.py
ra34b811 rb297ba9 299 299 attrs['category'] = model_info.category 300 300 attrs['is_structure_factor'] = model_info.structure_factor 301 attrs['is_form_factor'] = model_info. radius_effective_modesis not None301 attrs['is_form_factor'] = model_info.effective_radius_type is not None 302 302 attrs['is_multiplicity_model'] = variants[0] > 1 303 303 attrs['multiplicity_info'] = variants … … 763 763 # if er_mode > 0: 764 764 # res = calculator.Fq(call_details, values, cutoff=self.cutoff, 765 # magnetic=False, radius_effective_mode=mode)765 # magnetic=False, effective_radius_type=mode) 766 766 # R_eff, form_shell_ratio = res[2], res[4] 767 767 # return R_eff, form_shell_ratio
Note: See TracChangeset
for help on using the changeset viewer.