Changeset 8dc0b746 in sasview for sansmodels


Ignore:
Timestamp:
Aug 4, 2009 6:17:28 PM (15 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:
9188cc1
Parents:
96b59384
Message:

added 2D and corrected polydisp. parameters…

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

Legend:

Unmodified
Added
Removed
  • sansmodels/src/sans/models/c_extensions/prolate.c

    r27a0771 r8dc0b746  
    1818 */ 
    1919double prolate_analytical_1D(ProlateParameters *pars, double q) { 
    20         double dp[10]; 
    21          
     20        double dp[8]; 
     21 
    2222        // Fill paramater array 
    2323        dp[0] = pars->scale; 
     
    2929        dp[6] = pars->sld_solvent; 
    3030        dp[7] = pars->background; 
    31         dp[8] = pars->axis_theta; 
    32         dp[9] = pars->axis_phi; 
    33          
     31 
    3432        // Call library function to evaluate model 
    35         return ProlateForm(dp, q);       
     33        return ProlateForm(dp, q); 
    3634} 
    3735 
     
    4543        double q; 
    4644        q = sqrt(qx*qx+qy*qy); 
    47     return prolate_analytical_2D_scaled(pars, q, qx/q, qy/q); 
    48 }  
     45    return prolate_analytical_1D(pars, q); 
     46} 
    4947 
    5048 
     
    5755 */ 
    5856double prolate_analytical_2D(ProlateParameters *pars, double q, double phi) { 
    59     return prolate_analytical_2D_scaled(pars, q, cos(phi), sin(phi)); 
    60 }  
    61          
     57    return prolate_analytical_1D(pars, q); 
     58} 
     59 
    6260/** 
    6361 * Function to evaluate 2D scattering function 
     
    6866 * @return: function value 
    6967 */ 
    70 double prolate_analytical_2D_scaled(ProlateParameters *pars, double q, double q_x, double q_y) { 
    71          
    72         return 1.0; 
    73 } 
    74      
     68//double prolate_analytical_2D_scaled(ProlateParameters *pars, double q, double q_x, double q_y) { 
     69// 
     70//      return 1.0; 
     71//} 
     72 
  • sansmodels/src/sans/models/c_extensions/prolate.h

    r27a0771 r8dc0b746  
    33/** Structure definition for prolate parameters 
    44 * [PYTHONCLASS] = ProlateModel 
    5  * [DISP_PARAMS] = major_core, minor_core, major_shell,minor_shell, axis_theta, axis_phi 
    6    [DESCRIPTION] = <text> Calculates the form factor for a monodisperse prolate ellipsoid particle with a 
    7                                                 core/shell structure 
    8                                                 Note:It is the users' responsibility to ensure that shell radii are larger than core radii, and 
    9                                         that major radii are larger than minor radii.</text> 
    10  
    11    [FIXED] = <text>axis_phi.width; axis_theta.width; major_core.width;minor_core.width; major_shell; minor_shell</text> 
    12    [ORIENTATION_PARAMS] = <text>axis_phi; axis_theta; axis_phi.width; axis_theta.width</text> 
     5 * [DISP_PARAMS] = major_core, minor_core, major_shell,minor_shell 
     6   [DESCRIPTION] = <text>[ProlateCoreShellModel] Calculates the form factor for a prolate 
     7                        ellipsoid particle with a core_shell structure. 
     8                        The form factor is averaged over all possible 
     9                        orientations of the ellipsoid such that P(q) 
     10                        = scale*<f^2>/Vol + bkg, where f is the 
     11                        single particle scattering amplitude. 
     12                        [Parameters]: 
     13                        major_core = radius of major_core, 
     14                        minor_core = radius of minor_core, 
     15                        major_shell = radius of major_shell, 
     16                        minor_shell = radius of minor_shell, 
     17                        contrast = SLD_core - SLD_shell 
     18                        sld_solvent = SLD_solvent 
     19                        background = Incoherent bkg 
     20                        scale = scale 
     21                        Note:It is the users' responsibility to ensure 
     22                        that shell radii are larger than core radii. 
     23                        </text> 
     24   [FIXED] = <text>major_core.width;minor_core.width; major_shell.width; minor_shell.width</text> 
     25   [ORIENTATION_PARAMS] = 
    1326 
    1427 **/ 
     
    3851        //  [DEFAULT]=background=0.001 [1/cm] 
    3952        double background; 
    40     /// Orientation of the prolate axis w/respect incoming beam [rad] 
    41     //  [DEFAULT]=axis_theta=1.0 [rad] 
    42     double axis_theta; 
    43     /// Orientation of the prolate in the plane of the detector [rad] 
    44     //  [DEFAULT]=axis_phi=1.0 [rad] 
    45     double axis_phi; 
    4653 
    4754} ProlateParameters; 
     
    5562double prolate_analytical_2D(ProlateParameters *pars, double q, double phi); 
    5663double prolate_analytical_2DXY(ProlateParameters *pars, double qx, double qy); 
    57 double prolate_analytical_2D_scaled(ProlateParameters *pars, double q, double q_x, double q_y); 
     64//double prolate_analytical_2D_scaled(ProlateParameters *pars, double q, double q_x, double q_y); 
    5865 
    5966#endif 
  • sansmodels/src/sans/models/c_models/COblateModel.cpp

    r27a0771 r8dc0b746  
    108108        self->model->minor_shell.dispersion->accept_as_source(visitor, self->model->minor_shell.dispersion, disp_dict); 
    109109        PyDict_SetItemString(self->dispersion, "minor_shell", disp_dict); 
    110         disp_dict = PyDict_New(); 
    111         self->model->axis_theta.dispersion->accept_as_source(visitor, self->model->axis_theta.dispersion, disp_dict); 
    112         PyDict_SetItemString(self->dispersion, "axis_theta", disp_dict); 
    113         disp_dict = PyDict_New(); 
    114         self->model->axis_phi.dispersion->accept_as_source(visitor, self->model->axis_phi.dispersion, disp_dict); 
    115         PyDict_SetItemString(self->dispersion, "axis_phi", disp_dict); 
    116110 
    117111 
     
    187181    disp_dict = PyDict_GetItemString(self->dispersion, "minor_shell"); 
    188182    self->model->minor_shell.dispersion->accept_as_destination(visitor, self->model->minor_shell.dispersion, disp_dict); 
    189     disp_dict = PyDict_GetItemString(self->dispersion, "axis_theta"); 
    190     self->model->axis_theta.dispersion->accept_as_destination(visitor, self->model->axis_theta.dispersion, disp_dict); 
    191     disp_dict = PyDict_GetItemString(self->dispersion, "axis_phi"); 
    192     self->model->axis_phi.dispersion->accept_as_destination(visitor, self->model->axis_phi.dispersion, disp_dict); 
    193183 
    194184         
     
    263253    disp_dict = PyDict_GetItemString(self->dispersion, "minor_shell"); 
    264254    self->model->minor_shell.dispersion->accept_as_destination(visitor, self->model->minor_shell.dispersion, disp_dict); 
    265     disp_dict = PyDict_GetItemString(self->dispersion, "axis_theta"); 
    266     self->model->axis_theta.dispersion->accept_as_destination(visitor, self->model->axis_theta.dispersion, disp_dict); 
    267     disp_dict = PyDict_GetItemString(self->dispersion, "axis_phi"); 
    268     self->model->axis_phi.dispersion->accept_as_destination(visitor, self->model->axis_phi.dispersion, disp_dict); 
    269255 
    270256         
     
    330316    } else    if (!strcmp(par_name, "minor_shell")) { 
    331317        self->model->minor_shell.dispersion = dispersion; 
    332     } else    if (!strcmp(par_name, "axis_theta")) { 
    333         self->model->axis_theta.dispersion = dispersion; 
    334     } else    if (!strcmp(par_name, "axis_phi")) { 
    335         self->model->axis_phi.dispersion = dispersion; 
    336318    } else { 
    337319            PyErr_SetString(COblateModelError, 
  • sansmodels/src/sans/models/c_models/CProlateModel.cpp

    r72a90bd r8dc0b746  
    8686        PyDict_SetItemString(self->params,"scale",Py_BuildValue("d",1.000000)); 
    8787        PyDict_SetItemString(self->params,"minor_core",Py_BuildValue("d",50.000000)); 
    88         PyDict_SetItemString(self->params,"axis_theta",Py_BuildValue("d",1.000000)); 
    8988        PyDict_SetItemString(self->params,"sld_solvent",Py_BuildValue("d",0.000006)); 
    90         PyDict_SetItemString(self->params,"axis_phi",Py_BuildValue("d",1.000000)); 
    9189        PyDict_SetItemString(self->params,"background",Py_BuildValue("d",0.001000)); 
    9290        PyDict_SetItemString(self->params,"major_shell",Py_BuildValue("d",110.000000)); 
     
    108106        self->model->minor_shell.dispersion->accept_as_source(visitor, self->model->minor_shell.dispersion, disp_dict); 
    109107        PyDict_SetItemString(self->dispersion, "minor_shell", disp_dict); 
    110         disp_dict = PyDict_New(); 
    111         self->model->axis_theta.dispersion->accept_as_source(visitor, self->model->axis_theta.dispersion, disp_dict); 
    112         PyDict_SetItemString(self->dispersion, "axis_theta", disp_dict); 
    113         disp_dict = PyDict_New(); 
    114         self->model->axis_phi.dispersion->accept_as_source(visitor, self->model->axis_phi.dispersion, disp_dict); 
    115         PyDict_SetItemString(self->dispersion, "axis_phi", disp_dict); 
    116108 
    117109 
     
    169161    self->model->scale = PyFloat_AsDouble( PyDict_GetItemString(self->params, "scale") ); 
    170162    self->model->minor_core = PyFloat_AsDouble( PyDict_GetItemString(self->params, "minor_core") ); 
    171     self->model->axis_theta = PyFloat_AsDouble( PyDict_GetItemString(self->params, "axis_theta") ); 
    172163    self->model->sld_solvent = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_solvent") ); 
    173     self->model->axis_phi = PyFloat_AsDouble( PyDict_GetItemString(self->params, "axis_phi") ); 
    174164    self->model->background = PyFloat_AsDouble( PyDict_GetItemString(self->params, "background") ); 
    175165    self->model->major_shell = PyFloat_AsDouble( PyDict_GetItemString(self->params, "major_shell") ); 
     
    187177    disp_dict = PyDict_GetItemString(self->dispersion, "minor_shell"); 
    188178    self->model->minor_shell.dispersion->accept_as_destination(visitor, self->model->minor_shell.dispersion, disp_dict); 
    189     disp_dict = PyDict_GetItemString(self->dispersion, "axis_theta"); 
    190     self->model->axis_theta.dispersion->accept_as_destination(visitor, self->model->axis_theta.dispersion, disp_dict); 
    191     disp_dict = PyDict_GetItemString(self->dispersion, "axis_phi"); 
    192     self->model->axis_phi.dispersion->accept_as_destination(visitor, self->model->axis_phi.dispersion, disp_dict); 
    193179 
    194180         
     
    245231    self->model->scale = PyFloat_AsDouble( PyDict_GetItemString(self->params, "scale") ); 
    246232    self->model->minor_core = PyFloat_AsDouble( PyDict_GetItemString(self->params, "minor_core") ); 
    247     self->model->axis_theta = PyFloat_AsDouble( PyDict_GetItemString(self->params, "axis_theta") ); 
    248233    self->model->sld_solvent = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_solvent") ); 
    249     self->model->axis_phi = PyFloat_AsDouble( PyDict_GetItemString(self->params, "axis_phi") ); 
    250234    self->model->background = PyFloat_AsDouble( PyDict_GetItemString(self->params, "background") ); 
    251235    self->model->major_shell = PyFloat_AsDouble( PyDict_GetItemString(self->params, "major_shell") ); 
     
    263247    disp_dict = PyDict_GetItemString(self->dispersion, "minor_shell"); 
    264248    self->model->minor_shell.dispersion->accept_as_destination(visitor, self->model->minor_shell.dispersion, disp_dict); 
    265     disp_dict = PyDict_GetItemString(self->dispersion, "axis_theta"); 
    266     self->model->axis_theta.dispersion->accept_as_destination(visitor, self->model->axis_theta.dispersion, disp_dict); 
    267     disp_dict = PyDict_GetItemString(self->dispersion, "axis_phi"); 
    268     self->model->axis_phi.dispersion->accept_as_destination(visitor, self->model->axis_phi.dispersion, disp_dict); 
    269249 
    270250         
     
    330310    } else    if (!strcmp(par_name, "minor_shell")) { 
    331311        self->model->minor_shell.dispersion = dispersion; 
    332     } else    if (!strcmp(par_name, "axis_theta")) { 
    333         self->model->axis_theta.dispersion = dispersion; 
    334     } else    if (!strcmp(par_name, "axis_phi")) { 
    335         self->model->axis_phi.dispersion = dispersion; 
    336312    } else { 
    337313            PyErr_SetString(CProlateModelError, 
  • sansmodels/src/sans/models/c_models/prolate.cpp

    r27a0771 r8dc0b746  
    4545        sld_solvent = Parameter(6.3e-6); 
    4646        background = Parameter(0.0); 
    47         axis_theta  = Parameter(0.0, true); 
    48         axis_phi    = Parameter(0.0, true); 
    4947} 
    5048 
     
    6765        dp[5] = contrast(); 
    6866        dp[6] = sld_solvent(); 
    69         dp[7] = background(); 
    70          
     67        dp[7] = 0.0; 
     68 
    7169        // Get the dispersion points for the major core 
    7270        vector<WeightPoint> weights_major_core; 
     
    106104                                        dp[4] = weights_minor_shell[l].value; 
    107105 
    108                                         sum += weights_major_core[i].weight* weights_minor_core[j].weight * weights_major_shell[k].weight  
     106                                        sum += weights_major_core[i].weight* weights_minor_core[j].weight * weights_major_shell[k].weight 
    109107                                                * weights_minor_shell[l].weight * ProlateForm(dp, q); 
    110                                         norm += weights_major_core[i].weight* weights_minor_core[j].weight * weights_major_shell[k].weight  
     108                                        norm += weights_major_core[i].weight* weights_minor_core[j].weight * weights_major_shell[k].weight 
    111109                                                        * weights_minor_shell[l].weight; 
    112110                                } 
     
    123121 * @return: function value 
    124122 */ 
     123double ProlateModel :: operator()(double qx, double qy) { 
     124        double q = sqrt(qx*qx + qy*qy); 
     125 
     126        return (*this).operator()(q); 
     127} 
     128 
     129/** 
     130 * Function to evaluate 2D scattering function 
     131 * @param pars: parameters of the prolate 
     132 * @param q: q-value 
     133 * @param phi: angle phi 
     134 * @return: function value 
     135 */ 
     136double ProlateModel :: evaluate_rphi(double q, double phi) { 
     137        return (*this).operator()(q); 
     138} 
     139/* 
    125140double ProlateModel :: operator()(double qx, double qy) { 
    126141        ProlateParameters dp; 
     
    216231} 
    217232 
    218 /** 
    219  * Function to evaluate 2D scattering function 
    220  * @param pars: parameters of the prolate 
    221  * @param q: q-value 
    222  * @param phi: angle phi 
    223  * @return: function value 
    224  */ 
    225 double ProlateModel :: evaluate_rphi(double q, double phi) { 
    226         double qx = q*cos(phi); 
    227         double qy = q*sin(phi); 
    228         return (*this).operator()(qx, qy); 
    229 } 
     233*/ 
Note: See TracChangeset for help on using the changeset viewer.