Changeset 1896dff in sasmodels
- Timestamp:
- Feb 28, 2017 9:31:56 AM (8 years ago)
- Branches:
- master, core_shell_microgels, costrafo411, magnetic_model, ticket-1257-vesicle-product, ticket_1156, ticket_1265_superball, ticket_822_more_unit_tests
- Children:
- ae32bb8
- Parents:
- faf83f2 (diff), a3002be (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent. - Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
sasmodels/models/ellipsoid.c
r925ad6e r130d4c7 4 4 double radius_polar, double radius_equatorial, double theta, double phi); 5 5 6 double _ellipsoid_kernel(double q, double radius_polar, double radius_equatorial, double sin_alpha); 7 double _ellipsoid_kernel(double q, double radius_polar, double radius_equatorial, double sin_alpha)6 static double 7 _ellipsoid_kernel(double q, double radius_polar, double radius_equatorial, double cos_alpha) 8 8 { 9 9 double ratio = radius_polar/radius_equatorial; 10 // Given the following under the radical: 11 // 1 + sin^2(T) (v^2 - 1) 12 // we can expand to match the form given in Guinier (1955) 13 // = (1 - sin^2(T)) + v^2 sin^2(T) = cos^2(T) + sin^2(T) 10 // Using ratio v = Rp/Re, we can expand the following to match the 11 // form given in Guinier (1955) 12 // r = Re * sqrt(1 + cos^2(T) (v^2 - 1)) 13 // = Re * sqrt( (1 - cos^2(T)) + v^2 cos^2(T) ) 14 // = Re * sqrt( sin^2(T) + v^2 cos^2(T) ) 15 // = sqrt( Re^2 sin^2(T) + Rp^2 cos^2(T) ) 16 // 14 17 // Instead of using pythagoras we could pass in sin and cos; this may be 15 18 // slightly better for 2D which has already computed it, but it introduces … … 17 20 // leave it as is. 18 21 const double r = radius_equatorial 19 * sqrt(1.0 + sin_alpha*sin_alpha*(ratio*ratio - 1.0));22 * sqrt(1.0 + cos_alpha*cos_alpha*(ratio*ratio - 1.0)); 20 23 const double f = sas_3j1x_x(q*r); 21 24 … … 39 42 double total = 0.0; 40 43 for (int i=0;i<76;i++) { 41 //const double sin_alpha = (Gauss76Z[i]*(upper-lower) + upper + lower)/2;42 const double sin_alpha = Gauss76Z[i]*zm + zb;43 total += Gauss76Wt[i] * _ellipsoid_kernel(q, radius_polar, radius_equatorial, sin_alpha);44 //const double cos_alpha = (Gauss76Z[i]*(upper-lower) + upper + lower)/2; 45 const double cos_alpha = Gauss76Z[i]*zm + zb; 46 total += Gauss76Wt[i] * _ellipsoid_kernel(q, radius_polar, radius_equatorial, cos_alpha); 44 47 } 45 48 // translate dx in [-1,1] to dx in [lower,upper] … … 59 62 double q, sin_alpha, cos_alpha; 60 63 ORIENT_SYMMETRIC(qx, qy, theta, phi, q, sin_alpha, cos_alpha); 61 const double form = _ellipsoid_kernel(q, radius_polar, radius_equatorial, sin_alpha);64 const double form = _ellipsoid_kernel(q, radius_polar, radius_equatorial, cos_alpha); 62 65 const double s = (sld - sld_solvent) * form_volume(radius_polar, radius_equatorial); 63 66 -
sasmodels/models/hayter_msa.c
r4962519 r3fc5d27 70 70 SofQ=sqhcal(Qdiam, gMSAWave); 71 71 }else{ 72 //SofQ=NaN; 73 SofQ=-1.0; 72 SofQ=NAN; 74 73 // print "Error Level = ",ierr 75 74 // print "Please report HPMSA problem with above error code" -
sasmodels/sasview_model.py
rfe8ff99 r749a7d4 16 16 import logging 17 17 from os.path import basename, splitext 18 import thread 18 19 19 20 import numpy as np # type: ignore … … 38 39 except ImportError: 39 40 pass 41 42 calculation_lock = thread.allocate_lock() 40 43 41 44 SUPPORT_OLD_STYLE_PLUGINS = True … … 605 608 to the card for each evaluation. 606 609 """ 610 ## uncomment the following when trying to debug the uncoordinated calls 611 ## to calculate_Iq 612 #if calculation_lock.locked(): 613 # logging.info("calculation waiting for another thread to complete") 614 # logging.info("\n".join(traceback.format_stack())) 615 616 with calculation_lock: 617 return self._calculate_Iq(qx, qy) 618 619 def _calculate_Iq(self, qx, qy=None): 607 620 #core.HAVE_OPENCL = False 608 621 if self._model is None: … … 721 734 return [self.params[par.name]], [1.0] 722 735 723 def test_ model():736 def test_cylinder(): 724 737 # type: () -> float 725 738 """ 726 Test that a sasview model (cylinder) can be run.739 Test that the cylinder model runs, returning the value at [0.1,0.1]. 727 740 """ 728 741 Cylinder = _make_standard_model('cylinder') … … 733 746 # type: () -> float 734 747 """ 735 Test that a sasview model (cylinder) can be run.748 Test that 2-D hardsphere model runs and doesn't produce NaN. 736 749 """ 737 750 Model = _make_standard_model('hardsphere') … … 744 757 # type: () -> float 745 758 """ 746 Test that a sasview model (cylinder) can be run.759 Test that the 2-D RPA model runs 747 760 """ 748 761 RPA = _make_standard_model('rpa') … … 750 763 return rpa.evalDistribution([0.1, 0.1]) 751 764 765 def test_empty_distribution(): 766 # type: () -> None 767 """ 768 Make sure that sasmodels returns NaN when there are no polydispersity points 769 """ 770 Cylinder = _make_standard_model('cylinder') 771 cylinder = Cylinder() 772 cylinder.setParam('radius', -1.0) 773 cylinder.setParam('background', 0.) 774 Iq = cylinder.evalDistribution(np.asarray([0.1])) 775 assert np.isnan(Iq[0]), "empty distribution fails" 752 776 753 777 def test_model_list(): 754 778 # type: () -> None 755 779 """ 756 Make sure that all models build as sasview models .780 Make sure that all models build as sasview models 757 781 """ 758 782 from .exception import annotate_exception … … 781 805 782 806 if __name__ == "__main__": 783 print("cylinder(0.1,0.1)=%g"%test_model()) 807 print("cylinder(0.1,0.1)=%g"%test_cylinder()) 808 #test_empty_distribution() -
doc/ref/gpu/gpu_computations.rst
r3f5a566 r7e74ed5 31 31 from available OpenCL platforms. 32 32 33 OpenCL devices can be set from OpenCL options dialog in Fitting menu or as 34 enviromental variables. 35 36 **If you don't want to use OpenCL, you can select "No OpenCL" option from** 37 **GUI dialog or set *SAS_OPENCL=None* in your environment settings** 38 **This will only use normal programs.** 39 33 40 SasView prefers AMD or NVIDIA drivers for GPU, and prefers Intel or 34 41 Apple drivers for CPU. Both GPU and CPU are included on the assumption that CPU … … 39 46 chose to run the model. 40 47 41 **If you don't want to use OpenCL, you can set** *SAS_OPENCL=None* 42 **in your environment settings, and it will only use normal programs.** 43 44 If you want to use one of the other devices, you can run the following 45 from the python console in SasView:: 48 If you want to use one of the other devices, you can select it from OpenCL 49 options dialog (accessible from Fitting menu) or run the following from 50 the python console in SasView:: 46 51 47 52 import pyopencl as cl
Note: See TracChangeset
for help on using the changeset viewer.