Changes in / [1896dff:faf83f2] in sasmodels


Ignore:
Location:
sasmodels
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • sasmodels/models/ellipsoid.c

    r130d4c7 r925ad6e  
    44    double radius_polar, double radius_equatorial, double theta, double phi); 
    55 
    6 static double 
    7 _ellipsoid_kernel(double q, double radius_polar, double radius_equatorial, double cos_alpha) 
     6double _ellipsoid_kernel(double q, double radius_polar, double radius_equatorial, double sin_alpha); 
     7double _ellipsoid_kernel(double q, double radius_polar, double radius_equatorial, double sin_alpha) 
    88{ 
    99    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) 
    1714    // Instead of using pythagoras we could pass in sin and cos; this may be 
    1815    // slightly better for 2D which has already computed it, but it introduces 
     
    2017    // leave it as is. 
    2118    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)); 
    2320    const double f = sas_3j1x_x(q*r); 
    2421 
     
    4239    double total = 0.0; 
    4340    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); 
    4744    } 
    4845    // translate dx in [-1,1] to dx in [lower,upper] 
     
    6259    double q, sin_alpha, cos_alpha; 
    6360    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); 
    6562    const double s = (sld - sld_solvent) * form_volume(radius_polar, radius_equatorial); 
    6663 
  • sasmodels/models/hayter_msa.c

    r3fc5d27 r4962519  
    7070                SofQ=sqhcal(Qdiam, gMSAWave); 
    7171        }else{ 
    72         SofQ=NAN; 
     72        //SofQ=NaN; 
     73                SofQ=-1.0; 
    7374                //      print "Error Level = ",ierr 
    7475                //      print "Please report HPMSA problem with above error code" 
  • sasmodels/sasview_model.py

    r749a7d4 r64614ad  
    1616import logging 
    1717from os.path import basename, splitext 
    18 import thread 
    1918 
    2019import numpy as np  # type: ignore 
     
    3938except ImportError: 
    4039    pass 
    41  
    42 calculation_lock = thread.allocate_lock() 
    4340 
    4441SUPPORT_OLD_STYLE_PLUGINS = True 
     
    608605        to the card for each evaluation. 
    609606        """ 
    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): 
    620607        #core.HAVE_OPENCL = False 
    621608        if self._model is None: 
     
    734721            return [self.params[par.name]], [1.0] 
    735722 
    736 def test_cylinder(): 
     723def test_model(): 
    737724    # type: () -> float 
    738725    """ 
    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. 
    740727    """ 
    741728    Cylinder = _make_standard_model('cylinder') 
     
    746733    # type: () -> float 
    747734    """ 
    748     Test that 2-D hardsphere model runs and doesn't produce NaN. 
     735    Test that a sasview model (cylinder) can be run. 
    749736    """ 
    750737    Model = _make_standard_model('hardsphere') 
     
    757744    # type: () -> float 
    758745    """ 
    759     Test that the 2-D RPA model runs 
     746    Test that a sasview model (cylinder) can be run. 
    760747    """ 
    761748    RPA = _make_standard_model('rpa') 
     
    763750    return rpa.evalDistribution([0.1, 0.1]) 
    764751 
    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" 
    776752 
    777753def test_model_list(): 
    778754    # type: () -> None 
    779755    """ 
    780     Make sure that all models build as sasview models 
     756    Make sure that all models build as sasview models. 
    781757    """ 
    782758    from .exception import annotate_exception 
     
    805781 
    806782if __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.