Changeset 42f193a in sasview for sansmodels/src/sans/models


Ignore:
Timestamp:
Aug 4, 2009 1:20:01 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:
8e91f01
Parents:
2cc633b
Message:

some corrections on dips-parameters and adding 2D cal

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

Legend:

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

    r34c3020 r42f193a  
    11/** 
    2  * Scattering model for lamellar 
     2 * Scattering model for dilute lamellar model: polydipsersion in thickness (delta) included 
    33 * @author: Gervaise B. Alina / UTK 
    44 */ 
     
    1919double lamellar_analytical_1D(LamellarParameters *pars, double q) { 
    2020        double dp[5]; 
    21          
     21 
    2222        // Fill paramater array 
    2323        dp[0] = pars->scale; 
     
    2626        dp[3] = pars->contrast; 
    2727        dp[4] = pars->background; 
    28          
    29          
     28 
     29 
    3030        // Call library function to evaluate model 
    31         return LamellarFF(dp, q);        
     31        return LamellarFF(dp, q); 
     32} 
     33/** 
     34 * Function to evaluate 2D scattering function 
     35 * @param pars: parameters of the lamellar 
     36 * @param q: q-value 
     37 * @return: function value 
     38 */ 
     39 
     40 
     41double lamellar_analytical_2D(LamellarParameters *pars, double q, double phi){ 
     42        return lamellar_analytical_1D(pars,q); 
     43} 
     44double lamellar_analytical_2DXY(LamellarParameters *pars, double qx, double qy){ 
     45        return lamellar_analytical_1D(pars,sqrt(qx*qx+qy*qy)); 
    3246} 
    3347 
    34 double lamellar_analytical_2D(LamellarParameters *pars, double q, double phi){ 
    35         return 1.0; 
    36 } 
    37 double lamellar_analytical_2DXY(LamellarParameters *pars, double qx, double qy){ 
    38         return 1.0; 
    39 } 
    40 double lamellar_analytical_2D_scaled(LamellarParameters *pars, double q, double q_x, double q_y){ 
    41         return 1.0; 
    42 } 
    43  
  • sansmodels/src/sans/models/c_extensions/lamellar.h

    r34c3020 r42f193a  
    33/** Structure definition for lamellar parameters 
    44 * [PYTHONCLASS] = LamellarModel 
    5  * [DISP_PARAMS] =  delta 
    6    [DESCRIPTION] = <text> I(q)= 2*pi*P(q)/(delta *q^(2)) 
    7                                                 where: 
    8                                                 P(q)=2*(contrast/q)^(2)*(1-cos(q*delta)*e^(1/2*(q*sigma)^(2)) 
    9                                    </text> 
    10         [FIXED]= delta.width  
    11         [ORIENTATION_PARAMS]=  
     5   [DESCRIPTION] = <text>[Dilute Lamellar Form Factor](from a lyotropic lamellar phase) 
     6           I(q)= 2*pi*P(q)/(delta *q^(2)), where 
     7                P(q)=2*(contrast/q)^(2)*(1-cos(q*delta) 
     8                *e^(1/2*(q*sigma)^(2)). 
     9                delta = bilayer thickness 
     10                sigma = variation in bilayer thickness 
     11                        = delta*polydispersity 
     12                contrast = SLD_solvent - SLD_bilayer 
     13        Note: the polydispersity in delta is included. 
     14 </text> 
    1215 **/ 
    1316typedef struct { 
     
    1821    //  [DEFAULT]=delta=50.0 [A] 
    1922    double delta; 
    20     /// variation in bilayer thickness  
     23    /// variation in bilayer thickness 
    2124    //  [DEFAULT]=sigma=0.15 
    2225    double sigma; 
     
    2730        //  [DEFAULT]=background=0.0 [1/cm] 
    2831        double background; 
    29     
     32 
    3033 
    3134} LamellarParameters; 
  • sansmodels/src/sans/models/c_extensions/vesicle.h

    r3d25331f r42f193a  
    44/** 
    55 * Structure definition for vesicle parameters 
    6  
    7         [PYTHONCLASS] = VesicleModel 
    8         [DISP_PARAMS] = core_radius 
    9         [DESCRIPTION] =<text> 
    10                                                 Model parameters: 
    11                                                 scale : scale factor 
    12                                                 core_radius : Core radius of the vesicle 
    13                                                 thickness: shell thickness 
    14                                                 core_sld: core scattering length density 
    15                                                 shell_sld: shell scattering length density 
    16                                                 background: incoherent background 
    17                </text> 
    18         [FIXED]=  core_radius.width 
    19         [ORIENTATION_PARAMS]= <text> </text> 
     6[PYTHONCLASS] = VesicleModel 
     7[DISP_PARAMS] = core_radius,thickness 
     8[DESCRIPTION] =<text>Model parameters:  core_radius : Core radius of the vesicle 
     9                thickness: shell thickness 
     10                core_sld: core scattering length density 
     11                shell_sld: shell scattering length density 
     12                background: incoherent background 
     13                scale : scale factor 
     14</text> 
     15[FIXED]=  core_radius.width; thickness.width 
     16[ORIENTATION_PARAMS]= <text> </text> 
    2017 */ 
    2118typedef struct { 
  • sansmodels/src/sans/models/c_models/CLamellarModel.cpp

    r34c3020 r42f193a  
    9191        DispersionVisitor* visitor = new DispersionVisitor(); 
    9292        PyObject * disp_dict; 
    93         disp_dict = PyDict_New(); 
    94         self->model->delta.dispersion->accept_as_source(visitor, self->model->delta.dispersion, disp_dict); 
    95         PyDict_SetItemString(self->dispersion, "delta", disp_dict); 
    9693 
    9794 
     
    154151    PyObject* disp_dict; 
    155152    DispersionVisitor* visitor = new DispersionVisitor(); 
    156     disp_dict = PyDict_GetItemString(self->dispersion, "delta"); 
    157     self->model->delta.dispersion->accept_as_destination(visitor, self->model->delta.dispersion, disp_dict); 
    158153 
    159154         
     
    215210    PyObject* disp_dict; 
    216211    DispersionVisitor* visitor = new DispersionVisitor(); 
    217     disp_dict = PyDict_GetItemString(self->dispersion, "delta"); 
    218     self->model->delta.dispersion->accept_as_destination(visitor, self->model->delta.dispersion, disp_dict); 
    219212 
    220213         
     
    272265        // Ugliness necessary to go from python to C 
    273266            // TODO: refactor this 
    274     if (!strcmp(par_name, "delta")) { 
    275         self->model->delta.dispersion = dispersion; 
    276     } else { 
     267 { 
    277268            PyErr_SetString(CLamellarModelError, 
    278269                "CLamellarModel.set_dispersion expects a valid parameter name."); 
  • sansmodels/src/sans/models/c_models/CVesicleModel.cpp

    r3d25331f r42f193a  
    9595        self->model->core_radius.dispersion->accept_as_source(visitor, self->model->core_radius.dispersion, disp_dict); 
    9696        PyDict_SetItemString(self->dispersion, "core_radius", disp_dict); 
     97        disp_dict = PyDict_New(); 
     98        self->model->thickness.dispersion->accept_as_source(visitor, self->model->thickness.dispersion, disp_dict); 
     99        PyDict_SetItemString(self->dispersion, "thickness", disp_dict); 
    97100 
    98101 
     
    158161    disp_dict = PyDict_GetItemString(self->dispersion, "core_radius"); 
    159162    self->model->core_radius.dispersion->accept_as_destination(visitor, self->model->core_radius.dispersion, disp_dict); 
     163    disp_dict = PyDict_GetItemString(self->dispersion, "thickness"); 
     164    self->model->thickness.dispersion->accept_as_destination(visitor, self->model->thickness.dispersion, disp_dict); 
    160165 
    161166         
     
    220225    disp_dict = PyDict_GetItemString(self->dispersion, "core_radius"); 
    221226    self->model->core_radius.dispersion->accept_as_destination(visitor, self->model->core_radius.dispersion, disp_dict); 
     227    disp_dict = PyDict_GetItemString(self->dispersion, "thickness"); 
     228    self->model->thickness.dispersion->accept_as_destination(visitor, self->model->thickness.dispersion, disp_dict); 
    222229 
    223230         
     
    277284    if (!strcmp(par_name, "core_radius")) { 
    278285        self->model->core_radius.dispersion = dispersion; 
     286    } else    if (!strcmp(par_name, "thickness")) { 
     287        self->model->thickness.dispersion = dispersion; 
    279288    } else { 
    280289            PyErr_SetString(CVesicleModelError, 
  • sansmodels/src/sans/models/c_models/lamellar.cpp

    r34c3020 r42f193a  
    3434LamellarModel :: LamellarModel() { 
    3535        scale      = Parameter(1.0); 
    36         delta     = Parameter(50.0, true); 
     36        delta     = Parameter(50.0); 
    3737        delta.set_min(0.0); 
    38         sigma    = Parameter(0.15, true); 
     38        sigma    = Parameter(0.15); 
     39        sigma.set_min(0.0); 
    3940        contrast   = Parameter(5.3e-6); 
    4041        background = Parameter(0.0); 
     
    5960        dp[4] = background(); 
    6061 
    61  
    62         // Get the dispersion points for the bilayer thickness(delta) 
    63         vector<WeightPoint> weights_delta; 
    64         delta.get_weights(weights_delta); 
    65  
    66         // Perform the computation, with all weight points 
    67         double sum = 0.0; 
    68         double norm = 0.0; 
    69  
    70         // Loop over semi axis A weight points 
    71         for(int i=0; i< (int)weights_delta.size(); i++) { 
    72                 dp[1] = weights_delta[i].value; 
    73                 sum += weights_delta[i].weight* LamellarFF(dp, q); 
    74                 norm += weights_delta[i].weight; 
    75                                  
    76         } 
    77         return sum/norm + background(); 
     62        return LamellarFF(dp, q); 
    7863} 
    7964 
     
    8671 
    8772double LamellarModel :: operator()(double qx, double qy) { 
    88         LamellarParameters dp; 
    89  
    90         // Fill parameter array for IGOR library 
    91         // Add the background after averaging 
    92         dp.scale = scale(); 
    93         dp.delta = delta(); 
    94         dp.sigma = sigma(); 
    95         dp.contrast = contrast(); 
    96         dp.background = background(); 
    97  
    98  
    99         // Get the dispersion points for the bilayer thickness(delta) 
    100         vector<WeightPoint> weights_delta; 
    101         delta.get_weights(weights_delta); 
    102  
    103         // Perform the computation, with all weight points 
    104         double sum = 0.0; 
    105         double norm = 0.0; 
    106  
    107         // Loop over detla  weight points 
    108         for(int i=0; i< (int)weights_delta.size(); i++) { 
    109                 dp.delta = weights_delta[i].value; 
    110                 sum += weights_delta[i].weight* lamellar_analytical_2DXY(&dp, qx, qy); 
    111                 norm += weights_delta[i].weight; 
    112                                  
    113         } 
    114         return sum/norm + background(); 
     73        double q = sqrt(qx*qx + qy*qy); 
     74        return (*this).operator()(q); 
    11575} 
    11676 
     
    12383 */ 
    12484double LamellarModel :: evaluate_rphi(double q, double phi) { 
    125         double qx = q*cos(phi); 
    126         double qy = q*sin(phi); 
    127         return (*this).operator()(qx, qy); 
     85        return (*this).operator()(q); 
    12886} 
  • sansmodels/src/sans/models/c_models/multishell.cpp

    r2cc633b r42f193a  
    3434        core_radius     = Parameter(60.0, true); 
    3535        core_radius.set_min(0.0); 
    36         s_thickness  = Parameter(10.0); 
    37         w_thickness   = Parameter(10.0); 
     36        s_thickness  = Parameter(10.0, true); 
     37        s_thickness.set_min(0.0); 
     38        w_thickness   = Parameter(10.0, true); 
     39        w_thickness.set_min(0.0); 
    3840        core_sld   = Parameter(6.4e-6); 
    3941        shell_sld   = Parameter(4.0e-7); 
     
    6062        dp[5] = shell_sld(); 
    6163        dp[6] = n_pairs(); 
    62         dp[7] = background(); 
     64        dp[7] = 0.0; 
    6365 
    6466        // Get the dispersion points for the core radius 
  • sansmodels/src/sans/models/c_models/vesicle.cpp

    r3d25331f r42f193a  
    3434        core_radius     = Parameter(100.0, true); 
    3535        core_radius.set_min(0.0); 
    36         thickness  = Parameter(30.0); 
     36        thickness  = Parameter(30.0, true); 
     37        thickness.set_min(0.0); 
    3738        core_sld   = Parameter(6.36e-6); 
    3839        shell_sld   = Parameter(5.0e-7); 
     
    5758        dp[4] = shell_sld(); 
    5859        dp[5] = background(); 
    59          
     60 
    6061 
    6162        // Get the dispersion points for the core radius 
    6263        vector<WeightPoint> weights_core_radius; 
    6364        core_radius.get_weights(weights_core_radius); 
     65        // Get the dispersion points for the thickness 
     66        vector<WeightPoint> weights_thickness; 
     67        thickness.get_weights(weights_thickness); 
    6468 
    6569        // Perform the computation, with all weight points 
     
    7074        for(int i=0; i< (int)weights_core_radius.size(); i++) { 
    7175                dp[1] = weights_core_radius[i].value; 
    72  
    73                 sum += weights_core_radius[i].weight 
    74                         * VesicleForm(dp, q); 
    75                 norm += weights_core_radius[i].weight; 
     76                for(int j=0; j< (int)weights_core_radius.size(); j++) { 
     77                        dp[2] = weights_thickness[j].value; 
     78                        sum += weights_core_radius[i].weight 
     79                                * weights_thickness[j].weight * VesicleForm(dp, q); 
     80                        norm += weights_core_radius[i].weight * weights_thickness[j].weight; 
     81                } 
    7682        } 
    7783        return sum/norm + background(); 
Note: See TracChangeset for help on using the changeset viewer.