Changeset 18f2ca1 in sasview for sansmodels


Ignore:
Timestamp:
Oct 15, 2010 6:43:06 PM (14 years ago)
Author:
Jae Cho <jhjcho@…>
Branches:
master, ESS_GUI, ESS_GUI_Docs, ESS_GUI_batch_fitting, ESS_GUI_bumps_abstraction, ESS_GUI_iss1116, ESS_GUI_iss879, ESS_GUI_iss959, ESS_GUI_opencl, ESS_GUI_ordering, ESS_GUI_sync_sascalc, costrafo411, magnetic_scatt, release-4.1.1, release-4.1.2, release-4.2.2, release_4.0.1, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
Children:
2e862a0
Parents:
495c377
Message:

hope this was the last model left to add

Location:
sansmodels/src/sans/models
Files:
5 added
8 edited

Legend:

Unmodified
Added
Removed
  • sansmodels/src/sans/models/CappedCylinderModel.py

    r339ce67 r18f2ca1  
    5858        self.name = "CappedCylinderModel" 
    5959        ## Model description 
    60         self.description ="""Calculates the scattering from a cylinder with spherical 
    61                 section end-caps. That is, a sphereocylinder 
     60        self.description ="""Calculates the scattering from a cylinder with spherical section end-caps. 
     61                That is, a sphereocylinder 
    6262                with end caps that have a radius larger than 
    6363                that of the cylinder and the center of the 
  • sansmodels/src/sans/models/c_extensions/bcc.c

    r8f20419d r18f2ca1  
    110110    // Compute the angle btw vector q and the a3 axis 
    111111    cos_val_a3 = a3_x*q_x + a3_y*q_y + a3_z*q_z; 
    112     //alpha = acos(cos_val_a3); 
     112    alpha = acos(cos_val_a3); 
    113113    a3_dot_q = aa*q*cos_val_a3; 
    114114 
    115115    // a1 axis 
    116116    cos_val_a1 = a1_x*q_x + a1_y*q_y; 
    117     a1_dot_q = aa*q*cos_val_a1; 
     117    a1_dot_q = aa*q*cos_val_a1*sin(alpha); 
    118118 
    119119    // a2 axis 
    120     cos_val_a2 = a2_x*q_x + a2_y*q_y; //sin(acos(cos_val_a1)) ; 
    121     a2_dot_q = aa*q*cos_val_a2; 
     120    cos_val_a2 = sin(acos(cos_val_a1));//a2_x*q_x + a2_y*q_y; 
     121    a2_dot_q = aa*q*cos_val_a2*sin(alpha); //aa*q*cos_val_a2 
    122122 
    123123    // The following test should always pass 
  • sansmodels/src/sans/models/c_extensions/capcyl.h

    r339ce67 r18f2ca1  
    77 //[PYTHONCLASS] = CappedCylinderModel 
    88 //[DISP_PARAMS] = rad_cyl,len_cyl,rad_cap,phi,  theta 
    9  //[DESCRIPTION] =<text>Calculates the scattering from a cylinder with spherical 
    10  //                             section end-caps. That is, a sphereocylinder 
     9 //[DESCRIPTION] =<text>Calculates the scattering from a cylinder with spherical section end-caps. 
     10 //                             That is, a sphereocylinder 
    1111 //                             with end caps that have a radius larger than 
    1212 //                             that of the cylinder and the center of the 
  • sansmodels/src/sans/models/c_extensions/fcc.c

    r8f20419d r18f2ca1  
    7777        Da = pars->d_factor*aa; 
    7878        qDa_2 = pow(q*Da,2.0); 
    79         contrast = pars->sldSph - pars->sldSolv; 
     79        //contrast = pars->sldSph - pars->sldSolv; 
    8080 
    8181        latticeScale = 4.0*(4.0/3.0)*Pi*(dp[1]*dp[1]*dp[1])/pow(aa*sqrt(2.0),3.0); 
     
    109109 
    110110    // Compute the angle btw vector q and the a3 axis 
    111     cos_val_a3 = a3_x*q_x + a3_y*q_y;// + a3_z*q_z; 
     111    cos_val_a3 = a3_x*q_x + a3_y*q_y + a3_z*q_z; 
     112    alpha = acos(cos_val_a3); 
    112113    a3_dot_q = aa*q*cos_val_a3; 
    113114 
    114115    // a1 axis 
    115116    cos_val_a1 = a1_x*q_x + a1_y*q_y; 
    116     a1_dot_q = aa*q*cos_val_a1; 
     117    a1_dot_q = aa*q*cos_val_a1*sin(alpha); 
    117118 
    118119    // a2 axis 
    119     cos_val_a2 = a2_x*q_x + a2_y*q_y; //sin(acos(cos_val_a1)) ; 
    120     a2_dot_q = aa*q*cos_val_a2; 
     120    cos_val_a2 = sin(acos(cos_val_a1));//a2_x*q_x + a2_y*q_y; 
     121    a2_dot_q = aa*q*cos_val_a2*sin(alpha); 
    121122 
    122123    // The following test should always pass 
     
    134135 
    135136        // Use SphereForm directly from libigor 
    136         answer = SphereForm_Paracrystal(pars->radius,contrast,q)*Zq; 
     137        answer = SphereForm(dp,q)*Zq; 
    137138 
    138139        //consider scales 
  • sansmodels/src/sans/models/c_extensions/sc.c

    r8f20419d r18f2ca1  
    8989    // Compute the angle btw vector q and the a3 axis 
    9090    cos_val_a3 = a3_x*q_x + a3_y*q_y + a3_z*q_z; 
     91    alpha = acos(cos_val_a3); 
    9192    //alpha = acos(cos_val_a3); 
    9293    a3_dot_q = aa*q*cos_val_a3; 
     
    9697 
    9798    cos_val_a1 = a1_x*q_x + a1_y*q_y; 
    98     a1_dot_q = aa*q*cos_val_a1; 
     99    a1_dot_q = aa*q*cos_val_a1*sin(alpha); 
    99100 
    100101    // a2 axis orientation 
     
    102103    a2_y = sqrt(1.0-sin(pars->theta)*cos(pars->phi))*sin(pars->psi); 
    103104    // a2 axis 
    104     cos_val_a2 =  a2_x*q_x + a2_y*q_y;//sin(acos(cos_val_a1)) ; 
    105     a2_dot_q = aa*q*cos_val_a2; 
     105    cos_val_a2 =  sin(acos(cos_val_a1));//a2_x*q_x + a2_y*q_y; 
     106    a2_dot_q = aa*q*cos_val_a2*sin(alpha); 
    106107 
    107108    // The following test should always pass 
  • sansmodels/src/sans/models/c_models/c_models.cpp

    rfbd09fa0 r18f2ca1  
    1616void addCTriaxialEllipsoidModel(PyObject *module); 
    1717void addCParallelepipedModel(PyObject *module); 
     18void addCCSParallelepipedModel(PyObject *module); 
    1819void addCSphereModel(PyObject *module); 
    1920void addCOnionModel(PyObject *module); 
     
    227228        addCCappedCylinderModel(m); 
    228229        addCParallelepipedModel(m); 
     230        addCCSParallelepipedModel(m); 
    229231        addCCoreShellCylinderModel(m); 
    230232        addCCoreShellModel(m); 
  • sansmodels/src/sans/models/c_models/models.hh

    r339ce67 r18f2ca1  
    9898class ParallelepipedModel{ 
    9999public: 
    100         // TODO: add 2D 
    101100        // Model parameters 
    102101        Parameter scale; 
     
    121120}; 
    122121 
     122 
     123class CSParallelepipedModel{ 
     124public: 
     125        // Model parameters 
     126        Parameter scale; 
     127        Parameter shortA; 
     128        Parameter midB; 
     129        Parameter longC; 
     130        Parameter rimA; 
     131        Parameter rimB; 
     132        Parameter rimC; 
     133        Parameter sld_rimA; 
     134        Parameter sld_rimB; 
     135        Parameter sld_rimC; 
     136        Parameter sld_pcore; 
     137        Parameter sld_solv; 
     138        Parameter background; 
     139        Parameter parallel_theta; 
     140        Parameter parallel_phi; 
     141        Parameter parallel_psi; 
     142 
     143        // Constructor 
     144        CSParallelepipedModel(); 
     145 
     146        // Operators to get I(Q) 
     147        double operator()(double q); 
     148        double operator()(double qx, double qy); 
     149        double calculate_ER(); 
     150        double evaluate_rphi(double q, double phi); 
     151}; 
    123152 
    124153class OnionModel{ 
  • sansmodels/src/sans/models/test/utest_extra_models.py

    r495c377 r18f2ca1  
    346346        self.assertAlmostEqual(self.model4.runXY(0.4425284), 0.00306386, 8)   
    347347                                                                               
    348                                                                                                                                                                                   
     348 
     349class TestCSPP(unittest.TestCase): 
     350    """ 
     351    Unit tests for CSParallelepiped Model function 
     352    """ 
     353    def setUp(self): 
     354        from sans.models.CSParallelepipedModel import CSParallelepipedModel 
     355        self.model= CSParallelepipedModel() 
     356         
     357    def test1D(self):         
     358        # the values are from Igor pro calculation   
     359        # the different digits are due to precision of q values   
     360        self.assertAlmostEqual(self.model.run(0.001), 1383.96, 2) 
     361        self.assertAlmostEqual(self.model.run(0.1501412), 2.51932, 4) 
     362        self.assertAlmostEqual(self.model.runXY(0.4425284), 0.0736735, 6) 
     363                                                                                                                                                           
    349364if __name__ == '__main__': 
    350365    unittest.main() 
Note: See TracChangeset for help on using the changeset viewer.