Changes in / [1896dff:faf83f2] in sasmodels
- Location:
- sasmodels
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
sasmodels/models/ellipsoid.c
r130d4c7 r925ad6e 4 4 double radius_polar, double radius_equatorial, double theta, double phi); 5 5 6 static double 7 _ellipsoid_kernel(double q, double radius_polar, double radius_equatorial, double cos_alpha)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) 8 8 { 9 9 double ratio = radius_polar/radius_equatorial; 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 // 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) 17 14 // Instead of using pythagoras we could pass in sin and cos; this may be 18 15 // slightly better for 2D which has already computed it, but it introduces … … 20 17 // leave it as is. 21 18 const double r = radius_equatorial 22 * sqrt(1.0 + cos_alpha*cos_alpha*(ratio*ratio - 1.0));19 * sqrt(1.0 + sin_alpha*sin_alpha*(ratio*ratio - 1.0)); 23 20 const double f = sas_3j1x_x(q*r); 24 21 … … 42 39 double total = 0.0; 43 40 for (int i=0;i<76;i++) { 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);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); 47 44 } 48 45 // translate dx in [-1,1] to dx in [lower,upper] … … 62 59 double q, sin_alpha, cos_alpha; 63 60 ORIENT_SYMMETRIC(qx, qy, theta, phi, q, sin_alpha, cos_alpha); 64 const double form = _ellipsoid_kernel(q, radius_polar, radius_equatorial, cos_alpha);61 const double form = _ellipsoid_kernel(q, radius_polar, radius_equatorial, sin_alpha); 65 62 const double s = (sld - sld_solvent) * form_volume(radius_polar, radius_equatorial); 66 63 -
sasmodels/models/hayter_msa.c
r3fc5d27 r4962519 70 70 SofQ=sqhcal(Qdiam, gMSAWave); 71 71 }else{ 72 SofQ=NAN; 72 //SofQ=NaN; 73 SofQ=-1.0; 73 74 // print "Error Level = ",ierr 74 75 // print "Please report HPMSA problem with above error code" -
sasmodels/sasview_model.py
r749a7d4 r64614ad 16 16 import logging 17 17 from os.path import basename, splitext 18 import thread19 18 20 19 import numpy as np # type: ignore … … 39 38 except ImportError: 40 39 pass 41 42 calculation_lock = thread.allocate_lock()43 40 44 41 SUPPORT_OLD_STYLE_PLUGINS = True … … 608 605 to the card for each evaluation. 609 606 """ 610 ## uncomment the following when trying to debug the uncoordinated calls611 ## to calculate_Iq612 #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):620 607 #core.HAVE_OPENCL = False 621 608 if self._model is None: … … 734 721 return [self.params[par.name]], [1.0] 735 722 736 def test_ cylinder():723 def test_model(): 737 724 # type: () -> float 738 725 """ 739 Test that the cylinder model runs, returning the value at [0.1,0.1].726 Test that a sasview model (cylinder) can be run. 740 727 """ 741 728 Cylinder = _make_standard_model('cylinder') … … 746 733 # type: () -> float 747 734 """ 748 Test that 2-D hardsphere model runs and doesn't produce NaN.735 Test that a sasview model (cylinder) can be run. 749 736 """ 750 737 Model = _make_standard_model('hardsphere') … … 757 744 # type: () -> float 758 745 """ 759 Test that the 2-D RPA model runs746 Test that a sasview model (cylinder) can be run. 760 747 """ 761 748 RPA = _make_standard_model('rpa') … … 763 750 return rpa.evalDistribution([0.1, 0.1]) 764 751 765 def test_empty_distribution():766 # type: () -> None767 """768 Make sure that sasmodels returns NaN when there are no polydispersity points769 """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"776 752 777 753 def test_model_list(): 778 754 # type: () -> None 779 755 """ 780 Make sure that all models build as sasview models 756 Make sure that all models build as sasview models. 781 757 """ 782 758 from .exception import annotate_exception … … 805 781 806 782 if __name__ == "__main__": 807 print("cylinder(0.1,0.1)=%g"%test_cylinder()) 808 #test_empty_distribution() 783 print("cylinder(0.1,0.1)=%g"%test_model())
Note: See TracChangeset
for help on using the changeset viewer.