Changeset 2cb89e7 in sasview for sansmodels


Ignore:
Timestamp:
Aug 16, 2009 12:30:27 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:
7d11b81
Parents:
b0d0723
Message:

Changed the def. of lengths of sides for 2D,thus consistent w/ 1D. And shortened the names.

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

Legend:

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

    r975ec8e r2cb89e7  
    3333        List of default parameters: 
    3434         scale           = 1.0  
    35          short_edgeA     = 35.0 [A] 
    36          longer_edgeB    = 75.0 [A] 
    37          longuest_edgeC  = 400.0 [A] 
     35         short_a         = 35.0 [A] 
     36         long_b          = 75.0 [A] 
     37         longer_c        = 400.0 [A] 
    3838         contrast        = 5.3e-006 [1/A²] 
    3939         background      = 0.0 [1/cm] 
     
    5454        self.name = "ParallelepipedModel" 
    5555        ## Model description 
    56         self.description =""" Calculates the form factor for a rectangular solid with uniform scattering length density. 
     56        self.description =""" Form factor for a rectangular solid with uniform scattering length density. 
    5757                 
    5858                scale:Scale factor 
    59                 short_edgeA: Shortest edge of the parallelepiped [A] 
    60                 longer_edgeB: Longer edge of the parallelepiped [A] 
    61                 longuest_edgeC: Longuest edge of the parallelepiped [A] 
    62                 constrast: particle_sld - solvent_sld 
     59                short_a: length of short side of the parallelepiped [A] 
     60                long_b: length of long side of the parallelepiped [A] 
     61                longer_c: length of longer side of the parallelepiped [A] 
     62                contrast: particle_sld - solvent_sld 
    6363                background:Incoherent Background [1/cm]""" 
    6464        
     
    6666        self.details = {} 
    6767        self.details['scale'] = ['', None, None] 
    68         self.details['short_edgeA'] = ['[A]', None, None] 
    69         self.details['longer_edgeB'] = ['[A]', None, None] 
    70         self.details['longuest_edgeC'] = ['[A]', None, None] 
     68        self.details['short_a'] = ['[A]', None, None] 
     69        self.details['long_b'] = ['[A]', None, None] 
     70        self.details['longer_c'] = ['[A]', None, None] 
    7171        self.details['contrast'] = ['[1/A²]', None, None] 
    7272        self.details['background'] = ['[1/cm]', None, None] 
     
    7676 
    7777                ## fittable parameters 
    78         self.fixed=['short_edgeA.width', 'longer_edgeB.width', 'longuest_edgeC.width', 'parallel_phi.width', 'parallel_psi.width', 'parallel_theta.width'] 
     78        self.fixed=['short_a.width', 'long_b.width', 'longer_c.width', 'parallel_phi.width', 'parallel_psi.width', 'parallel_theta.width'] 
    7979         
    8080        ## parameters with orientation 
  • sansmodels/src/sans/models/c_extensions/parallelepiped.c

    rd5bd424 r2cb89e7  
    2222        // Fill paramater array 
    2323        dp[0] = pars->scale; 
    24         dp[1] = pars->short_edgeA; 
    25         dp[2] = pars->longer_edgeB; 
    26         dp[3] = pars->longuest_edgeC; 
     24        dp[1] = pars->short_a; 
     25        dp[2] = pars->long_b; 
     26        dp[3] = pars->longer_c; 
    2727        dp[4] = pars->contrast; 
    2828        dp[5] = pars->background; 
     
    3838 
    3939    //handle arg=0 separately, as sin(t)/t -> 1 as t->0 
    40     argA = a*ala; 
    41     argB = b*alb; 
    42     argC = c*alc; 
     40    argA = a*ala/2; 
     41    argB = b*alb/2; 
     42    argC = c*alc/2; 
    4343    if(argA==0.0) { 
    4444                tmp1 = 1.0; 
     
    105105        double pi = 4.0*atan(1.0); 
    106106 
    107         edgeA = pars->short_edgeA; 
    108         edgeB = pars->longer_edgeB; 
    109         edgeC = pars->longuest_edgeC; 
     107        edgeA = pars->short_a; 
     108        edgeB = pars->long_b; 
     109        edgeC = pars->longer_c; 
    110110 
    111111 
     
    152152        //normalize by cylinder volume 
    153153        //NOTE that for this (Fournet) definition of the integral, one must MULTIPLY by Vparallel 
    154     vol = 8*edgeA* edgeB * edgeC; 
     154    vol = edgeA* edgeB * edgeC; 
    155155        answer *= vol; 
    156156 
  • sansmodels/src/sans/models/c_extensions/parallelepiped.h

    r975ec8e r2cb89e7  
    77/** Structure definition for Parallelepiped parameters 
    88 * [PYTHONCLASS] = ParallelepipedModel 
    9  * [DISP_PARAMS] = short_edgeA, longer_edgeB, longuest_edgeC,parallel_phi,parallel_psi, parallel_theta 
    10    [DESCRIPTION] = <text> Calculates the form factor for a rectangular solid with uniform scattering length density. 
     9 * [DISP_PARAMS] = short_a, long_b, longer_c,parallel_phi,parallel_psi, parallel_theta 
     10   [DESCRIPTION] = <text> Form factor for a rectangular solid with uniform scattering length density. 
    1111 
    1212                scale:Scale factor 
    13                 short_edgeA: Shortest edge of the parallelepiped [A] 
    14                 longer_edgeB: Longer edge of the parallelepiped [A] 
    15                 longuest_edgeC: Longuest edge of the parallelepiped [A] 
    16                 constrast: particle_sld - solvent_sld 
     13                short_a: length of short side of the parallelepiped [A] 
     14                long_b: length of long side of the parallelepiped [A] 
     15                longer_c: length of longer side of the parallelepiped [A] 
     16                contrast: particle_sld - solvent_sld 
    1717                background:Incoherent Background [1/cm] 
    1818                </text> 
    19         [FIXED]= <text>short_edgeA.width; longer_edgeB.width; longuest_edgeC.width;parallel_phi.width;parallel_psi.width; parallel_theta.width</text> 
     19        [FIXED]= <text>short_a.width; long_b.width; longer_c.width;parallel_phi.width;parallel_psi.width; parallel_theta.width</text> 
    2020        [ORIENTATION_PARAMS]= <text>parallel_phi;parallel_psi; parallel_theta; parallel_phi.width;parallel_psi.width; parallel_theta.width</text> 
    2121 
     
    2626    //  [DEFAULT]=scale=1.0 
    2727    double scale; 
    28     /// Shortest edge of the parallelepiped [A] 
    29     //  [DEFAULT]=short_edgeA=35 [A] 
    30     double short_edgeA; 
    31         /// Longer edge of the parallelepiped [A] 
    32     //  [DEFAULT]=longer_edgeB=75 [A] 
    33     double longer_edgeB; 
    34         /// Longuest edge of the parallelepiped [A] 
    35     //  [DEFAULT]=longuest_edgeC=400 [A] 
    36     double longuest_edgeC; 
     28    ///  Length of short side of the parallelepiped [A] 
     29    //  [DEFAULT]=short_a=35 [A] 
     30    double short_a; 
     31        /// Length of long side edge of the parallelepiped [A] 
     32    //  [DEFAULT]=long_b=75 [A] 
     33    double long_b; 
     34        /// Length of longer side of the parallelepiped [A] 
     35    //  [DEFAULT]=longer_c=400 [A] 
     36    double longer_c; 
    3737    /// Contrast [1/A²] 
    3838    //  [DEFAULT]=contrast=5.3e-6 [1/A²] 
  • sansmodels/src/sans/models/c_models/CParallelepipedModel.cpp

    r975ec8e r2cb89e7  
    8686         
    8787        // Initialize parameter dictionary 
     88        PyDict_SetItemString(self->params,"short_a",Py_BuildValue("d",35.000000)); 
    8889        PyDict_SetItemString(self->params,"scale",Py_BuildValue("d",1.000000)); 
    89         PyDict_SetItemString(self->params,"longer_edgeB",Py_BuildValue("d",75.000000)); 
     90        PyDict_SetItemString(self->params,"long_b",Py_BuildValue("d",75.000000)); 
     91        PyDict_SetItemString(self->params,"longer_c",Py_BuildValue("d",400.000000)); 
    9092        PyDict_SetItemString(self->params,"parallel_psi",Py_BuildValue("d",0.000000)); 
    91         PyDict_SetItemString(self->params,"longuest_edgeC",Py_BuildValue("d",400.000000)); 
    9293        PyDict_SetItemString(self->params,"parallel_phi",Py_BuildValue("d",0.000000)); 
    9394        PyDict_SetItemString(self->params,"parallel_theta",Py_BuildValue("d",0.000000)); 
    9495        PyDict_SetItemString(self->params,"background",Py_BuildValue("d",0.000000)); 
    95         PyDict_SetItemString(self->params,"short_edgeA",Py_BuildValue("d",35.000000)); 
    9696        PyDict_SetItemString(self->params,"contrast",Py_BuildValue("d",0.000005)); 
    9797        // Initialize dispersion / averaging parameter dict 
     
    9999        PyObject * disp_dict; 
    100100        disp_dict = PyDict_New(); 
    101         self->model->short_edgeA.dispersion->accept_as_source(visitor, self->model->short_edgeA.dispersion, disp_dict); 
    102         PyDict_SetItemString(self->dispersion, "short_edgeA", disp_dict); 
     101        self->model->short_a.dispersion->accept_as_source(visitor, self->model->short_a.dispersion, disp_dict); 
     102        PyDict_SetItemString(self->dispersion, "short_a", disp_dict); 
    103103        disp_dict = PyDict_New(); 
    104         self->model->longer_edgeB.dispersion->accept_as_source(visitor, self->model->longer_edgeB.dispersion, disp_dict); 
    105         PyDict_SetItemString(self->dispersion, "longer_edgeB", disp_dict); 
     104        self->model->long_b.dispersion->accept_as_source(visitor, self->model->long_b.dispersion, disp_dict); 
     105        PyDict_SetItemString(self->dispersion, "long_b", disp_dict); 
    106106        disp_dict = PyDict_New(); 
    107         self->model->longuest_edgeC.dispersion->accept_as_source(visitor, self->model->longuest_edgeC.dispersion, disp_dict); 
    108         PyDict_SetItemString(self->dispersion, "longuest_edgeC", disp_dict); 
     107        self->model->longer_c.dispersion->accept_as_source(visitor, self->model->longer_c.dispersion, disp_dict); 
     108        PyDict_SetItemString(self->dispersion, "longer_c", disp_dict); 
    109109        disp_dict = PyDict_New(); 
    110110        self->model->parallel_phi.dispersion->accept_as_source(visitor, self->model->parallel_phi.dispersion, disp_dict); 
     
    246246         
    247247            // Reader parameter dictionary 
     248    self->model->short_a = PyFloat_AsDouble( PyDict_GetItemString(self->params, "short_a") ); 
    248249    self->model->scale = PyFloat_AsDouble( PyDict_GetItemString(self->params, "scale") ); 
    249     self->model->longer_edgeB = PyFloat_AsDouble( PyDict_GetItemString(self->params, "longer_edgeB") ); 
     250    self->model->long_b = PyFloat_AsDouble( PyDict_GetItemString(self->params, "long_b") ); 
     251    self->model->longer_c = PyFloat_AsDouble( PyDict_GetItemString(self->params, "longer_c") ); 
    250252    self->model->parallel_psi = PyFloat_AsDouble( PyDict_GetItemString(self->params, "parallel_psi") ); 
    251     self->model->longuest_edgeC = PyFloat_AsDouble( PyDict_GetItemString(self->params, "longuest_edgeC") ); 
    252253    self->model->parallel_phi = PyFloat_AsDouble( PyDict_GetItemString(self->params, "parallel_phi") ); 
    253254    self->model->parallel_theta = PyFloat_AsDouble( PyDict_GetItemString(self->params, "parallel_theta") ); 
    254255    self->model->background = PyFloat_AsDouble( PyDict_GetItemString(self->params, "background") ); 
    255     self->model->short_edgeA = PyFloat_AsDouble( PyDict_GetItemString(self->params, "short_edgeA") ); 
    256256    self->model->contrast = PyFloat_AsDouble( PyDict_GetItemString(self->params, "contrast") ); 
    257257    // Read in dispersion parameters 
    258258    PyObject* disp_dict; 
    259259    DispersionVisitor* visitor = new DispersionVisitor(); 
    260     disp_dict = PyDict_GetItemString(self->dispersion, "short_edgeA"); 
    261     self->model->short_edgeA.dispersion->accept_as_destination(visitor, self->model->short_edgeA.dispersion, disp_dict); 
    262     disp_dict = PyDict_GetItemString(self->dispersion, "longer_edgeB"); 
    263     self->model->longer_edgeB.dispersion->accept_as_destination(visitor, self->model->longer_edgeB.dispersion, disp_dict); 
    264     disp_dict = PyDict_GetItemString(self->dispersion, "longuest_edgeC"); 
    265     self->model->longuest_edgeC.dispersion->accept_as_destination(visitor, self->model->longuest_edgeC.dispersion, disp_dict); 
     260    disp_dict = PyDict_GetItemString(self->dispersion, "short_a"); 
     261    self->model->short_a.dispersion->accept_as_destination(visitor, self->model->short_a.dispersion, disp_dict); 
     262    disp_dict = PyDict_GetItemString(self->dispersion, "long_b"); 
     263    self->model->long_b.dispersion->accept_as_destination(visitor, self->model->long_b.dispersion, disp_dict); 
     264    disp_dict = PyDict_GetItemString(self->dispersion, "longer_c"); 
     265    self->model->longer_c.dispersion->accept_as_destination(visitor, self->model->longer_c.dispersion, disp_dict); 
    266266    disp_dict = PyDict_GetItemString(self->dispersion, "parallel_phi"); 
    267267    self->model->parallel_phi.dispersion->accept_as_destination(visitor, self->model->parallel_phi.dispersion, disp_dict); 
     
    332332         
    333333            // Reader parameter dictionary 
     334    self->model->short_a = PyFloat_AsDouble( PyDict_GetItemString(self->params, "short_a") ); 
    334335    self->model->scale = PyFloat_AsDouble( PyDict_GetItemString(self->params, "scale") ); 
    335     self->model->longer_edgeB = PyFloat_AsDouble( PyDict_GetItemString(self->params, "longer_edgeB") ); 
     336    self->model->long_b = PyFloat_AsDouble( PyDict_GetItemString(self->params, "long_b") ); 
     337    self->model->longer_c = PyFloat_AsDouble( PyDict_GetItemString(self->params, "longer_c") ); 
    336338    self->model->parallel_psi = PyFloat_AsDouble( PyDict_GetItemString(self->params, "parallel_psi") ); 
    337     self->model->longuest_edgeC = PyFloat_AsDouble( PyDict_GetItemString(self->params, "longuest_edgeC") ); 
    338339    self->model->parallel_phi = PyFloat_AsDouble( PyDict_GetItemString(self->params, "parallel_phi") ); 
    339340    self->model->parallel_theta = PyFloat_AsDouble( PyDict_GetItemString(self->params, "parallel_theta") ); 
    340341    self->model->background = PyFloat_AsDouble( PyDict_GetItemString(self->params, "background") ); 
    341     self->model->short_edgeA = PyFloat_AsDouble( PyDict_GetItemString(self->params, "short_edgeA") ); 
    342342    self->model->contrast = PyFloat_AsDouble( PyDict_GetItemString(self->params, "contrast") ); 
    343343    // Read in dispersion parameters 
    344344    PyObject* disp_dict; 
    345345    DispersionVisitor* visitor = new DispersionVisitor(); 
    346     disp_dict = PyDict_GetItemString(self->dispersion, "short_edgeA"); 
    347     self->model->short_edgeA.dispersion->accept_as_destination(visitor, self->model->short_edgeA.dispersion, disp_dict); 
    348     disp_dict = PyDict_GetItemString(self->dispersion, "longer_edgeB"); 
    349     self->model->longer_edgeB.dispersion->accept_as_destination(visitor, self->model->longer_edgeB.dispersion, disp_dict); 
    350     disp_dict = PyDict_GetItemString(self->dispersion, "longuest_edgeC"); 
    351     self->model->longuest_edgeC.dispersion->accept_as_destination(visitor, self->model->longuest_edgeC.dispersion, disp_dict); 
     346    disp_dict = PyDict_GetItemString(self->dispersion, "short_a"); 
     347    self->model->short_a.dispersion->accept_as_destination(visitor, self->model->short_a.dispersion, disp_dict); 
     348    disp_dict = PyDict_GetItemString(self->dispersion, "long_b"); 
     349    self->model->long_b.dispersion->accept_as_destination(visitor, self->model->long_b.dispersion, disp_dict); 
     350    disp_dict = PyDict_GetItemString(self->dispersion, "longer_c"); 
     351    self->model->longer_c.dispersion->accept_as_destination(visitor, self->model->longer_c.dispersion, disp_dict); 
    352352    disp_dict = PyDict_GetItemString(self->dispersion, "parallel_phi"); 
    353353    self->model->parallel_phi.dispersion->accept_as_destination(visitor, self->model->parallel_phi.dispersion, disp_dict); 
     
    407407         
    408408            // Reader parameter dictionary 
     409    self->model->short_a = PyFloat_AsDouble( PyDict_GetItemString(self->params, "short_a") ); 
    409410    self->model->scale = PyFloat_AsDouble( PyDict_GetItemString(self->params, "scale") ); 
    410     self->model->longer_edgeB = PyFloat_AsDouble( PyDict_GetItemString(self->params, "longer_edgeB") ); 
     411    self->model->long_b = PyFloat_AsDouble( PyDict_GetItemString(self->params, "long_b") ); 
     412    self->model->longer_c = PyFloat_AsDouble( PyDict_GetItemString(self->params, "longer_c") ); 
    411413    self->model->parallel_psi = PyFloat_AsDouble( PyDict_GetItemString(self->params, "parallel_psi") ); 
    412     self->model->longuest_edgeC = PyFloat_AsDouble( PyDict_GetItemString(self->params, "longuest_edgeC") ); 
    413414    self->model->parallel_phi = PyFloat_AsDouble( PyDict_GetItemString(self->params, "parallel_phi") ); 
    414415    self->model->parallel_theta = PyFloat_AsDouble( PyDict_GetItemString(self->params, "parallel_theta") ); 
    415416    self->model->background = PyFloat_AsDouble( PyDict_GetItemString(self->params, "background") ); 
    416     self->model->short_edgeA = PyFloat_AsDouble( PyDict_GetItemString(self->params, "short_edgeA") ); 
    417417    self->model->contrast = PyFloat_AsDouble( PyDict_GetItemString(self->params, "contrast") ); 
    418418    // Read in dispersion parameters 
    419419    PyObject* disp_dict; 
    420420    DispersionVisitor* visitor = new DispersionVisitor(); 
    421     disp_dict = PyDict_GetItemString(self->dispersion, "short_edgeA"); 
    422     self->model->short_edgeA.dispersion->accept_as_destination(visitor, self->model->short_edgeA.dispersion, disp_dict); 
    423     disp_dict = PyDict_GetItemString(self->dispersion, "longer_edgeB"); 
    424     self->model->longer_edgeB.dispersion->accept_as_destination(visitor, self->model->longer_edgeB.dispersion, disp_dict); 
    425     disp_dict = PyDict_GetItemString(self->dispersion, "longuest_edgeC"); 
    426     self->model->longuest_edgeC.dispersion->accept_as_destination(visitor, self->model->longuest_edgeC.dispersion, disp_dict); 
     421    disp_dict = PyDict_GetItemString(self->dispersion, "short_a"); 
     422    self->model->short_a.dispersion->accept_as_destination(visitor, self->model->short_a.dispersion, disp_dict); 
     423    disp_dict = PyDict_GetItemString(self->dispersion, "long_b"); 
     424    self->model->long_b.dispersion->accept_as_destination(visitor, self->model->long_b.dispersion, disp_dict); 
     425    disp_dict = PyDict_GetItemString(self->dispersion, "longer_c"); 
     426    self->model->longer_c.dispersion->accept_as_destination(visitor, self->model->longer_c.dispersion, disp_dict); 
    427427    disp_dict = PyDict_GetItemString(self->dispersion, "parallel_phi"); 
    428428    self->model->parallel_phi.dispersion->accept_as_destination(visitor, self->model->parallel_phi.dispersion, disp_dict); 
     
    486486        // Ugliness necessary to go from python to C 
    487487            // TODO: refactor this 
    488     if (!strcmp(par_name, "short_edgeA")) { 
    489         self->model->short_edgeA.dispersion = dispersion; 
    490     } else    if (!strcmp(par_name, "longer_edgeB")) { 
    491         self->model->longer_edgeB.dispersion = dispersion; 
    492     } else    if (!strcmp(par_name, "longuest_edgeC")) { 
    493         self->model->longuest_edgeC.dispersion = dispersion; 
     488    if (!strcmp(par_name, "short_a")) { 
     489        self->model->short_a.dispersion = dispersion; 
     490    } else    if (!strcmp(par_name, "long_b")) { 
     491        self->model->long_b.dispersion = dispersion; 
     492    } else    if (!strcmp(par_name, "longer_c")) { 
     493        self->model->longer_c.dispersion = dispersion; 
    494494    } else    if (!strcmp(par_name, "parallel_phi")) { 
    495495        self->model->parallel_phi.dispersion = dispersion; 
  • sansmodels/src/sans/models/c_models/models.hh

    r975ec8e r2cb89e7  
    4949        // Model parameters 
    5050        Parameter scale; 
    51         Parameter short_edgeA; 
    52         Parameter longer_edgeB; 
    53         Parameter longuest_edgeC; 
     51        Parameter short_a; 
     52        Parameter long_b; 
     53        Parameter longer_c; 
    5454        Parameter contrast; 
    5555        Parameter background; 
Note: See TracChangeset for help on using the changeset viewer.